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

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

Changes to XTIDE Universal BIOS:

  • L-CHS parameters are now generated differently for LBA enabled drives.
  • Booting to EBIOS partitions now seems to work (at least on one drive).
File size: 3.9 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
17; CF: 0 if succesfull, 1 if error
18;--------------------------------------------------------------------
19ALIGN JUMP_ALIGN
20AH9h_HandlerForInitializeDriveParameters:
[84]21%ifndef USE_186
[3]22 call AH9h_InitializeDriveForUse
[148]23 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[84]24%else
[148]25 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[162]26 ; Fall to AH9h_InitializeDriveForUse
[84]27%endif
[3]28
29
30;--------------------------------------------------------------------
31; Initialized drive to be ready for use.
32;
33; AH9h_InitializeDriveForUse
34; Parameters:
[148]35; DS:DI: Ptr to DPT (in RAMVARS segment)
[150]36; SS:BP: Ptr to IDEPACK
[3]37; Returns:
38; AH: Int 13h return status
39; CF: 0 if succesfull, 1 if error
40; Corrupts registers:
[148]41; AL, BX, DX
[3]42;--------------------------------------------------------------------
[170]43;ALIGN JUMP_ALIGN
[3]44AH9h_InitializeDriveForUse:
45 push cx
46
47 ; Try to select drive and wait until ready
[158]48 or BYTE [di+DPT.bFlagsHigh], MASKH_DPT_RESET ; Everything uninitialized
[150]49 call AccessDPT_GetDriveSelectByteToAL
50 mov [bp+IDEPACK.bDrvAndHead], al
51 call Device_SelectDrive
[3]52 jc SHORT .ReturnNotSuccessfull
[158]53 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nDRDY ; Clear since success
[3]54
55 ; Initialize CHS parameters if LBA is not used
[150]56 call InitializeDeviceParameters
[3]57 jc SHORT .RecalibrateDrive
[158]58 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nINITPRMS
[3]59
60 ; Recalibrate drive by seeking to cylinder 0
61.RecalibrateDrive:
62 call AH11h_RecalibrateDrive
63 jc SHORT .InitializeBlockMode
[158]64 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nRECALIBRATE
[3]65
66 ; Initialize block mode transfers
67.InitializeBlockMode:
[150]68 call InitializeBlockMode
[3]69 jc SHORT .ReturnNotSuccessfull
[158]70 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nSETBLOCK ; Keeps CF clear
[3]71
72.ReturnNotSuccessfull:
73 pop cx
74 ret
75
76
77;--------------------------------------------------------------------
[150]78; InitializeDeviceParameters
[3]79; Parameters:
[150]80; DS:DI: Ptr to DPT (in RAMVARS segment)
81; SS:BP: Ptr to IDEPACK
[3]82; Returns:
83; AH: BIOS Error code
84; CF: Cleared if succesfull
85; Set if any error
86; Corrupts registers:
[150]87; AL, BX, CX, DX
[3]88;--------------------------------------------------------------------
89ALIGN JUMP_ALIGN
[150]90InitializeDeviceParameters:
[3]91 ; No need to initialize CHS parameters if LBA mode enabled
[158]92 test BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA ; Clear CF
[150]93 jnz SHORT ReturnSuccessSinceInitializationNotNeeded
[3]94
[157]95 ; Initialize Logical Sectors per Track and Max Head number
[173]96 mov ah, [di+DPT.bHeads]
[150]97 dec ah ; Max Head number
[173]98 mov dl, [di+DPT.bSectors] ; Sectors per Track
[150]99 mov al, COMMAND_INITIALIZE_DEVICE_PARAMETERS
100 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY)
101 jmp Idepack_StoreNonExtParametersAndIssueCommandFromAL
[3]102
103
104;--------------------------------------------------------------------
[150]105; InitializeBlockMode
[3]106; Parameters:
[150]107; DS:DI: Ptr to DPT (in RAMVARS segment)
[3]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
[150]116InitializeBlockMode:
[158]117 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_BLOCK_MODE_SUPPORTED ; Clear CF
[150]118 jz SHORT ReturnSuccessSinceInitializationNotNeeded
119
120 mov al, [di+DPT_ATA.bMaxBlock] ; Load max block size, zero AH
[3]121 jmp AH24h_SetBlockSize
[150]122ReturnSuccessSinceInitializationNotNeeded:
[3]123 ret
Note: See TracBrowser for help on using the repository browser.