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


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.
Location:
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs
Files:
4 edited

Legend:

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

    r99 r150  
    66
    77;--------------------------------------------------------------------
    8 ; Returns L-CHS values from DPT.
    9 ;
     8; AccessDPT_GetDriveSelectByteToAL
     9;   Parameters:
     10;       DS:DI:  Ptr to Disk Parameter Table
     11;   Returns:
     12;       AL:     Drive Select Byte
     13;   Corrupts registers:
     14;       Nothing
     15;--------------------------------------------------------------------
     16ALIGN JUMP_ALIGN
     17AccessDPT_GetDriveSelectByteToAL:
     18    mov     al, [di+DPT.wFlags]
     19    and     al, FLG_DRVNHEAD_LBA | FLG_DRVNHEAD_DRV
     20    or      al, MASK_DRVNHEAD_SET   ; Bits set to 1 for old drives
     21    ret
     22
     23
     24;--------------------------------------------------------------------
     25; AccessDPT_GetDeviceControlByteToAL
     26;   Parameters:
     27;       DS:DI:  Ptr to Disk Parameter Table
     28;   Returns:
     29;       AL:     Device Control Byte
     30;   Corrupts registers:
     31;       Nothing
     32;--------------------------------------------------------------------
     33ALIGN JUMP_ALIGN
     34AccessDPT_GetDeviceControlByteToAL:
     35    xor     al, al
     36    test    BYTE [di+DPT.wFlags], FLG_DPT_ENABLE_IRQ
     37    jnz     SHORT .EnableDeviceIrq
     38    or      al, FLG_DEVCONTROL_nIEN ; Disable IRQ
     39.EnableDeviceIrq:
     40    ret
     41
     42
     43;--------------------------------------------------------------------
     44; AccessDPT_GetAddressingModeForWordLookToBX
     45;   Parameters:
     46;       DS:DI:  Ptr to Disk Parameter Table
     47;   Returns:
     48;       BX:     Addressing Mode (L-CHS, P-CHS, LBA28, LBA48) shifted for WORD lookup
     49;   Corrupts registers:
     50;       Nothing
     51;--------------------------------------------------------------------
     52ALIGN JUMP_ALIGN
     53AccessDPT_GetAddressingModeForWordLookToBX:
     54    mov     bl, [di+DPT.wFlags]
     55    and     bx, BYTE MASK_DPT_ADDRESSING_MODE
     56    eSHR_IM bx, ADDRESSING_MODE_FIELD_POSITION-1
     57    ret
     58
     59
     60;--------------------------------------------------------------------
    1061; AccessDPT_GetLCHSfromPCHS
    1162;   Parameters:
     
    2172AccessDPT_GetLCHSfromPCHS:
    2273    xchg    ax, cx
    23     mov     cl, [di+DPT.bShLtoP]        ; Load shift count
    24     mov     bx, [di+DPT.wPCyls]         ; Load P-CHS cylinders
    25     shr     bx, cl                      ; Shift to L-CHS cylinders
     74    mov     cl, [di+DPT.wFlags]
     75    and     cl, MASK_DPT_CHS_SHIFT_COUNT    ; Load shift count
     76    mov     bx, [di+DPT.wPchsCylinders]     ; Load P-CHS cylinders
     77    shr     bx, cl                          ; Shift to L-CHS cylinders
    2678    xchg    cx, ax
    27     mov     dx, [di+DPT.wLHeads]        ; Load L-CHS heads
    28     eMOVZX  ax, BYTE [di+DPT.bPSect]    ; Load Sectors per track
     79    eMOVZX  dx, BYTE [di+DPT.bLchsHeads]    ; Load L-CHS heads
     80    eMOVZX  ax, BYTE [di+DPT.bPchsSectors]  ; Load Sectors per track
    2981    ret
    3082
    3183
    3284;--------------------------------------------------------------------
    33 ; Tests IDEVARS flags for master or slave drive.
    34 ;
    3585; AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive
    3686;   Parameters:
     
    63113ALIGN JUMP_ALIGN
    64114AccessDPT_GetPointerToDRVPARAMStoCSBX:
    65     eMOVZX  bx, [di+DPT.bIdeOff]        ; CS:BX points to IDEVARS
    66     test    BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_DRV
    67     jnz     SHORT .ReturnPointerToSlaveDRVPARAMS
    68     add     bx, BYTE IDEVARS.drvParamsMaster
     115    eMOVZX  bx, [di+DPT.bIdevarsOffset]         ; CS:BX points to IDEVARS
     116    add     bx, BYTE IDEVARS.drvParamsMaster    ; CS:BX points to Master Drive DRVPARAMS
     117    test    BYTE [di+DPT.wFlags], FLG_DPT_SLAVE
     118    jz      SHORT .ReturnPointerToDRVPARAMS
     119    add     bx, BYTE DRVPARAMS_size             ; CS:BX points to Slave Drive DRVPARAMS
     120.ReturnPointerToDRVPARAMS:
    69121    ret
    70 ALIGN JUMP_ALIGN
    71 .ReturnPointerToSlaveDRVPARAMS:
    72     add     bx, BYTE IDEVARS.drvParamsSlave
    73     ret
  • 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
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm

    r3 r150  
    1 ; File name     :   FindDPT.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   14.3.2010
    4 ; Last update   :   12.4.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Functions for finding Disk Parameter Table.
    73
     
    128; Finds pointer to first unused Disk Parameter Table.
    139;
    14 ; FindDPT_ForNewDrive
     10; FindDPT_ForNewDriveToDSDI
    1511;   Parameters:
    1612;       DS:     RAMVARS segment
     
    1814;       DS:DI:  Ptr to first unused DPT
    1915;   Corrupts registers:
    20 ;       Nothing
     16;       DL
    2117;--------------------------------------------------------------------
    2218ALIGN JUMP_ALIGN
    23 FindDPT_ForNewDrive:
    24     push    si
    25     mov     si, FindDPT_ReturnWrongDPT
    26     jmp     SHORT FindDPT_StartIterationAndReturnAfterDone
    27 
    28 
    29 ;--------------------------------------------------------------------
    30 ; Finds Disk Parameter Table for
    31 ; Master or Slave drive at wanted port.
    32 ;
    33 ; FindDPT_ForIdeSlaveAtPort
    34 ; FindDPT_ForIdeMasterAtPort
    35 ;   Parameters:
    36 ;       DX:     IDE Base Port address
    37 ;       DS:     RAMVARS segment
    38 ;   Returns:
    39 ;       DL:     Drive number (if DPT found)
    40 ;       DS:DI:  Ptr to DPT
    41 ;       CF:     Set if wanted DPT found
    42 ;               Cleared if DPT not found
    43 ;   Corrupts registers:
    44 ;       Nothing
    45 ;--------------------------------------------------------------------
    46 ALIGN JUMP_ALIGN
    47 FindDPT_ForIdeSlaveAtPort:
    48     push    si
    49     mov     si, FindDPT_IterateToSlaveAtPortCallback
    50     jmp     SHORT FindDPT_StartIterationAndReturnAfterDone
    51 
    52 ALIGN JUMP_ALIGN
    53 FindDPT_ForIdeMasterAtPort:
    54     push    si
    55     mov     si, FindDPT_IterateToMasterAtPortCallback
    56     jmp     SHORT FindDPT_StartIterationAndReturnAfterDone
    57 
    58 ;--------------------------------------------------------------------
    59 ; Iteration callback for finding DPT using
    60 ; IDE base port for Master or Slave drive.
    61 ;
    62 ; FindDPT_IterateToSlaveAtPortCallback
    63 ; FindDPT_IterateToMasterAtPortCallback
    64 ;   Parameters:
    65 ;       DX:     IDE Base Port address
    66 ;       DS:DI:  Ptr to DPT to examine
    67 ;   Returns:
    68 ;       DL:     Drive number if correct DPT
    69 ;       CF:     Set if wanted DPT found
    70 ;               Cleared if wrong DPT
    71 ;   Corrupts registers:
    72 ;       Nothing
    73 ;--------------------------------------------------------------------
    74 ALIGN JUMP_ALIGN
    75 FindDPT_IterateToSlaveAtPortCallback:
    76     test    BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_DRV
    77     jnz     SHORT FindDPT_IterateToMasterOrSlaveAtPortCallback
    78     jmp     SHORT FindDPT_ReturnWrongDPT    ; Return if master drive
    79 
    80 ALIGN JUMP_ALIGN
    81 FindDPT_IterateToMasterAtPortCallback:
    82     test    BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_DRV
    83     jnz     SHORT FindDPT_ReturnWrongDPT    ; Return if slave drive
    84 
    85     ; If BIOS partitioned, ignore all but first partition
    86 ALIGN JUMP_ALIGN
    87 FindDPT_IterateToMasterOrSlaveAtPortCallback:
    88     test    BYTE [di+DPT.bFlags], FLG_DPT_PARTITION
    89     jz      SHORT .CompareBasePortAddress
    90     test    BYTE [di+DPT.bFlags], FLG_DPT_FIRSTPART
    91     jz      SHORT FindDPT_ReturnWrongDPT
    92 ALIGN JUMP_ALIGN
    93 .CompareBasePortAddress:
    94     push    bx
    95     eMOVZX  bx, BYTE [di+DPT.bIdeOff]       ; CS:BX now points to IDEVARS
    96     cmp     dx, [cs:bx+IDEVARS.wPort]       ; Wanted port?
    97     pop     bx
    98     jne     SHORT FindDPT_ReturnWrongDPT
    99     mov     dl, [di+DPT.bDrvNum]            ; Load drive number
    100     stc                                     ; Set CF since wanted DPT
    101     ret
     19FindDPT_ForNewDriveToDSDI:
     20    mov     dl, [RAMVARS.bFirstDrv]
     21    add     dl, [RAMVARS.bDrvCnt]
     22    ; Fall to FindDPT_ForDriveNumber
    10223
    10324
     
    11233;   Returns:
    11334;       DS:DI:  Ptr to DPT
    114 ;       CF:     Set if wanted DPT found
    115 ;               Cleared if DPT not found
    11635;   Corrupts registers:
    11736;       Nothing
     
    11938ALIGN JUMP_ALIGN
    12039FindDPT_ForDriveNumber:
    121     push    si
    122     mov     si, FindDPT_IterateToDriveNumberCallback
    123 FindDPT_StartIterationAndReturnAfterDone:
    124     call    FindDPT_IterateAllDPTs
    125     pop     si
     40    push    dx
     41    push    ax
     42
     43    mov     al, LARGEST_DPT_SIZE
     44    sub     dl, [RAMVARS.bFirstDrv]
     45    mul     dl
     46    add     ax, BYTE RAMVARS_size
     47    xchg    di, ax
     48
     49    pop     ax
     50    pop     dx
    12651    ret
    12752
     53
    12854;--------------------------------------------------------------------
    129 ; Iteration callback for finding DPT for drive number.
     55; Finds Disk Parameter Table for
     56; Master or Slave drive at wanted port.
    13057;
    131 ; FindDPT_IterateToDriveNumberCallback
     58; FindDPT_ToDSDIForIdeMasterAtPortDX
     59; FindDPT_ToDSDIForIdeSlaveAtPortDX
    13260;   Parameters:
    133 ;       DL:     Drive number to search for
     61;       DX:     IDE Base Port address
     62;       DS:     RAMVARS segment
     63;   Returns:
     64;       DL:     Drive number (if DPT found)
     65;       DS:DI:  Ptr to DPT
     66;       CF:     Set if wanted DPT found
     67;               Cleared if DPT not found
     68;   Corrupts registers:
     69;       SI
     70;--------------------------------------------------------------------
     71ALIGN JUMP_ALIGN
     72FindDPT_ToDSDIForIdeMasterAtPortDX:
     73    mov     si, FindDPT_IterateToMasterAtPortCallback
     74    jmp     SHORT IterateAllDPTs
     75
     76ALIGN JUMP_ALIGN
     77FindDPT_ToDSDIForIdeSlaveAtPortDX:
     78    mov     si, FindDPT_IterateToSlaveAtPortCallback
     79    jmp     SHORT IterateAllDPTs
     80
     81;--------------------------------------------------------------------
     82; Iteration callback for finding DPT using
     83; IDE base port for Master or Slave drive.
     84;
     85; FindDPT_IterateToSlaveAtPortCallback
     86; FindDPT_IterateToMasterAtPortCallback
     87;   Parameters:
     88;       CH:     Drive number
     89;       DX:     IDE Base Port address
    13490;       DS:DI:  Ptr to DPT to examine
    13591;   Returns:
     92;       DL:     Drive number if correct DPT
    13693;       CF:     Set if wanted DPT found
    13794;               Cleared if wrong DPT
     
    14097;--------------------------------------------------------------------
    14198ALIGN JUMP_ALIGN
    142 FindDPT_IterateToDriveNumberCallback:
    143     cmp     dl, [di+DPT.bDrvNum]            ; Wanted DPT found?
    144     je      SHORT FindDPT_RightDriveNumber  ;  If so, return
    145 FindDPT_ReturnWrongDPT:
    146     clc                                     ; Clear CF since wrong DPT
     99FindDPT_IterateToSlaveAtPortCallback:
     100    test    BYTE [di+DPT.wFlags], FLG_DPT_SLAVE ; Clears CF
     101    jnz     SHORT CompareBasePortAddress
     102    ret     ; Wrong DPT
     103
     104ALIGN JUMP_ALIGN
     105FindDPT_IterateToMasterAtPortCallback:
     106    test    BYTE [di+DPT.wFlags], FLG_DPT_SLAVE
     107    jnz     SHORT ReturnWrongDPT                ; Return if slave drive
     108
     109CompareBasePortAddress:
     110    push    bx
     111    eMOVZX  bx, BYTE [di+DPT.bIdevarsOffset]    ; CS:BX now points to IDEVARS
     112    cmp     dx, [cs:bx+IDEVARS.wPort]           ; Wanted port?
     113    pop     bx
     114    jne     SHORT ReturnWrongDPT
     115    mov     dl, ch                              ; Return drive number in DL
     116    stc                                         ; Set CF since wanted DPT
    147117    ret
    148 ALIGN JUMP_ALIGN
    149 FindDPT_RightDriveNumber:
    150     push    bx
    151     eMOVZX  bx, BYTE [di+DPT.bIdeOff]       ; CS:BX now points to IDEVARS
    152     mov     bx, [cs:bx+IDEVARS.wPort]       ; Load IDE Base Port address...
    153     mov     [RAMVARS.wIdeBase], bx          ; ...and store it to RAMVARS
    154     pop     bx
    155     stc
     118ReturnWrongDPT:
     119    clc                                         ; Clear CF since wrong DPT
    156120    ret
    157121
     
    160124; Iterates all Disk Parameter Tables.
    161125;
    162 ; FindDPT_IterateAllDPTs
     126; IterateAllDPTs
    163127;   Parameters:
    164128;       BX,DX:  Parameters to callback function
     
    170134;               Cleared if DPT not found
    171135;   Corrupts registers:
    172 ;       Nothing, unless corrupted by callback function
     136;       Nothing unless corrupted by callback function
    173137;--------------------------------------------------------------------
    174138ALIGN JUMP_ALIGN
    175 FindDPT_IterateAllDPTs:
    176     push    ax
     139IterateAllDPTs:
    177140    push    cx
     141    mov     cx, [RAMVARS.wDrvCntAndFirst]
     142    jcxz    .AllDptsIterated            ; Return if no drives
    178143    call    FindDPT_PointToFirstDPT     ; Point DS:DI to first DPT
    179     eMOVZX  cx, BYTE [RAMVARS.bDrvCnt]  ; Load number of drives
    180     xor     ax, ax                      ; Zero AX for DPT size and clear CF
    181     jcxz    .Return                     ; Return if no drives
    182144ALIGN JUMP_ALIGN
    183145.LoopWhileDPTsLeft:
    184146    call    si                          ; Is wanted DPT?
    185     jc      SHORT .Return               ;  If so, return
    186     mov     al, [di+DPT.bSize]          ; Load DPT size to AX
    187     add     di, ax                      ; Point to next DPT
    188     loop    .LoopWhileDPTsLeft          ; Check next DPT
     147    jc      SHORT .AllDptsIterated      ;  If so, return
     148    inc     ch                          ; Increment drive number
     149    add     di, BYTE LARGEST_DPT_SIZE   ; Point to next DPT
     150    dec     cl                          ; Decrement drives left
     151    jnz     SHORT .LoopWhileDPTsLeft
    189152    clc                                 ; Clear CF since DPT not found
    190153ALIGN JUMP_ALIGN
    191 .Return:
     154.AllDptsIterated:
    192155    pop     cx
    193     pop     ax
    194156    ret
    195157
     
    209171FindDPT_PointToFirstDPT:
    210172    mov     di, RAMVARS_size
    211     test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
    212     jz      SHORT .Return                           ; RAMVARS used (top of interrupt vectors)
    213     add     di, BYTE FULLRAMVARS_size-RAMVARS_size  ; FULLRAMVARS used (top of base memory)
    214 ALIGN JUMP_ALIGN
    215 .Return:
    216173    ret
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm

    r148 r150  
    4040    eSHL_IM ax, 6                       ; Segment to first stolen kB (*=40h)
    4141    mov     ds, ax
    42     mov     WORD [FULLRAMVARS.wSign], W_SIGN_FULLRAMVARS
    43     ; Fall to .InitializeRamvarsFromDS
     42    mov     WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
     43    ; Fall to .InitializeRamvars
    4444
    4545;--------------------------------------------------------------------
     
    5959    pop     es
    6060    call    Memory_ZeroESDIwithSizeInCX
     61    mov     WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
    6162    ; Fall to .InitializeDriveTranslationAndReturn
    6263
     
    9293    test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
    9394    jnz     SHORT .GetStolenSegmentToDS
    94     mov     di, SEGMENT_RAMVARS_TOP_OF_INTERRUPT_VECTORS
     95    mov     di, LITE_MODE_RAMVARS_SEGMENT
    9596    mov     ds, di
    9697    ret
     
    105106    mov     ds, di                  ; EBDA segment to DS
    106107    add     di, BYTE 64             ; DI to next stolen kB
    107     cmp     WORD [FULLRAMVARS.wSign], W_SIGN_FULLRAMVARS
     108    cmp     WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
    108109    jne     SHORT .LoopStolenKBs    ; Loop until sign found (always found eventually)
    109110    ret
     
    167168
    168169;--------------------------------------------------------------------
    169 ; RamVars_IncrementHardDiskCount
    170 ;   Parameters:
    171 ;       DL:     Drive number for new drive
    172 ;       DS:     RAMVARS segment
    173 ;   Returns:
    174 ;       Nothing
    175 ;   Corrupts registers:
    176 ;       Nothing
    177 ;--------------------------------------------------------------------
    178 RamVars_IncrementHardDiskCount:
    179     inc     BYTE [RAMVARS.bDrvCnt]      ; Increment drive count to RAMVARS
    180     cmp     BYTE [RAMVARS.bFirstDrv], 0 ; First drive set?
    181     ja      SHORT .Return               ;  If so, return
    182     mov     [RAMVARS.bFirstDrv], dl     ; Store first drive number
    183 .Return:
    184     ret
    185 
    186 
    187 ;--------------------------------------------------------------------
    188170; RamVars_GetHardDiskCountFromBDAtoCX
    189171;   Parameters:
Note: See TracChangeset for help on using the changeset viewer.