aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhpa <hpa>2002-04-28 05:40:11 +0000
committerhpa <hpa>2002-04-28 05:40:11 +0000
commitbdb0fcf1acccec785084bfe0b3802d4674638b64 (patch)
treebfe06e9b601affd91f3e028a3e274dc05a668c13
parentc0cd85e0e93e2390f3f33169c78e4ed0033e5ceb (diff)
downloadsyslinux-1.73-pre6.tar.gz
syslinux-1.73-pre6.tar.xz
syslinux-1.73-pre6.zip
Factor out CPU initialization and some common configuration intosyslinux-1.73-pre6
separate files; fix bcopy bugs.
-rw-r--r--Makefile8
-rw-r--r--Makefile.private9
-rw-r--r--bcopy32.inc39
-rw-r--r--config.inc37
-rw-r--r--cpuinit.inc106
-rw-r--r--isolinux-debug.asm21
-rw-r--r--isolinux.asm100
-rw-r--r--ldlinux.asm101
-rw-r--r--pxelinux.asm87
-rw-r--r--runkernel.inc5
10 files changed, 225 insertions, 288 deletions
diff --git a/Makefile b/Makefile
index 250aac97..a7edfb75 100644
--- a/Makefile
+++ b/Makefile
@@ -39,7 +39,7 @@ VERSION = $(shell cat version)
#
CSRC = syslinux.c gethostip.c
NASMSRC = ldlinux.asm syslinux.asm copybs.asm \
- pxelinux.asm mbr.asm isolinux.asm
+ pxelinux.asm mbr.asm isolinux.asm isolinux-debug.asm
SOURCES = $(CSRC) $(NASMSRC) *.inc
BTARGET = ldlinux.bss ldlinux.sys ldlinux.bin ldlinux.lst \
pxelinux.0 mbr.bin isolinux.bin isolinux-debug.bin
@@ -102,10 +102,10 @@ pxelinux.0: pxelinux.bin
cp pxelinux.bin pxelinux.0
# Special verbose version of isolinux.bin
-isolinux-debug.bin: isolinux.asm kwdhash.inc
+isolinux-debug.bin: isolinux-debug.asm kwdhash.inc
$(NASM) -f bin -dVERSION="'$(VERSION)'" -dDATE_STR="'$(DATE)'" \
- -dHEXDATE="$(HEXDATE)" -dDEBUG_MESSAGES \
- -l isolinux-debug.lst -o isolinux-debug.bin isolinux.asm
+ -dHEXDATE="$(HEXDATE)" \
+ -l isolinux-debug.lst -o isolinux-debug.bin isolinux-debug.asm
ldlinux.bss: ldlinux.bin
dd if=ldlinux.bin of=ldlinux.bss bs=512 count=1
diff --git a/Makefile.private b/Makefile.private
index d03a51d8..5f650621 100644
--- a/Makefile.private
+++ b/Makefile.private
@@ -1,6 +1,6 @@
## -*- makefile -*- ------------------------------------------------------
##
-## Copyright 2000 H. Peter Anvin - All Rights Reserved
+## Copyright 2000-2002 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -20,9 +20,12 @@
PRIVATE = Makefile.private
-isolinux.iso: isolinux-debug.bin
+isolinux.iso: all
cp isolinux-debug.bin isolinux-test/isolinux/isolinux.bin
- mkisofs -v -r -J -o isolinux.iso isolinux-test
+ mkisofs -v -r -J \
+ -b isolinux/isolinux.bin -c isolinux/boot.cat \
+ -no-emul-boot -boot-load-size 4 -boot-info-table \
+ -o isolinux.iso isolinux-test
burn: isolinux.iso
cdrecord -v blank=fast isolinux.iso
diff --git a/bcopy32.inc b/bcopy32.inc
index af322f91..ed14aee8 100644
--- a/bcopy32.inc
+++ b/bcopy32.inc
@@ -77,7 +77,7 @@ bcopy: push eax
mov eax,cr0
or al,1
mov cr0,eax ; Enter protected mode
- jmp 08h:.in_pm
+.adj3a: jmp 08h:.in_pm
.in_pm: mov ax,10h ; Data segment selector
mov es,ax
@@ -91,23 +91,20 @@ bcopy: push eax
mov al,cl ; Save low bits
shr ecx,2 ; Convert to dwords
a32 rep movsd ; Do our business
+ ; At this point ecx == 0
- test al,2
- jz .noword
- a32 movsw
-.noword:
- test al,1
- jz .nobyte
- a32 movsb
-.nobyte:
-
- mov es,ax ; Set to "real-mode-like"
+ mov cl,al ; Copy any fractional dword
+ and cl,3
+ a32 rep movsb
+
+ mov al,18h ; "Real-mode-like" data segment
+ mov es,ax
mov ds,ax
-
+
mov eax,cr0
and al,~1
mov cr0,eax ; Disable protected mode
-.adj3: jmp 0:.in_rm
+.adj3b: jmp 0:.in_rm
.in_rm: ; Back in real mode
lss sp,[cs:SavedSSSP]
@@ -144,7 +141,6 @@ bcopy: push eax
A20List dw a20_dunno, a20_none, a20_bios, a20_kbc, a20_fast
A20DList dw a20d_dunno, a20d_none, a20d_bios, a20d_kbc, a20d_fast
a20_adjust_cnt equ ($-A20List)/2
-A20Type dw A20_DUNNO ; A20 type unknown
slow_out: out dx, al ; Fall through
@@ -160,7 +156,9 @@ try_enable_a20:
;
; Flush the caches
;
-; call try_wbinvd
+%if DO_WBINVD
+ call try_wbinvd
+%endif
;
; If the A20 type is known, jump straight to type
@@ -287,7 +285,9 @@ disable_a20:
;
; Flush the caches
;
-; call try_wbinvd
+%if DO_WBINVD
+ call try_wbinvd
+%endif
mov bp,[cs:A20Type]
add bp,bp ; Convert to word offset
@@ -359,11 +359,13 @@ empty_8042:
.done: ret
;
-; WBINVD instruction; gets auto-eliminated on 386 CPUs
+; Execute a WBINVD instruction if possible on this CPU
;
+%if DO_WBINVD
try_wbinvd:
wbinvd
ret
+%endif
;
; bcopy_over_self:
@@ -388,7 +390,8 @@ try_wbinvd:
align 2
adjlist dw bcopy_gdt.adj1 - ADJUST
dw bcopy.adj2 + 5 - ADJUST
- dw bcopy.adj3 + 1 - ADJUST
+ dw bcopy.adj3a + 1 - ADJUST
+ dw bcopy.adj3b + 1 - ADJUST
dw try_enable_a20.adj4 + 3 - ADJUST
dw disable_a20.adj5 + 3 - ADJUST
adjlist_cnt equ ($-adjlist)/2
diff --git a/config.inc b/config.inc
new file mode 100644
index 00000000..3282d5b9
--- /dev/null
+++ b/config.inc
@@ -0,0 +1,37 @@
+;; $Id$
+;; -----------------------------------------------------------------------
+;;
+;; Copyright 2002 H. Peter Anvin - All Rights Reserved
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+;; Bostom MA 02111-1307, USA; either version 2 of the License, or
+;; (at your option) any later version; incorporated herein by reference.
+;;
+;; -----------------------------------------------------------------------
+
+;;
+;; config.inc
+;;
+;; Common configuration options. Some of these are imposed by the kernel.
+;;
+
+%ifndef _CONFIG_INC
+%define _CONFIG_INC
+
+max_cmd_len equ 255 ; Must be odd; 255 is the kernel limit
+HIGHMEM_MAX equ 037FFFFFFh ; DEFAULT highest address for an initrd
+DEFAULT_BAUD equ 9600 ; Default baud rate for serial port
+BAUD_DIVISOR equ 115200 ; Serial port parameter
+
+%assign DO_WBINVD 0 ; Should we use WBINVD or not?
+
+;
+; Should be updated with every release to avoid bootsector/SYS file mismatch
+;
+%define version_str VERSION ; Must be 4 characters long!
+%define date DATE_STR ; Defined from the Makefile
+%define year '2002'
+
+%endif ; _CONFIG_INC
diff --git a/cpuinit.inc b/cpuinit.inc
new file mode 100644
index 00000000..a6923b54
--- /dev/null
+++ b/cpuinit.inc
@@ -0,0 +1,106 @@
+;; $Id$
+;; -----------------------------------------------------------------------
+;;
+;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+;; Bostom MA 02111-1307, USA; either version 2 of the License, or
+;; (at your option) any later version; incorporated herein by reference.
+;;
+;; -----------------------------------------------------------------------
+
+;;
+;; cpuinit.inc
+;;
+;; CPU-dependent initialization and related checks.
+;;
+
+;
+; Check that no moron is trying to boot Linux on a 286 or so. According
+; to Intel, the way to check is to see if the high 4 bits of the FLAGS
+; register are either all stuck at 1 (8086/8088) or all stuck at 0
+; (286 in real mode), if not it is a 386 or higher. They didn't
+; say how to check for a 186/188, so I *hope* it falls out as a 8086
+; or 286 in this test.
+;
+; Also, provide an escape route in case it doesn't work.
+;
+check_escapes:
+ mov ah,02h ; Check keyboard flags
+ int 16h
+ mov [KbdFlags],al ; Save for boot prompt check
+ test al,04h ; Ctrl->skip 386 check
+ jnz skip_checks
+test_8086:
+ pushf ; Get flags
+ pop ax
+ and ax,0FFFh ; Clear top 4 bits
+ push ax ; Load into FLAGS
+ popf
+ pushf ; And load back
+ pop ax
+ and ax,0F000h ; Get top 4 bits
+ cmp ax,0F000h ; If set -> 8086/8088
+ je not_386
+test_286:
+ pushf ; Get flags
+ pop ax
+ or ax,0F000h ; Set top 4 bits
+ push ax
+ popf
+ pushf
+ pop ax
+ and ax,0F000h ; Get top 4 bits
+ jnz is_386 ; If not clear -> 386
+not_386:
+ mov si,err_not386
+ call writestr
+ jmp kaboom
+is_386:
+ ; Now we know it's a 386 or higher
+;
+; Now check that there is sufficient low (DOS) memory
+;
+ int 12h
+ cmp ax,(real_mode_seg+0xa00) >> 6
+ jae enough_ram
+ mov si,err_noram
+ call writestr
+ jmp kaboom
+enough_ram:
+skip_checks:
+
+;
+; Check if we're 386 (as opposed to 486+); if so we need to blank out
+; the WBINVD instruction
+;
+; We check for 486 by setting EFLAGS.AC
+;
+%if DO_WBINVD
+ pushfd ; Save the good flags
+ pushfd
+ pop eax
+ mov ebx,eax
+ xor eax,(1 << 18) ; AC bit
+ push eax
+ popfd
+ pushfd
+ pop eax
+ popfd ; Restore the original flags
+ xor eax,ebx
+ jnz is_486
+;
+; 386 - Looks like we better blot out the WBINVD instruction
+;
+ mov byte [try_wbinvd],0c3h ; Near RET
+is_486:
+%endif ; DO_WBINVD
+;
+; Mark A20 type as unknown. This particular word needs to be in BSS,
+; so it needs to be initialized.
+;
+ mov word [A20Type],0
+
+
diff --git a/isolinux-debug.asm b/isolinux-debug.asm
new file mode 100644
index 00000000..be3b6cec
--- /dev/null
+++ b/isolinux-debug.asm
@@ -0,0 +1,21 @@
+;; $Id$
+;; -----------------------------------------------------------------------
+;;
+;; Copyright 2002 H. Peter Anvin - All Rights Reserved
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+;; Bostom MA 02111-1307, USA; either version 2 of the License, or
+;; (at your option) any later version; incorporated herein by reference.
+;;
+;; -----------------------------------------------------------------------
+
+;;
+;; isolinux-debug.asm
+;;
+;; Wrapper for debugging version of ISOLINUX
+;;
+
+%define DEBUG_MESSAGES
+%include "isolinux.asm"
diff --git a/isolinux.asm b/isolinux.asm
index d9e6682c..b3a4a7ac 100644
--- a/isolinux.asm
+++ b/isolinux.asm
@@ -21,36 +21,25 @@
%define IS_ISOLINUX 1
%include "macros.inc"
+%include "config.inc"
%include "kernel.inc"
%include "bios.inc"
%include "tracers.inc"
;
-; Some semi-configurable constants... change on your own risk. Most are imposed
-; by the kernel.
+; Some semi-configurable constants... change on your own risk.
;
my_id equ isolinux_id
-max_cmd_len equ 255 ; Must be odd; 255 is the kernel limit
FILENAME_MAX_LG2 equ 8 ; log2(Max filename size Including final null)
FILENAME_MAX equ (1 << FILENAME_MAX_LG2)
NULLFILE equ 0 ; Zero byte == null file name
-HIGHMEM_MAX equ 037FFFFFFh ; DEFAULT highest address for an initrd
%assign HIGHMEM_SLOP 128*1024 ; Avoid this much memory near the top
-DEFAULT_BAUD equ 9600 ; Default baud rate for serial port
-BAUD_DIVISOR equ 115200 ; Serial port parameter
MAX_OPEN_LG2 equ 6 ; log2(Max number of open files)
MAX_OPEN equ (1 << MAX_OPEN_LG2)
SECTORSIZE_LG2 equ 11 ; 2048 bytes/sector (El Torito requirement)
SECTORSIZE equ (1 << SECTORSIZE_LG2)
;
-; Should be updated with every release to avoid bootsector/SYS file mismatch
-;
-%define version_str VERSION ; Must be 4 characters long!
-%define date DATE_STR ; Defined from the Makefile
-%define year '2002'
-
-;
; The following structure is used for "virtual kernels"; i.e. LILO-style
; option labels. The options we permit here are `kernel' and `append
; Since there is no room in the bottom 64K for all of these, we
@@ -173,6 +162,7 @@ InitRDCNameLen resw 1 ; Length of unmangled initrd name
NextCharJump resw 1 ; Routine to interpret next print char
SetupSecs resw 1 ; Number of setup sectors
A20Test resw 1 ; Counter for testing status of A20
+A20Type resw 1 ; A20 type
CmdLineLen resw 1 ; Length of command line including null
GraphXSize resw 1 ; Width of splash screen file
VGAPos resw 1 ; Pointer into VGA memory
@@ -713,6 +703,11 @@ all_read:
TRACER '>'
;
+; Common initialization code
+;
+%include "cpuinit.inc"
+
+;
; Clear Files structures
;
mov di,Files
@@ -720,85 +715,6 @@ all_read:
xor eax,eax
rep stosd
-;
-; Check that no moron is trying to boot Linux on a 286 or so. According
-; to Intel, the way to check is to see if the high 4 bits of the FLAGS
-; register are either all stuck at 1 (8086/8088) or all stuck at 0
-; (286 in real mode), if not it is a 386 or higher. They didn't
-; say how to check for a 186/188, so I *hope* it falls out as a 8086
-; or 286 in this test.
-;
-; Also, provide an escape route in case it doesn't work.
-;
-check_escapes:
- mov ah,02h ; Check keyboard flags
- int 16h
- mov [KbdFlags],al ; Save for boot prompt check
- test al,04h ; Ctrl->skip 386 check
- jnz skip_checks
-test_8086:
- pushf ; Get flags
- pop ax
- and ax,0FFFh ; Clear top 4 bits
- push ax ; Load into FLAGS
- popf
- pushf ; And load back
- pop ax
- and ax,0F000h ; Get top 4 bits
- cmp ax,0F000h ; If set -> 8086/8088
- je not_386
-test_286:
- pushf ; Get flags
- pop ax
- or ax,0F000h ; Set top 4 bits
- push ax
- popf
- pushf
- pop ax
- and ax,0F000h ; Get top 4 bits
- jnz is_386 ; If not clear -> 386
-not_386:
- mov si,err_not386
- call writestr
- jmp kaboom
-is_386:
- ; Now we know it's a 386 or higher
-;
-; Now check that there is sufficient low (DOS) memory
-;
- int 12h
- cmp ax,(real_mode_seg+0xa00) >> 6
- jae enough_ram
- mov si,err_noram
- call writestr
- jmp kaboom
-enough_ram:
-skip_checks:
-
-;
-; Check if we're 386 (as opposed to 486+); if so we need to blank out
-; the WBINVD instruction
-;
-; We check for 486 by setting EFLAGS.AC
-;
- pushfd ; Save the good flags
- pushfd
- pop eax
- mov ebx,eax
- xor eax,(1 << 18) ; AC bit
- push eax
- popfd
- pushfd
- pop eax
- popfd ; Restore the original flags
- xor eax,ebx
- jnz is_486
-;
-; 386 - Looks like we better blot out the WBINVD instruction
-;
- mov byte [try_wbinvd],0c3h ; Near RET
-is_486:
-
;
; Now we're all set to start with our *real* business. First load the
; configuration file (if any) and parse it.
diff --git a/ldlinux.asm b/ldlinux.asm
index ec8157d1..8bfdf763 100644
--- a/ldlinux.asm
+++ b/ldlinux.asm
@@ -28,30 +28,20 @@
%define IS_SYSLINUX 1
%include "macros.inc"
+%include "config.inc"
%include "kernel.inc"
%include "bios.inc"
%include "tracers.inc"
;
-; Some semi-configurable constants... change on your own risk. Most are imposed
-; by the kernel.
+; Some semi-configurable constants... change on your own risk.
;
my_id equ syslinux_id
-max_cmd_len equ 255 ; Must be odd; 255 is the kernel limit
FILENAME_MAX_LG2 equ 4 ; log2(Max filename size Including final null)
FILENAME_MAX equ 11 ; Max mangled filename size
NULLFILE equ ' ' ; First char space == null filename
retry_count equ 6 ; How patient are we with the disk?
-HIGHMEM_MAX equ 037FFFFFFh ; DEFAULT highest address for an initrd
%assign HIGHMEM_SLOP 0 ; Avoid this much memory near the top
-DEFAULT_BAUD equ 9600 ; Default baud rate for serial port
-BAUD_DIVISOR equ 115200 ; Serial port parameter
-;
-; Should be updated with every release to avoid bootsector/SYS file mismatch
-;
-%define version_str VERSION ; Must be 4 characters long!
-%define date DATE_STR ; Defined from the Makefile
-%define year '2002'
;
; The following structure is used for "virtual kernels"; i.e. LILO-style
@@ -170,6 +160,7 @@ InitRDCNameLen resw 1 ; Length of unmangled initrd name
NextCharJump resw 1 ; Routine to interpret next print char
SetupSecs resw 1 ; Number of setup sectors
A20Test resw 1 ; Counter for testing status of A20
+A20Type resw 1 ; A20 type
CmdLineLen resw 1 ; Length of command line including null
GraphXSize resw 1 ; Width of splash screen file
VGAPos resw 1 ; Pointer into VGA memory
@@ -937,83 +928,11 @@ all_read:
;
mov si,copyright_str
call writestr
+
;
-; Check that no moron is trying to boot Linux on a 286 or so. According
-; to Intel, the way to check is to see if the high 4 bits of the FLAGS
-; register are either all stuck at 1 (8086/8088) or all stuck at 0
-; (286 in real mode), if not it is a 386 or higher. They didn't
-; say how to check for a 186/188, so I *hope* it falls out as a 8086
-; or 286 in this test.
-;
-; Also, provide an escape route in case it doesn't work.
-;
-check_escapes:
- mov ah,02h ; Check keyboard flags
- int 16h
- mov [KbdFlags],al ; Save for boot prompt check
- test al,04h ; Ctrl->skip 386 check
- jnz skip_checks
-test_8086:
- pushf ; Get flags
- pop ax
- and ax,0FFFh ; Clear top 4 bits
- push ax ; Load into FLAGS
- popf
- pushf ; And load back
- pop ax
- and ax,0F000h ; Get top 4 bits
- cmp ax,0F000h ; If set -> 8086/8088
- je not_386
-test_286:
- pushf ; Get flags
- pop ax
- or ax,0F000h ; Set top 4 bits
- push ax
- popf
- pushf
- pop ax
- and ax,0F000h ; Get top 4 bits
- jnz is_386 ; If not clear -> 386
-not_386:
- mov si,err_not386
- call writestr
- jmp kaboom
-is_386:
- ; Now we know it's a 386 or higher
-;
-; Now check that there is sufficient low (DOS) memory
-;
- int 12h
- cmp ax,(real_mode_seg+0xa00) >> 6
- jae enough_ram
- mov si,err_noram
- call writestr
- jmp kaboom
-enough_ram:
-skip_checks:
-;
-; Check if we're 386 (as opposed to 486+); if so we need to blank out
-; the WBINVD instruction
-;
-; We check for 486 by setting EFLAGS.AC
-;
- pushfd ; Save the good flags
- pushfd
- pop eax
- mov ebx,eax
- xor eax,(1 << 18) ; AC bit
- push eax
- popfd
- pushfd
- pop eax
- popfd ; Restore the original flags
- xor eax,ebx
- jnz is_486
-;
-; 386 - Looks like we better blot out the WBINVD instruction
+; Common initialization code
;
- mov byte [try_wbinvd],0c3h ; Near RET
-is_486:
+%include "cpuinit.inc"
;
; Initialization that does not need to go into the any of the pre-load
@@ -1029,6 +948,14 @@ is_486:
mov word [kaboom.patch+1],kaboom2-(kaboom.patch+3)
;
+; Compute some parameters that depend on cluster size
+;
+ mov dx,1
+ xor ax,ax
+ div word [ClustSize]
+ mov [ClustPerMoby],ax ; Clusters/64K
+
+;
; Now we're all set to start with our *real* business. First load the
; configuration file (if any) and parse it.
;
diff --git a/pxelinux.asm b/pxelinux.asm
index f447b7de..6735615f 100644
--- a/pxelinux.asm
+++ b/pxelinux.asm
@@ -20,25 +20,21 @@
%define IS_PXELINUX 1
%include "macros.inc"
+%include "config.inc"
%include "kernel.inc"
%include "bios.inc"
%include "tracers.inc"
%include "pxe.inc"
;
-; Some semi-configurable constants... change on your own risk. Most are imposed
-; by the kernel.
+; Some semi-configurable constants... change on your own risk.
;
my_id equ pxelinux_id
-max_cmd_len equ 255 ; Must be odd; 255 is the kernel limit
FILENAME_MAX_LG2 equ 6 ; log2(Max filename size Including final null)
FILENAME_MAX equ (1 << FILENAME_MAX_LG2)
NULLFILE equ 0 ; Zero byte == null file name
REBOOT_TIME equ 5*60 ; If failure, time until full reset
-HIGHMEM_MAX equ 037FFFFFFh ; DEFAULT highest address for an initrd
%assign HIGHMEM_SLOP 128*1024 ; Avoid this much memory near the top
-DEFAULT_BAUD equ 9600 ; Default baud rate for serial port
-BAUD_DIVISOR equ 115200 ; Serial port parameter
MAX_SOCKETS_LG2 equ 6 ; log2(Max number of open sockets)
MAX_SOCKETS equ (1 << MAX_SOCKETS_LG2)
TFTP_PORT equ htons(69) ; Default TFTP port
@@ -213,6 +209,7 @@ InitRDCNameLen resw 1 ; Length of unmangled initrd name
NextCharJump resw 1 ; Routine to interpret next print char
SetupSecs resw 1 ; Number of setup sectors
A20Test resw 1 ; Counter for testing status of A20
+A20Type resw 1 ; A20 type
CmdLineLen resw 1 ; Length of command line including null
GraphXSize resw 1 ; Width of splash screen file
VGAPos resw 1 ; Pointer into VGA memory
@@ -593,84 +590,10 @@ udp_init:
jmp kaboom
.success:
-;
-; Check that no moron is trying to boot Linux on a 286 or so. According
-; to Intel, the way to check is to see if the high 4 bits of the FLAGS
-; register are either all stuck at 1 (8086/8088) or all stuck at 0
-; (286 in real mode), if not it is a 386 or higher. They didn't
-; say how to check for a 186/188, so I *hope* it falls out as a 8086
-; or 286 in this test.
-;
-; Also, provide an escape route in case it doesn't work.
-;
-check_escapes:
- mov ah,02h ; Check keyboard flags
- int 16h
- mov [KbdFlags],al ; Save for boot prompt check
- test al,04h ; Ctrl->skip 386 check
- jnz skip_checks
-test_8086:
- pushf ; Get flags
- pop ax
- and ax,0FFFh ; Clear top 4 bits
- push ax ; Load into FLAGS
- popf
- pushf ; And load back
- pop ax
- and ax,0F000h ; Get top 4 bits
- cmp ax,0F000h ; If set -> 8086/8088
- je not_386
-test_286:
- pushf ; Get flags
- pop ax
- or ax,0F000h ; Set top 4 bits
- push ax
- popf
- pushf
- pop ax
- and ax,0F000h ; Get top 4 bits
- jnz is_386 ; If not clear -> 386
-not_386:
- mov si,err_not386
- call writestr
- jmp kaboom
-is_386:
- ; Now we know it's a 386 or higher
-;
-; Now check that there is sufficient low (DOS) memory
-;
- int 12h
- cmp ax,(real_mode_seg+0xa00) >> 6
- jae enough_ram
- mov si,err_noram
- call writestr
- jmp kaboom
-enough_ram:
-skip_checks:
-
-;
-; Check if we're 386 (as opposed to 486+); if so we need to blank out
-; the WBINVD instruction
-;
-; We check for 486 by setting EFLAGS.AC
-;
- pushfd ; Save the good flags
- pushfd
- pop eax
- mov ebx,eax
- xor eax,(1 << 18) ; AC bit
- push eax
- popfd
- pushfd
- pop eax
- popfd ; Restore the original flags
- xor eax,ebx
- jnz is_486
;
-; 386 - Looks like we better blot out the WBINVD instruction
+; Common initialization code
;
- mov byte [try_wbinvd],0c3h ; Near RET
-is_486:
+%include "cpuinit.inc"
;
; Now we're all set to start with our *real* business. First load the
diff --git a/runkernel.inc b/runkernel.inc
index 1240444c..165af987 100644
--- a/runkernel.inc
+++ b/runkernel.inc
@@ -318,13 +318,14 @@ read_kernel:
; Move the stuff beyond the setup code to high memory at 100000h
;
movzx esi,word [SetupSecs] ; Setup sectors
- inc esi ; plus 1 boot sector
- shl esi,9 ; Convert to bytes
+ inc si ; plus 1 boot sector
+ shl si,9 ; Convert to bytes
mov ecx,8000h ; 32K
sub ecx,esi ; Number of bytes to copy
push ecx
add esi,(real_mode_seg << 4) ; Pointer to source
mov edi,100000h ; Copy to address 100000h
+
call bcopy ; Transfer to high memory
; On exit EDI -> where to load the rest