Eliminate relocations in initdisk.c + dyninit.c.

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@596 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2003-06-15 18:40:03 +00:00
parent 542b0c1b89
commit 056fded527
3 changed files with 26 additions and 23 deletions

View File

@ -123,8 +123,6 @@ STATIC BOOL tdelay(ddt *pddt, ULONG ticks)
#define N_PART 4 /* number of partitions per #define N_PART 4 /* number of partitions per
table partition */ table partition */
COUNT nUnits; /* number of returned units */
#define PARTOFF 0x1be #define PARTOFF 0x1be
#ifdef PROTO #ifdef PROTO
@ -187,7 +185,7 @@ static dsk_proc * const dispatch[NENTRY] =
COUNT ASMCFUNC FAR blk_driver(rqptr rp) COUNT ASMCFUNC FAR blk_driver(rqptr rp)
{ {
if (rp->r_unit >= nUnits && rp->r_command != C_INIT) if (rp->r_unit >= blk_dev.dh_name[0] && rp->r_command != C_INIT)
return failure(E_UNIT); return failure(E_UNIT);
if (rp->r_command > NENTRY) if (rp->r_command > NENTRY)
{ {
@ -207,14 +205,14 @@ STATIC WORD play_dj(ddt * pddt)
{ {
int i; int i;
ddt *pddt2 = getddt(0); ddt *pddt2 = getddt(0);
for (i = 0; i < nUnits; i++, pddt2++) for (i = 0; i < blk_dev.dh_name[0]; i++, pddt2++)
{ {
if (pddt->ddt_driveno == pddt2->ddt_driveno && if (pddt->ddt_driveno == pddt2->ddt_driveno &&
(pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) ==
(DF_MULTLOG | DF_CURLOG)) (DF_MULTLOG | DF_CURLOG))
break; break;
} }
if (i == nUnits) if (i == blk_dev.dh_name[0])
{ {
put_string("Error in the DJ mechanism!\n"); /* should not happen! */ put_string("Error in the DJ mechanism!\n"); /* should not happen! */
return M_CHANGED; return M_CHANGED;
@ -314,7 +312,7 @@ STATIC WORD Getlogdev(rqptr rp, ddt * pddt)
return S_DONE; return S_DONE;
} }
for (i = 0; i < nUnits; i++, pddt2++) for (i = 0; i < blk_dev.dh_name[0]; i++, pddt2++)
{ {
if (pddt->ddt_driveno == pddt2->ddt_driveno && if (pddt->ddt_driveno == pddt2->ddt_driveno &&
(pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) ==
@ -336,7 +334,7 @@ STATIC WORD Setlogdev(rqptr rp, ddt * pddt)
return S_DONE; return S_DONE;
} }
for (i = 0; i < nUnits; i++, pddt2++) for (i = 0; i < blk_dev.dh_name[0]; i++, pddt2++)
{ {
if (pddt->ddt_driveno == pddt2->ddt_driveno && if (pddt->ddt_driveno == pddt2->ddt_driveno &&
(pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) ==

View File

@ -38,6 +38,7 @@ additionally:
#include "portab.h" #include "portab.h"
#include "init-mod.h" #include "init-mod.h"
#include "dyndata.h" #include "dyndata.h"
#include "lol.h"
#if defined(DEBUG) #if defined(DEBUG)
#define DebugPrintf(x) printf x #define DebugPrintf(x) printf x
@ -58,37 +59,41 @@ void far *DynAlloc(char *what, unsigned num, unsigned size)
{ {
void far *now; void far *now;
unsigned total = num * size; unsigned total = num * size;
struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn));
#ifndef DEBUG #ifndef DEBUG
UNREFERENCED_PARAMETER(what); UNREFERENCED_PARAMETER(what);
#endif #endif
if ((ULONG) total + Dyn.Allocated > 0xffff) if ((ULONG) total + Dynp->Allocated > 0xffff)
{ {
printf("PANIC:Dyn %lu\n", (ULONG) total + Dyn.Allocated); printf("PANIC:Dyn %lu\n", (ULONG) total + Dynp->Allocated);
for (;;) ; for (;;) ;
} }
DebugPrintf(("DYNDATA:allocating %s - %u * %u bytes, total %u, %u..%u\n", DebugPrintf(("DYNDATA:allocating %s - %u * %u bytes, total %u, %u..%u\n",
what, num, size, total, Dyn.Allocated, what, num, size, total, Dynp->Allocated,
Dyn.Allocated + total)); Dynp->Allocated + total));
now = (void far *)&Dyn.Buffer[Dyn.Allocated]; now = (void far *)&Dynp->Buffer[Dynp->Allocated];
fmemset(now, 0, total); fmemset(now, 0, total);
Dyn.Allocated += total; Dynp->Allocated += total;
return now; return now;
} }
void DynFree(void *ptr) void DynFree(void *ptr)
{ {
Dyn.Allocated = (char *)ptr - (char *)Dyn.Buffer; struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn));
Dynp->Allocated = (char *)ptr - (char *)Dynp->Buffer;
} }
void FAR * DynLast() void FAR * DynLast()
{ {
struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn));
DebugPrintf(("dynamic data end at %p\n", DebugPrintf(("dynamic data end at %p\n",
(void FAR *)(Dyn.Buffer + Dyn.Allocated))); (void FAR *)(Dynp->Buffer + Dynp->Allocated)));
return Dyn.Buffer + Dyn.Allocated; return Dynp->Buffer + Dynp->Allocated;
} }

View File

@ -33,12 +33,12 @@ static BYTE *dskRcsId =
"$Id$"; "$Id$";
#endif #endif
UBYTE InitDiskTransferBuffer[SEC_SIZE];
COUNT nUnits;
/* /*
data shared between DSK.C and INITDISK.C data shared between DSK.C and INITDISK.C
*/ */
extern UBYTE DOSFAR DiskTransferBuffer[1 * SEC_SIZE];
extern COUNT DOSFAR nUnits;
extern UWORD DOSFAR LBA_WRITE_VERIFY; extern UWORD DOSFAR LBA_WRITE_VERIFY;
@ -766,7 +766,7 @@ ErrorReturn:
*/ */
BOOL ConvPartTableEntryToIntern(struct PartTableEntry * pEntry, BOOL ConvPartTableEntryToIntern(struct PartTableEntry * pEntry,
UBYTE FAR * pDisk) UBYTE * pDisk)
{ {
int i; int i;
@ -948,7 +948,7 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type,
void BIOS_drive_reset(unsigned drive); void BIOS_drive_reset(unsigned drive);
int Read1LBASector(struct DriveParamS *driveParam, unsigned drive, int Read1LBASector(struct DriveParamS *driveParam, unsigned drive,
ULONG LBA_address, void FAR * buffer) ULONG LBA_address, void * buffer)
{ {
static struct _bios_LBA_address_packet dap = { static struct _bios_LBA_address_packet dap = {
16, 0, 0, 0, 0, 0, 0 16, 0, 0, 0, 0, 0, 0
@ -1051,14 +1051,14 @@ ReadNextPartitionTable:
strange_restart: strange_restart:
if (Read1LBASector if (Read1LBASector
(&driveParam, drive, RelSectorOffset, DiskTransferBuffer)) (&driveParam, drive, RelSectorOffset, InitDiskTransferBuffer))
{ {
printf("Error reading partition table drive %02x sector %lu", drive, printf("Error reading partition table drive %02x sector %lu", drive,
RelSectorOffset); RelSectorOffset);
return PartitionsToIgnore; return PartitionsToIgnore;
} }
if (!ConvPartTableEntryToIntern(PTable, DiskTransferBuffer)) if (!ConvPartTableEntryToIntern(PTable, InitDiskTransferBuffer))
{ {
/* there is some strange hardware out in the world, /* there is some strange hardware out in the world,
which returns OK on first read, but the data are which returns OK on first read, but the data are