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

Last change on this file since 227 was 227, checked in by aitotat@…, 12 years ago

Changes to XTIDE Universal BIOS:

  • EBIOS functions now work in lite mode.
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;--------------------------------------------------------------------
19AH9h_HandlerForInitializeDriveParameters:
[84]20%ifndef USE_186
[3]21    call    AH9h_InitializeDriveForUse
[148]22    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[84]23%else
[148]24    push    Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[162]25    ; Fall to AH9h_InitializeDriveForUse
[84]26%endif
[3]27
28
29;--------------------------------------------------------------------
30; Initialized drive to be ready for use.
31;
32; AH9h_InitializeDriveForUse
33;   Parameters:
[148]34;       DS:DI:  Ptr to DPT (in RAMVARS segment)
[150]35;       SS:BP:  Ptr to IDEPACK
[3]36;   Returns:
37;       AH:     Int 13h return status
38;       CF:     0 if succesfull, 1 if error
39;   Corrupts registers:
[148]40;       AL, BX, DX
[3]41;--------------------------------------------------------------------
42AH9h_InitializeDriveForUse:
43    push    cx
44
45    ; Try to select drive and wait until ready
[158]46    or      BYTE [di+DPT.bFlagsHigh], MASKH_DPT_RESET       ; Everything uninitialized
[150]47    call    AccessDPT_GetDriveSelectByteToAL
48    mov     [bp+IDEPACK.bDrvAndHead], al
49    call    Device_SelectDrive
[3]50    jc      SHORT .ReturnNotSuccessfull
[158]51    and     BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nDRDY ; Clear since success
[3]52
53    ; Initialize CHS parameters if LBA is not used
[150]54    call    InitializeDeviceParameters
[3]55    jc      SHORT .RecalibrateDrive
[158]56    and     BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nINITPRMS
[3]57
58    ; Recalibrate drive by seeking to cylinder 0
59.RecalibrateDrive:
60    call    AH11h_RecalibrateDrive
61    jc      SHORT .InitializeBlockMode
[158]62    and     BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nRECALIBRATE
[3]63
64    ; Initialize block mode transfers
65.InitializeBlockMode:
[150]66    call    InitializeBlockMode
[3]67    jc      SHORT .ReturnNotSuccessfull
[158]68    and     BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nSETBLOCK ; Keeps CF clear
[3]69
70.ReturnNotSuccessfull:
71    pop     cx
72    ret
73
74
75;--------------------------------------------------------------------
[150]76; InitializeDeviceParameters
[3]77;   Parameters:
[150]78;       DS:DI:  Ptr to DPT (in RAMVARS segment)
79;       SS:BP:  Ptr to IDEPACK
[3]80;   Returns:
81;       AH:     BIOS Error code
82;       CF:     Cleared if succesfull
83;               Set if any error
84;   Corrupts registers:
[150]85;       AL, BX, CX, DX
[3]86;--------------------------------------------------------------------
[150]87InitializeDeviceParameters:
[3]88    ; No need to initialize CHS parameters if LBA mode enabled
[158]89    test    BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA   ; Clear CF
[150]90    jnz     SHORT ReturnSuccessSinceInitializationNotNeeded
[3]91
[157]92    ; Initialize Logical Sectors per Track and Max Head number
[227]93    mov     ah, [di+DPT.bPchsHeads]
[150]94    dec     ah                          ; Max Head number
[227]95    mov     dl, [di+DPT.bPchsSectors]   ; Sectors per Track
[150]96    mov     al, COMMAND_INITIALIZE_DEVICE_PARAMETERS
97    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY)
98    jmp     Idepack_StoreNonExtParametersAndIssueCommandFromAL
[3]99
100
101;--------------------------------------------------------------------
[150]102; InitializeBlockMode
[3]103;   Parameters:
[150]104;       DS:DI:  Ptr to DPT (in RAMVARS segment)
[3]105;   Returns:
106;       AH:     BIOS Error code
107;       CF:     Cleared if succesfull
108;               Set if any error
109;   Corrupts registers:
110;       AL, BX, CX, DX
111;--------------------------------------------------------------------
[150]112InitializeBlockMode:
[158]113    test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_BLOCK_MODE_SUPPORTED ; Clear CF
[150]114    jz      SHORT ReturnSuccessSinceInitializationNotNeeded
115
116    mov     al, [di+DPT_ATA.bMaxBlock]  ; Load max block size, zero AH
[3]117    jmp     AH24h_SetBlockSize
[150]118ReturnSuccessSinceInitializationNotNeeded:
[3]119    ret
Note: See TracBrowser for help on using the repository browser.