Skip to content

Commit

Permalink
add some comments regarding relocation of kernel during configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
PerditionC committed Feb 10, 2024
1 parent 114236d commit a593799
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions kernel/inithma.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,19 @@ VOID FAR * HMAalloc(COUNT bytesToAllocate)

unsigned CurrentKernelSegment = 0;

/* relocate segment with HMA_TEXT code group */
void MoveKernel(unsigned NewKernelSegment)
{
UBYTE FAR *HMADest;
UBYTE FAR *HMASource;
unsigned len;
unsigned jmpseg = CurrentKernelSegment;

/* if the first time called, initialize to end of HMA_TEXT code group segment */
if (CurrentKernelSegment == 0)
CurrentKernelSegment = FP_SEG(_HMATextEnd);

/* if already relocated into HMA, nothing to do */
if (CurrentKernelSegment == 0xffff)
return;

Expand All @@ -324,6 +327,8 @@ void MoveKernel(unsigned NewKernelSegment)

len = (FP_OFF(_HMATextEnd) | 0x000f) - (FP_OFF(_HMATextStart) & 0xfff0);

/* HMA doesn't start until a paragraph into 0xffff segment */
/* HMA begins with VDISK header to mark area is used */
if (NewKernelSegment == 0xffff)
{
HMASource += HMAOFFSET;
Expand Down
9 changes: 8 additions & 1 deletion kernel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,14 @@ STATIC void init_kernel(void)
/* Init oem hook - returns memory size in KB */
ram_top = init_oem();

/* move kernel to high conventional RAM, just below the init code */
/* Note: HMA_TEXT and init code already moved higher in
conventional memory by startup code, however, we still
need to adjust any references to new location. So use
current CS as that is where we were moved to and perform
any fixups needed. Note this will also re-copy the
HMA_TEXT segment, so be sure not to overwrite it prior
to the MoveKernel() call. Kernel moved to around 8F??:0000
*/
#ifdef __WATCOMC__
lpTop = MK_FP(_CS, 0);
#else
Expand Down

0 comments on commit a593799

Please sign in to comment.