aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2011-04-21 21:32:41 -0700
committerH. Peter Anvin <hpa@zytor.com>2011-04-21 21:32:41 -0700
commitd8aff990d76ffa90f83c284cf13e5b3346b523b7 (patch)
tree67bbb75a7b2345261b6b6951316d01855db806d7 /core
parent8f5829b9f32fa9de1727255b1ef73fe4c0e6f2a7 (diff)
parentece69c7abc5b24523251e22a077951f2111311ad (diff)
downloadsyslinux-d8aff990d76ffa90f83c284cf13e5b3346b523b7.tar.gz
syslinux-d8aff990d76ffa90f83c284cf13e5b3346b523b7.tar.xz
syslinux-d8aff990d76ffa90f83c284cf13e5b3346b523b7.zip
Merge branch 'master' into lwip-threads
Diffstat (limited to 'core')
-rw-r--r--core/Makefile2
-rw-r--r--core/diskboot.inc2
-rw-r--r--core/diskfs.inc4
-rw-r--r--core/diskstart.inc40
-rw-r--r--core/head.inc4
5 files changed, 33 insertions, 19 deletions
diff --git a/core/Makefile b/core/Makefile
index f1afd6e4..34462619 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -110,7 +110,7 @@ ldlinux.bss: ldlinux.bin
dd if=$< of=$@ bs=512 count=1
ldlinux.sys: ldlinux.bin
- dd if=$< of=$@ bs=512 skip=1
+ dd if=$< of=$@ bs=512 skip=2
codepage.cp: ../codepage/$(CODEPAGE).cp
cp -f $< $@
diff --git a/core/diskboot.inc b/core/diskboot.inc
index 68672e4a..141986e8 100644
--- a/core/diskboot.inc
+++ b/core/diskboot.inc
@@ -278,7 +278,7 @@ Sect1Ptr1 equ $-4
cmp dword [ldlinux_magic+4],LDLINUX_MAGIC^HEXDATE
jne kaboom
- ; Go for it! This also normalizes CS:IP.
+ ; Go for it!
jmp ldlinux_ent
;
diff --git a/core/diskfs.inc b/core/diskfs.inc
index fc80a153..41391e7f 100644
--- a/core/diskfs.inc
+++ b/core/diskfs.inc
@@ -30,8 +30,8 @@ LDLINUX_MAGIC equ 0x3eb202fe ; A random number to identify ourselves with
; This indicates the general format of the last few bytes in the boot sector
BS_MAGIC_VER equ 0x1b << 9
-SECTOR_SHIFT equ 9
-SECTOR_SIZE equ (1 << SECTOR_SHIFT)
+MIN_SECTOR_SHIFT equ 9
+MIN_SECTOR_SIZE equ (1 << MIN_SECTOR_SHIFT)
;
; The following structure is used for "virtual kernels"; i.e. LILO-style
diff --git a/core/diskstart.inc b/core/diskstart.inc
index 02505a6b..b2ef2b63 100644
--- a/core/diskstart.inc
+++ b/core/diskstart.inc
@@ -23,6 +23,14 @@ Sect1Ptr1_VAL equ 0xfeedface
%include "diskboot.inc"
; ===========================================================================
+; Padding after the (minimum) 512-byte boot sector so that the rest of
+; the file has aligned sectors, even if they are larger than 512 bytes.
+; ===========================================================================
+
+ section .init
+align_pad zb 512
+
+; ===========================================================================
; Start of LDLINUX.SYS
; ===========================================================================
@@ -110,13 +118,15 @@ ldlinux_ent:
; Checksum data thus far
;
mov si,ldlinux_sys
- mov cx,SECTOR_SIZE >> 2
+ mov cx,[bsBytesPerSec]
+ shr cx,2
mov edx,-LDLINUX_MAGIC
.checksum:
lodsd
add edx,eax
loop .checksum
mov [CheckSum],edx ; Save intermediate result
+ movzx ebx,si ; Start of the next sector
;
; Tell the user if we're using EBIOS or CBIOS
@@ -132,6 +142,7 @@ print_bios:
call writestr_early
section .earlybss
+ alignb 2
%define HAVE_BIOSNAME 1
BIOSName resw 1
@@ -140,8 +151,9 @@ BIOSName resw 1
; Now we read the rest of LDLINUX.SYS.
;
load_rest:
+ push bx ; LSW of load address
+
lea esi,[SectorPtrs]
- mov ebx,TEXT_START+2*SECTOR_SIZE ; Where we start loading
mov cx,[DataSectors]
dec cx ; Minus this sector
@@ -157,7 +169,7 @@ load_rest:
xor bx,bx
call getlinsec
pop ebx
- shl ebp,SECTOR_SHIFT
+ imul bp,[bsBytesPerSec] ; Will be < 64K
add ebx,ebp
add si,10
jmp .get_chunk
@@ -170,9 +182,11 @@ load_rest:
; by the time we get to the end it should all cancel out.
;
verify_checksum:
- mov si,ldlinux_sys + SECTOR_SIZE
- mov ecx,[LDLDwords]
- sub ecx,SECTOR_SIZE >> 2
+ pop si ; LSW of load address
+ movzx eax,word [bsBytesPerSec]
+ shr ax,2
+ mov ecx,[LDLDwords] ; Total dwords
+ sub ecx,eax ; ... minus one sector
mov eax,[CheckSum]
.checksum:
add eax,[si]
@@ -260,7 +274,7 @@ getlinsec_ebios:
add eax,edi ; Advance sector pointer
adc edx,0
sub bp,di ; Sectors left
- shl di,SECTOR_SHIFT ; 512-byte sectors
+ imul di,[bsBytesPerSec]
add bx,di ; Advance buffer pointer
and bp,bp
jnz .loop
@@ -350,7 +364,7 @@ getlinsec_cbios:
jc .error
.resume:
movzx ecx,al ; ECX <- sectors transferred
- shl ax,SECTOR_SHIFT ; Convert sectors in AL to bytes in AX
+ imul ax,[bsBytesPerSec] ; Convert sectors in AL to bytes in AX
pop bx
add bx,ax
pop bp
@@ -418,10 +432,10 @@ safedumpregs:
rl_checkpt equ $ ; Must be <= 8000h
-rl_checkpt_off equ ($-$$)
+rl_checkpt_off equ $-ldlinux_sys
%ifndef DEPEND
- %if rl_checkpt_off > 3F6h ; Need one extent
- %assign rl_checkpt_overflow rl_checkpt_off - 3F6h
+ %if rl_checkpt_off > 512-10 ; Need minimum one extent
+ %assign rl_checkpt_overflow rl_checkpt_off - (512-10)
%error Sector 1 overflow by rl_checkpt_overflow bytes
%endif
%endif
@@ -434,8 +448,8 @@ rl_checkpt_off equ ($-$$)
;
alignz 2
MaxInitDataSize equ 96 << 10
-MaxLMA equ TEXT_START+SECTOR_SIZE+MaxInitDataSize
-SectorPtrs zb 10*(MaxInitDataSize >> SECTOR_SHIFT)
+MaxLMA equ LDLINUX_SYS+MaxInitDataSize
+SectorPtrs zb 10*(MaxInitDataSize >> MIN_SECTOR_SHIFT)
SectorPtrsEnd equ $
; ----------------------------------------------------------------------------
diff --git a/core/head.inc b/core/head.inc
index 18ce132c..71eb5744 100644
--- a/core/head.inc
+++ b/core/head.inc
@@ -20,8 +20,8 @@
%ifndef _HEAD_INC
%define _HEAD_INC
-%if __NASM_MAJOR__ < 2
- %error "NASM 2.00 or later required to compile correctly"
+%if __NASM_MAJOR__ < 2 || (__NASM_MAJOR__ == 2 && __NASM_MINOR__ < 3)
+ %error "NASM 2.03 or later required to compile correctly"
%endif
%include "macros.inc"