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

Changed register interface for LBA read/write sector [v1.1.1-testing]

Changed passing the LBA address from BX:CX to BX:AX, so it corresponds
to the load/save sector functions, which do more checking.

This loses the return-status in AH for reading sectors and specifying
write-verify for writing sectors, but that does not really matter.
Status of the last operation should be available using INT13 function
01h and verification of sectors can be done with function 44h if wanted.
CF indicates success or not, which is enough.

This register combination makes it possible to hold both CHS and LBA
sector addresses in registers if needed:
BX:AX ; LBA32
DX:CX ; CHS10

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

    r117 r118  
    741741
    742742        mov     di, ds                  ; segment for transfer address
    743         mov     cx, ax                  ; low word of lba
    744743        call    DriveIO_ReadSectorLBA   ; extended read
    745744        jc      DriveIO_GotLoadError    ; halt on error
     
    792791;# EFFECTS  : Modifies DAP structure and fills transfer buffer
    793792;# ----------------------------------------------------------------------------
    794 ;# IN       : BX:CX - LBA address of sector
     793;# IN       : BX:AX - LBA address of sector
    795794;#          : DI:SI - SEG:OFF of transfer buffer
    796795;# ----------------------------------------------------------------------------
    797 ;# OUT      : CF=1  - failure, AH failure code
     796;# OUT      : CF=1  - failure
    798797;##############################################################################
    799 DriveIO_ReadSectorLBA       Proc Near  Uses bx cx dx si di ds es
     798DriveIO_ReadSectorLBA       Proc Near
    800799
    801800IFDEF   AUX_DEBUG
     
    818817ENDIF
    819818
     819        ; Push all registers
     820        pusha
     821        push    ds
     822        push    es
     823
    820824        ; One sector to read
    821825        mov     cs:[INT13X_DAP_NumBlocks], 1
     
    826830
    827831        ; Setup LBA64 address of requested sector
    828         mov     wptr cs:[INT13X_DAP_Absolute+0], cx     ; low word lower part
     832        mov     wptr cs:[INT13X_DAP_Absolute+0], ax     ; low word lower part
    829833        mov     wptr cs:[INT13X_DAP_Absolute+2], bx     ; high word lower part
    830834        mov     wptr cs:[INT13X_DAP_Absolute+4], 0      ; low word upper part
     
    850854
    851855    DriveIO_ReadSectorLBA_exit:
    852         ret
    853 
     856
     857        ; Pop all registers
     858        pop     es
     859        pop     ds
     860        popa
     861
     862        ret
    854863DriveIO_ReadSectorLBA       EndP
    855864
     
    861870;# EFFECTS  : Modifies DAP structure and mofifies the disk
    862871;# ----------------------------------------------------------------------------
    863 ;# IN       : AL    - write flags, AL.0 verify (1.0,2.0), AL.1 verify (2.1+)
    864 ;#          : BX:CX - LBA address of sector
     872;# IN       : BX:AX - LBA address of sector
    865873;#          : DI:SI - SEG:OFF of transfer buffer
    866874;# ----------------------------------------------------------------------------
    867 ;# OUT      : CF=1  - failure, AH failure code
     875;# OUT      : CF=1  - failure
    868876;##############################################################################
    869 DriveIO_WriteSectorLBA      Proc Near  Uses bx cx dx si di ds es
     877DriveIO_WriteSectorLBA      Proc Near
    870878
    871879IFDEF   AUX_DEBUG
     
    886894ENDIF
    887895
    888         ; Mask reserved bits for write flags -- should check version here
    889         and     al, 03h
    890 
    891         ; Actually, force 'no-write-verify' for now...
    892         xor     al, al
     896        ; Push all registers
     897        pusha
     898        push    ds
     899        push    es
    893900
    894901        ; One sector to read
     
    900907
    901908        ; Setup LBA64 address of requested sector
    902         mov     wptr cs:[INT13X_DAP_Absolute+0], cx     ; low word lower part
     909        mov     wptr cs:[INT13X_DAP_Absolute+0], ax     ; low word lower part
    903910        mov     wptr cs:[INT13X_DAP_Absolute+2], bx     ; high word lower part
    904911        mov     wptr cs:[INT13X_DAP_Absolute+4], 0      ; low word upper part
     
    909916
    910917        ; Do the extended write
     918        xor     al, al                                  ; no write verify
    911919        mov     ah, 43h                                 ; write function
    912920        int     13h                                     ; transfer to bios
     
    924932
    925933    DriveIO_WriteSectorLBA_exit:
    926         ret
    927 
     934
     935        ; Pop all registers
     936        pop     es
     937        pop     ds
     938        popa
     939
     940        ret
    928941DriveIO_WriteSectorLBA      EndP
    929942
     
    10171030
    10181031        ; Now read the LBA sector specified in CX
    1019         xor     bx, bx                  ; LBA high, CX already has LBA low
     1032        mov     ax, cx                  ; LBA low
     1033        xor     bx, bx                  ; LBA high
    10201034        mov     di, ds                  ; Segment of temp buffer
    10211035        mov     si, offset [TmpSector]  ; Offset of temp buffer
     
    10541068        ; For now we assume this is the correct Master LVM sector for the disk.
    10551069        inc     cx      ; CX was prepared to read next, correct that
    1056         stc             ; Indicate we have found a Master LVM sector
     1070        stc             ; Indicate we have found the Master LVM sector
    10571071
    10581072    DriveIO_LocateMasterLVMSector_done:
     
    13641378
    13651379        mov     di, ds                  ; segment for transfer address
    1366         mov     cx, ax                  ; low word of lba
    1367         xor     ax, ax                  ; no verify
    13681380        call    DriveIO_WriteSectorLBA  ; extended write
    13691381        jc      MBR_SaveError           ; halt on error
Note: See TracChangeset for help on using the changeset viewer.