source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm @ 157

Last change on this file since 157 was 157, checked in by krille_n_@…, 13 years ago

Changes to the XTIDE Universal BIOS:

  • Size optimizations in IdeTransfer.asm and IdeCommand.asm (saved 12 bytes).
File size: 3.8 KB
RevLine 
[148]1; Project name  :   XTIDE Universal BIOS
[3]2; Description   :   Int 13h function AH=9h, Initialize Drive Parameters.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Int 13h function AH=9h, Initialize Drive Parameters.
9;
10; AH9h_HandlerForInitializeDriveParameters
11;   Parameters:
[148]12;       DL:     Translated Drive number
13;       DS:DI:  Ptr to DPT (in RAMVARS segment)
[150]14;       SS:BP:  Ptr to IDEPACK
15;   Returns with INTPACK:
[3]16;       AH:     Int 13h return status
17;       CF:     0 if succesfull, 1 if error
18;--------------------------------------------------------------------
19ALIGN JUMP_ALIGN
20AH9h_HandlerForInitializeDriveParameters:
[84]21%ifndef USE_186
[3]22    call    AH9h_InitializeDriveForUse
[148]23    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[84]24%else
[148]25    push    Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[84]26    ; Fall through to AH9h_InitializeDriveForUse
27%endif
[3]28
29
30;--------------------------------------------------------------------
31; Initialized drive to be ready for use.
32;
33; AH9h_InitializeDriveForUse
34;   Parameters:
[148]35;       DS:DI:  Ptr to DPT (in RAMVARS segment)
[150]36;       SS:BP:  Ptr to IDEPACK
[3]37;   Returns:
38;       AH:     Int 13h return status
39;       CF:     0 if succesfull, 1 if error
40;   Corrupts registers:
[148]41;       AL, BX, DX
[3]42;--------------------------------------------------------------------
43ALIGN JUMP_ALIGN
44AH9h_InitializeDriveForUse:
45    push    cx
46
47    ; Try to select drive and wait until ready
[150]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
[3]52    jc      SHORT .ReturnNotSuccessfull
[150]53    and     WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nDRDY  ; Clear since success
[3]54
55    ; Initialize CHS parameters if LBA is not used
[150]56    call    InitializeDeviceParameters
[3]57    jc      SHORT .RecalibrateDrive
[150]58    and     WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nINITPRMS
[3]59
60    ; Recalibrate drive by seeking to cylinder 0
61.RecalibrateDrive:
62    call    AH11h_RecalibrateDrive
63    jc      SHORT .InitializeBlockMode
[150]64    and     WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nRECALIBRATE
[3]65
66    ; Initialize block mode transfers
67.InitializeBlockMode:
[150]68    call    InitializeBlockMode
[3]69    jc      SHORT .ReturnNotSuccessfull
[150]70    and     WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nSETBLOCK  ; Keeps CF clear
[3]71
72.ReturnNotSuccessfull:
73    pop     cx
74    ret
75
76
77;--------------------------------------------------------------------
[150]78; InitializeDeviceParameters
[3]79;   Parameters:
[150]80;       DS:DI:  Ptr to DPT (in RAMVARS segment)
81;       SS:BP:  Ptr to IDEPACK
[3]82;   Returns:
83;       AH:     BIOS Error code
84;       CF:     Cleared if succesfull
85;               Set if any error
86;   Corrupts registers:
[150]87;       AL, BX, CX, DX
[3]88;--------------------------------------------------------------------
89ALIGN JUMP_ALIGN
[150]90InitializeDeviceParameters:
[3]91    ; No need to initialize CHS parameters if LBA mode enabled
[150]92    test    BYTE [di+DPT.wFlags], FLG_DRVNHEAD_LBA  ; Clear CF
93    jnz     SHORT ReturnSuccessSinceInitializationNotNeeded
[3]94
[157]95    ; Initialize Logical Sectors per Track and Max Head number
[150]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
[3]102
103
104;--------------------------------------------------------------------
[150]105; InitializeBlockMode
[3]106;   Parameters:
[150]107;       DS:DI:  Ptr to DPT (in RAMVARS segment)
[3]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
[150]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
[3]121    jmp     AH24h_SetBlockSize
[150]122ReturnSuccessSinceInitializationNotNeeded:
[3]123    ret
Note: See TracBrowser for help on using the repository browser.