2001-07-10 00:19:33 +02:00
|
|
|
/*
|
|
|
|
DYNINIT.C
|
|
|
|
|
|
|
|
this serves requests from the INIT modules to
|
|
|
|
allocate dynamic data.
|
|
|
|
|
|
|
|
kernel layout:
|
|
|
|
00000H 000FFH 00100H PSP PSP
|
|
|
|
00100H 004E1H 003E2H _TEXT CODE
|
|
|
|
004E2H 007A7H 002C6H _IO_TEXT CODE
|
|
|
|
007A8H 008E5H 0013EH _IO_FIXED_DATA CODE
|
|
|
|
008F0H 0139FH 00AB0H _FIXED_DATA DATA
|
|
|
|
013A0H 019F3H 00654H _DATA DATA
|
|
|
|
019F4H 0240DH 00A1AH _BSS BSS
|
|
|
|
|
|
|
|
additionally:
|
|
|
|
DYN_DATA DYN
|
|
|
|
|
|
|
|
|
|
|
|
02610H 0F40EH 0CDFFH HMA_TEXT HMA
|
|
|
|
|
|
|
|
FCB's, f_nodes, buffers,...
|
|
|
|
drivers
|
|
|
|
|
|
|
|
|
|
|
|
0F410H 122DFH 02ED0H INIT_TEXT INIT
|
|
|
|
122E0H 12AA5H 007C6H ID ID
|
|
|
|
12AA6H 12CBFH 0021AH IB IB
|
|
|
|
|
|
|
|
purpose is to move the HMA_TEXT = resident kernel
|
|
|
|
around, so that below it - after BSS, there is data
|
|
|
|
addressable near by the kernel, to hold some arrays
|
|
|
|
like f_nodes
|
|
|
|
|
|
|
|
making f_nodes near saves ~2.150 code in HMA
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
*/
|
2001-07-10 00:19:33 +02:00
|
|
|
#include "portab.h"
|
|
|
|
#include "init-mod.h"
|
2001-11-18 15:01:12 +01:00
|
|
|
#include "dyndata.h"
|
2003-06-15 20:40:03 +02:00
|
|
|
#include "lol.h"
|
2001-07-10 00:19:33 +02:00
|
|
|
|
|
|
|
#if defined(DEBUG)
|
2001-11-18 15:01:12 +01:00
|
|
|
#define DebugPrintf(x) printf x
|
2001-07-10 00:19:33 +02:00
|
|
|
#else
|
2001-11-18 15:01:12 +01:00
|
|
|
#define DebugPrintf(x)
|
2001-07-10 00:19:33 +02:00
|
|
|
#endif
|
|
|
|
|
2001-09-23 22:39:44 +02:00
|
|
|
/*extern struct DynS FAR Dyn;*/
|
|
|
|
|
|
|
|
#ifndef __TURBOC__
|
2001-11-18 15:01:12 +01:00
|
|
|
#include "init-dat.h"
|
2002-01-23 23:29:41 +01:00
|
|
|
extern struct DynS DOSFAR ASM Dyn;
|
2001-09-23 22:39:44 +02:00
|
|
|
#else
|
2002-01-23 23:29:41 +01:00
|
|
|
extern struct DynS FAR ASM Dyn;
|
2001-11-18 15:01:12 +01:00
|
|
|
#endif
|
2001-07-10 00:19:33 +02:00
|
|
|
|
2001-07-28 20:13:06 +02:00
|
|
|
void far *DynAlloc(char *what, unsigned num, unsigned size)
|
2001-07-10 00:19:33 +02:00
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
void far *now;
|
|
|
|
unsigned total = num * size;
|
2003-06-15 20:40:03 +02:00
|
|
|
struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn));
|
|
|
|
|
2001-07-28 20:13:06 +02:00
|
|
|
#ifndef DEBUG
|
2001-11-18 15:01:12 +01:00
|
|
|
UNREFERENCED_PARAMETER(what);
|
2001-07-28 20:13:06 +02:00
|
|
|
#endif
|
2001-09-23 22:39:44 +02:00
|
|
|
|
2003-06-15 20:40:03 +02:00
|
|
|
if ((ULONG) total + Dynp->Allocated > 0xffff)
|
2001-11-18 15:01:12 +01:00
|
|
|
{
|
2003-06-15 20:40:03 +02:00
|
|
|
printf("PANIC:Dyn %lu\n", (ULONG) total + Dynp->Allocated);
|
2001-11-18 15:01:12 +01:00
|
|
|
for (;;) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
DebugPrintf(("DYNDATA:allocating %s - %u * %u bytes, total %u, %u..%u\n",
|
2003-06-15 20:40:03 +02:00
|
|
|
what, num, size, total, Dynp->Allocated,
|
|
|
|
Dynp->Allocated + total));
|
2001-11-18 15:01:12 +01:00
|
|
|
|
2003-06-15 20:40:03 +02:00
|
|
|
now = (void far *)&Dynp->Buffer[Dynp->Allocated];
|
2001-11-18 15:01:12 +01:00
|
|
|
fmemset(now, 0, total);
|
|
|
|
|
2003-06-15 20:40:03 +02:00
|
|
|
Dynp->Allocated += total;
|
2001-11-18 15:01:12 +01:00
|
|
|
|
|
|
|
return now;
|
|
|
|
}
|
2001-07-10 00:19:33 +02:00
|
|
|
|
2001-07-28 20:13:06 +02:00
|
|
|
void DynFree(void *ptr)
|
2001-07-10 00:19:33 +02:00
|
|
|
{
|
2003-06-15 20:40:03 +02:00
|
|
|
struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn));
|
|
|
|
Dynp->Allocated = (char *)ptr - (char *)Dynp->Buffer;
|
2001-07-28 20:13:06 +02:00
|
|
|
}
|
2001-07-10 00:19:33 +02:00
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
void FAR * DynLast()
|
2001-07-10 00:19:33 +02:00
|
|
|
{
|
2003-06-15 20:40:03 +02:00
|
|
|
struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn));
|
2001-11-18 15:01:12 +01:00
|
|
|
DebugPrintf(("dynamic data end at %p\n",
|
2003-06-15 20:40:03 +02:00
|
|
|
(void FAR *)(Dynp->Buffer + Dynp->Allocated)));
|
2001-07-10 00:19:33 +02:00
|
|
|
|
2003-06-15 20:40:03 +02:00
|
|
|
return Dynp->Buffer + Dynp->Allocated;
|
2001-11-18 15:01:12 +01:00
|
|
|
}
|