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

Last change on this file since 114 was 84, checked in by krille_n_@…, 14 years ago

Minor size optimizations in various files.

File size: 4.4 KB
Line 
1; File name : AH9h_HInit.asm
2; Project name : IDE BIOS
3; Created date : 9.12.2007
4; Last update : 14.1.2011
5; Author : Tomi Tilli,
6; : Krister Nordvall (optimizations)
7; Description : Int 13h function AH=9h, Initialize Drive Parameters.
8
9; Section containing code
10SECTION .text
11
12;--------------------------------------------------------------------
13; Int 13h function AH=9h, Initialize Drive Parameters.
14;
15; AH9h_HandlerForInitializeDriveParameters
16; Parameters:
17; AH: Bios function 9h
18; DL: Drive number
19; Parameters loaded by Int13h_Jump:
20; DS: RAMVARS segment
21; Returns:
22; AH: Int 13h return status
23; CF: 0 if succesfull, 1 if error
24; IF: 1
25; Corrupts registers:
26; Flags
27;--------------------------------------------------------------------
28ALIGN JUMP_ALIGN
29AH9h_HandlerForInitializeDriveParameters:
30 push dx
31 push cx
32 push bx
33 push ax
34%ifndef USE_186
35 call AH9h_InitializeDriveForUse
36 jmp Int13h_PopXRegsAndReturn
37%else
38 push Int13h_PopXRegsAndReturn
39 ; Fall through to AH9h_InitializeDriveForUse
40%endif
41
42
43;--------------------------------------------------------------------
44; Initialized drive to be ready for use.
45;
46; AH9h_InitializeDriveForUse
47; Parameters:
48; DL: Drive number
49; DS: RAMVARS segment
50; Returns:
51; DS:DI: Ptr to DPT
52; AH: Int 13h return status
53; CF: 0 if succesfull, 1 if error
54; Corrupts registers:
55; AL, BX
56;--------------------------------------------------------------------
57ALIGN JUMP_ALIGN
58AH9h_InitializeDriveForUse:
59 push dx
60 push cx
61
62 ; Try to select drive and wait until ready
63 call FindDPT_ForDriveNumber
64 or BYTE [di+DPT.bReset], MASK_RESET_ALL ; Everything uninitialized
65 call HDrvSel_SelectDriveAndDisableIRQ
66 jc SHORT .ReturnNotSuccessfull
67 and BYTE [di+DPT.bReset], ~FLG_RESET_nDRDY ; Clear since success
68
69 ; Initialize CHS parameters if LBA is not used
70 call AH9h_InitializeDeviceParameters
71 jc SHORT .RecalibrateDrive
72 and BYTE [di+DPT.bReset], ~FLG_RESET_nINITPRMS
73
74 ; Recalibrate drive by seeking to cylinder 0
75ALIGN JUMP_ALIGN
76.RecalibrateDrive:
77 call AH11h_RecalibrateDrive
78 mov dl, [di+DPT.bDrvNum] ; Restore DL
79 jc SHORT .InitializeBlockMode
80 and BYTE [di+DPT.bReset], ~FLG_RESET_nRECALIBRATE
81
82 ; Initialize block mode transfers
83ALIGN JUMP_ALIGN
84.InitializeBlockMode:
85 call AH9h_InitializeBlockMode
86 ;mov dl, [di+DPT.bDrvNum] ; Restore DL
87 jc SHORT .ReturnNotSuccessfull
88 and BYTE [di+DPT.bReset], ~FLG_RESET_nSETBLOCK
89
90.ReturnNotSuccessfull:
91 pop cx
92 pop dx
93 ret
94
95
96;--------------------------------------------------------------------
97; Sends Initialize Device Parameters command to IDE Hard Disk.
98; Initialization is used to initialize logical CHS parameters. Drives
99; may not support all CHS values.
100; This command is only supported by drives that supports CHS addressing.
101;
102; AH9h_InitializeDeviceParameters
103; Parameters:
104; DS:DI: Ptr to DPT
105; Returns:
106; AH: BIOS Error code
107; CF: Cleared if succesfull
108; Set if any error
109; Corrupts registers:
110; AL, BX, CX
111;--------------------------------------------------------------------
112ALIGN JUMP_ALIGN
113AH9h_InitializeDeviceParameters:
114 ; No need to initialize CHS parameters if LBA mode enabled
115 test BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_LBA ; Clears CF
116 jnz SHORT .Return
117
118 push dx
119 mov bh, [di+DPT.bPHeads]
120 dec bh ; Max head number
121 mov dx, [RAMVARS.wIdeBase]
122 call HCommand_OutputTranslatedLCHSaddress
123 mov ah, HCMD_INIT_DEV
124 mov al, [di+DPT.bPSect] ; Sectors per track
125 call HCommand_OutputSectorCountAndCommand
126 call HStatus_WaitBsyDefTime ; Wait until drive ready (DRDY won't be set!)
127 pop dx
128.Return:
129 ret
130
131
132;--------------------------------------------------------------------
133; Initializes block mode transfers.
134;
135; AH9h_InitializeBlockMode
136; Parameters:
137; DL: Drive number
138; DS:DI: Ptr to DPT
139; Returns:
140; AH: BIOS Error code
141; CF: Cleared if succesfull
142; Set if any error
143; Corrupts registers:
144; AL, BX, CX, DX
145;--------------------------------------------------------------------
146ALIGN JUMP_ALIGN
147AH9h_InitializeBlockMode:
148 mov ax, FLG_DRVPARAMS_BLOCKMODE
149 call AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive
150 jz SHORT .Return ; Block mode disabled (CF cleared)
151 eMOVZX ax, BYTE [di+DPT.bMaxBlock] ; Load max block size, zero AH
152 test al, al ; Block mode supported? (clears CF)
153 jz SHORT .Return ; If not, return
154 jmp AH24h_SetBlockSize
155.Return:
156 ret
Note: See TracBrowser for help on using the repository browser.