Changeset 147


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

Reimplemented the loading 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

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bootcode/regular/driveio.asm

    r146 r147  
    419419
    420420
    421 ; Keeps DS:SI for caller, sets carry if valid LVM sector encountered
    422 DriveIO_LoadLVMSector   Proc Near  Uses ax bx cx dx
    423 
    424 IFDEF   AUX_DEBUG
    425         IF 0
     421;##############################################################################
     422;# The location of LVM sectors depends on the OS/2 geometry used when the disk
     423;# was prepared. This geometry is present in the Master LVM sector, which has
     424;# already been located if it exists. All partitions, whether primary or
     425;# logical, have an entry in a partition table. For primary partitions this
     426;# table is located in the MBR, while for logical partitions this table is
     427;# located in the EBR for that logical partition. An LVM record is located
     428;# LVM_SPT-1 sectors above an MBR or EBR. The Master LVM record contains the
     429;# information for all primary partitions. For logical partitions, the LVM
     430;# sector only has one entry, because EBRs are chained. The global LVM info,
     431;# like disk-name, sectors per track, etc. is replicated between the Master
     432;# LVM sector and LVM sectors corresponding to logical partitions. This info
     433;# is kept in sync by the OS/2 LVM Engine.
     434;##############################################################################
     435;# ACTION   : Attempts to load the corresponding LVM sector for a partition
     436;# ----------------------------------------------------------------------------
     437;# EFFECTS  : Modifies DAP structure and fills or clears sector buffer
     438;# ----------------------------------------------------------------------------
     439;# IN       : None   - Location info is in [CurPartition_Location]
     440;# ----------------------------------------------------------------------------
     441;# OUT      : CF=1   - failure, no valid LVM sector was loaded
     442;#          : SI     - Points to the sector buffer ([LVMSector])
     443;##############################################################################
     444DriveIO_LoadLVMSector   Proc Near  Uses ax bx cx dx di
     445
     446IFDEF   AUX_DEBUG
     447        IF 1
    426448        DBG_TEXT_OUT_AUX    'DriveIO_LoadLVMSector:'
     449        PUSHRF
     450            call    DEBUG_DumpRegisters
     451            ;~ call    AuxIO_DumpSector
     452            ;~ call    AuxIO_DumpParagraph
     453            ;~ call    AuxIO_TeletypeNL
     454        POPRF
     455        ENDIF
     456ENDIF
     457
     458        ; Clear the sector buffer
     459        mov     si, offset [LVMSector]
     460        call    ClearSectorBuffer
     461
     462        ; Quit with CY if LVM is ignored in SETUP
     463        test    byte ptr [CFG_IgnoreLVM], 1     ; ZF=0 means ignore LVM
     464        jnz     DIOLLVMS_NoLVMSector            ; Quit if so
     465
     466        ; Calculate the entry in the DISKINFO array for this disk
     467        call    DriveIO_CalcDiskInfoPointer
     468
     469        ; If the LVM_SPT is ZERO, no LVM info is present and we quit with CY
     470        mov     di, [bx+LocDISKINFO_LVM_Secs]   ; Get LVM_SPT
     471        test    di, di                          ; See if it is 0
     472        jz      DIOLLVMS_NoLVMSector            ; Quit if so
     473
     474        ; Load the location of the current partition being acted upon.
     475        ; Note that this is not the actual LBA of the partition, but the
     476        ; sector that has the partition table that contains the entry
     477        ; for the partition. In other words, for primary partitions the LBA
     478        ; address points to the MBR while for extended partitions it points
     479        ; to an EBR. In both cases the LVM sector is located LVM_SPT-1 above.
     480        ; Also note that the BIOS CHS values (DH and CX) below are not used,
     481        ; because we explicitly use LBA sector loading.
     482        mov     ax, wptr cs:[CurPartition_Location+0]   ; LBA lo of MBR/EBR
     483        mov     bx, wptr cs:[CurPartition_Location+2]   ; LBA hi of MBR/EBR
     484        mov     dx, wptr cs:[CurPartition_Location+4]   ; BIOS disk num & head
     485        mov     cx, wptr cs:[CurPartition_Location+6]   ; BIOS cyl & sec
     486
     487        ; Adjust the location to point to the LVM sector
     488        add     ax, di      ; Add the LVM sectors-per-track
     489        adc     bx, 0       ; Propagate LBA lo overflow to LBA hi
     490        sub     ax, 1       ; LVM sector is located one sector below
     491        sbb     bx, 0       ; Propagate borrow to LBA hi
     492
     493        ; Load the LVM sector into [LVMSector]
     494        mov     si, offset [LVMSector]          ; Points to sector buffer
     495        mov     di, ds                          ; Segment of that buffer
     496        call    DriveIO_ReadSectorLBA           ; Read the LVM sector
     497        jc      DIOLLVMS_NoLVMSector            ; Quit on error
     498
     499        ; Check the validity of the LVM sector, quit with CY if invalid
     500        call    LVM_ValidateSector              ; Check signature and CRC
     501        jnc     DIOLLVMS_NoLVMSector            ; Quit if not valid
     502
     503
     504IFDEF   AUX_DEBUG
     505        IF 1
     506        DBG_TEXT_OUT_AUX    'CurPartition'
    427507        PUSHRF
    428508            call    DEBUG_DumpRegisters
     
    434514ENDIF
    435515
    436         test    byte ptr [CFG_IgnoreLVM], 1            ; We are supposed to ignore LVM, so
    437         jnz     DIOLLVMS_NoLVMSector          ;  don't load but declare as bad!
    438         mov     ax, wptr cs:[CurPartition_Location+0]
    439         mov     bx, wptr cs:[CurPartition_Location+2]
    440         mov     dx, wptr cs:[CurPartition_Location+4]
    441         mov     cx, wptr cs:[CurPartition_Location+6] ; Gets cur. partition location
    442 
    443         call    DriveIO_LVMAdjustToInfoSector
    444 
     516        ; We're done, indicate success and return
     517        clc
     518        jmp     DIOLLVMS_Done
     519
     520    DIOLLVMS_NoLVMSector:
     521
     522        ; Clear the sector buffer
    445523        mov     si, offset [LVMSector]
    446         call    DriveIO_LoadSector
    447 
    448 IFDEF   AUX_DEBUG
    449         IF 0
    450         DBG_TEXT_OUT_AUX    'lvm record ex'
    451         PUSHRF
    452             ;~ call    AuxIO_TeletypeHexWord
    453             ;~ call    AuxIO_TeletypeNL
    454             call    DEBUG_DumpRegisters
    455             ;~ call    AuxIO_DumpSector
    456             mov     cx, 7
    457         @@:
    458             call    AuxIO_DumpParagraph
    459             call    AuxIO_TeletypeNL
    460             add     si, 16
    461             loop @B
    462         POPRF
    463         ENDIF
    464 ENDIF
    465 
    466 
    467         call    LVM_CheckSectorSignature
    468         jnc     DIOLLVMS_NoLVMSector
    469         call    LVM_CheckSectorCRC
    470         jnc     DIOLLVMS_NoLVMSector
    471         ret
    472 
    473         ; This here is called, if an invalid (or no) LVM information sector is found
    474         ;  It will truncate the first byte of the sector, so all other routines
    475         ;  will notice it easily by just comparing the first byte.
    476     DIOLLVMS_NoLVMSector:
     524        call    ClearSectorBuffer
    477525        mov     bptr [si+LocLVM_SignatureStart], 0
     526
     527        ; Indicate no valid LVM sector was loaded
     528        stc
     529
     530    DIOLLVMS_Done:
     531
    478532        ret
    479533DriveIO_LoadLVMSector   EndP
  • trunk/include/version.h

    r130 r147  
    3232#define     BLDLVL_YEAR             "2017"
    3333#define     BLDLVL_MONTH            "04"
    34 #define     BLDLVL_DAY              "04"
     34#define     BLDLVL_DAY              "05"
    3535// Build time
    3636//~ #define     BLDLVL_HOURS            "01"
  • trunk/include/version.inc

    r130 r147  
    7070AB_YEAR             EQU     2017h
    7171AB_MONTH            EQU     04h
    72 AB_DAY              EQU     04h
     72AB_DAY              EQU     05h
    7373
    7474; The Hours, Minutes and Seconds, again in BCD for easy manipulation.
Note: See TracChangeset for help on using the changeset viewer.