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

Last change on this file since 347 was 294, checked in by krille_n_@…, 12 years ago

Commit 2/2 (BIOS):

  • Fixed a bug in AH1h_HStatus.asm.
  • Minor optimizations.
  • Fixed spelling and did some cleaning.
File size: 5.1 KB
RevLine 
[148]1; Project name : XTIDE Universal BIOS
[3]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:
[148]12; DL: Translated Drive number
13; DS:DI: Ptr to DPT (in RAMVARS segment)
[150]14; SS:BP: Ptr to IDEPACK
15; Returns with INTPACK:
[3]16; AH: Int 13h return status
[294]17; CF: 0 if successful, 1 if error
[3]18;--------------------------------------------------------------------
19AH9h_HandlerForInitializeDriveParameters:
[84]20%ifndef USE_186
[3]21 call AH9h_InitializeDriveForUse
[148]22 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[84]23%else
[148]24 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[162]25 ; Fall to AH9h_InitializeDriveForUse
[84]26%endif
[3]27
28
29;--------------------------------------------------------------------
30; Initialized drive to be ready for use.
31;
32; AH9h_InitializeDriveForUse
33; Parameters:
[148]34; DS:DI: Ptr to DPT (in RAMVARS segment)
[150]35; SS:BP: Ptr to IDEPACK
[3]36; Returns:
37; AH: Int 13h return status
[294]38; CF: 0 if successful, 1 if error
[3]39; Corrupts registers:
[148]40; AL, BX, DX
[3]41;--------------------------------------------------------------------
42AH9h_InitializeDriveForUse:
[276]43 push si
[3]44 push cx
45
[258]46%ifdef MODULE_SERIAL
[294]47 ;
48 ; no need to do this for serial devices, and we use the DPT_RESET flag bits
[258]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
[294]53 jnz .ReturnNotSuccessful
[258]54%endif
[294]55
[3]56 ; Try to select drive and wait until ready
[158]57 or BYTE [di+DPT.bFlagsHigh], MASKH_DPT_RESET ; Everything uninitialized
[150]58 call AccessDPT_GetDriveSelectByteToAL
59 mov [bp+IDEPACK.bDrvAndHead], al
60 call Device_SelectDrive
[294]61 jc SHORT .ReturnNotSuccessful
[158]62 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nDRDY ; Clear since success
[3]63
64 ; Initialize CHS parameters if LBA is not used
[150]65 call InitializeDeviceParameters
[276]66 jc SHORT .SetWriteCache
[158]67 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nINITPRMS
[3]68
[276]69 ; Enable or Disable Write Cache
70.SetWriteCache:
[279]71 call SetWriteCache
[276]72
[3]73 ; Recalibrate drive by seeking to cylinder 0
74.RecalibrateDrive:
75 call AH11h_RecalibrateDrive
76 jc SHORT .InitializeBlockMode
[158]77 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nRECALIBRATE
[3]78
79 ; Initialize block mode transfers
80.InitializeBlockMode:
[150]81 call InitializeBlockMode
[294]82 jc SHORT .ReturnNotSuccessful
[158]83 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nSETBLOCK ; Keeps CF clear
[3]84
[294]85.ReturnNotSuccessful:
[3]86 pop cx
[276]87 pop si
[3]88 ret
89
90
91;--------------------------------------------------------------------
[150]92; InitializeDeviceParameters
[3]93; Parameters:
[150]94; DS:DI: Ptr to DPT (in RAMVARS segment)
95; SS:BP: Ptr to IDEPACK
[3]96; Returns:
97; AH: BIOS Error code
[294]98; CF: Cleared if successful
[3]99; Set if any error
100; Corrupts registers:
[150]101; AL, BX, CX, DX
[3]102;--------------------------------------------------------------------
[150]103InitializeDeviceParameters:
[3]104 ; No need to initialize CHS parameters if LBA mode enabled
[158]105 test BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA ; Clear CF
[150]106 jnz SHORT ReturnSuccessSinceInitializationNotNeeded
[3]107
[157]108 ; Initialize Logical Sectors per Track and Max Head number
[227]109 mov ah, [di+DPT.bPchsHeads]
[150]110 dec ah ; Max Head number
[227]111 mov dl, [di+DPT.bPchsSectors] ; Sectors per Track
[150]112 mov al, COMMAND_INITIALIZE_DEVICE_PARAMETERS
113 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY)
114 jmp Idepack_StoreNonExtParametersAndIssueCommandFromAL
[3]115
116
117;--------------------------------------------------------------------
[276]118; SetWriteCache
119; Parameters:
120; DS:DI: Ptr to DPT (in RAMVARS segment)
121; Returns:
122; AH: BIOS Error code
[294]123; CF: Cleared if successful
[276]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;--------------------------------------------------------------------
[150]143; InitializeBlockMode
[3]144; Parameters:
[150]145; DS:DI: Ptr to DPT (in RAMVARS segment)
[3]146; Returns:
147; AH: BIOS Error code
[294]148; CF: Cleared if successful
[3]149; Set if any error
150; Corrupts registers:
151; AL, BX, CX, DX
152;--------------------------------------------------------------------
[150]153InitializeBlockMode:
[158]154 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_BLOCK_MODE_SUPPORTED ; Clear CF
[150]155 jz SHORT ReturnSuccessSinceInitializationNotNeeded
156
[276]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
[3]161 jmp AH24h_SetBlockSize
[150]162ReturnSuccessSinceInitializationNotNeeded:
[276]163 xor ah, ah
[3]164 ret
Note: See TracBrowser for help on using the repository browser.