aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-05-24 19:18:02 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-05-24 19:18:02 -0700
commit96b9346c67f0c61e9b073f3f7c152154f97c0e3f (patch)
tree31466983a411e077dc84b65b3c8d1e45a76cb5a5
parent476a17a03b9729d4455e7f5516a4bc4c38b83efd (diff)
downloadsyslinux-96b9346c67f0c61e9b073f3f7c152154f97c0e3f.tar.gz
syslinux-96b9346c67f0c61e9b073f3f7c152154f97c0e3f.tar.xz
syslinux-96b9346c67f0c61e9b073f3f7c152154f97c0e3f.zip
Avoid clobbering PM code when loading the kernel
We can't safely use 1 MB to directly load the kernel, so shift the kernel just as we do when loading low. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--core/com32.inc3
-rw-r--r--core/layout.inc3
-rw-r--r--core/runkernel.inc14
-rw-r--r--core/syslinux.ld4
4 files changed, 12 insertions, 12 deletions
diff --git a/core/com32.inc b/core/com32.inc
index 3dd37b9e..1ab42488 100644
--- a/core/com32.inc
+++ b/core/com32.inc
@@ -27,8 +27,7 @@
; "mov ax,0x4cff; int 0x21" in 16-bit mode. This will abort the
; program with an error if run in 16-bit mode.
;
-
- extern com32_entry
+com32_entry equ free_high_memory
section .text16
is_com32_image:
diff --git a/core/layout.inc b/core/layout.inc
index c096c6f8..38238b3b 100644
--- a/core/layout.inc
+++ b/core/layout.inc
@@ -81,6 +81,8 @@ RBFG_brainfuck: resb 2048 ; Bigger than an Ethernet packet...
SECINFO pm_code
extern __bss_start, __bss_end, __bss_len, __bss_dwords
+ extern free_high_memory
+
global _start
section .text16
@@ -136,7 +138,6 @@ comboot_seg equ real_mode_seg ; COMBOOT image loading zone
; The prefix is a small structure that prefaces the actual code;
; it gives the compression program necessary information.
;
- extern __pm_code_lma
section .prefix nowrite progbits align=16
pfx_start dd _start ; Start of raw chunk
diff --git a/core/runkernel.inc b/core/runkernel.inc
index 083c9672..8d0f2968 100644
--- a/core/runkernel.inc
+++ b/core/runkernel.inc
@@ -257,7 +257,7 @@ read_kernel:
mov ecx,8000h ; 32K
sub ecx,esi ; Number of bytes to copy
add esi,(real_mode_seg << 4) ; Pointer to source
- mov edi,100000h ; Copy to address 100000h
+ mov edi,free_high_memory ; Copy to free high memory
call bcopy ; Transfer to high memory
@@ -412,6 +412,7 @@ setup_move:
push ds ; We need DS == ES == CS here
pop es
+ mov edx,100000h
test byte [LoadFlags],LOAD_HIGH
jnz .loading_high
@@ -423,20 +424,19 @@ setup_move:
movzx eax,word [CmdLineEnd]
stosd
inc cx
+ mov edx,10000h ; Revised target address
+ mov bx,9000h ; Revised real mode segment
- mov eax,10000h ; Target address of low kernel
+.loading_high:
+ mov eax,edx ; Target address of kernel
stosd
- mov eax,100000h ; Where currently loaded
+ mov eax,free_high_memory ; Where currently loaded
stosd
neg eax
add eax,[KernelEnd]
stosd
inc cx
- mov bx,9000h ; Revised real mode segment
-
-.loading_high:
-
cmp word [InitRDPtr],0 ; Did we have an initrd?
je .no_initrd
diff --git a/core/syslinux.ld b/core/syslinux.ld
index 718f2594..97294e85 100644
--- a/core/syslinux.ld
+++ b/core/syslinux.ld
@@ -256,7 +256,7 @@ SECTIONS
_end = .;
- /* COM32R binaries are loaded after our own PM code */
+ /* COM32R and kernels are loaded after our own PM code */
. = ALIGN(4096);
- com32_entry = .;
+ free_high_memory = .;
}