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

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

Changes to all parts of the project:

  • Size optimizations, mostly by excluding code from the BIOS.
  • Cleaned the source a bit, fixed spelling and grammar mistakes.
File size: 3.9 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;--------------------------------------------------------------------
19ALIGN JUMP_ALIGN
20AH9h_HandlerForInitializeDriveParameters:
21%ifndef USE_186
22 call AH9h_InitializeDriveForUse
23 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
24%else
25 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
26 ; Fall to AH9h_InitializeDriveForUse
27%endif
28
29
30;--------------------------------------------------------------------
31; Initialized drive to be ready for use.
32;
33; AH9h_InitializeDriveForUse
34; Parameters:
35; DS:DI: Ptr to DPT (in RAMVARS segment)
36; SS:BP: Ptr to IDEPACK
37; Returns:
38; AH: Int 13h return status
39; CF: 0 if succesfull, 1 if error
40; Corrupts registers:
41; AL, BX, DX
42;--------------------------------------------------------------------
43ALIGN JUMP_ALIGN
44AH9h_InitializeDriveForUse:
45 push cx
46
47 ; Try to select drive and wait until ready
48 or BYTE [di+DPT.bFlagsHigh], MASKH_DPT_RESET ; Everything uninitialized
49 call AccessDPT_GetDriveSelectByteToAL
50 mov [bp+IDEPACK.bDrvAndHead], al
51 call Device_SelectDrive
52 jc SHORT .ReturnNotSuccessfull
53 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nDRDY ; Clear since success
54
55 ; Initialize CHS parameters if LBA is not used
56 call InitializeDeviceParameters
57 jc SHORT .RecalibrateDrive
58 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nINITPRMS
59
60 ; Recalibrate drive by seeking to cylinder 0
61.RecalibrateDrive:
62 call AH11h_RecalibrateDrive
63 jc SHORT .InitializeBlockMode
64 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nRECALIBRATE
65
66 ; Initialize block mode transfers
67.InitializeBlockMode:
68 call InitializeBlockMode
69 jc SHORT .ReturnNotSuccessfull
70 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nSETBLOCK ; Keeps CF clear
71
72.ReturnNotSuccessfull:
73 pop cx
74 ret
75
76
77;--------------------------------------------------------------------
78; InitializeDeviceParameters
79; Parameters:
80; DS:DI: Ptr to DPT (in RAMVARS segment)
81; SS:BP: Ptr to IDEPACK
82; Returns:
83; AH: BIOS Error code
84; CF: Cleared if succesfull
85; Set if any error
86; Corrupts registers:
87; AL, BX, CX, DX
88;--------------------------------------------------------------------
89ALIGN JUMP_ALIGN
90InitializeDeviceParameters:
91 ; No need to initialize CHS parameters if LBA mode enabled
92 test BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA ; Clear CF
93 jnz SHORT ReturnSuccessSinceInitializationNotNeeded
94
95 ; Initialize Logical 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 BYTE [di+DPT.bFlagsHigh], FLGH_DPT_BLOCK_MODE_SUPPORTED ; Clear CF
118 jz SHORT ReturnSuccessSinceInitializationNotNeeded
119
120 mov al, [di+DPT_ATA.bMaxBlock] ; Load max block size, zero AH
121 jmp AH24h_SetBlockSize
122ReturnSuccessSinceInitializationNotNeeded:
123 ret
Note: See TracBrowser for help on using the repository browser.