aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2011-04-04 17:26:59 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2011-04-04 17:26:59 -0700
commit851b968489f2d31b0dd0dd07055656e59fa92404 (patch)
treea602958c0f50baf984ca79bd07c92184c830aa49 /core
parent0c527252d94c5fc54e637143ec9fdb36ac698c62 (diff)
downloadsyslinux-851b968489f2d31b0dd0dd07055656e59fa92404.tar.gz
syslinux-851b968489f2d31b0dd0dd07055656e59fa92404.tar.xz
syslinux-851b968489f2d31b0dd0dd07055656e59fa92404.zip
disk: Make the sector size dynamic
Make the sector size dynamic in anticipation of disks with non-512-byte logical sectors. With this change, bsBytesPerSec *must* be correct; this still needs to be added to the installers to enforce. Furthermore, the number of sectors in one extent can still only be < 64K. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'core')
-rw-r--r--core/diskfs.inc4
-rw-r--r--core/diskstart.inc26
2 files changed, 18 insertions, 12 deletions
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 d2154d94..db4955f7 100644
--- a/core/diskstart.inc
+++ b/core/diskstart.inc
@@ -105,13 +105,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
+ mov ebx,edi ; Start of the next sector
;
; Tell the user if we're using EBIOS or CBIOS
@@ -127,6 +129,7 @@ print_bios:
call writestr_early
section .earlybss
+ alignb 2
%define HAVE_BIOSNAME 1
BIOSName resw 1
@@ -135,8 +138,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
@@ -152,7 +156,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
@@ -165,9 +169,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]
@@ -255,7 +261,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
@@ -345,7 +351,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
@@ -429,8 +435,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 $
; ----------------------------------------------------------------------------