Changeset 152


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

Splitted-up the load/save LVM sector functions [v1.1.1-testing]

The high-level variants use '[CurPartition_Location]' to get the LBA
address of the MBR/EBR. However, we also need access to LVM information
at other points and we don't want to mess with '[CurPartition_Location]'
there. So, the new low-level variants, *XBR, take the LBA address of
the MBR/EBR and BIOS disk number in registers. Since the IPT stores the
LBA address where the partition tables for a partition are located,
the *XBR funtions now provide a convenient way to load the corresponding
LVM sector.

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/regular/driveio.asm

    r151 r152  
    382382
    383383IFDEF   AUX_DEBUG
    384         IF 1
     384        IF 0
    385385        DBG_TEXT_OUT_AUX    'DriveIO_LoadLVMSector:'
    386386        PUSHRF
     
    414414        mov     cx, wptr cs:[CurPartition_Location+6]   ; BIOS cyl & sec
    415415
     416        ; Do the actual loading.
     417        ; This is in a separate function so that LVM records can also be
     418        ; loaded using the MBR/EBR LBA addresses from IPT entries.
     419        call    DriveIO_LoadLVMSectorXBR
     420        jc      DIOLLVMS_NoLVMSector
     421
     422        ; We're done, indicate success and return
     423        clc
     424        jmp     DIOLLVMS_Done
     425
     426    DIOLLVMS_NoLVMSector:
     427
     428        ; Clear the sector buffer
     429        mov     si, offset [LVMSector]
     430        call    ClearSectorBuffer
     431        mov     bptr [si+LocLVM_SignatureStart], 0
     432
     433        ; Indicate no valid LVM sector was loaded
     434        stc
     435
     436    DIOLLVMS_Done:
     437
     438        ret
     439DriveIO_LoadLVMSector   EndP
     440
     441
     442
     443
     444
     445;------------------------------------------------------------------------------
     446; Attempts to load the corresponding LVM sector for a partition
     447;------------------------------------------------------------------------------
     448; IN    : AX    - LBA lo of MBR or EBR
     449;       : BX    - LBA hi of MBR or EBR
     450;       ; DL    - BIOS disk number
     451;       ; SI    - Pointer to sector buffer (usually [LVMSec])
     452; OUT   : CF=0  - A valid LVM sector was loaded
     453; NOTE  : LocIPT_AbsolutePartTable and LocIPT_Drive can provide LBA and DISK
     454;------------------------------------------------------------------------------
     455DriveIO_LoadLVMSectorXBR    Proc    Near
     456
     457IFDEF   AUX_DEBUG
     458        IF 1
     459        DBG_TEXT_OUT_AUX    'DriveIO_LoadLVMSectorXBR:'
     460        PUSHRF
     461            call    DEBUG_DumpRegisters
     462            ;~ call    AuxIO_DumpSector
     463            ;~ call    AuxIO_DumpParagraph
     464            ;~ call    AuxIO_TeletypeNL
     465        POPRF
     466        ENDIF
     467ENDIF
     468
     469        ; Save all registers
     470        pusha
     471
    416472        ; Calculate the entry in the DISKINFO array for this disk,
    417473        ; and put the LVM_SPT in DI
     
    423479        ; If the LVM_SPT is ZERO, no LVM info is present and we quit with CY
    424480        test    di, di                          ; See if it is 0
    425         jz      DIOLLVMS_NoLVMSector            ; Quit if so
     481        jz      DriveIO_LoadLVMSectorXBR_no_lvm ; Quit if so
    426482
    427483        ; Adjust the location to point to the LVM sector
     
    431487        sbb     bx, 0       ; Propagate borrow to LBA hi
    432488
    433         ; Load the LVM sector into [LVMSector]
    434         mov     si, offset [LVMSector]          ; Points to sector buffer
     489        ; Load the LVM sector into sector buffer pointed to by SI
    435490        mov     di, ds                          ; Segment of that buffer
    436491        call    DriveIO_ReadSectorLBA           ; Read the LVM sector
     
    441496        PUSHRF
    442497            call    DEBUG_DumpRegisters
    443             call    AuxIO_DumpSector
     498            ;~ call    AuxIO_DumpSector
     499            mov     cx, 3
     500        @@:
     501            call    AuxIO_DumpParagraph
     502            call    AuxIO_TeletypeNL
     503            add     si, 16
     504            loop @B
    444505            ;~ call    AuxIO_DumpParagraph
    445506            ;~ call    AuxIO_TeletypeNL
     
    448509ENDIF
    449510
    450         jc      DIOLLVMS_NoLVMSector            ; Quit on error
     511        jc      DriveIO_LoadLVMSectorXBR_no_lvm ; Quit on error
    451512
    452513        ; Check the validity of the LVM sector, quit with CY if invalid
    453514        call    LVM_ValidateSector              ; Check signature and CRC
    454         jnc     DIOLLVMS_NoLVMSector            ; Quit if not valid
     515        jnc     DriveIO_LoadLVMSectorXBR_no_lvm ; Quit if not valid
    455516
    456517        ; We're done, indicate success and return
    457518        clc
    458         jmp     DIOLLVMS_Done
    459 
    460     DIOLLVMS_NoLVMSector:
    461 
    462         ; Clear the sector buffer
    463         mov     si, offset [LVMSector]
    464         call    ClearSectorBuffer
    465         mov     bptr [si+LocLVM_SignatureStart], 0
    466 
     519        jmp     DriveIO_LoadLVMSectorXBR_done
     520
     521    DriveIO_LoadLVMSectorXBR_no_lvm:
    467522        ; Indicate no valid LVM sector was loaded
    468523        stc
    469524
    470     DIOLLVMS_Done:
    471 
    472         ret
    473 DriveIO_LoadLVMSector   EndP
    474 
     525    DriveIO_LoadLVMSectorXBR_done:
     526        ; Restore all registers
     527        popa
     528
     529        ret
     530DriveIO_LoadLVMSectorXBR    EndP
    475531
    476532
     
    501557
    502558IFDEF   AUX_DEBUG
    503         IF 1
     559        IF 0
    504560        DBG_TEXT_OUT_AUX    'DriveIO_SaveLVMSector:'
    505561        PUSHRF
     
    513569        ; Quit with CY if LVM is ignored in SETUP
    514570        test    byte ptr [CFG_IgnoreLVM], 1     ; ZF=0 means ignore LVM
    515         jnz     DIOSLVMS_SevereError            ; Quit if so
    516 
    517         ; Check the validity of the LVM sector, quit with CY if invalid
    518         call    LVM_ValidateSector              ; Check signature and CRC
    519         jnc     DIOSLVMS_SevereError            ; Quit if not valid
     571        jnz     DIOSLVMS_NoLVMSector            ; Quit if so
    520572
    521573        ; Load the location of the current partition being acted upon.
     
    532584        mov     cx, wptr cs:[CurPartition_Location+6]   ; BIOS cyl & sec
    533585
     586        ; Do the actual saving.
     587        ; This is in a separate function so that LVM records can also be
     588        ; saved using the MBR/EBR LBA addresses from IPT entries.
     589        call    DriveIO_SaveLVMSectorXBR
     590        jc      DIOSLVMS_NoLVMSector
     591
     592        ; We're done, indicate success and return
     593        clc
     594        jmp     DIOSLVMS_Done
     595
     596    DIOSLVMS_NoLVMSector:
     597        ; Indicate no valid LVM sector was saved
     598        stc
     599
     600    DIOSLVMS_Done:
     601        ret
     602DriveIO_SaveLVMSector   EndP
     603
     604
     605;------------------------------------------------------------------------------
     606; Attempts to save the corresponding LVM sector for a partition
     607;------------------------------------------------------------------------------
     608; IN    : AX    - LBA lo of MBR or EBR
     609;       : BX    - LBA hi of MBR or EBR
     610;       ; DL    - BIOS disk number
     611;       ; SI    - Pointer to sector buffer (usually [LVMSec])
     612; OUT   : CF=0  - A valid LVM sector was saved
     613; NOTE  : LocIPT_AbsolutePartTable and LocIPT_Drive can provide LBA and DISK
     614;------------------------------------------------------------------------------
     615DriveIO_SaveLVMSectorXBR    Proc    Near
     616
     617        ; Save all registers
     618        pusha
     619
     620        ; Check the validity of the LVM sector, quit with CY if invalid
     621        push    ax                              ; Save LBA lo
     622        call    LVM_ValidateSector              ; Check signature and CRC
     623        pop     ax                              ; Restore LBA lo
     624        jnc     DriveIO_SaveLVMSectorXBR_no_lvm ; Quit if not valid
     625
    534626        ; Calculate the entry in the DISKINFO array for this disk,
    535627        ; and put the LVM_SPT in DI
     
    541633        ; If the LVM_SPT is ZERO, no LVM info is present and we quit with CY
    542634        test    di, di                          ; See if it is 0
    543         jz      DIOSLVMS_SevereError            ; Quit if so
     635        jz      DriveIO_SaveLVMSectorXBR_no_lvm ; Quit if so
    544636
    545637        ; Adjust the location to point to the LVM sector
     
    549641        sbb     bx, 0       ; Propagate borrow to LBA hi
    550642
     643        ; Save the LVM sector pointed to by SI
     644        mov     di, ds                          ; Segment of that buffer
     645        call    DriveIO_WriteSectorLBA          ; Read the LVM sector
     646
    551647IFDEF   AUX_DEBUG
    552648        IF 1
     
    561657ENDIF
    562658
    563         ; Save the LVM sector pointed to by SI
    564         mov     di, ds                          ; Segment of that buffer
    565         call    DriveIO_WriteSectorLBA          ; Read the LVM sector
    566         clc
    567         jc      DIOSLVMS_SevereError            ; Quit on error
     659        jc      DriveIO_SaveLVMSectorXBR_no_lvm ; Quit on error
    568660
    569661        ; We're done, indicate success and return
    570662        clc
    571         jmp     DIOSLVMS_Done
    572 
    573     DIOSLVMS_SevereError:
    574         ; Indicate no valid LVM sector was saved
     663        jmp     DriveIO_SaveLVMSectorXBR_done
     664
     665    DriveIO_SaveLVMSectorXBR_no_lvm:
     666        ; Indicate no valid LVM sector was loaded
    575667        stc
    576668
    577     DIOSLVMS_Done:
    578         ret
    579 DriveIO_SaveLVMSector   EndP
     669    DriveIO_SaveLVMSectorXBR_done:
     670        ; Restore all registers
     671        popa
     672
     673        ret
     674DriveIO_SaveLVMSectorXBR    EndP
    580675
    581676
Note: See TracChangeset for help on using the changeset viewer.