core: Move sector 1 to address 0x8000 so it is aligned
authorH. Peter Anvin <hpa@linux.intel.com>
Tue, 5 Apr 2011 21:07:32 +0000 (14:07 -0700)
committerH. Peter Anvin <hpa@linux.intel.com>
Tue, 5 Apr 2011 21:07:32 +0000 (14:07 -0700)
Move sector 1 to 0x8000, so that it will be sector-aligned no matter
what the sector size is (well, as long as it is <= 32K).  This avoids
potential conflicts between the 64K "seams" and the sector size.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
core/Makefile
core/diskboot.inc
core/diskstart.inc

index 33ad7e9..e89c419 100644 (file)
@@ -109,7 +109,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 $< $@
index 68672e4..141986e 100644 (file)
@@ -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
 
 ;
index 71cdaee..0124853 100644 (file)
@@ -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
 ; ===========================================================================
 
@@ -424,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