Changeset 150


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

Reimplemented the saving of LVM sectors [v1.1.1-testing]

This new method does away with ugly and faulty adjustments which
assumed LVM sectors were located below actual partition starts,
which is true most of the time, but not always, especially not for
the first primary partition which could be offset more than SPT.

Because MBR and EBR locations are now used, the need to distinguish
between primary and logical partitions is also not needed anymore.

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

    r149 r150  
    538538
    539539
    540 ; Keeps DS:SI for caller, saves at anytime w/o checks (!)
    541 DriveIO_SaveLVMSector   Proc Near  Uses ax bx cx dx
    542 
    543 IFDEF   AUX_DEBUG
    544         IF 0
     540;##############################################################################
     541;# The location of LVM sectors depends on the OS/2 geometry used when the disk
     542;# was prepared. This geometry is present in the Master LVM sector, which has
     543;# already been located if it exists. All partitions, whether primary or
     544;# logical, have an entry in a partition table. For primary partitions this
     545;# table is located in the MBR, while for logical partitions this table is
     546;# located in the EBR for that logical partition. An LVM record is located
     547;# LVM_SPT-1 sectors above an MBR or EBR. The Master LVM record contains the
     548;# information for all primary partitions. For logical partitions, the LVM
     549;# sector only has one entry, because EBRs are chained. The global LVM info,
     550;# like disk-name, sectors per track, etc. is replicated between the Master
     551;# LVM sector and LVM sectors corresponding to logical partitions. This info
     552;# is kept in sync by the OS/2 LVM Engine.
     553;##############################################################################
     554;# ACTION   : Attempts to save the corresponding LVM sector for a partition
     555;# ----------------------------------------------------------------------------
     556;# EFFECTS  : Modifies DAP structure and writes LVM sector to disk
     557;# ----------------------------------------------------------------------------
     558;# IN       : MEM   - Location info is in [CurPartition_Location]
     559;#          : SI    - Pointer to sector buffer
     560;# ----------------------------------------------------------------------------
     561;# OUT      : CF=1  - failure, no valid LVM sector was saved
     562;##############################################################################
     563DriveIO_SaveLVMSector   Proc Near  Uses ax bx cx dx di
     564
     565IFDEF   AUX_DEBUG
     566        IF 1
    545567        DBG_TEXT_OUT_AUX    'DriveIO_SaveLVMSector:'
    546568        PUSHRF
    547             ;~ call    DEBUG_DumpRegisters
     569            call    DEBUG_DumpRegisters
    548570            ;~ call    AuxIO_DumpParagraph
    549571            ;~ call    AuxIO_TeletypeNL
     
    552574ENDIF
    553575
    554         test    byte ptr [CFG_IgnoreLVM], 1            ; We are supposed to ignore LVM, so
    555         jnz     DIOSLVMS_SevereError          ;  don't save at anytime (security!)
    556         mov     ax, wptr cs:[CurPartition_Location+0]
    557         mov     bx, wptr cs:[CurPartition_Location+2]
    558         mov     dx, wptr cs:[CurPartition_Location+4]
    559         mov     cx, wptr cs:[CurPartition_Location+6] ; Gets cur. partition location
    560         call    LVM_CheckSectorSignature
    561         jnc     DIOSLVMS_SevereError                  ; LVM Signature must be there
    562 
    563 IFDEF   AUX_DEBUG
    564         IF 0
    565         pushf
    566         pusha
    567             ;~ dioatlvm    db 'DriveIO_LVMAdjustToInfoSector',10,0
    568             ;~ pushf
    569             ;~ pusha
    570             ;~ mov     si,offset dioatlvm
    571             ;~ call    AuxIO_Print
    572             ;~ popa
    573             ;~ popf
     576        ; Quit with CY if LVM is ignored in SETUP
     577        test    byte ptr [CFG_IgnoreLVM], 1     ; ZF=0 means ignore LVM
     578        jnz     DIOSLVMS_SevereError            ; Quit if so
     579
     580        ; Check the validity of the LVM sector, quit with CY if invalid
     581        call    LVM_ValidateSector              ; Check signature and CRC
     582        jnc     DIOSLVMS_SevereError            ; Quit if not valid
     583
     584        ; Load the location of the current partition being acted upon.
     585        ; Note that this is not the actual LBA of the partition, but the
     586        ; sector that has the partition table that contains the entry
     587        ; for the partition. In other words, for primary partitions the LBA
     588        ; address points to the MBR while for extended partitions it points
     589        ; to an EBR. In both cases the LVM sector is located LVM_SPT-1 above.
     590        ; Also note that the BIOS CHS values (DH and CX) below are not used,
     591        ; because we explicitly use LBA sector loading.
     592        mov     ax, wptr cs:[CurPartition_Location+0]   ; LBA lo of MBR/EBR
     593        mov     bx, wptr cs:[CurPartition_Location+2]   ; LBA hi of MBR/EBR
     594        mov     dx, wptr cs:[CurPartition_Location+4]   ; BIOS disk num & head
     595        mov     cx, wptr cs:[CurPartition_Location+6]   ; BIOS cyl & sec
     596
     597        ; Calculate the entry in the DISKINFO array for this disk,
     598        ; and put the LVM_SPT in DI
     599        push    bx
     600        call    DriveIO_CalcDiskInfoPointer
     601        mov     di, [bx+LocDISKINFO_LVM_Secs]
     602        pop     bx
     603
     604        ; If the LVM_SPT is ZERO, no LVM info is present and we quit with CY
     605        test    di, di                          ; See if it is 0
     606        jz      DIOSLVMS_SevereError            ; Quit if so
     607
     608        ; Adjust the location to point to the LVM sector
     609        add     ax, di      ; Add the LVM sectors-per-track
     610        adc     bx, 0       ; Propagate LBA lo overflow to LBA hi
     611        sub     ax, 1       ; LVM sector is located one sector below
     612        sbb     bx, 0       ; Propagate borrow to LBA hi
     613
     614IFDEF   AUX_DEBUG
     615        IF 1
     616        DBG_TEXT_OUT_AUX    'LVMSecSaved'
     617        PUSHRF
    574618            call    DEBUG_DumpRegisters
    575             call    DEBUG_DumpCHS
    576         popa
    577         popf
    578         ENDIF
    579 ENDIF
    580 
    581         call    DriveIO_LVMAdjustToInfoSector
    582 
    583 IFDEF   AUX_DEBUG
    584         IF 0
    585         pushf
    586         pusha
    587             call    DEBUG_DumpRegisters
    588             call    DEBUG_DumpCHS
    589         popa
    590         popf
    591         ENDIF
    592 ENDIF
    593 
    594         mov     si, offset LVMSector
    595         call    DriveIO_SaveSector
     619            call    AuxIO_DumpSector
     620            ;~ call    AuxIO_DumpParagraph
     621            ;~ call    AuxIO_TeletypeNL
     622        POPRF
     623        ENDIF
     624ENDIF
     625
     626        ; Save the LVM sector pointed to by SI
     627        mov     di, ds                          ; Segment of that buffer
     628        call    DriveIO_WriteSectorLBA          ; Read the LVM sector
     629        clc
     630        jc      DIOSLVMS_SevereError            ; Quit on error
     631
     632        ; We're done, indicate success and return
     633        clc
     634        jmp     DIOSLVMS_Done
     635
    596636    DIOSLVMS_SevereError:
     637        ; Indicate no valid LVM sector was saved
     638        stc
     639
     640    DIOSLVMS_Done:
    597641        ret
    598642DriveIO_SaveLVMSector   EndP
Note: See TracChangeset for help on using the changeset viewer.