Use the linker to assign xfer_bug_seg and real_mode_seg.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
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
;; conio.inc
;;
;; Console I/O code, except:
-;; writechr, writestr_early - module-dependent
+;; writechr, writestr_early - module-dependent
;; writestr, crlf - writestr.inc
;; writehex* - writehex.inc
;;
; 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:
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'
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.
;
; 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]
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
; 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
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
ja .overflow
push esi ; <D> 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 ; <D> File handle/cluster pointer
popf ; <C> EOF status
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
; 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
; 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
__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