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

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

Changes:

  • Added some missing PIO mode timings to ATA_ID.inc (based on info from http://www.singlix.net/specs/cfspc4_0.pdf)
  • Updated Configuration_FullMode.txt but it may need additional changes as the Tandy info doesn't match the wiki.
  • Optimizations.
  • Excluded some unused code from XTIDECFG.
File size: 3.8 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 successful, 1 if error
18;--------------------------------------------------------------------
19AHDh_HandlerForResetHardDisk:
20%ifndef USE_186
21 call AHDh_ResetDrive
22 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
23%else
24 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
25 ; Fall to AHDh_ResetDrive
26%endif
27
28
29;--------------------------------------------------------------------
30; Resets hard disk.
31;
32; AHDh_ResetDrive
33; Parameters:
34; DS:DI: Ptr to DPT
35; SS:BP: Ptr to IDEPACK
36; Returns:
37; AH: Int 13h return status
38; CF: 0 if successful, 1 if error
39; Corrupts registers:
40; AL, SI
41;--------------------------------------------------------------------
42AHDh_ResetDrive:
43 push dx
44 push cx
45 push bx
46 push di
47
48 call Interrupts_UnmaskInterruptControllerForDriveInDSDI
49 call Device_ResetMasterAndSlaveController
50 ;jc SHORT .ReturnError ; CF would be set if slave drive present without master
51 ; (error register has special values after reset)
52
53 ; Initialize Master and Slave drives
54 eMOVZX ax, [di+DPT.bIdevarsOffset] ; (AL) pointer to controller we are looking to reset
55 ; (AH) initialize error code, assume success
56
57 mov si, IterateAndResetDrives ; Callback function for FindDPT_IterateAllDPTs
58 call FindDPT_IterateAllDPTs
59
60 shr ah, 1 ; Move error code and CF into proper position
61
62 pop di
63 pop bx
64 pop cx
65 pop dx
66 ret
67
68;--------------------------------------------------------------------
69; IterateAndResetDrives: Iteration routine for use with IterateAllDPTs.
70;
71; When a drive on the controller is found, it is reset, and the error code
72; merged into overall error code for this controller. Master will be reset
73; first. Note that the iteration will go until the end of the DPT list.
74;
75; Parameters:
76; AL: Offset to IDEVARS for drives to initialize
77; AH: Error status from previous initialization
78; DS:DI: Ptr to DPT to examine
79; Returns:
80; AH: Error status from initialization
81; CF: Set to iterate all DPTs
82; Corrupts registers:
83; AL, BX, DX
84;--------------------------------------------------------------------
85IterateAndResetDrives:
86 cmp al, [di+DPT.bIdevarsOffset] ; The right controller?
87 jne .Done
88 push cx
89 push ax
90 call AH9h_InitializeDriveForUse ; Reset Master and Slave (Master will come first in DPT list)
91
92%ifdef MODULE_ADVANCED_ATA
93 jc SHORT .SkipControllerInitSinceError
94 ; Here we initialize the more advanced controllers (VLB and PCI) to get better performance for systems with 32-bit bus.
95 ; This step is optional since the controllers use slowest possible settings by default if they are not initialized.
96
97 pop ax
98 push ax
99 cmp al, [di+LARGEST_DPT_SIZE+DPT.bIdevarsOffset] ; We check if next DPT is for the same IDE controller.
100 je SHORT .SkipInitializationUntilNextDrive ; If it is, we skip the initialization.
101 call AdvAtaInit_InitializeControllerForDPTinDSDI ; Done after drive init so drives are first set to advanced PIO mode, then the controller
102.SkipInitializationUntilNextDrive:
103.SkipControllerInitSinceError:
104%endif ; MODULE_ADVANCED_ATA
105
106 pop ax
107 pop cx
108 jnc .Done
109 or ah, (RET_HD_RESETFAIL << 1) | 1 ; OR in Reset Failed error code and CF, will SHR into position later
110.Done:
111 stc ; From IterateAllDPTs perspective, the DPT is never found (continue iteration)
112 ret
113
Note: See TracBrowser for help on using the repository browser.