Make CS the same for INIT and HMA text for Watcom. Move HMA text up

in kernel.asm. Use std for the memory move: helps if there's overlap
(PCs with a very low amount of RAM).


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@860 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2004-04-10 14:18:25 +00:00
parent e6e3b7a3a4
commit 147f4069e4
5 changed files with 47 additions and 25 deletions

View File

@ -330,22 +330,8 @@ void MoveKernel(unsigned NewKernelSegment)
if (NewKernelSegment < CurrentKernelSegment ||
NewKernelSegment == 0xffff)
{
unsigned i;
UBYTE FAR *s, FAR * d;
for (i = 0, s = HMASource, d = HMADest; i < len; i++)
d[i] = s[i];
}
else
{
/* might overlap */
unsigned i;
UBYTE FAR *s, FAR * d;
for (i = len, s = HMASource, d = HMADest; i != 0; i--)
d[i] = s[i];
}
fmemcpy(HMADest, HMASource, len);
/* else it's the very first relocation: handled by kernel.asm */
HMAFree = (FP_OFF(HMADest) + len + 0xf) & 0xfff0;
/* first free byte after HMA_TEXT on 16 byte boundary */

View File

@ -109,7 +109,6 @@ segment INIT_TEXT
;
kernel_start:
push ax
push bx
pushf
mov ax, 0e32h ; '2' Tracecode - kernel entered
@ -117,13 +116,12 @@ kernel_start:
int 010h
popf
pop bx
pop ax
mov ax,seg init_tos
cli
mov ss,ax
mov sp,init_tos
int 12h ; move the init code to higher memory
int 12h ; move init text+data to higher memory
mov cl,6
shl ax,cl
mov dx,15 + init_end wrt INIT_TEXT
@ -137,13 +135,43 @@ kernel_start:
mov ss,ax ; set SS to init data segment
sti ; now enable them
mov ax,cs
mov dx,__InitTextStart wrt HMA_TEXT
%ifdef WATCOM
mov cx,dx
shr cx,4
add ax,cx
%endif
mov ds,ax
xor si,si
xor di,di
mov cx,1 + init_end wrt INIT_TEXT
mov cx,-2 + init_end wrt INIT_TEXT
mov si,cx
mov di,cx
shr cx,1
cld
inc cx
std ; if there's overlap only std is safe
rep movsw
; move HMA_TEXT to higher memory
mov cx,dx ; cx = __InitTextStart wrt HMA_TEXT
shr dx,4
sub ax,dx
mov ds,ax ; ds = HMA_TEXT
mov ax,es
sub ax,dx
mov es,ax ; es = new HMA_TEXT
mov si,cx
dec si
dec si
mov di,si
shr cx,1
rep movsw
cld
%ifndef WATCOM ; for WATCOM: CS equal for HMA and INIT
add ax,dx
mov es,ax ; otherwise CS -> init_text
%endif
push es
mov ax,cont
push ax

View File

@ -227,7 +227,11 @@ STATIC void init_kernel(void)
ram_top = init_oem();
/* move kernel to high conventional RAM, just below the init code */
#ifdef __WATCOMC__
lpTop = MK_FP(_CS, 0);
#else
lpTop = MK_FP(_CS - (FP_OFF(_HMATextEnd) + 15) / 16, 0);
#endif
MoveKernel(FP_SEG(lpTop));
lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0);

View File

@ -30,8 +30,12 @@
group PGROUP PSP
group LGROUP _LOWTEXT _IO_TEXT _IO_FIXED_DATA _TEXT
group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA
%ifdef WATCOM
group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END INIT_TEXT_START INIT_TEXT INIT_TEXT_END
%else
group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END
group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END
%endif
group I_GROUP ID_B ID ID_E IC IDATA ICONST ICONST2 I_DATA IB_B I_BSS IB IB_E
segment PSP class=PSP

View File

@ -62,7 +62,7 @@ MATH_INSERT=+i4m
#
ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff-r
INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-ndI
INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-gTGROUP-ndI
CFLAGS=$(ALLCFLAGS)-ntHMA_TEXT
INITPATCH=..\utils\patchobj __U4D=_IU4D __U4M=_IU4M