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

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

Changes to XTIDE Universal BIOS:

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