Support for switches=/e[[:]nnnn] and for moving the EBDA (with Lucho)

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@675 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2003-09-04 19:14:16 +00:00
parent d1f48fb2b2
commit 72c8bf17b8
3 changed files with 77 additions and 23 deletions

View File

@ -70,6 +70,7 @@ struct config Config = {
, 0 /* amount required memory */ , 0 /* amount required memory */
, 0 /* pointer to loaded data */ , 0 /* pointer to loaded data */
, 0 /* strategy for command.com is low by default */ , 0 /* strategy for command.com is low by default */
, 0xFFFF /* default value for switches=/E:nnnn */
}; };
/* MSC places uninitialized data into COMDEF records, /* MSC places uninitialized data into COMDEF records,
that end up in DATA segment. this can't be tolerated that end up in DATA segment. this can't be tolerated
@ -285,6 +286,7 @@ void PreConfig(void)
void PreConfig2(void) void PreConfig2(void)
{ {
struct sfttbl FAR *sp; struct sfttbl FAR *sp;
unsigned ebda_size;
/* initialize NEAR allocated things */ /* initialize NEAR allocated things */
@ -305,15 +307,24 @@ void PreConfig2(void)
base_seg = LoL->first_mcb = FP_SEG(AlignParagraph((BYTE FAR *) DynLast() + 0x0f)); base_seg = LoL->first_mcb = FP_SEG(AlignParagraph((BYTE FAR *) DynLast() + 0x0f));
ebda_size = ebdasize();
if (ebda_size > Config.ebda2move)
ebda_size = Config.ebda2move;
ram_top += ebda_size / 1024;
/* We expect ram_top as Kbytes, so convert to paragraphs */ /* We expect ram_top as Kbytes, so convert to paragraphs */
mcb_init(base_seg, ram_top * 64 - LoL->first_mcb - 1, MCB_LAST); mcb_init(base_seg, ram_top * 64 - LoL->first_mcb - 1, MCB_LAST);
if (UmbState == 2)
umb_init();
sp = LoL->sfthead; sp = LoL->sfthead;
sp = sp->sftt_next = KernelAlloc(sizeof(sftheader) + 3 * sizeof(sft), 'F', 0); sp = sp->sftt_next = KernelAlloc(sizeof(sftheader) + 3 * sizeof(sft), 'F', 0);
sp->sftt_next = (sfttbl FAR *) - 1; sp->sftt_next = (sfttbl FAR *) - 1;
sp->sftt_count = 3; sp->sftt_count = 3;
if (ebda_size) /* move the Extended BIOS Data Area from top of RAM here */
movebda(ebda_size, FP_SEG(KernelAlloc(ebda_size, 'I', 0)));
if (UmbState == 2)
umb_init();
} }
/* Do third pass initialization. */ /* Do third pass initialization. */
@ -991,6 +1002,28 @@ STATIC VOID CfgSwitches(BYTE * pLine)
case 'F': case 'F':
InitKernelConfig.SkipConfigSeconds = 0; InitKernelConfig.SkipConfigSeconds = 0;
break; break;
case 'E': /* /E[[:]nnnn] Set the desired EBDA amount to move in bytes */
{ /* Note that if there is no EBDA, this will have no effect */
char *p;
int n = 0;
if (*++pLine == ':')
pLine++; /* skip optional separator */
if ((p = GetNumArg(pLine, &n)) == 0) {
Config.ebda2move = 0;
break;
}
pLine = p - 1; /* p points past number */
/* allowed values: [0..1024] bytes, multiples of 16
* e.g. AwardBIOS: 48, AMIBIOS: 1024
* (Phoenix, MRBIOS, Unicore = ????)
*/
if (n >= 48 && n <= 1024)
{
Config.ebda2move = (n + 15) & 0xfff0;
break;
}
/* else fall through (failure) */
}
default: default:
CfgFailure(pLine); CfgFailure(pLine);
} }
@ -1349,7 +1382,6 @@ void FAR * KernelAlloc(size_t nBytes, char type, int mode)
/* prealloc */ /* prealloc */
lpTop = MK_FP(FP_SEG(lpTop) - nPara, FP_OFF(lpTop)); lpTop = MK_FP(FP_SEG(lpTop) - nPara, FP_OFF(lpTop));
return AlignParagraph(lpTop); return AlignParagraph(lpTop);
} }
else else
{ {

View File

@ -109,6 +109,8 @@ struct config {
/* where the loaded data is for PostConfig() */ /* where the loaded data is for PostConfig() */
UBYTE cfgP_0_startmode; UBYTE cfgP_0_startmode;
/* load command.com high or not */ /* load command.com high or not */
unsigned ebda2move;
/* value for switches=/E:nnnn */
}; };
extern struct config Config; extern struct config Config;
@ -139,7 +141,9 @@ int MoveKernelToHMA(void);
VOID FAR * HMAalloc(COUNT bytesToAllocate); VOID FAR * HMAalloc(COUNT bytesToAllocate);
/* initoem.c */ /* initoem.c */
UWORD init_oem(void); unsigned init_oem(void);
void movebda(int bytes, unsigned new_seg);
unsigned ebdasize(void);
/* intr.asm */ /* intr.asm */

View File

@ -35,20 +35,38 @@ static BYTE *RcsId =
"$Id$"; "$Id$";
#endif #endif
UWORD init_oem(void) #define EBDASEG 0x40e
{ #define RAMSIZE 0x413
UWORD top_k = 0;
#ifdef __TURBOC__ unsigned init_oem(void)
__int__(0x12); {
top_k = _AX; iregs r;
#elif defined(I86) init_call_intr(0x12, &r);
asm return r.a.x;
{
int 0x12;
mov top_k, ax;
}
#endif
return top_k;
} }
void movebda(size_t bytes, unsigned new_seg)
{
unsigned old_seg = peek(0, EBDASEG);
fmemcpy(MK_FP(new_seg, 0), MK_FP(old_seg, 0), bytes);
poke(0, EBDASEG, new_seg);
poke(0, RAMSIZE, ram_top);
}
unsigned ebdasize(void)
{
unsigned ebdaseg = peek(0, EBDASEG);
unsigned ramsize = ram_top;
if (ramsize * 64 == ebdaseg && ramsize < 640 && peek(0, RAMSIZE) == ramsize)
{
unsigned ebdasz = peekb(ebdaseg, 0);
/* sanity check: is there really no more than 63 KB?
* must be at 640k (all other values never seen and are untested)
*/
if (ebdasz <= 63 && ramsize + ebdasz == 640)
return ebdasz * 1024U;
}
return 0;
}