Changeset 173 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs


Ignore:
Timestamp:
Sep 18, 2011, 11:41:29 AM (13 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • L-CHS parameters are now generated differently for LBA enabled drives.
  • Booting to EBIOS partitions now seems to work (at least on one drive).
Location:
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm

    r161 r173  
    5959
    6060;--------------------------------------------------------------------
    61 ; AccessDPT_GetLCHSfromPCHS
     61; AccessDPT_GetLCHS
    6262;   Parameters:
    6363;       DS:DI:  Ptr to Disk Parameter Table
     
    6767;       DX:     Number of L-CHS heads
    6868;   Corrupts registers:
     69;       CX
     70;--------------------------------------------------------------------
     71AccessDPT_GetLCHS:
     72    ; Load CHS from DPT
     73    eMOVZX  ax, BYTE [di+DPT.bSectors]
     74    mov     bx, [di+DPT.dwCylinders]
     75    cwd
     76    mov     dl, [di+DPT.bHeads]
     77
     78    ; Only need to limit sectors for LBA assist
     79    test    BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA
     80    jnz     SHORT .ReturnLbaAssistedLCHS
     81
     82    ; P-CHS to L-CHS translation when necessary
     83    jmp     SHORT AccessDPT_ShiftPCHinBXDXtoLCH
     84
     85.ReturnLbaAssistedLCHS:
     86    cmp     WORD [di+DPT.dwCylinders+2], BYTE 0
     87    jz      SHORT .LimitCylindersTo1024
     88    mov     bx, MAX_LCHS_CYLINDERS
     89.LimitCylindersTo1024:
     90    MIN_U   bx, MAX_LCHS_CYLINDERS
     91    ret
     92
     93
     94;--------------------------------------------------------------------
     95; AccessDPT_ShiftPCHinBXDXtoLCH
     96;   Parameters:
     97;       BX:     P-CHS cylinders (1...16383)
     98;       DX:     P-CHS heads (1...16)
     99;   Returns:
     100;       BX:     Number of L-CHS cylinders (1...1024)
     101;       DX:     Number of L-CHS heads (1...255)
     102;       CX:     Number of bits shifted
     103;   Corrupts registers:
    69104;       Nothing
    70105;--------------------------------------------------------------------
    71 ALIGN JUMP_ALIGN
    72 AccessDPT_GetLCHSfromPCHS:
    73     mov     al, [di+DPT.bFlagsLow]
    74     and     al, MASKL_DPT_CHS_SHIFT_COUNT   ; Load shift count
    75     xchg    cx, ax
    76     mov     bx, [di+DPT.wPchsCylinders]     ; Load P-CHS cylinders
    77     shr     bx, cl                          ; Shift to L-CHS cylinders
    78     xchg    cx, ax
    79     eMOVZX  ax, BYTE [di+DPT.bPchsSectors]  ; Load Sectors per track
    80     cwd
    81     mov     dl, [di+DPT.bLchsHeads]         ; Load L-CHS heads
     106AccessDPT_ShiftPCHinBXDXtoLCH:
     107    xor     cx, cx
     108.ShiftLoop:
     109    cmp     bx, MAX_LCHS_CYLINDERS      ; Need to shift?
     110    jbe     SHORT .LimitHeadsTo255      ;  If not, return
     111    inc     cx                          ; Increment shift count
     112    shr     bx, 1                       ; Halve cylinders
     113    shl     dx, 1                       ; Double heads
     114    jmp     SHORT .ShiftLoop
     115.LimitHeadsTo255:                       ; DOS does not support drives with 256 heads
     116    sub     dl, dh                      ; BH set only when 256 logical heads
     117    xor     dh, dh
    82118    ret
    83119
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm

    r169 r173  
    6363.StoreFlags:
    6464    mov     [di+DPT.wFlags], ax
    65     ; Fall to .StorePCHS
    66 
    67 ;--------------------------------------------------------------------
    68 ; .StorePCHS
    69 ;   Parameters:
    70 ;       BH:     Drive Select byte for Drive and Head Register
    71 ;       DS:DI:  Ptr to Disk Parameter Table
    72 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    73 ;       CS:BP:  Ptr to IDEVARS for the controller
    74 ;   Returns:
    75 ;       AX:     P-CHS cylinders
    76 ;       BL:     P-CHS heads
    77 ;       BH:     P-CHS sectors
    78 ;   Corrupts registers:
    79 ;       Nothing
    80 ;--------------------------------------------------------------------
    81 .StorePCHS:
     65    ; Fall to .StoreAddressing
     66
     67;--------------------------------------------------------------------
     68; .StoreAddressing
     69;   Parameters:
     70;       DS:DI:  Ptr to Disk Parameter Table
     71;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     72;       CS:BP:  Ptr to IDEVARS for the controller
     73;   Returns:
     74;       DX:AX or AX:    Number of cylinders
     75;       BH:             Number of sectors per track
     76;       BL:             Number of heads
     77;   Corrupts registers:
     78;       CX, (DX)
     79;--------------------------------------------------------------------
     80.StoreAddressing:
     81    ; Check if CHS defined in ROMVARS
    8282    mov     al, FLG_DRVPARAMS_USERCHS   ; User specified CHS?
    8383    call    AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive
    84     jnz     SHORT .GetUserSpecifiedPCHS
     84    jnz     SHORT .StoreUserDefinedCHSaddressing
     85
     86    ; Check if LBA supported
    8587    call    AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI
    86     jmp     SHORT .StorePCHStoDPT
    87 
    88 .GetUserSpecifiedPCHS:
     88    test    BYTE [es:si+ATA1.wCaps+1], A1_wCaps_LBA>>8
     89    jz      SHORT .StoreCHSaddressing
     90
     91    ; Check if 48-bit LBA supported
     92    test    BYTE [es:si+ATA6.wSetSup83+1], A6_wSetSup83_LBA48>>8
     93    jz      SHORT .StoreLBA28addressing
     94    or      BYTE [di+DPT.bFlagsLow], ADDRESSING_MODE_LBA48<<ADDRESSING_MODE_FIELD_POSITION
     95.StoreLBA28addressing:
     96    or      BYTE [di+DPT.bFlagsLow], ADDRESSING_MODE_LBA28<<ADDRESSING_MODE_FIELD_POSITION
     97    call    AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI
     98    call    AtaID_GetLbaAssistedCHStoDXAXBLBH
     99    jmp     SHORT .StoreChsFromDXAXBX
     100
     101    ; Check if P-CHS to L-CHS translation required
     102.StoreUserDefinedCHSaddressing:
    89103    call    AccessDPT_GetPointerToDRVPARAMStoCSBX
    90104    mov     ax, [cs:bx+DRVPARAMS.wCylinders]
    91105    mov     bx, [cs:bx+DRVPARAMS.wHeadsAndSectors]
    92 
    93 .StorePCHStoDPT:
    94     mov     [di+DPT.wPchsCylinders], ax
    95     mov     [di+DPT.wPchsHeadsAndSectors], bx
    96     ; Fall to .StoreLCHS
    97 
    98 ;--------------------------------------------------------------------
    99 ; .StoreLCHS
    100 ;   Parameters:
    101 ;       AX:     P-CHS cylinders
    102 ;       BL:     P-CHS heads
    103 ;       DS:DI:  Ptr to Disk Parameter Table
    104 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    105 ;       CS:BP:  Ptr to IDEVARS for the controller
    106 ;   Returns:
    107 ;       Nothing
    108 ;   Corrupts registers:
    109 ;       AX, BX, CX
    110 ;--------------------------------------------------------------------
    111 .StoreLCHS:
    112     xor     bh, bh                      ; BX = P-CHS Heads (1...16)
    113     xor     cx, cx
    114 .ShiftLoop:
    115     cmp     ax, 1024                    ; Need to shift?
    116     jbe     SHORT .LimitHeadsTo255      ;  If not, return
    117     inc     cx                          ; Increment shift count
    118     shr     ax, 1                       ; Halve cylinders
    119     shl     bx, 1                       ; Double heads
    120     jmp     SHORT .ShiftLoop
    121 
    122 .LimitHeadsTo255:                       ; DOS does not support drives with 256 heads
    123     rcr     bh, 1                       ; Set CF if 256 heads
    124     sbb     bl, 0                       ; Decrement to 255 if 256 heads
    125     or      [di+DPT.wFlags], cl
    126     mov     [di+DPT.bLchsHeads], bl
    127     ; Fall to .StoreAddressing
    128 
    129 ;--------------------------------------------------------------------
    130 ; .StoreAddressing
    131 ;   Parameters:
    132 ;       DS:DI:  Ptr to Disk Parameter Table
    133 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    134 ;       CS:BP:  Ptr to IDEVARS for the controller
    135 ;   Returns:
    136 ;       Nothing
    137 ;   Corrupts registers:
    138 ;       AX, BX
    139 ;--------------------------------------------------------------------
    140 .StoreAddressing:
    141     ; Check if L-CHS addressing should be used
    142     cmp     WORD [di+DPT.wPchsCylinders], 1024  ; L-CHS possible? (no translation needed)
    143     jbe     SHORT .StoreBlockMode               ;  If so, nothing needs to be changed
    144 
    145     ; Check if P-CHS addressing should be used
    146     mov     al, FLG_DRVPARAMS_USERCHS           ; User specified CHS?
    147     call    AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive
    148     jnz     SHORT .StorePCHSaddressing
    149     test    WORD [es:si+ATA1.wCaps], A2_wCaps_LBA
    150     jz      SHORT .StorePCHSaddressing          ; Use P-CHS since LBA not supported
    151 
    152     ; LBA needs to be used. Check if 48-bit LBA is supported
    153     test    WORD [es:si+ATA6.wSetSup83], A6_wSetSup83_LBA48
    154     jz      SHORT .StoreLBA28addressing         ; Use LBA-28 since LBA-48 not supported
    155     or      BYTE [di+DPT.wFlags], ADDRESSING_MODE_LBA48<<ADDRESSING_MODE_FIELD_POSITION
    156 .StoreLBA28addressing:
    157     or      BYTE [di+DPT.wFlags], ADDRESSING_MODE_LBA28<<ADDRESSING_MODE_FIELD_POSITION
    158     jmp     SHORT .StoreBlockMode
    159 .StorePCHSaddressing:
    160     or      BYTE [di+DPT.wFlags], ADDRESSING_MODE_PCHS<<ADDRESSING_MODE_FIELD_POSITION
     106.StoreCHSaddressing:
     107    cmp     ax, MAX_LCHS_CYLINDERS
     108    jbe     SHORT .StoreChsFromAXBX     ; No translation required
     109
     110    ; We need to get number of bits to shift for translation
     111    push    bx
     112    push    ax
     113    eMOVZX  dx, bl                      ; Heads now in DX
     114    xchg    bx, ax                      ; Sectors now in BX
     115    call    AccessDPT_ShiftPCHinBXDXtoLCH
     116    or      cl, ADDRESSING_MODE_PCHS<<ADDRESSING_MODE_FIELD_POSITION
     117    or      [di+DPT.bFlagsLow], cl      ; Store bits to shift
     118    pop     ax
     119    pop     bx
     120    ; Fall to .StoreChsFromAXBX
     121
     122;--------------------------------------------------------------------
     123; .StoreChsFromAXBX
     124; .StoreChsFromDXAXBX
     125;   Parameters:
     126;       DX:AX or AX:    Number of cylinders
     127;       BH:     Number of sectors per track
     128;       BL:     Number of heads
     129;       DS:DI:  Ptr to Disk Parameter Table
     130;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     131;       CS:BP:  Ptr to IDEVARS for the controller
     132;   Returns:
     133;       Nothing
     134;   Corrupts registers:
     135;       DX
     136;--------------------------------------------------------------------
     137.StoreChsFromAXBX:
     138    xor     dx, dx
     139.StoreChsFromDXAXBX:
     140    mov     [di+DPT.dwCylinders], ax
     141    mov     [di+DPT.dwCylinders+2], dx
     142    mov     [di+DPT.wHeadsAndSectors], bx
    161143    ; Fall to .StoreBlockMode
    162144
Note: See TracChangeset for help on using the changeset viewer.