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

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

Changes to XTIDE Universal BIOS:

  • Changed version number to 2.0.0
  • Block will no longer be enabled if it is forced off using configurator.
  • Implemented non-working feature to disable drive internal write cache.
File size: 5.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 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 si
44 push cx
45
46%ifdef MODULE_SERIAL
47 ;
48 ; no need to do this for serial deveices, and we use the DPT_RESET flag bits
49 ; to store the drive type for serial floppy drives (MODULE_SERIAL_FLOPPY)
50 ;
51 xor ah, ah
52 test byte [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE ; Clears CF
53 jnz .ReturnNotSuccessfull
54%endif
55
56 ; Try to select drive and wait until ready
57 or BYTE [di+DPT.bFlagsHigh], MASKH_DPT_RESET ; Everything uninitialized
58 call AccessDPT_GetDriveSelectByteToAL
59 mov [bp+IDEPACK.bDrvAndHead], al
60 call Device_SelectDrive
61 jc SHORT .ReturnNotSuccessfull
62 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nDRDY ; Clear since success
63
64 ; Initialize CHS parameters if LBA is not used
65 call InitializeDeviceParameters
66 jc SHORT .SetWriteCache
67 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nINITPRMS
68
69 ; Enable or Disable Write Cache
70.SetWriteCache:
71 ;call SetWriteCache
72
73 ; Recalibrate drive by seeking to cylinder 0
74.RecalibrateDrive:
75 call AH11h_RecalibrateDrive
76 jc SHORT .InitializeBlockMode
77 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nRECALIBRATE
78
79 ; Initialize block mode transfers
80.InitializeBlockMode:
81 call InitializeBlockMode
82 jc SHORT .ReturnNotSuccessfull
83 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nSETBLOCK ; Keeps CF clear
84
85.ReturnNotSuccessfull:
86 pop cx
87 pop si
88 ret
89
90
91;--------------------------------------------------------------------
92; InitializeDeviceParameters
93; Parameters:
94; DS:DI: Ptr to DPT (in RAMVARS segment)
95; SS:BP: Ptr to IDEPACK
96; Returns:
97; AH: BIOS Error code
98; CF: Cleared if succesfull
99; Set if any error
100; Corrupts registers:
101; AL, BX, CX, DX
102;--------------------------------------------------------------------
103InitializeDeviceParameters:
104 ; No need to initialize CHS parameters if LBA mode enabled
105 test BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA ; Clear CF
106 jnz SHORT ReturnSuccessSinceInitializationNotNeeded
107
108 ; Initialize Logical Sectors per Track and Max Head number
109 mov ah, [di+DPT.bPchsHeads]
110 dec ah ; Max Head number
111 mov dl, [di+DPT.bPchsSectors] ; Sectors per Track
112 mov al, COMMAND_INITIALIZE_DEVICE_PARAMETERS
113 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY)
114 jmp Idepack_StoreNonExtParametersAndIssueCommandFromAL
115
116
117;--------------------------------------------------------------------
118; SetWriteCache
119; Parameters:
120; DS:DI: Ptr to DPT (in RAMVARS segment)
121; Returns:
122; AH: BIOS Error code
123; CF: Cleared if succesfull
124; Set if any error
125; Corrupts registers:
126; AL, BX, CX, DX, SI
127;--------------------------------------------------------------------
128SetWriteCache:
129 call AccessDPT_GetPointerToDRVPARAMStoCSBX
130 mov bl, [cs:bx+DRVPARAMS.wFlags]
131 and bx, BYTE MASK_DRVPARAMS_WRITECACHE
132 jz SHORT ReturnSuccessSinceInitializationNotNeeded ; DEFAULT_WRITE_CACHE
133 mov si, [cs:bx+.rgbWriteCacheCommands]
134 jmp AH23h_SetControllerFeatures
135
136.rgbWriteCacheCommands:
137 db 0 ; DEFAULT_WRITE_CACHE
138 db FEATURE_DISABLE_WRITE_CACHE ; DISABLE_WRITE_CACHE
139 db FEATURE_ENABLE_WRITE_CACHE ; ENABLE_WRITE_CACHE
140
141
142;--------------------------------------------------------------------
143; InitializeBlockMode
144; Parameters:
145; DS:DI: Ptr to DPT (in RAMVARS segment)
146; Returns:
147; AH: BIOS Error code
148; CF: Cleared if succesfull
149; Set if any error
150; Corrupts registers:
151; AL, BX, CX, DX
152;--------------------------------------------------------------------
153InitializeBlockMode:
154 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_BLOCK_MODE_SUPPORTED ; Clear CF
155 jz SHORT ReturnSuccessSinceInitializationNotNeeded
156
157 call AccessDPT_GetPointerToDRVPARAMStoCSBX
158 mov al, 1 ; Disable block mode
159 test BYTE [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_BLOCKMODE
160 eCMOVNZ al, [di+DPT_ATA.bMaxBlock] ; Load max block size
161 jmp AH24h_SetBlockSize
162ReturnSuccessSinceInitializationNotNeeded:
163 xor ah, ah
164 ret
Note: See TracBrowser for help on using the repository browser.