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/Handlers/Int13h/AH9h_HInit.asm

    r148 r150  
    1212;       DL:     Translated Drive number
    1313;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    14 ;       SS:BP:  Ptr to INTPACK
    15 ;   Returns with INTPACK in SS:BP:
     14;       SS:BP:  Ptr to IDEPACK
     15;   Returns with INTPACK:
    1616;       AH:     Int 13h return status
    1717;       CF:     0 if succesfull, 1 if error
     
    3434;   Parameters:
    3535;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     36;       SS:BP:  Ptr to IDEPACK
    3637;   Returns:
    3738;       AH:     Int 13h return status
     
    4546
    4647    ; Try to select drive and wait until ready
    47     or      BYTE [di+DPT.bReset], MASK_RESET_ALL        ; Everything uninitialized
    48     call    HDrvSel_SelectDriveAndDisableIRQ
     48    or      WORD [di+DPT.wFlags], MASK_DPT_RESET        ; Everything uninitialized
     49    call    AccessDPT_GetDriveSelectByteToAL
     50    mov     [bp+IDEPACK.bDrvAndHead], al
     51    call    Device_SelectDrive
    4952    jc      SHORT .ReturnNotSuccessfull
    50     and     BYTE [di+DPT.bReset], ~FLG_RESET_nDRDY      ; Clear since success
     53    and     WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nDRDY  ; Clear since success
    5154
    5255    ; Initialize CHS parameters if LBA is not used
    53     call    AH9h_InitializeDeviceParameters
     56    call    InitializeDeviceParameters
    5457    jc      SHORT .RecalibrateDrive
    55     and     BYTE [di+DPT.bReset], ~FLG_RESET_nINITPRMS
     58    and     WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nINITPRMS
    5659
    5760    ; Recalibrate drive by seeking to cylinder 0
    58 ALIGN JUMP_ALIGN
    5961.RecalibrateDrive:
    6062    call    AH11h_RecalibrateDrive
    6163    jc      SHORT .InitializeBlockMode
    62     and     BYTE [di+DPT.bReset], ~FLG_RESET_nRECALIBRATE
     64    and     WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nRECALIBRATE
    6365
    6466    ; Initialize block mode transfers
    6567.InitializeBlockMode:
    66     call    AH9h_InitializeBlockMode
     68    call    InitializeBlockMode
    6769    jc      SHORT .ReturnNotSuccessfull
    68     and     BYTE [di+DPT.bReset], ~FLG_RESET_nSETBLOCK  ; Keeps CF clear
     70    and     WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nSETBLOCK  ; Keeps CF clear
    6971
    7072.ReturnNotSuccessfull:
     
    7476
    7577;--------------------------------------------------------------------
    76 ; Sends Initialize Device Parameters command to IDE Hard Disk.
    77 ; Initialization is used to initialize logical CHS parameters. Drives
    78 ; may not support all CHS values.
    79 ; This command is only supported by drives that supports CHS addressing.
    80 ;
    81 ; AH9h_InitializeDeviceParameters
     78; InitializeDeviceParameters
    8279;   Parameters:
    83 ;       DS:DI:  Ptr to DPT
    84 ;   Returns:
    85 ;       AH:     BIOS Error code
    86 ;       CF:     Cleared if succesfull
    87 ;               Set if any error
    88 ;   Corrupts registers:
    89 ;       AL, BX, CX
    90 ;--------------------------------------------------------------------
    91 ALIGN JUMP_ALIGN
    92 AH9h_InitializeDeviceParameters:
    93     ; No need to initialize CHS parameters if LBA mode enabled
    94     test    BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_LBA    ; Clears CF
    95     jnz     SHORT .Return
    96 
    97     push    dx
    98     mov     bh, [di+DPT.bPHeads]
    99     dec     bh                      ; Max head number
    100     mov     dx, [RAMVARS.wIdeBase]
    101     call    HCommand_OutputTranslatedLCHSaddress
    102     mov     ah, HCMD_INIT_DEV
    103     mov     al, [di+DPT.bPSect]     ; Sectors per track
    104     call    HCommand_OutputSectorCountAndCommand
    105     call    HStatus_WaitBsyDefTime  ; Wait until drive ready (DRDY won't be set!)
    106     pop     dx
    107 .Return:
    108     ret
    109 
    110 
    111 ;--------------------------------------------------------------------
    112 ; Initializes block mode transfers.
    113 ;
    114 ; AH9h_InitializeBlockMode
    115 ;   Parameters:
    116 ;       DS:DI:  Ptr to DPT
     80;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     81;       SS:BP:  Ptr to IDEPACK
    11782;   Returns:
    11883;       AH:     BIOS Error code
     
    12388;--------------------------------------------------------------------
    12489ALIGN JUMP_ALIGN
    125 AH9h_InitializeBlockMode:
    126     mov     ax, FLG_DRVPARAMS_BLOCKMODE
    127     call    AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive
    128     jz      SHORT .Return               ; Block mode disabled (CF cleared)
    129     eMOVZX  ax, BYTE [di+DPT.bMaxBlock] ; Load max block size, zero AH
    130     test    al, al                      ; Block mode supported? (clears CF)
    131     jz      SHORT .Return               ;  If not, return
     90InitializeDeviceParameters:
     91    ; No need to initialize CHS parameters if LBA mode enabled
     92    test    BYTE [di+DPT.wFlags], FLG_DRVNHEAD_LBA  ; Clear CF
     93    jnz     SHORT ReturnSuccessSinceInitializationNotNeeded
     94
     95    ; Initialize Locigal Sectors per Track and Max Head number
     96    mov     ah, [di+DPT.bPchsHeads]
     97    dec     ah                          ; Max Head number
     98    mov     dl, [di+DPT.bPchsSectors]   ; Sectors per Track
     99    mov     al, COMMAND_INITIALIZE_DEVICE_PARAMETERS
     100    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY)
     101    jmp     Idepack_StoreNonExtParametersAndIssueCommandFromAL
     102
     103
     104;--------------------------------------------------------------------
     105; InitializeBlockMode
     106;   Parameters:
     107;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     108;   Returns:
     109;       AH:     BIOS Error code
     110;       CF:     Cleared if succesfull
     111;               Set if any error
     112;   Corrupts registers:
     113;       AL, BX, CX, DX
     114;--------------------------------------------------------------------
     115ALIGN JUMP_ALIGN
     116InitializeBlockMode:
     117    test    WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED  ; Clear CF
     118    jz      SHORT ReturnSuccessSinceInitializationNotNeeded
     119
     120    mov     al, [di+DPT_ATA.bMaxBlock]  ; Load max block size, zero AH
    132121    jmp     AH24h_SetBlockSize
    133 .Return:
     122ReturnSuccessSinceInitializationNotNeeded:
    134123    ret
Note: See TracChangeset for help on using the changeset viewer.