Changeset 99 in xtideuniversalbios


Ignore:
Timestamp:
Jan 31, 2011, 11:27:17 AM (13 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Changes to XTIDE Universal BIOS:

  • Even more initialization code inlining.
Location:
trunk/XTIDE_Universal_BIOS
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc

    r3 r99  
    1 ; File name     :   CustomDPT.inc
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   23.3.2010
    4 ; Last update   :   10.4.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Defines for DPT structs containing custom
    73;                   Disk Parameter Table used by this BIOS.
     
    1511    ; General Disk Parameter Table related
    1612    .bSize      resb    1   ; Size of DPT (with extensions) in bytes
     13    .wDrvNumAndFlags:
    1714    .bDrvNum    resb    1   ; Drive number
    1815    .bFlags     resb    1   ; DPT and Drive related flags
     
    2623    ; IDE related
    2724    .wPCyls     resb    2   ; Number of P-CHS (IDE) Cylinders (1...16383)
     25    .wHeadsAndSectors:
    2826    .bPHeads    resb    1   ; Number of P-CHS (IDE) Heads (1...16)
    2927    .bPSect     resb    1   ; Number of P-CHS (IDE) Sectors per Track (1...63)
  • trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc

    r97 r99  
    5454    .wFlags         resb    2   ; Drive flags
    5555    .wCylinders     resb    2   ; User specified cylinders (1...16383)
    56     .wSectAndHeads:
     56    .wHeadsAndSectors:
     57    .bHeads         resb    1   ; User specified Heads (1...16)
    5758    .bSect          resb    1   ; User specified Sectors per track (1...63)
    58     .bHeads         resb    1   ; User specified Heads (1...16)
    5959endstruc
    6060
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm

    r3 r99  
    1 ; File name     :   AtaID.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   6.4.2010
    4 ; Last update   :   9.4.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Functions for accessing ATA information read with
    73;                   IDENTIFY DEVICE command.
     
    117
    128;--------------------------------------------------------------------
    13 ; Returns P-CHS values from ATA information.
    14 ;
    159; AtaID_GetPCHS
    1610;   Parameters:
     
    1812;   Returns:
    1913;       AX:     Number of user specified P-CHS cylinders
    20 ;       BL:     Number of user specified P-CHS sectors per track
    21 ;       BH:     Number of user specified P-CHS heads
     14;       BH:     Number of user specified P-CHS sectors per track
     15;       BL:     Number of user specified P-CHS heads
    2216;   Corrupts registers:
    2317;       Nothing
    2418;--------------------------------------------------------------------
    25 ALIGN JUMP_ALIGN
    2619AtaID_GetPCHS:
    2720    mov     ax, [es:si+ATA1.wCylCnt]    ; Cylinders (1...16383)
    28     mov     bh, [es:si+ATA1.wHeadCnt]   ; Heads (1...16)
    29     mov     bl, [es:si+ATA1.wSPT]       ; Sectors per Track (1...63)
     21    mov     bl, [es:si+ATA1.wHeadCnt]   ; Heads (1...16)
     22    mov     bh, [es:si+ATA1.wSPT]       ; Sectors per Track (1...63)
    3023    ret
    3124
    3225
    3326;--------------------------------------------------------------------
    34 ; Returns total number of available sectors from ATA information.
    35 ;
    3627; AtaID_GetTotalSectorCount
    3728;   Parameters:
     
    4233;       Nothing
    4334;--------------------------------------------------------------------
    44 ALIGN JUMP_ALIGN
    4535AtaID_GetTotalSectorCount:
     36    push    ds
     37
     38    push    es
     39    pop     ds
    4640    xor     bx, bx
    47     test    WORD [es:si+ATA1.wCaps], A1_wCaps_LBA
    48     jz      SHORT AtaID_GetChsSectorCount
    49     ; Fall to AtaID_GetLbaSectorCount
     41    test    WORD [si+ATA1.wCaps], A1_wCaps_LBA
     42    jz      SHORT .GetChsSectorCount
     43    ; Fall to .GetLbaSectorCount
    5044
    5145;--------------------------------------------------------------------
    52 ; Returns total number of available sectors for LBA addressing.
    53 ;
    54 ; AtaID_GetLbaSectorCount
     46; .GetLbaSectorCount
    5547;   Parameters:
    5648;       BX:     Zero
    57 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     49;       DS:SI:  Ptr to 512-byte ATA information read from the drive
    5850;   Returns:
    5951;       BX:DX:AX:   48-bit sector count
     
    6153;       Nothing
    6254;--------------------------------------------------------------------
    63 ;ALIGN JUMP_ALIGN
    64 AtaID_GetLbaSectorCount:
    65     test    WORD [es:si+ATA6.wSetSup83], A6_wSetSup83_LBA48
     55.GetLbaSectorCount:
     56    test    WORD [si+ATA6.wSetSup83], A6_wSetSup83_LBA48
    6657    jz      SHORT .GetLba28SectorCount
    67     mov     ax, [es:si+ATA6.qwLBACnt]
    68     mov     dx, [es:si+ATA6.qwLBACnt+2]
    69     mov     bx, [es:si+ATA6.qwLBACnt+4]
     58    mov     ax, [si+ATA6.qwLBACnt]
     59    mov     dx, [si+ATA6.qwLBACnt+2]
     60    mov     bx, [si+ATA6.qwLBACnt+4]
     61    pop     ds
    7062    ret
    71 ALIGN JUMP_ALIGN
    7263.GetLba28SectorCount:
    73     mov     ax, [es:si+ATA1.dwLBACnt]
    74     mov     dx, [es:si+ATA1.dwLBACnt+2]
     64    mov     ax, [si+ATA1.dwLBACnt]
     65    mov     dx, [si+ATA1.dwLBACnt+2]
     66    pop     ds
    7567    ret
    7668
    7769;--------------------------------------------------------------------
    78 ; Returns total number of available sectors for P-CHS addressing.
    79 ;
    80 ; AtaID_GetChsSectorCount
     70; .GetChsSectorCount
    8171;   Parameters:
    82 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     72;       DS:SI:  Ptr to 512-byte ATA information read from the drive
    8373;   Returns:
    8474;       DX:AX:  24-bit sector count
     
    8676;       Nothing
    8777;--------------------------------------------------------------------
    88 ALIGN JUMP_ALIGN
    89 AtaID_GetChsSectorCount:
    90     mov     al, [es:si+ATA1.wSPT]       ; AL=Sectors per track
    91     mul     BYTE [es:si+ATA1.wHeadCnt]  ; AX=Sectors per track * number of heads
    92     mul     WORD [es:si+ATA1.wCylCnt]   ; DX:AX=Sectors per track * number of heads * number of cylinders
     78.GetChsSectorCount:
     79    mov     al, [si+ATA1.wSPT]      ; AL=Sectors per track
     80    mul     BYTE [si+ATA1.wHeadCnt] ; AX=Sectors per track * number of heads
     81    mul     WORD [si+ATA1.wCylCnt]  ; DX:AX=Sectors per track * number of heads * number of cylinders
     82    pop     ds
    9383    ret
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/DriveXlate.asm

    r35 r99  
    1 ; File name     :   DriveXlate.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   15.3.2010
    4 ; Last update   :   24.8.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Functions for swapping drive letters.
    73
     
    10096DriveXlate_SwapFloppyDriveOrHardDisk:
    10197    test    dl, 80h                         ; Hard disk?
    102     jnz     SHORT DriveXlate_SwapHardDisk   ; If so, jump to swap
    103     ; Fall to DriveXlate_SwapFloppyDrive
    104 
    105 ;--------------------------------------------------------------------
    106 ; Swaps Floppy Drive number.
    107 ;
    108 ; DriveXlate_SwapFloppyDrive
    109 ;   Parameters:
    110 ;       DL:     Drive number to be possibly swapped
    111 ;       DS:     RAMVARS segment
    112 ;   Returns:
    113 ;       DL:     Translated drive number
    114 ;   Corrupts registers:
    115 ;       AX
    116 ;--------------------------------------------------------------------
    117 ;ALIGN JUMP_ALIGN
    118 DriveXlate_SwapFloppyDrive:
     98    jnz     SHORT .SwapHardDisk ; If so, jump to swap
     99    ; Fall to .SwapFloppyDrive
     100
     101;--------------------------------------------------------------------
     102; .SwapFloppyDrive
     103;   Parameters:
     104;       DL:     Drive number to be possibly swapped
     105;       DS:     RAMVARS segment
     106;   Returns:
     107;       DL:     Translated drive number
     108;   Corrupts registers:
     109;       AX
     110;--------------------------------------------------------------------
     111.SwapFloppyDrive:
    119112    eMOVZX  ax, BYTE [RAMVARS.xlateVars+XLATEVARS.bFDSwap]
    120     jmp     SHORT DriveXlate_SwapDrive
    121 
    122 ;--------------------------------------------------------------------
    123 ; Swaps Hard Disk number.
    124 ;
    125 ; DriveXlate_SwapHardDisk
    126 ;   Parameters:
    127 ;       DL:     Drive number to be possibly swapped
    128 ;       DS:     RAMVARS segment
    129 ;   Returns:
    130 ;       DL:     Translated drive number
    131 ;   Corrupts registers:
    132 ;       AX
    133 ;--------------------------------------------------------------------
    134 ALIGN JUMP_ALIGN
    135 DriveXlate_SwapHardDisk:
     113    jmp     SHORT SwapDrive
     114
     115;--------------------------------------------------------------------
     116; .SwapHardDisk
     117;   Parameters:
     118;       DL:     Drive number to be possibly swapped
     119;       DS:     RAMVARS segment
     120;   Returns:
     121;       DL:     Translated drive number
     122;   Corrupts registers:
     123;       AX
     124;--------------------------------------------------------------------
     125ALIGN JUMP_ALIGN
     126.SwapHardDisk:
    136127    mov     ah, 80h
    137128    mov     al, BYTE [RAMVARS.xlateVars+XLATEVARS.bHDSwap]
    138     ; Fall to DriveXlate_SwapDrive
    139 
    140 ;--------------------------------------------------------------------
    141 ; Swaps Hard Disk or Floppy Drive number.
    142 ;
    143 ; DriveXlate_SwapDrive
     129    ; Fall to SwapDrive
     130
     131;--------------------------------------------------------------------
     132; SwapDrive
    144133;   Parameters:
    145134;       AL:     Drive number to swap to 00h/80h
     
    151140;       Nothing
    152141;--------------------------------------------------------------------
    153 ;ALIGN JUMP_ALIGN
    154 DriveXlate_SwapDrive:
     142SwapDrive:
    155143    cmp     ah, dl              ; Swap DL from 00h/80h to xxh?
    156144    je      SHORT .SwapToXXhInAL
     
    201189DriveXlate_SetDriveToSwap:
    202190    test    dl, 80h             ; Floppy drive?
    203     jnz     SHORT DriveXlate_SetHardDiskToSwap
    204     ; Fall to DriveXlate_SetFloppyDriveToSwap
    205 
    206 ;--------------------------------------------------------------------
    207 ; Stores floppy drive to be swapped.
    208 ;
    209 ; DriveXlate_SetFloppyDriveToSwap
    210 ;   Parameters:
    211 ;       DL:     Drive to swap to 00h
    212 ;       DS:     RAMVARS segment
    213 ;   Returns:
    214 ;       Nothing
    215 ;   Corrupts registers:
    216 ;       Nothing
    217 ;--------------------------------------------------------------------   
    218 ALIGN JUMP_ALIGN
    219 DriveXlate_SetFloppyDriveToSwap:
     191    jnz     SHORT .SetHardDiskToSwap
     192.SetFloppyDriveToSwap:
    220193    mov     [RAMVARS.xlateVars+XLATEVARS.bFDSwap], dl
    221194    ret
    222 
    223 ;--------------------------------------------------------------------
    224 ; Stores hard disk to be swapped.
    225 ;
    226 ; DriveXlate_SetHardDiskToSwap
    227 ;   Parameters:
    228 ;       DL:     Drive to swap to 80h
    229 ;       DS:     RAMVARS segment
    230 ;   Returns:
    231 ;       Nothing
    232 ;   Corrupts registers:
    233 ;       Nothing
    234 ;--------------------------------------------------------------------   
    235 ALIGN JUMP_ALIGN
    236 DriveXlate_SetHardDiskToSwap:
     195ALIGN JUMP_ALIGN
     196.SetHardDiskToSwap:
    237197    mov     [RAMVARS.xlateVars+XLATEVARS.bHDSwap], dl
    238198    ret
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm

    r86 r99  
    1818;       BX, CX, DI
    1919;--------------------------------------------------------------------
    20 ;ALIGN JUMP_ALIGN
    2120FloppyDrive_IsInt40hInstalled:
    2221    cmp     WORD [es:INTV_FLOPPY_FUNC*4+2], 0C000h  ; Any ROM segment?
    2322    jb      SHORT .Int40hHandlerIsNotInstalled
     23%ifdef USE_AT
    2424    call    .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h
     25%else
     26    clc     ; INT 40h installed. No need to verify on XT systems.
     27%endif
    2528.Int40hHandlerIsNotInstalled:
    2629    cmc
     
    3740;       BX, CX, DI
    3841;--------------------------------------------------------------------
    39 ;ALIGN JUMP_ALIGN
     42%ifdef USE_AT
    4043.VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h:
    4144    push    es
     
    4548    call    .LoadInt40hVerifyParameters
    4649    int     INTV_DISK_FUNC
    47     jc      SHORT .AH08hNotSupported    ; AH=08h not supported on XTs but that doesn't
    48     push    es                          ; matter since INT 40h does not need to be verified
    49     push    di                          ; on XTs
     50    jc      SHORT .Int40hIsInstalled    ; Maybe there are not any floppy drives at all
     51    push    es
     52    push    di
    5053
    5154    call    .LoadInt40hVerifyParameters
     
    5861    mov     dx, es
    5962    cmp     cx, dx                      ; Difference in segments?
    60     jne     SHORT .Int40hNotInstalled
    61 .AH08hNotSupported:
    62     clc
    63     jmp     SHORT .Int40hIsInstalled
     63    je      SHORT .Int40hIsInstalled
    6464.Int40hNotInstalled:
    6565    stc
     
    8181;       DH
    8282;--------------------------------------------------------------------
    83 ;ALIGN JUMP_ALIGN
    8483.LoadInt40hVerifyParameters:
    8584    mov     ah, 08h             ; Get Drive Parameters
     
    8887    mov     es, dx              ; ES:DI = 0000:0000h to guard against BIOS bugs
    8988    ret
     89%endif
    9090
    9191
     
    133133FloppyDrive_GetCount:
    134134    push    es
     135%ifdef USE_AT
    135136    call    FloppyDrive_GetCountFromBIOS
    136     jnc     SHORT .CompareToUserMinimum
     137%else
    137138    call    FloppyDrive_GetCountFromBDA
    138 ALIGN JUMP_ALIGN
    139 .CompareToUserMinimum:
     139%endif
    140140    MAX_U   cl, [cs:ROMVARS.bMinFddCnt]
    141141    xor     ch, ch
     
    159159;       CH, ES
    160160;--------------------------------------------------------------------
     161%ifdef USE_AT
    161162ALIGN JUMP_ALIGN
    162163FloppyDrive_GetCountFromBIOS:
     
    176177    pop     di
    177178    ret
     179%endif
    178180
    179181
     
    190192;       CH, ES
    191193;--------------------------------------------------------------------
     194%ifndef USE_AT
    192195ALIGN JUMP_ALIGN
    193196FloppyDrive_GetCountFromBDA:
     
    199202    add     cl, ch                          ; CL = Floppy Drive count
    200203    ret
     204%endif
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm

    r3 r99  
    1 ; File name     :   AccessDPT.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   16.3.2010
    4 ; Last update   :   26.4.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Functions for accessing DPT data.
    73
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm

    r3 r99  
    1 ; File name     :   CreateDPT.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   12.3.2010
    4 ; Last update   :   26.4.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Functions for creating Disk Parameter Table.
    73
     
    2622;               Set if any error
    2723;   Corrupts registers:
    28 ;       AX, CX, BX, DH
    29 ;--------------------------------------------------------------------
    30 ALIGN JUMP_ALIGN
     24;       AX, BX, CX, DH
     25;--------------------------------------------------------------------
    3126CreateDPT_FromAtaInformation:
    3227    call    FindDPT_ForNewDrive     ; Get new DPT to DS:DI
    33     call    CreateDPT_Initialize
    34     call    CreateDPT_StoreDriveControlByte
    35     call    CreateDPT_StorePCHS
    36     call    CreateDPT_StoreLCHS
    37     call    CreateDPT_StoreAddressing
    38     call    CreateDPT_StoreBlockMode
    39     call    CreateDPT_StoreEBIOSSupport
    40     jmp     CreateDPT_StoreDriveNumberAndUpdateDriveCount
    41 
    42 
    43 ;--------------------------------------------------------------------
    44 ; Initializes empty DPT by storing initial values that are not
    45 ; read from ATA information.
    46 ;
    47 ; CreateDPT_Initialize
    48 ;   Parameters:
    49 ;       BH:     Drive Select byte for Drive and Head Register
    50 ;       DS:DI:  Ptr to Disk Parameter Table
    51 ;       CS:BP:  Ptr to IDEVARS for the controller
    52 ;   Returns:
    53 ;       CF:     Cleared if DPT parameters stored successfully
    54 ;               Set if any error
    55 ;   Corrupts registers:
    56 ;       Nothing
    57 ;--------------------------------------------------------------------
    58 ALIGN JUMP_ALIGN
    59 CreateDPT_Initialize:
    60     xor     ax, ax                      ; Clear AX and CF
     28    ; Fall to .InitializeDPT
     29
     30;--------------------------------------------------------------------
     31; .InitializeDPT
     32;   Parameters:
     33;       BH:     Drive Select byte for Drive and Head Register
     34;       DS:DI:  Ptr to Disk Parameter Table
     35;       CS:BP:  Ptr to IDEVARS for the controller
     36;   Returns:
     37;       AX:     Zero
     38;   Corrupts registers:
     39;       Nothing
     40;--------------------------------------------------------------------
     41.InitializeDPT:
     42    xor     ax, ax
    6143    mov     BYTE [di+DPT.bSize], DPT_size
    62     mov     BYTE [di+DPT.bDrvNum], al
    63     mov     BYTE [di+DPT.bFlags], al
     44    mov     [di+DPT.wDrvNumAndFlags], ax
    6445    mov     BYTE [di+DPT.bReset], MASK_RESET_ALL
    65     mov     WORD [di+DPT.bIdeOff], bp
    66     mov     BYTE [di+DPT.bDrvSel], bh
    67     ret
    68 
    69 
    70 ;--------------------------------------------------------------------
    71 ; Stores Drive Control Byte for Device Control Register.
    72 ;
    73 ; CreateDPT_StoreDriveControlByte
    74 ;   Parameters:
    75 ;       BH:     Drive Select byte for Drive and Head Register
    76 ;       DS:DI:  Ptr to Disk Parameter Table
    77 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    78 ;       CS:BP:  Ptr to IDEVARS for the controller
    79 ;   Returns:
    80 ;       CF:     Cleared if DPT parameters stored successfully
    81 ;               Set if any error
     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
     54;       BH:     Drive Select byte for Drive and Head Register
     55;       DS:DI:  Ptr to Disk Parameter Table
     56;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     57;       CS:BP:  Ptr to IDEVARS for the controller
     58;   Returns:
     59;       Nothing
    8260;   Corrupts registers:
    8361;       AX
    8462;--------------------------------------------------------------------
    85 ALIGN JUMP_ALIGN
    86 CreateDPT_StoreDriveControlByte:
    87     xor     ax, ax                          ; Zero AX
    88     cmp     BYTE [cs:bp+IDEVARS.bIRQ], 0    ; Interrupts enabled?
     63.StoreDriveControlByte:
     64    cmp     BYTE [cs:bp+IDEVARS.bIRQ], al   ; Interrupts enabled?
    8965    jne     SHORT .CheckHeadCount
    9066    or      al, FLG_IDE_CTRL_nIEN           ; Disable interrupts
    91 ALIGN JUMP_ALIGN
    9267.CheckHeadCount:
    9368    cmp     BYTE [es:si+ATA1.wHeadCnt], 8   ; 1...8 heads?
    94     jbe     SHORT .StoreDriveControlByte
     69    jbe     SHORT .StoreDrvCtrlByteToDPT
    9570    or      al, FLG_IDE_CTRL_O8H            ; Over 8 heads (pre-ATA)
    96 ALIGN JUMP_ALIGN
    97 .StoreDriveControlByte:
     71.StoreDrvCtrlByteToDPT:
    9872    mov     [di+DPT.bDrvCtrl], al
    99     clc
    100     ret
    101 
    102 
    103 ;--------------------------------------------------------------------
    104 ; Stores P-CHS values from ATA information or user specified values to DPT.
    105 ;
    106 ; CreateDPT_StorePCHS
    107 ;   Parameters:
    108 ;       BH:     Drive Select byte for Drive and Head Register
    109 ;       DS:DI:  Ptr to Disk Parameter Table
    110 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    111 ;       CS:BP:  Ptr to IDEVARS for the controller
    112 ;   Returns:
    113 ;       CF:     Cleared if DPT parameters stored successfully
    114 ;               Set if any error
    115 ;   Corrupts registers:
    116 ;       AX, BX
    117 ;--------------------------------------------------------------------
    118 ALIGN JUMP_ALIGN
    119 CreateDPT_StorePCHS:
    120     call    CreateDPT_GetUserOrAtaPCHS
    121     mov     [di+DPT.wPCyls], ax
    122     mov     [di+DPT.bPHeads], bh
    123     mov     [di+DPT.bPSect], bl
    124     clc
    125     ret
    126 
    127 ;--------------------------------------------------------------------
    128 ; Returns user specified P-CHS or values read from ATA information.
    129 ;
    130 ; CreateDPT_GetUserOrAtaPCHS
    131 ;   Parameters:
    132 ;       BH:     Drive Select byte for Drive and Head Register
    133 ;       DS:DI:  Ptr to Disk Parameter Table
    134 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    135 ;       CS:BP:  Ptr to IDEVARS for the controller
    136 ;   Returns:
    137 ;       AX:     Number of P-CHS cylinders
    138 ;       BL:     Number of P-CHS sectors per track
    139 ;       BH:     Number of P-CHS heads
    140 ;   Corrupts registers:
    141 ;       Nothing
    142 ;--------------------------------------------------------------------
    143 ALIGN JUMP_ALIGN
    144 CreateDPT_GetUserOrAtaPCHS:
    145     mov     ax, FLG_DRVPARAMS_USERCHS   ; User specified CHS?
     73    ; Fall to .StorePCHS
     74
     75;--------------------------------------------------------------------
     76; .StorePCHS
     77;   Parameters:
     78;       AH:     Zero
     79;       BH:     Drive Select byte for Drive and Head Register
     80;       DS:DI:  Ptr to Disk Parameter Table
     81;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     82;       CS:BP:  Ptr to IDEVARS for the controller
     83;   Returns:
     84;       AX:     P-CHS cylinders
     85;       BL:     P-CHS heads
     86;       BH:     P-CHS sectors
     87;   Corrupts registers:
     88;       Nothing
     89;--------------------------------------------------------------------
     90.StorePCHS:
     91    mov     al, FLG_DRVPARAMS_USERCHS   ; User specified CHS?
    14692    call    AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive
    147     jnz     SHORT CreateDPT_GetUserSpecifiedPCHS
    148     jmp     AtaID_GetPCHS
    149 
    150 ;--------------------------------------------------------------------
    151 ; Returns user specified P-CHS values from ROMVARS.
    152 ;
    153 ; CreateDPT_GetUserSpecifiedPCHS
    154 ;   Parameters:
    155 ;       DS:DI:  Ptr to Disk Parameter Table
    156 ;       CS:BP:  Ptr to IDEVARS for the controller
    157 ;   Returns:
    158 ;       AX:     Number of user specified P-CHS cylinders
    159 ;       BL:     Number of user specified P-CHS sectors per track
    160 ;       BH:     Number of user specified P-CHS heads
    161 ;   Corrupts registers:
    162 ;       Nothing
    163 ;--------------------------------------------------------------------
    164 ALIGN JUMP_ALIGN
    165 CreateDPT_GetUserSpecifiedPCHS:
     93    jnz     SHORT .GetUserSpecifiedPCHS
     94    call    AtaID_GetPCHS               ; Get from ATA information
     95    jmp     SHORT .StorePCHStoDPT
     96
     97.GetUserSpecifiedPCHS:
    16698    call    AccessDPT_GetPointerToDRVPARAMStoCSBX
    16799    mov     ax, [cs:bx+DRVPARAMS.wCylinders]
    168     mov     bx, [cs:bx+DRVPARAMS.wSectAndHeads]
     100    mov     bx, [cs:bx+DRVPARAMS.wHeadsAndSectors]
    169101    or      BYTE [di+DPT.bFlags], FLG_DPT_USERCHS
    170     ret
    171 
    172 
    173 ;--------------------------------------------------------------------
    174 ; Stores L-CHS values by converting from P-CHS values if necessary.
    175 ;
    176 ; CreateDPT_StoreLCHS
    177 ;   Parameters:
    178 ;       DS:DI:  Ptr to Disk Parameter Table
    179 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    180 ;   Returns:
    181 ;       CF:     Cleared if DPT parameters stored successfully
    182 ;               Set if any error
    183 ;   Corrupts registers:
    184 ;       AX, CX, DX
    185 ;--------------------------------------------------------------------
    186 ALIGN JUMP_ALIGN
    187 CreateDPT_StoreLCHS:
    188     mov     cx, [di+DPT.wPCyls]         ; P-CHS Cylinders (1...16383)
    189     eMOVZX  dx, BYTE [di+DPT.bPHeads]   ; P-CHS Heads (1...16)
    190     call    CreateDPT_ShiftPCHtoLCH
    191     test    dh, dh                      ; 256 heads?
    192     jz      SHORT .StoreToDPT           ;  If less, no correction needed
    193     dec     dx                          ; Limit to 255 heads since DOS does not support 256 heads
    194 ALIGN JUMP_ALIGN
    195 .StoreToDPT:
    196     mov     [di+DPT.bShLtoP], al
    197     mov     [di+DPT.wLHeads], dx
    198     clc
    199     ret
    200 
    201 ;--------------------------------------------------------------------
    202 ; Returns L-CHS values from P-CHS values.
    203 ; Sectors per track is always the same for both addressing modes.
    204 ;
    205 ; CreateDPT_ShiftPCHtoLCH:
    206 ;   Parameters:
    207 ;       CX:     Number of P-CHS cylinders (1...16383)
    208 ;       DX:     Number of P-CHS heads (1...16)
    209 ;   Returns:
    210 ;       AL:     Number of bits shifted
    211 ;       CX:     Number of L-CHS cylinders (1...1024)
    212 ;       DX:     Number of L-CHS heads (1...256)
    213 ;   Corrupts registers:
    214 ;       Nothing
    215 ;--------------------------------------------------------------------
    216 ALIGN JUMP_ALIGN
    217 CreateDPT_ShiftPCHtoLCH:
    218     xor     al, al              ; Zero AL
    219 ALIGN JUMP_ALIGN
     102
     103.StorePCHStoDPT:
     104    mov     [di+DPT.wPCyls], ax
     105    mov     [di+DPT.wHeadsAndSectors], bx
     106    ; Fall to .StoreLCHS
     107
     108;--------------------------------------------------------------------
     109; .StoreLCHS
     110;   Parameters:
     111;       AX:     P-CHS cylinders
     112;       BL:     P-CHS heads
     113;       DS:DI:  Ptr to Disk Parameter Table
     114;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     115;   Returns:
     116;       Nothing
     117;   Corrupts registers:
     118;       AX, BX, CX
     119;--------------------------------------------------------------------
     120.StoreLCHS:
     121    xor     bh, bh                      ; BX = P-CHS Heads (1...16)
     122    xor     cx, cx
    220123.ShiftLoop:
    221     cmp     cx, 1024            ; Need to shift?
    222     jbe     SHORT .Return       ;  If not, return
    223     inc     ax                  ; Increment shift count
    224     shr     cx, 1               ; Halve cylinders
    225     shl     dx, 1               ; Double heads
     124    cmp     ax, 1024                    ; Need to shift?
     125    jbe     SHORT .LimitHeadsTo255      ;  If not, return
     126    inc     cx                          ; Increment shift count
     127    shr     ax, 1                       ; Halve cylinders
     128    shl     bx, 1                       ; Double heads
    226129    jmp     SHORT .ShiftLoop
    227 ALIGN JUMP_ALIGN
    228 .Return:
    229     ret
    230 
    231 
    232 ;--------------------------------------------------------------------
    233 ; Stores addressing information (L-CHS, P-CHS, LBA28 or LBA48).
    234 ;
    235 ; CreateDPT_StoreAddressing
    236 ;   Parameters:
    237 ;       DS:DI:  Ptr to Disk Parameter Table
    238 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    239 ;   Returns:
    240 ;       CF:     Cleared if DPT parameters stored successfully
    241 ;               Set if any error
    242 ;   Corrupts registers:
    243 ;       Nothing
    244 ;--------------------------------------------------------------------
    245 ALIGN JUMP_ALIGN
    246 CreateDPT_StoreAddressing:
     130
     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
     138    ; Fall to .StoreAddressing
     139
     140;--------------------------------------------------------------------
     141; .StoreAddressing
     142;   Parameters:
     143;       DS:DI:  Ptr to Disk Parameter Table
     144;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     145;   Returns:
     146;       Nothing
     147;   Corrupts registers:
     148;       Nothing
     149;--------------------------------------------------------------------
     150.StoreAddressing:
    247151    cmp     WORD [di+DPT.wPCyls], 1024      ; L-CHS possible? (no translation needed)
    248     jbe     SHORT .Return                   ;  If so, nothing needs to be changed
     152    jbe     SHORT .StoreBlockMode           ;  If so, nothing needs to be changed
    249153    test    BYTE [di+DPT.bFlags], FLG_DPT_USERCHS
    250     jnz     SHORT .StorePCHS                ; Use user defined P-CHS
     154    jnz     SHORT .StorePCHSaddressing      ; Use user defined P-CHS
    251155    test    WORD [es:si+ATA1.wCaps], A2_wCaps_LBA
    252     jz      SHORT .StorePCHS                ; Use P-CHS since LBA not supported
     156    jz      SHORT .StorePCHSaddressing      ; Use P-CHS since LBA not supported
    253157    test    WORD [es:si+ATA6.wSetSup83], A6_wSetSup83_LBA48
    254     jz      SHORT .StoreLBA28               ; Use LBA-28 since LBA-48 not supported
     158    jz      SHORT .StoreLBA28addressing     ; Use LBA-28 since LBA-48 not supported
    255159    or      BYTE [di+DPT.bFlags], ADDR_DPT_LBA48<<1
    256 ALIGN JUMP_ALIGN
    257 .StoreLBA28:
     160.StoreLBA28addressing:
    258161    or      BYTE [di+DPT.bFlags], ADDR_DPT_LBA28<<1
    259162    or      BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_LBA
    260     ret
    261 ALIGN JUMP_ALIGN
    262 .StorePCHS:
     163    jmp     SHORT .StoreBlockMode
     164.StorePCHSaddressing:
    263165    or      BYTE [di+DPT.bFlags], ADDR_DPT_PCHS<<1
    264 ALIGN JUMP_ALIGN
    265 .Return:
    266     clc
    267     ret
    268 
    269 
    270 ;--------------------------------------------------------------------
    271 ; Stores Block Mode information.
    272 ;
    273 ; CreateDPT_StoreBlockMode
    274 ;   Parameters:
    275 ;       DS:DI:  Ptr to Disk Parameter Table
    276 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    277 ;   Returns:
    278 ;       CF:     Cleared if DPT parameters stored successfully
    279 ;               Set if any error
    280 ;   Corrupts registers:
    281 ;       Nothing
    282 ;--------------------------------------------------------------------
    283 ALIGN JUMP_ALIGN
    284 CreateDPT_StoreBlockMode:
     166    ; Fall to .StoreBlockMode
     167
     168;--------------------------------------------------------------------
     169; .StoreBlockMode
     170;   Parameters:
     171;       DS:DI:  Ptr to Disk Parameter Table
     172;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     173;   Returns:
     174;       Nothing
     175;   Corrupts registers:
     176;       AX
     177;--------------------------------------------------------------------
     178.StoreBlockMode:
    285179    mov     al, 1                       ; Minimum block size is 1 sector
    286180    mov     ah, [es:si+ATA1.bBlckSize]  ; Load max block size in sectors
    287181    mov     [di+DPT.wSetAndMaxBlock], ax
    288     ret
    289 
    290 
    291 ;--------------------------------------------------------------------
    292 ; Stores variables required by EBIOS functions.
    293 ;
    294 ; CreateDPT_StoreEBIOSSupport
    295 ;   Parameters:
    296 ;       DS:DI:  Ptr to Disk Parameter Table
    297 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    298 ;   Returns:
    299 ;       CF:     Cleared if DPT parameters stored successfully
    300 ;               Set if any error
     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
    301191;   Corrupts registers:
    302192;       AX, BX, DX
    303193;--------------------------------------------------------------------
    304 ALIGN JUMP_ALIGN
    305 CreateDPT_StoreEBIOSSupport:
    306     test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE  ; (clears CF)
    307     jz      SHORT .DoNotSupportEBIOS    ; No EBIOS support since small DPTs needed
     194.StoreEBIOSSupport:
     195    test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
     196    jz      SHORT .StoreDriveNumberAndUpdateDriveCount  ; No EBIOS support since small DPTs needed
     197
    308198    mov     bl, [di+DPT.bFlags]
    309     and     bx, BYTE MASK_DPT_ADDR      ; Addressing mode (clears CF)
    310     jmp     [cs:bx+.rgwAddrJmp]         ; Jump to handle addressing mode
    311 ALIGN WORD_ALIGN
     199    and     bx, BYTE MASK_DPT_ADDR                      ; Addressing mode
     200    jmp     [cs:bx+.rgwAddrJmp]                         ; Jump to handle addressing mode
    312201.rgwAddrJmp:
    313     dw      .DoNotSupportEBIOS          ; ADDR_DPT_LCHS
    314     dw      .DoNotSupportEBIOS          ; ADDR_DPT_PCHS
    315     dw      .SupportForLBA28            ; ADDR_DPT_LBA28
    316     dw      .SupportForLBA48            ; ADDR_DPT_LBA48
    317 ALIGN JUMP_ALIGN
    318 .DoNotSupportEBIOS:
    319     ret
    320 ALIGN JUMP_ALIGN
     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
    321207.SupportForLBA28:
    322208    sub     BYTE [di+DPT.bSize], 2      ; Only 4 bytes for sector count
    323 ALIGN JUMP_ALIGN
    324209.SupportForLBA48:
    325210    add     BYTE [di+DPT.bSize], EBDPT_size - DPT_size
    326211    or      BYTE [di+DPT.bFlags], FLG_DPT_EBIOS
    327     ; Fall to CreateDPT_StoreEbiosSectorCount
    328 
    329 ;--------------------------------------------------------------------
    330 ; Stores EBIOS total sector count for LBA addressing.
    331 ;
    332 ; CreateDPT_StoreEbiosSectorCount
    333 ;   Parameters:
    334 ;       DS:DI:  Ptr to Disk Parameter Table
    335 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    336 ;   Returns:
    337 ;       CF:     Cleared if DPT parameters stored successfully
    338 ;               Set if any error
    339 ;   Corrupts registers:
    340 ;       AX, BX, DX
    341 ;--------------------------------------------------------------------
    342 ;ALIGN JUMP_ALIGN
    343 CreateDPT_StoreEbiosSectorCount:
    344212    call    AtaID_GetTotalSectorCount
    345213    mov     [di+EBDPT.twCapacity], ax
    346214    mov     [di+EBDPT.twCapacity+2], dx
    347215    mov     [di+EBDPT.twCapacity+4], bx
    348     clc
    349     ret
    350 
    351 
    352 ;--------------------------------------------------------------------
    353 ; Stores number for drive and updates drive count.
    354 ;
    355 ; CreateDPT_StoreDriveNumberAndUpdateDriveCount
     216    ; Fall to .StoreDriveNumberAndUpdateDriveCount
     217
     218;--------------------------------------------------------------------
     219; .StoreDriveNumberAndUpdateDriveCount
    356220;   Parameters:
    357221;       DS:DI:  Ptr to Disk Parameter Table
     
    365229;       Nothing
    366230;--------------------------------------------------------------------
    367 ALIGN JUMP_ALIGN
    368 CreateDPT_StoreDriveNumberAndUpdateDriveCount:
     231.StoreDriveNumberAndUpdateDriveCount:
    369232    ; Make sure that more drives can be accepted
    370233    mov     dl, [es:BDA.bHDCount]   ; Load number of hard disks
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm

    r97 r99  
    171171
    172172;--------------------------------------------------------------------
    173 ; Increments hard disk count to RAMVARS.
    174 ;
    175173; RamVars_IncrementHardDiskCount
    176174;   Parameters:
     
    182180;       Nothing
    183181;--------------------------------------------------------------------
    184 ALIGN JUMP_ALIGN
    185182RamVars_IncrementHardDiskCount:
    186183    inc     BYTE [RAMVARS.bDrvCnt]      ; Increment drive count to RAMVARS
     
    188185    ja      SHORT .Return               ;  If so, return
    189186    mov     [RAMVARS.bFirstDrv], dl     ; Store first drive number
    190 ALIGN JUMP_ALIGN
    191187.Return:
    192188    ret
     
    242238;       Nothing
    243239;--------------------------------------------------------------------   
    244 ALIGN JUMP_ALIGN
    245240RamVars_GetIdeControllerCountToCX:
    246     mov     cx, 1                   ; Assume lite mode (one controller)
    247     test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
    248     jz      SHORT .Return
    249     mov     cl, [cs:ROMVARS.bIdeCnt]
    250 ALIGN JUMP_ALIGN, ret
    251 .Return:
    252     ret
     241    eMOVZX  cx, BYTE [cs:ROMVARS.bIdeCnt]
     242    ret
Note: See TracChangeset for help on using the changeset viewer.