source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm@ 198

Last change on this file since 198 was 170, checked in by krille_n_@…, 13 years ago

Changes to all parts of the project:

  • Minor size optimizations
  • Commented away some ALIGN JUMP_ALIGN directives in the Int13h handler (they are either in init procedures, procedures that are rarely called or are unnecessary due to conditional assembly)
  • Fixed what appears to be a typo in EBIOS.inc
File size: 2.9 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
9;
10; AHDh_HandlerForResetHardDisk
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;--------------------------------------------------------------------
19ALIGN JUMP_ALIGN
20AHDh_HandlerForResetHardDisk:
21%ifndef USE_186
22 call AHDh_ResetDrive
23 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
24%else
25 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
26 ; Fall to AHDh_ResetDrive
27%endif
28
29
30;--------------------------------------------------------------------
31; Resets hard disk.
32;
33; AHDh_ResetDrive
34; Parameters:
35; DL: Drive number
36; DS: RAMVARS segment
37; SS:BP: Ptr to IDEPACK
38; Returns:
39; AH: Int 13h return status
40; CF: 0 if succesfull, 1 if error
41; Corrupts registers:
42; AL, CX, SI, DI
43;--------------------------------------------------------------------
44;ALIGN JUMP_ALIGN
45AHDh_ResetDrive:
46 push dx
47 push bx
48
49 call FindDPT_ForDriveNumber ; DS:DI now points to DPT
50 call Interrupts_UnmaskInterruptControllerForDriveInDSDI
51 call Device_ResetMasterAndSlaveController
52 ;jc SHORT .ReturnError ; CF would be set if slave drive present without master
53 ; (error register has special values after reset)
54
55 ; Initialize Master and Slave drives
56 eMOVZX bx, BYTE [di+DPT.bIdevarsOffset]
57 mov dx, [cs:bx+IDEVARS.wPort]
58 call InitializeMasterAndSlaveDriveFromPortInDX
59
60 pop bx
61 pop dx
62 ret
63
64
65;--------------------------------------------------------------------
66; InitializeMasterAndSlaveDriveFromPortInDX
67; Parameters:
68; DX: IDE Base Port address
69; SS:BP: Ptr to IDEPACK
70; Returns:
71; AH: Error code
72; CF: 0 if initialization succesfull
73; 1 if any error
74; Corrupts registers:
75; AL, BX, CX, DX, SI, DI
76;--------------------------------------------------------------------
77ALIGN JUMP_ALIGN
78InitializeMasterAndSlaveDriveFromPortInDX:
79 push dx ; Store base port address
80 xor cx, cx ; Assume no errors
81 call FindDPT_ToDSDIForIdeMasterAtPortDX
82 jnc SHORT .InitializeSlave ; Master drive not present
83 call AH9h_InitializeDriveForUse
84 mov cl, ah ; Copy error code to CL
85.InitializeSlave:
86 pop dx ; Restore base port address
87 call FindDPT_ToDSDIForIdeSlaveAtPortDX
88 jnc SHORT .CombineErrors ; Slave drive not present
89 call AH9h_InitializeDriveForUse
90 mov ch, ah ; Copy error code to CH
91.CombineErrors:
92 or cl, ch ; OR error codes, clear CF
93 jz SHORT .Return
94 mov ah, RET_HD_RESETFAIL ; Load Reset Failed error code
95 stc
96.Return:
97 ret
Note: See TracBrowser for help on using the repository browser.