Export the 64-bit partition offset and use it in chain.c
authorH. Peter Anvin <hpa@zytor.com>
Sun, 27 Jun 2010 19:02:48 +0000 (12:02 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Sun, 27 Jun 2010 19:02:48 +0000 (12:02 -0700)
When used with the "fs" option to chain.c32, we need to know our own
filesystem offset.  That means knowing if we used the MBR vs GPT
partition information, as well as if we ended up using the passed-in
information or not.

Resolve this by providing an explicit pointer to the current partition
offset.  Eventually this should be replaced by some kind of statfs()
call.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
com32/include/syslinux/config.h
com32/modules/chain.c
core/comboot.inc
core/isolinux.asm
doc/comboot.txt

index f315f44..79a4750 100644 (file)
@@ -112,6 +112,7 @@ union syslinux_derivative_info {
        uint32_t _eflags;
        const void *ptab_ptr;
        const uint32_t *esdi_ptr;
+       const uint64_t *partoffset;
     } disk;                    /* syslinux/extlinux */
     struct {
        uint16_t _gs, _fs, _es, _ds;
@@ -138,6 +139,7 @@ union syslinux_derivative_info {
        uint32_t _eflags;
        const void *spec_packet;
        const uint32_t *esdi_ptr;
+       const uint64_t *partoffset;
     } iso;                     /* isolinux */
 };
 
index 555cff1..b53054e 100644 (file)
@@ -1425,9 +1425,10 @@ int main(int argc, char *argv[])
            drive = sdi->disk.drive_number;
        if (!strcmp(drivename, "fs")
            && (sdi->c.filesystem == SYSLINUX_FS_SYSLINUX
-               || sdi->c.filesystem == SYSLINUX_FS_EXTLINUX))
+               || sdi->c.filesystem == SYSLINUX_FS_EXTLINUX
+               || sdi->c.filesystem == SYSLINUX_FS_ISOLINUX))
            /* We should lookup the Syslinux partition number and use it */
-           fs_lba = ((struct part_entry *)sdi->disk.ptab_ptr)->start_lba;
+           fs_lba = *sdi->disk.partoffset;
     } else {
        error("Unparsable drive specification\n");
        goto bail;
index 91cc15a..65b20be 100644 (file)
@@ -593,6 +593,8 @@ comapi_derinfo:
                mov P_DL,al
                mov P_FS,cs
                mov P_SI,OrigESDI
+               mov P_GS,cs
+               mov P_DI,Hidden
 %if IS_SYSLINUX || IS_EXTLINUX
                mov P_ES,cs
                mov P_BX,PartInfo
index 8060767..d9d630e 100644 (file)
@@ -101,7 +101,7 @@ ISOFlags    resb 1                  ; Flags for ISO directory search
 RetryCount      resb 1                 ; Used for disk access retries
 
                alignb 8
-bsHidden       resq 1                  ; Used in hybrid mode
+Hidden resq 1                  ; Used in hybrid mode
 bsSecPerTrack  resw 1                  ; Used in hybrid mode
 bsHeads                resw 1                  ; Used in hybrid mode
 
@@ -242,8 +242,8 @@ _start_hybrid:
                pop eax
                pop ebx
 .nooffset:
-               mov [cs:bsHidden],eax
-               mov [cs:bsHidden+4],ebx
+               mov [cs:Hidden],eax
+               mov [cs:Hidden+4],ebx
 
                mov si,bios_cbios
                jcxz _start_common
@@ -779,8 +779,8 @@ getlinsec_ebios:
                xor edx,edx
                shld edx,eax,2
                shl eax,2                       ; Convert to HDD sectors
-               add eax,[bsHidden]
-               adc edx,[bsHidden+4]
+               add eax,[Hidden]
+               adc edx,[Hidden+4]
                shl bp,2
 
 .loop:
@@ -852,7 +852,7 @@ getlinsec_ebios:
 getlinsec_cbios:
                xor edx,edx
                shl eax,2                       ; Convert to HDD sectors
-               add eax,[bsHidden]
+               add eax,[Hidden]
                shl bp,2
 
 .loop:
@@ -1165,8 +1165,8 @@ init_fs:
 .hybrid:
                movzx ebp,word [MaxTransfer]
 .common:
-               mov ecx,[bsHidden]
-               mov ebx,[bsHidden+4]
+               mov ecx,[Hidden]
+               mov ebx,[Hidden+4]
                 mov si,[bsHeads]
                mov di,[bsSecPerTrack]
                pm_call fs_init
index 9e9f99a..4b4b880 100644 (file)
@@ -426,8 +426,12 @@ AX=000Ah [2.00]    Get Derivative-Specific Information
        Output: AL      31h (SYSLINUX), 34h (EXTLINUX)
                DL      drive number
                CL      sector size as a power of 2 (9 = 512 bytes) [3.35]
+               CH      mode [3.73]
+                       1 = CBIOS mode
+                       2 = EBIOS mode
                ES:BX   pointer to partition table entry (if DL >= 80h)
                FS:SI   pointer to initial ES:DI value [3.53]
+               GS:DI   pointer to partition offset (QWORD) [4.00]
 
                Note: This function was broken in EXTLINUX 3.00-3.02.
 
@@ -501,6 +505,7 @@ AX=000Ah [2.00]     Get Derivative-Specific Information
                        2 = Hybrid (hard disk), EBIOS mode
                ES:BX   pointer to El Torito spec packet
                FS:SI   pointer to initial ES:DI value [3.53]
+               GS:DI   pointer to partition offset (QWORD) [4.00]
 
                Note: Some very broken El Torito implementations do
                not provide the spec packet information.  If so, ES:BX
@@ -508,10 +513,6 @@ AX=000Ah [2.00]    Get Derivative-Specific Information
                AX=4B01h to obtain the spec packet directly from the
                BIOS if necessary.
 
-       This call gives information specific to a particular Syslinux
-       derivative.  The value returned in AL is the same as is
-       returned in DL by INT 22h AX=0001h.
-
 
 AX=000Bh [2.00]        Get Serial Console Configuration