source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvAtaInit.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: 4.0 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Common functions for initializing different
3; VLB and PCI IDE Controllers.
4
5; Section containing code
6SECTION .text
7
8;--------------------------------------------------------------------
9; AdvAtaInit_DetectControllerForIdeBaseInBX
10; Parameters:
11; BX: IDE Controller base port
12; Returns:
13; AX: ID WORD specific for detected controller
14; Zero if no controller detected
15; DX: Controller base port (not IDE)
16; CF: Set if controller detected
17; Cleared if no controller
18; Corrupts registers:
19; BX
20;--------------------------------------------------------------------
21AdvAtaInit_DetectControllerForIdeBaseInBX:
22 call Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent
23 jne SHORT .NoAdvancedControllerForPortBX
24 call Vision_DoesIdePortInBXbelongToControllerWithIDinAX
25 jne SHORT .NoAdvancedControllerForPortBX
26
27 stc ; Advanced Controller found for port BX
28 ret
29
30.NoAdvancedControllerForPortBX:
31 xor ax, ax
32 ret
33
34
35;--------------------------------------------------------------------
36; AdvAtaInit_GetControllerMaxPioModeToAL
37; Parameters:
38; AX: ID WORD specific for detected controller
39; Returns:
40; AL: Max supported PIO mode
41; AH: FLGH_DPT_IORDY if IORDY supported, zero otherwise
42; CF: Set if PIO limit necessary
43; Cleared if no need to limit timings
44; Corrupts registers:
45; (AX if CF cleared)
46;--------------------------------------------------------------------
47AdvAtaInit_GetControllerMaxPioModeToAL equ Vision_GetMaxPioModeToAL
48
49
50;--------------------------------------------------------------------
51; AdvAtaInit_InitializeControllerForDPTinDSDI
52; Parameters:
53; DS:DI: Ptr to DPT for Single or Slave Drive
54; Returns:
55; CF: Cleared if success or no controller to initialize
56; Set if error
57; Corrupts registers:
58; AX, BX, CX, DX
59;--------------------------------------------------------------------
60AdvAtaInit_InitializeControllerForDPTinDSDI:
61 push bp
62 push si
63
64 ; Call Controller Specific initialization function
65 mov ax, [di+DPT_ADVANCED_ATA.wControllerID]
66 test ax, ax
67 jz SHORT .NoAdvancedController ; Return with CF cleared
68
69 ; We only support Vision at the moment so no need to identify ID
70 call AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI
71 call Vision_InitializeWithIDinAHandConfigInAL
72
73.NoAdvancedController:
74 pop si
75 pop bp
76 ret
77
78
79;--------------------------------------------------------------------
80; AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI
81; Parameters:
82; DS:DI: Ptr to DPT for Single or Slave Drive
83; Returns:
84; DS:DI: Ptr to DPT for Single or Slave Drive
85; SI: Offset to Master DPT if Slave Drive present
86; Zero if Slave Drive not present
87; Corrupts registers:
88; AX
89;--------------------------------------------------------------------
90AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI:
91 ; Must be Slave Drive if previous DPT has same IDEVARS offset
92 lea si, [di-LARGEST_DPT_SIZE] ; DS:SI points to previous DPT
93 mov al, [di+DPT.bIdevarsOffset]
94 cmp al, [si+DPT.bIdevarsOffset]
95 je SHORT .MasterAndSlaveDrivePresent
96
97 ; We only have single drive so zero SI
98 xor si, si
99.MasterAndSlaveDrivePresent:
100 ret
101
102
103;--------------------------------------------------------------------
104; AdvAtaInit_SelectSlowestCommonPioTimingsToBXandCXfromDSSIandDSDI
105; Parameters:
106; DS:DI: Ptr to DPT for Single or Slave Drive
107; SI: Offset to Master DPT if Slave Drive present
108; Zero if Slave Drive not present
109; Returns:
110; BX: Best common PIO mode
111; CX: Slowest common PIO Cycle Time in nanosecs
112; Corrupts registers:
113; Nothing
114;--------------------------------------------------------------------
115AdvAtaInit_SelectSlowestCommonPioTimingsToBXandCXfromDSSIandDSDI:
116 eMOVZX bx, [di+DPT_ADVANCED_ATA.bPioMode]
117 mov cx, [di+DPT_ADVANCED_ATA.wMinPioCycleTime]
118 test si, si
119 jz SHORT .PioTimingsLoadedToAXandCX
120 MIN_U bl, [si+DPT_ADVANCED_ATA.bPioMode]
121 MAX_U cx, [si+DPT_ADVANCED_ATA.wMinPioCycleTime]
122.PioTimingsLoadedToAXandCX:
123 ret
Note: See TracBrowser for help on using the repository browser.