From ced4ec389bd2d915f3e00e41736737279fba89ec Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sun, 21 Feb 2010 15:42:03 -0800 Subject: [PATCH] core: let xfer_buf_seg, real_mode_seg be assigned by the linker Use the linker to assign xfer_bug_seg and real_mode_seg. Signed-off-by: H. Peter Anvin --- core/com32.inc | 2 +- core/conio.inc | 2 +- core/init.inc | 16 ++++++++++++---- core/isolinux.asm | 2 +- core/kernel.inc | 2 +- core/layout.inc | 25 +++++++++++++++++-------- core/loadhigh.inc | 2 +- core/runkernel.inc | 6 +++--- core/syslinux.ld | 15 +++++++++++++-- 9 files changed, 50 insertions(+), 22 deletions(-) diff --git a/core/com32.inc b/core/com32.inc index 3fa2d31..b198dac 100644 --- a/core/com32.inc +++ b/core/com32.inc @@ -86,7 +86,7 @@ com32_start: push dword core_cfarcall ; Cfarcall entry point push dword core_farcall ; Farcall entry point push dword (1 << 16) ; 64K bounce buffer - push dword (xfer_buf_seg << 4) ; Bounce buffer address + push dword core_xfer_buf ; Bounce buffer address push dword core_intcall ; Intcall entry point push dword command_line ; Command line pointer push dword 7 ; Argument count diff --git a/core/conio.inc b/core/conio.inc index 60d1fcb..5157e48 100644 --- a/core/conio.inc +++ b/core/conio.inc @@ -15,7 +15,7 @@ ;; conio.inc ;; ;; Console I/O code, except: -;; writechr, writestr_early - module-dependent +;; writechr, writestr_early - module-dependent ;; writestr, crlf - writestr.inc ;; writehex* - writehex.inc ;; diff --git a/core/init.inc b/core/init.inc index a3fe304..90c0293 100644 --- a/core/init.inc +++ b/core/init.inc @@ -64,11 +64,19 @@ check_escapes: ; NOTE: Linux doesn't use all of real_mode_seg, but we use the same ; segment for COMBOOT images, which can use all 64K ; -dosram_k equ (real_mode_seg+0x1000) >> 6 ; Minimum DOS memory (K) int 12h - cmp ax,dosram_k + mov dx,real_mode_seg + 0x1000 + shr dx,6 + cmp ax,dx jae enough_ram + mov ax,dx mov si,err_noram + mov cl,10 + div cl + add [si+err_noram.size-err_noram+2],ah + cbw + div cl + add [si+err_noram.size-err_noram],ax call writestr_early jmp kaboom enough_ram: @@ -76,7 +84,7 @@ skip_checks: section .data16 err_noram db 'It appears your computer has less than ' - asciidec dosram_k +.size db '000' db 'K of low ("DOS")' db CR, LF db 'RAM. Syslinux needs at least this amount to boot. If you get' @@ -84,8 +92,8 @@ err_noram db 'It appears your computer has less than ' db 'this message in error, hold down the Ctrl key while' db CR, LF db 'booting, and I will take your word for it.', CR, LF, 0 - section .text16 + section .text16 ; ; The code to decompress the PM code and initialize other segments. ; diff --git a/core/isolinux.asm b/core/isolinux.asm index d6be750..4a029c4 100644 --- a/core/isolinux.asm +++ b/core/isolinux.asm @@ -414,7 +414,7 @@ found_file: ; address (7C00h) is *not* 2K-sector-aligned, the safest ; way to deal with this is to load into the xfer_buf_seg ; and then copy the data in place. -MaxLMA equ xfer_buf_seg << 4 +MaxLMA equ core_xfer_buf mov bx,(7C00h+SECTOR_SIZE) >> 4 mov bp,[ImageSectors] diff --git a/core/kernel.inc b/core/kernel.inc index 3ac5af1..245cd6d 100644 --- a/core/kernel.inc +++ b/core/kernel.inc @@ -63,7 +63,7 @@ cmd_line_here equ $ ; F800 Should be out of the way endstruc global cmd_line -cmd_line equ (real_mode_seg << 4) + cmd_line_here +cmd_line equ core_real_mode + cmd_line_here ; ; Old kernel command line signature diff --git a/core/layout.inc b/core/layout.inc index baf45b9..b769832 100644 --- a/core/layout.inc +++ b/core/layout.inc @@ -115,13 +115,6 @@ RBFG_brainfuck: resb 2048 ; Bigger than an Ethernet packet... ; Keep the low-memory footprint as small as possible... overrun is a hard ; failure! ; -; 0000h - main code/data segment (and BIOS segment) -; -; This stuff really should come from the linker... -; - global xfer_buf_seg, core_xfer_buf -xfer_buf_seg equ 2000h -core_xfer_buf equ xfer_buf_seg << 4 serial_buf_size equ 4096 ; Should be a power of 2 @@ -141,8 +134,24 @@ serial_buf_size equ 4096 ; Should be a power of 2 auxseg resb aux_size ; +; Transfer buffer segment: guaranteed to be aligned 64K, used for disk I/O +; One symbol for the segment number, one for the absolute address +; + extern xfer_buf_seg + section .xfer_buf write nobits align=65536 + global core_xfer_buf +core_xfer_buf resb 65536 + +; ; Segment for the real mode code (needed as long as we have a in-kernel ; loader and/or COM16 support. +; One symbol for the segment number, one for the absolute address ; -real_mode_seg equ xfer_buf_seg + 1000h + extern real_mode_seg + section .real_mode write nobits align=65536 + global core_real_mode +core_real_mode resb 65536 + comboot_seg equ real_mode_seg ; COMBOOT image loading zone + + section .text16 diff --git a/core/loadhigh.inc b/core/loadhigh.inc index 63ab001..205c3e6 100644 --- a/core/loadhigh.inc +++ b/core/loadhigh.inc @@ -87,7 +87,7 @@ load_high: ja .overflow push esi ; File handle/cluster pointer - mov esi,(xfer_buf_seg << 4) ; Source address + mov esi,core_xfer_buf ; Source address call bcopy ; Copy to high memory pop esi ; File handle/cluster pointer popf ; EOF status diff --git a/core/runkernel.inc b/core/runkernel.inc index 30177e8..f4dc28e 100644 --- a/core/runkernel.inc +++ b/core/runkernel.inc @@ -259,7 +259,7 @@ read_kernel: shl si,9 ; Convert to bytes mov ecx,8000h ; 32K sub ecx,esi ; Number of bytes to copy - add esi,(real_mode_seg << 4) ; Pointer to source + add esi,core_real_mode ; Pointer to source mov edi,free_high_memory ; Copy to free high memory call bcopy ; Transfer to high memory @@ -359,7 +359,7 @@ setup_command_line: ; New cmdline protocol ; Store 32-bit (flat) pointer to command line ; This is the "high" location, since we have bzImage - mov dword [fs:su_cmd_line_ptr],(real_mode_seg << 4)+cmd_line_here + mov dword [fs:su_cmd_line_ptr],cmd_line mov word [HeapEnd],linux_stack mov word [fs:su_heapend],linux_stack-512 jmp .setup_done @@ -422,7 +422,7 @@ setup_move: ; Loading low: move real_mode stuff to 90000h, then move the kernel down mov eax,90000h stosd - mov eax,real_mode_seg << 4 + mov eax,core_real_mode stosd movzx eax,word [CmdLineEnd] stosd diff --git a/core/syslinux.ld b/core/syslinux.ld index df7242e..f503920 100644 --- a/core/syslinux.ld +++ b/core/syslinux.ld @@ -226,9 +226,20 @@ SECTIONS __high_clear_len = __high_clear_end - __high_clear_start; __high_clear_dwords = (__high_clear_len + 3) >> 2; + /* + * Special 16-bit segments + */ + . = ALIGN(65536); + .xfer_buf (NOLOAD) : { + *(.xfer_buf) + } + xfer_buf_seg = core_xfer_buf >> 4; - __assert_high = ASSERT(__high_clear_end <= core_xfer_buf, - "auxseg/lowmem region collides with xfer_buf_seg"); + . = ALIGN(65536); + .real_mode (NOLOAD) : { + *(.real_mode) + } + real_mode_seg = core_real_mode >> 4; /* * 32-bit code. This is a hack for the moment due to the -- 2.7.4