Changeset 136


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

Reimplemented loading of the Master LVM sector [v1.1.1-testing]

The new method now uses the disk information gathered in an earlier
stage and just loads an already found Master LVM sector. This fix gets
rid of the ugly and faulty 'sec_per_track_table' way of doing it.

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

    r134 r136  
    13621362
    13631363
    1364 ; ------------------------------------------------------
    1365 ; Rousseau: # Load the master LVM-sector if one exists #
    1366 ; ------------------------------------------------------
    1367 ; Load the master LVM-sector to get the number of sectors per track as
    1368 ; OS/2 views the drive. If no master LVM-sector is found it is assumed OS/2
    1369 ; is not installed. The master LVM-sector can be located at three different
    1370 ; places depending on drive size and partitioning scheme and driver used.
    1371 ; When DANIS506.ADD is used, the OS/2 extended geometry will be 255/127 for
    1372 ; drives >502GiB but <1TiB. Then the location will be sector 127 which
    1373 ; is LBA 126 (7Eh).
    1374 ; IBM1S506.ADD will always use 255/255 for the extended OS/2 geometry.
    1375 ; DANIS506.ADD will use 255/255 for drives >1TiB.
    1376 ; Then the location of the master LVM-sector will be 255 which is LBA 254 (FEh).
    1377 ; When OS/2 is installed on a huge drive that alread had a system on it, OS/2
    1378 ; will be confined to the lower 502GiB of the drive.
    1379 ; In this case the normal geometry from Int13X will be used.
    1380 ; This is also the case when no valid master LVM-sector can be found.
    1381 ;
    1382 ; Return CF when valid master LVM sector found, NC if not.
    1383 ; Loads sector at [LVMSector] !
     1364
     1365;##############################################################################
     1366;# When a disk has a Master LVM sector, it means it has been prepared for use
     1367;# by OS/2 and contains important information about how OS/2 views its geometry
     1368;# and other disk related properties. This function assumes the LBA address
     1369;# of the Master LVM sector has already been located and simply loads the
     1370;# sector into [LVMSector].
     1371;#
     1372;# Note that because this is an operation similar to the regular loading of
     1373;# sectors, the disk I/O semantics are used here. This means CF=0 when an LVM
     1374;# sector is successfully loaded and CF=1 otherwise.
     1375;##############################################################################
     1376;# ACTION   : Loads the Master LVM sector if one exists
     1377;# ----------------------------------------------------------------------------
     1378;# EFFECTS  : Modifies DAP structure and [LVMSector]
     1379;# ----------------------------------------------------------------------------
     1380;# IN       : DL     - BIOS disk number (80h,81h,etc)
     1381;# ----------------------------------------------------------------------------
     1382;# OUT      : CF=0   - Valid Master LVM sector found and loaded
     1383;##############################################################################
    13841384DriveIO_LoadMasterLVMSector     Proc  Near
    13851385
     
    13951395ENDIF
    13961396
     1397        ; Save all registers
    13971398        pusha
    13981399
    1399         ; Loop over the sector-translation table,
    1400         ; process the first three values from high (255) to low.
    1401         ; (bios spt, most likely 63)
    1402         mov     cx,3
    1403     DriveIO_LoadMasterLVMSector_NextTry:
    1404         ; Number of sectors to read
    1405         mov     [INT13X_DAP_NumBlocks],1
    1406 
    1407         ; Setup destination address
     1400        ; Check if BIOS disk number is valid
     1401        call    DriveIO_IsValidHarddisk
     1402        jc      DriveIO_LoadMasterLVMSector_error
     1403
     1404        ; Calculate the entry in the DISKINFO array for this disk
     1405        call    DriveIO_CalcDiskInfoPointer
     1406
     1407        ; Save the entry for later recalls
     1408        mov     bp, bx
     1409
     1410        ; Get the LBA address of the Master LVM sector
     1411        mov     ax, [bx+LocDISKINFO_LVM_MasterLBA+00h]
     1412        mov     bx, [bx+LocDISKINFO_LVM_MasterLBA+02h]
     1413
     1414        ; LBA of Master LVM sector cannot be 0, so none was found during
     1415        ; the gathering of disk information.
     1416        mov     cx, ax
     1417        or      cx, bx
     1418        jz      DriveIO_LoadMasterLVMSector_error
     1419
     1420        ; Load it into [LVMSector]
     1421        mov     di, ds
    14081422        mov     si, offset [LVMSector]
    1409         mov     word ptr [INT13X_DAP_Transfer+0],si
    1410         mov     ax, ds
    1411         mov     word ptr [INT13X_DAP_Transfer+2],ax
    1412 
    1413         ; Get the sector-number of the next possible LVM sector (255,127,63)
    1414         ; using the translation table and the counter as the index
    1415         mov     bx,offset [secs_per_track_table]
    1416         mov     ax,cx   ; 1-based index to sec_per_track_table
    1417         dec     ax      ; Adjust to 0-based
    1418         xlatb           ; Get the (well known) SPT
    1419         dec     al      ; Minus 1 for LVM-record
    1420 
    1421         ;
    1422         ; AX now contains the LBA address of the sector
    1423         ; that could be an LVM sector.
    1424         ; This is all in track0 so the address will not exceed 64kiB sectors.
    1425         ;
    1426 
    1427 
    1428 IFDEF   AUX_DEBUG
    1429         IF 0
    1430         DBG_TEXT_OUT_AUX    'geo'
    1431         PUSHRF
    1432             call    DEBUG_DumpRegisters
    1433             call    AuxIO_DumpParagraph
    1434             call    AuxIO_TeletypeNL
    1435         POPRF
    1436         ENDIF
    1437 ENDIF
    1438 
    1439 
    1440         ; Setup the requested LBA sector number
    1441         mov     word ptr [INT13X_DAP_Absolute+0],ax    ; LBA low                   NORMAL I/O GEBRUIKEN !
    1442         mov     word ptr [INT13X_DAP_Absolute+2],00h   ; LBA high
    1443         mov     si, offset [INT13X_DAP]                ; address request packet
    1444         mov     ah, 42h
    1445         int     13h                                    ; do the i/o, CF=1->error, CF=0->success
    1446 ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1447 IFDEF   AUX_DEBUG
    1448         IF 0
    1449         pushf
    1450         pusha
    1451             pushf
    1452             xor     ax, ax
    1453             mov     al, dl
    1454             call    AuxIO_TeletypeHexWord
    1455             mov     al, '#'
    1456             call    AuxIO_Teletype
    1457             popf
    1458             mov     ax,0000h
    1459             rcl     al, 1
    1460             call    AuxIO_TeletypeHexWord
    1461             mov     al, '#'
    1462             call    AuxIO_Teletype
    1463             mov     ax,word ptr [INT13X_DAP_Absolute+0]
    1464             call    AuxIO_TeletypeHexWord
    1465             mov     al, '#'
    1466             call    AuxIO_Teletype
     1423        call    DriveIO_ReadSectorLBA
     1424        jc      DriveIO_LoadMasterLVMSector_error
     1425
     1426        ; Validate the Master LVM sector
     1427        call    LVM_ValidateSector
     1428
     1429        ; Complement success indicator to conform to semantics of this function
     1430        cmc
     1431
     1432        ; Master LVM sector was valid and is now loaded in [LVMSector]
     1433        jnc     DriveIO_LoadMasterLVMSector_ret
     1434
     1435    DriveIO_LoadMasterLVMSector_error:
     1436
     1437        ; Clear the sector buffer for safety reasons
     1438        mov     si, offset [LVMSector]
     1439        call    ClearSectorBuffer
     1440
     1441        ; Indicate no Master LVM sector loaded
     1442        stc
     1443
     1444    DriveIO_LoadMasterLVMSector_ret:
     1445
     1446        ; Restore all registers
    14671447        popa
    1468         popf
    1469         ENDIF
    1470 ENDIF
    1471 
    1472         cmc     ; Complement carry so we can exit imm. on error
    1473         jnc     DriveIO_LoadMasterLVMSector_End  ; oops, return with NC
    1474 
    1475 
    1476         mov     si,offset [LVMSector]
    1477 
    1478         ; See if this is a valid LVM-sector
    1479         ; CY if valid
    1480         call    LVM_ValidateSector
    1481 
    1482 
    1483 
    1484 IFDEF   AUX_DEBUG
    1485         IF 0
    1486         DBG_TEXT_OUT_AUX    'lvm record'
    1487         PUSHRF
    1488             call    DEBUG_DumpRegisters
    1489             ;~ call    AuxIO_DumpSector
    1490             mov     cx, 7
    1491         @@:
    1492             call    AuxIO_DumpParagraph
    1493             call    AuxIO_TeletypeNL
    1494             add     si, 16
    1495             loop @B
    1496         POPRF
    1497         ENDIF
    1498 ENDIF
    1499 
    1500 
    1501         ; Yep, we found the master LVM-sector
    1502         jc      DriveIO_LoadMasterLVMSector_Found
    1503 
    1504         ; Try next location
    1505         loop    DriveIO_LoadMasterLVMSector_NextTry
    1506 
    1507         ; No master LVM-sector found, set CF=false
    1508         clc
    1509 
    1510     DriveIO_LoadMasterLVMSector_Found:
    1511         ; Store the address for later use.
    1512         mov     ax, word ptr [INT13X_DAP_Absolute]
    1513         mov     word ptr [MasterLVMLBA], ax
    1514 
    1515     DriveIO_LoadMasterLVMSector_End:
    1516         popa
     1448
    15171449        ret
    15181450DriveIO_LoadMasterLVMSector     Endp
     1451
    15191452
    15201453
Note: See TracChangeset for help on using the changeset viewer.