Ignore:
Timestamp:
Apr 29, 2011, 7:04:13 PM (13 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Changes to XTIDE Universal BIOS:

  • Redesigned Disk Parameter Tables.
  • Code generalizations for supporting non-IDE devices in the future.
File:
1 edited

Legend:

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

    r128 r150  
    2525;--------------------------------------------------------------------
    2626CreateDPT_FromAtaInformation:
    27     call    FindDPT_ForNewDrive     ; Get new DPT to DS:DI
     27    call    FindDPT_ForNewDriveToDSDI
    2828    ; Fall to .InitializeDPT
    2929
     
    3535;       CS:BP:  Ptr to IDEVARS for the controller
    3636;   Returns:
    37 ;       AX:     Zero
    38 ;   Corrupts registers:
    39 ;       Nothing
     37;       Nothing
     38;   Corrupts registers:
     39;       AX
    4040;--------------------------------------------------------------------
    4141.InitializeDPT:
    42     xor     ax, ax
    43     mov     BYTE [di+DPT.bSize], DPT_size
    44     mov     [di+DPT.wDrvNumAndFlags], ax
    45     mov     BYTE [di+DPT.bReset], MASK_RESET_ALL
    46     mov     [di+DPT.bIdeOff], bp
    47     mov     [di+DPT.bDrvSel], bh
    48     ; Fall to .StoreDriveControlByte
    49 
    50 ;--------------------------------------------------------------------
    51 ; .StoreDriveControlByte
    52 ;   Parameters:
    53 ;       AX:     Zero
     42    mov     [di+DPT.bIdevarsOffset], bp ; IDEVARS must start in first 256 bytes of ROM
     43    ; Fall to .StoreDriveSelectAndDriveControlByte
     44
     45;--------------------------------------------------------------------
     46; .StoreDriveSelectAndDriveControlByte
     47;   Parameters:
    5448;       BH:     Drive Select byte for Drive and Head Register
    5549;       DS:DI:  Ptr to Disk Parameter Table
     
    6155;       AX
    6256;--------------------------------------------------------------------
    63 .StoreDriveControlByte:
    64     cmp     BYTE [cs:bp+IDEVARS.bIRQ], al   ; Interrupts enabled?
    65     jne     SHORT .CheckHeadCount
    66     or      al, FLG_IDE_CTRL_nIEN           ; Disable interrupts
    67 .CheckHeadCount:
    68     cmp     BYTE [es:si+ATA1.wHeadCnt], 8   ; 1...8 heads?
    69     jbe     SHORT .StoreDrvCtrlByteToDPT
    70     or      al, FLG_IDE_CTRL_O8H            ; Over 8 heads (pre-ATA)
    71 .StoreDrvCtrlByteToDPT:
    72     mov     [di+DPT.bDrvCtrl], al
     57.StoreDriveSelectAndDriveControlByte:
     58    mov     al, bh
     59    and     ax, BYTE FLG_DRVNHEAD_DRV       ; AL now has Master/Slave bit
     60    cmp     [cs:bp+IDEVARS.bIRQ], ah        ; Interrupts enabled?
     61    jz      SHORT .StoreFlags               ;  If not, do not set interrupt flag
     62    or      al, FLG_DPT_ENABLE_IRQ
     63.StoreFlags:
     64    mov     [di+DPT.wFlags], ax
    7365    ; Fall to .StorePCHS
    7466
     
    7668; .StorePCHS
    7769;   Parameters:
    78 ;       AH:     Zero
    7970;       BH:     Drive Select byte for Drive and Head Register
    8071;       DS:DI:  Ptr to Disk Parameter Table
     
    9990    mov     ax, [cs:bx+DRVPARAMS.wCylinders]
    10091    mov     bx, [cs:bx+DRVPARAMS.wHeadsAndSectors]
    101     or      BYTE [di+DPT.bFlags], FLG_DPT_USERCHS
    10292
    10393.StorePCHStoDPT:
    104     mov     [di+DPT.wPCyls], ax
    105     mov     [di+DPT.wHeadsAndSectors], bx
     94    mov     [di+DPT.wPchsCylinders], ax
     95    mov     [di+DPT.wPchsHeadsAndSectors], bx
    10696    ; Fall to .StoreLCHS
    10797
     
    129119    jmp     SHORT .ShiftLoop
    130120
    131 .LimitHeadsTo255:
    132     test    bh, bh                      ; 256 heads?
    133     jz      SHORT .StoreLCHStoDPT       ;  If less, no correction needed
    134     dec     bx                          ; Limit to 255 heads since DOS does not support 256 heads
    135 .StoreLCHStoDPT:
    136     mov     [di+DPT.bShLtoP], cl
    137     mov     [di+DPT.wLHeads], bx
     121.LimitHeadsTo255:                       ; DOS does not support drives with 256 heads
     122    rcr     bh, 1                       ; Set CF if 256 heads
     123    sbb     bl, 0                       ; Decrement to 255 if 256 heads
     124    or      [di+DPT.wFlags], cl
     125    mov     [di+DPT.bLchsHeads], bl
    138126    ; Fall to .StoreAddressing
    139127
     
    146134;       Nothing
    147135;   Corrupts registers:
    148 ;       Nothing
     136;       AX, BX
    149137;--------------------------------------------------------------------
    150138.StoreAddressing:
    151     cmp     WORD [di+DPT.wPCyls], 1024      ; L-CHS possible? (no translation needed)
    152     jbe     SHORT .StoreBlockMode           ;  If so, nothing needs to be changed
    153     test    BYTE [di+DPT.bFlags], FLG_DPT_USERCHS
    154     jnz     SHORT .StorePCHSaddressing      ; Use user defined P-CHS
     139    ; Check if L-CHS addressing should be used
     140    cmp     WORD [di+DPT.wPchsCylinders], 1024  ; L-CHS possible? (no translation needed)
     141    jbe     SHORT .StoreBlockMode               ;  If so, nothing needs to be changed
     142
     143    ; Check if P-CHS addressing should be used
     144    mov     al, FLG_DRVPARAMS_USERCHS           ; User specified CHS?
     145    call    AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive
     146    jnz     SHORT .StorePCHSaddressing
    155147    test    WORD [es:si+ATA1.wCaps], A2_wCaps_LBA
    156     jz      SHORT .StorePCHSaddressing      ; Use P-CHS since LBA not supported
     148    jz      SHORT .StorePCHSaddressing          ; Use P-CHS since LBA not supported
     149
     150    ; LBA needs to be used. Check if 48-bit LBA is supported
    157151    test    WORD [es:si+ATA6.wSetSup83], A6_wSetSup83_LBA48
    158     jz      SHORT .StoreLBA28addressing     ; Use LBA-28 since LBA-48 not supported
    159     or      BYTE [di+DPT.bFlags], ADDR_DPT_LBA48<<1
     152    jz      SHORT .StoreLBA28addressing         ; Use LBA-28 since LBA-48 not supported
     153    or      BYTE [di+DPT.wFlags], ADDRESSING_MODE_LBA48<<ADDRESSING_MODE_FIELD_POSITION
    160154.StoreLBA28addressing:
    161     or      BYTE [di+DPT.bFlags], ADDR_DPT_LBA28<<1
    162     or      BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_LBA
     155    or      BYTE [di+DPT.wFlags], ADDRESSING_MODE_LBA28<<ADDRESSING_MODE_FIELD_POSITION
    163156    jmp     SHORT .StoreBlockMode
    164157.StorePCHSaddressing:
    165     or      BYTE [di+DPT.bFlags], ADDR_DPT_PCHS<<1
     158    or      BYTE [di+DPT.wFlags], ADDRESSING_MODE_PCHS<<ADDRESSING_MODE_FIELD_POSITION
    166159    ; Fall to .StoreBlockMode
    167160
     
    174167;       Nothing
    175168;   Corrupts registers:
    176 ;       AX
     169;       Nothing
    177170;--------------------------------------------------------------------
    178171.StoreBlockMode:
    179     mov     al, 1                       ; Minimum block size is 1 sector
    180     mov     ah, [es:si+ATA1.bBlckSize]  ; Load max block size in sectors
    181     mov     [di+DPT.wSetAndMaxBlock], ax
    182     ; Fall to .StoreEBIOSSupport
    183 
    184 ;--------------------------------------------------------------------
    185 ; .StoreEBIOSSupport
    186 ;   Parameters:
    187 ;       DS:DI:  Ptr to Disk Parameter Table
    188 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    189 ;   Returns:
    190 ;       Nothing
    191 ;   Corrupts registers:
    192 ;       AX, BX, DX
    193 ;--------------------------------------------------------------------
    194 .StoreEBIOSSupport:
    195     test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
    196     jz      SHORT .StoreDriveNumberAndUpdateDriveCount  ; No EBIOS support since small DPTs needed
    197 
    198     mov     bl, [di+DPT.bFlags]
    199     and     bx, BYTE MASK_DPT_ADDR                      ; Addressing mode
    200     jmp     [cs:bx+.rgwAddrJmp]                         ; Jump to handle addressing mode
    201 .rgwAddrJmp:
    202     dw      .StoreDriveNumberAndUpdateDriveCount        ; ADDR_DPT_LCHS
    203     dw      .StoreDriveNumberAndUpdateDriveCount        ; ADDR_DPT_PCHS
    204     dw      .SupportForLBA28                            ; ADDR_DPT_LBA28
    205     dw      .SupportForLBA48                            ; ADDR_DPT_LBA48
    206 
    207 .SupportForLBA28:
    208     sub     BYTE [di+DPT.bSize], 2      ; Only 4 bytes for sector count
    209 .SupportForLBA48:
    210     add     BYTE [di+DPT.bSize], EBDPT_size - DPT_size
    211     or      BYTE [di+DPT.bFlags], FLG_DPT_EBIOS
    212     call    AtaID_GetTotalSectorCount
    213     mov     [di+EBDPT.twCapacity], ax
    214     mov     [di+EBDPT.twCapacity+2], dx
    215     mov     [di+EBDPT.twCapacity+4], bx
     172    cmp     BYTE [es:si+ATA1.bBlckSize], 1  ; Max block size in sectors
     173    jbe     SHORT .BlockModeTransfersNotSupported
     174    or      WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED
     175.BlockModeTransfersNotSupported:
     176    ; Fall to .StoreDeviceSpecificParameters
     177
     178;--------------------------------------------------------------------
     179; .StoreDeviceSpecificParameters
     180;   Parameters:
     181;       DS:DI:  Ptr to Disk Parameter Table
     182;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     183;   Returns:
     184;       Nothing
     185;   Corrupts registers:
     186;       AX, BX, CX, DX
     187;--------------------------------------------------------------------
     188.StoreDeviceSpecificParameters:
     189    call    Device_FinalizeDPT
    216190    ; Fall to .StoreDriveNumberAndUpdateDriveCount
    217191
     
    230204;--------------------------------------------------------------------
    231205.StoreDriveNumberAndUpdateDriveCount:
    232     ; Make sure that more drives can be accepted
    233     mov     dl, [es:BDA.bHDCount]   ; Load number of hard disks
    234     test    dl, dl                  ; Hard disks at maximum?
    235     stc                             ; Assume error
    236     js      SHORT .TooManyDrives    ;  If so, return
    237 
    238     ; Store drive number to DPT
    239     or      dl, 80h                 ; Set bit 7 since hard disk
    240     mov     [di+DPT.bDrvNum], dl    ; Store drive number
    241 
    242     ; Update BDA and RAMVARS
    243     inc     BYTE [es:BDA.bHDCount]  ; Increment drive count to BDA
    244     call    RamVars_IncrementHardDiskCount
     206    mov     dl, [es:BDA.bHDCount]
     207    or      dl, 80h                     ; Set bit 7 since hard disk
     208
     209    inc     BYTE [RAMVARS.bDrvCnt]      ; Increment drive count to RAMVARS
     210    inc     BYTE [es:BDA.bHDCount]      ; Increment drive count to BDA
     211
     212    cmp     BYTE [RAMVARS.bFirstDrv], 0 ; First drive set?
     213    ja      SHORT .AllDone              ;  If so, return
     214    mov     [RAMVARS.bFirstDrv], dl     ; Store first drive number
     215.AllDone:
    245216    clc
    246 .TooManyDrives:
    247217    ret
Note: See TracChangeset for help on using the changeset viewer.