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

Last change on this file since 149 was 148, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

  • INT 13h optimizations to save almost 100 bytes.
File size: 4.1 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 INTPACK
15; Returns with INTPACK in SS:BP:
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 through 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; Returns:
37; AH: Int 13h return status
38; CF: 0 if succesfull, 1 if error
39; Corrupts registers:
40; AL, BX, DX
41;--------------------------------------------------------------------
42ALIGN JUMP_ALIGN
43AH9h_InitializeDriveForUse:
44 push cx
45
46 ; Try to select drive and wait until ready
47 or BYTE [di+DPT.bReset], MASK_RESET_ALL ; Everything uninitialized
48 call HDrvSel_SelectDriveAndDisableIRQ
49 jc SHORT .ReturnNotSuccessfull
50 and BYTE [di+DPT.bReset], ~FLG_RESET_nDRDY ; Clear since success
51
52 ; Initialize CHS parameters if LBA is not used
53 call AH9h_InitializeDeviceParameters
54 jc SHORT .RecalibrateDrive
55 and BYTE [di+DPT.bReset], ~FLG_RESET_nINITPRMS
56
57 ; Recalibrate drive by seeking to cylinder 0
58ALIGN JUMP_ALIGN
59.RecalibrateDrive:
60 call AH11h_RecalibrateDrive
61 jc SHORT .InitializeBlockMode
62 and BYTE [di+DPT.bReset], ~FLG_RESET_nRECALIBRATE
63
64 ; Initialize block mode transfers
65.InitializeBlockMode:
66 call AH9h_InitializeBlockMode
67 jc SHORT .ReturnNotSuccessfull
68 and BYTE [di+DPT.bReset], ~FLG_RESET_nSETBLOCK ; Keeps CF clear
69
70.ReturnNotSuccessfull:
71 pop cx
72 ret
73
74
75;--------------------------------------------------------------------
76; Sends Initialize Device Parameters command to IDE Hard Disk.
77; Initialization is used to initialize logical CHS parameters. Drives
78; may not support all CHS values.
79; This command is only supported by drives that supports CHS addressing.
80;
81; AH9h_InitializeDeviceParameters
82; Parameters:
83; DS:DI: Ptr to DPT
84; Returns:
85; AH: BIOS Error code
86; CF: Cleared if succesfull
87; Set if any error
88; Corrupts registers:
89; AL, BX, CX
90;--------------------------------------------------------------------
91ALIGN JUMP_ALIGN
92AH9h_InitializeDeviceParameters:
93 ; No need to initialize CHS parameters if LBA mode enabled
94 test BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_LBA ; Clears CF
95 jnz SHORT .Return
96
97 push dx
98 mov bh, [di+DPT.bPHeads]
99 dec bh ; Max head number
100 mov dx, [RAMVARS.wIdeBase]
101 call HCommand_OutputTranslatedLCHSaddress
102 mov ah, HCMD_INIT_DEV
103 mov al, [di+DPT.bPSect] ; Sectors per track
104 call HCommand_OutputSectorCountAndCommand
105 call HStatus_WaitBsyDefTime ; Wait until drive ready (DRDY won't be set!)
106 pop dx
107.Return:
108 ret
109
110
111;--------------------------------------------------------------------
112; Initializes block mode transfers.
113;
114; AH9h_InitializeBlockMode
115; Parameters:
116; DS:DI: Ptr to DPT
117; Returns:
118; AH: BIOS Error code
119; CF: Cleared if succesfull
120; Set if any error
121; Corrupts registers:
122; AL, BX, CX, DX
123;--------------------------------------------------------------------
124ALIGN JUMP_ALIGN
125AH9h_InitializeBlockMode:
126 mov ax, FLG_DRVPARAMS_BLOCKMODE
127 call AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive
128 jz SHORT .Return ; Block mode disabled (CF cleared)
129 eMOVZX ax, BYTE [di+DPT.bMaxBlock] ; Load max block size, zero AH
130 test al, al ; Block mode supported? (clears CF)
131 jz SHORT .Return ; If not, return
132 jmp AH24h_SetBlockSize
133.Return:
134 ret
Note: See TracBrowser for help on using the repository browser.