Changeset 153


Ignore:
Timestamp:
Apr 8, 2017, 12:27:55 AM (8 years ago)
Author:
Ben Rietbroek
Message:

Prepared 'LVM_GetDriveLetter' for reimplementation [v1.1.1-testing]

This is one ugly mthrfscker of which we won't even record the diff with
its reimplementation.

CAUTION:
This is a testbuild !
AirBoot uses the BIOS to access disks and a small coding error can trash
partition tables or other vital disk structures. You are advised to make
backups of TRACK0 and EBRs before using this testbuild. More info at:
https://rousseaux.github.io/netlabs.air-boot/pdf/AirBoot-v1.1.0-manual.pdf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bootcode/special/lvm.asm

    r124 r153  
    220220
    221221
    222 ; Gets a drive-letter from the LVM-info of a partition. (if it exists)
    223 ;        In: BX:CX - LBA starting sector of partition to be searched
    224 ;            DL = Physical Disk in BIOS notation. (80h+)
    225 ;       Out: CY=1 if LVM-info found, 0 if no LVM-info.
    226 ;            AL - drive-letter from LVM-info or zero if no drive-letter
    227 ;            assigned or no LVM-info.
     222
    228223LVM_GetDriveLetter      Proc Near   Uses bx cx dx si di ds es
    229 
    230 IFDEF   AUX_DEBUG
    231         IF 0
    232         DBG_TEXT_OUT_AUX    'LVM_GetDriveLetter:'
    233         PUSHRF
    234             ;~ call    DEBUG_DumpRegisters
    235             ;~ call    AuxIO_DumpParagraph
    236             ;~ call    AuxIO_TeletypeNL
    237         POPRF
    238         ENDIF
    239 ENDIF
    240 
    241 
    242 
    243         ; For primary partitions this information is stored in the last
    244         ; sector of track0; for all four partition entries in case they
    245         ; they are all primary ones.
    246         ;
    247         ; LVM DLAT info for logical partitions is stored in the sector
    248         ; preceding the start of the partition.
    249         ;
    250         ; Because the LVM info of a logical partition is the easiest to find,
    251         ; we do that first. The LVM info for primary partitions is located
    252         ; dependent on the geometry in use, so we use a special locater
    253         ; call for that. Also, since the LVM info for primaries contains
    254         ; info on all 4 entries, we need the partition index to obtain the
    255         ; correct drive-letter.
    256         ;
    257 
    258         ; See if this is a primary partition
    259         ; CY will be set if it is and AL will contain the 0-based
    260         ; index in the P-table.
    261         ; If it's a logical partition, CY will be clear and AL
    262         ; will be set to 0ffh indicating an invalid index.
    263         call    PART_IsPrimaryPartition
    264 IF 0
    265                 pushf
    266                 pusha
    267                 call    VideoIO_PrintHexWord
    268                 popa
    269                 popf
    270 ENDIF
    271         mov     al,0
    272         rcl     al,1        ; CY if primary
    273         mov     dh,al       ; Save PRI or LOG
    274 
    275         ; Save PRI/LOG indicator for later use
    276         push    dx
    277 
    278         ; Load *possible* LVM sector
    279         ; This load is only valid if the partition is logical, in which case
    280         ; the LVM sector is below the start of the partition.
    281         ; If primary, the LVM sector is at a location that
    282         ; DriveIO_LoadMasterLVMSector will find out.
    283 
    284         ; Push LBA address
    285         push    bx
    286         push    cx
    287 
    288         ; Adjust for logical LVM-sector
    289         sub     cx,1
    290         sbb     bx,0
    291 
    292         ; Load the LVM sector
    293         push    si
    294         push    di
    295         mov     si,offset [LVMSector]
    296         mov     di,ds
    297         mov     ax, cx                      ; LBA low is now in AX
    298         call    DriveIO_ReadSectorLBA
    299         pop     di
    300         pop     si
    301 
    302         ; Restore LBA address
    303         pop     cx
    304         pop     bx
    305 
    306         ; Restore PRI/LOG partition indicator in DH
    307         pop     dx
    308 
    309         ; Test PRI or not
    310         test    dh,dh
    311         ; It's not a PRI so we can use the previously loaded LVM sector
    312         jz      LVM_GetDriveLetter_is_not_pri
    313 
    314         ;
    315         ; It's a PRI so we use the special locator function.
    316         ; This locator takes care of extended OS/2 geometry should that be used
    317         ;
    318 IF 0
    319                 ; DH=0 or 1, DL=disk (8?h)
    320                 pushf
    321                 pusha
    322                 mov     ax, dx
    323                 call    VideoIO_PrintHexWord
    324                 mov     al,'-'
    325                 call    VideoIO_PrintSingleChar
    326                 popa
    327                 popf
    328 ENDIF
    329         ; THIS ONE FAULTERS WHEN DISKS > 1
    330         call    DriveIO_LoadMasterLVMSector
    331 
    332 IF 0
    333                 ; INVALID LVM SECTOR !!
    334                 pushf
    335                 pusha
    336                 mov     ax,0000h
    337                 rcl     al,1
    338                 call    VideoIO_PrintHexWord        ; LVMSector
    339                 mov     al,'-'
    340                 call    VideoIO_PrintSingleChar
    341                 mov     si, offset [LVMSector]
    342                 mov     ax, si
    343                 call    VideoIO_PrintHexWord        ; LVMSector
    344                 lodsw
    345                 call    VideoIO_PrintHexWord        ; sig
    346                 lodsw
    347                 call    VideoIO_PrintHexWord        ; sig
    348                 mov     al,'-'
    349                 call    VideoIO_PrintSingleChar
    350                 popa
    351                 popf
    352 ENDIF
    353 
    354     LVM_GetDriveLetter_is_not_pri:
    355 
    356 
    357         ;
    358         ; At this stage the LVM-info sector has been loaded at [LVMSector].
    359         ; From here we look for an LVM entry for the partition.
    360         ; If one is found, based on it's LBA-start, it's driveletter is used
    361         ; in case byte 25h in the BPB is zero.
    362         ;
    363 
    364 
    365         ; Search for the partition in the LVM info.
    366         ; If found, CY is set and SI points to LVM entry.
    367         push    si
    368         mov     ax,cx
    369         mov     dx,bx                   ; DL DESTROYED
    370         mov     si,offset [LVMSector]
    371         call    LVM_SearchForPartition
    372 
    373 IF 0
    374                 pushf
    375                 pusha
    376                 mov     ax, 0000h
    377                 rcl     al, 1
    378                 call    VideoIO_PrintHexWord
    379                 mov     ax, si
    380                 call    VideoIO_PrintHexWord
    381                 popa
    382                 popf
    383 ENDIF
    384 
    385 IFDEF   AUX_DEBUG
    386         IF 0
    387         DBG_TEXT_OUT_AUX    'LVM_GetDriveLetter:'
    388         PUSHRF
    389             call    DEBUG_DumpRegisters
    390             call    AuxIO_DumpParagraph
    391             call    AuxIO_TeletypeNL
    392         POPRF
    393         ENDIF
    394 ENDIF
    395 
    396         mov     bx,si   ; BX now points to LVM entry
    397         mov     dx,0
    398         pop     si
    399 
    400         mov     al,0    ; Setup null driveletter
    401         ; Oops, no valid LVM record was used so we have a null driveletter.
    402         jnc     LVM_GetDriveLetter_null_lvm_dl
    403 
    404         ;
    405         ; At this point BX points to the LVM-entry related to the
    406         ; partition, whether it was a logical or a primary one.
    407         ;
    408         mov     al,[bx+LocLVM_VolumeLetter]
    409         ; Test for zero dtive-letter.
    410         test    al,al
    411         ; Preset CY in case drive-letter is zero.
     224        xor     al, al
    412225        clc
    413         jz      LVM_GetDriveLetter_null_lvm_dl
    414 
    415         ; We have a non-zero drive-letter, so set CY.
    416         stc
    417 
    418     LVM_GetDriveLetter_null_lvm_dl:
    419226        ret
    420227LVM_GetDriveLetter      EndP
Note: See TracChangeset for help on using the changeset viewer.