source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvAtaInit.asm@ 375

Last change on this file since 375 was 370, checked in by krille_n_@…, 12 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
RevLine 
[363]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;--------------------------------------------------------------------
[364]9; AdvAtaInit_DetectControllerForIdeBaseInBX
[363]10; Parameters:
[364]11; BX: IDE Controller base port
[363]12; Returns:
13; AX: ID WORD specific for detected controller
14; Zero if no controller detected
[364]15; DX: Controller base port (not IDE)
[363]16; CF: Set if controller detected
17; Cleared if no controller
18; Corrupts registers:
19; BX
20;--------------------------------------------------------------------
[364]21AdvAtaInit_DetectControllerForIdeBaseInBX:
22 call Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent
23 jne SHORT .NoAdvancedControllerForPortBX
24 call Vision_DoesIdePortInBXbelongToControllerWithIDinAX
25 jne SHORT .NoAdvancedControllerForPortBX
[363]26
[364]27 stc ; Advanced Controller found for port BX
[363]28 ret
29
[364]30.NoAdvancedControllerForPortBX:
[363]31 xor ax, ax
32 ret
33
34
35;--------------------------------------------------------------------
36; AdvAtaInit_GetControllerMaxPioModeToAL
37; Parameters:
38; AX: ID WORD specific for detected controller
39; Returns:
[364]40; AL: Max supported PIO mode
41; AH: FLGH_DPT_IORDY if IORDY supported, zero otherwise
[363]42; CF: Set if PIO limit necessary
43; Cleared if no need to limit timings
44; Corrupts registers:
[364]45; (AX if CF cleared)
[363]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:
[364]61 push bp
[363]62 push si
63
64 ; Call Controller Specific initialization function
[364]65 mov ax, [di+DPT_ADVANCED_ATA.wControllerID]
[363]66 test ax, ax
[364]67 jz SHORT .NoAdvancedController ; Return with CF cleared
[363]68
[364]69 ; We only support Vision at the moment so no need to identify ID
70 call AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI
71 call Vision_InitializeWithIDinAHandConfigInAL
72
[363]73.NoAdvancedController:
74 pop si
[364]75 pop bp
[363]76 ret
77
78
79;--------------------------------------------------------------------
[364]80; AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI
[363]81; Parameters:
82; DS:DI: Ptr to DPT for Single or Slave Drive
83; Returns:
[364]84; DS:DI: Ptr to DPT for Single or Slave Drive
85; SI: Offset to Master DPT if Slave Drive present
[363]86; Zero if Slave Drive not present
87; Corrupts registers:
[364]88; AX
[363]89;--------------------------------------------------------------------
[364]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
[363]96
[364]97 ; We only have single drive so zero SI
98 xor si, si
99.MasterAndSlaveDrivePresent:
[363]100 ret
101
102
103;--------------------------------------------------------------------
[364]104; AdvAtaInit_SelectSlowestCommonPioTimingsToBXandCXfromDSSIandDSDI
[363]105; Parameters:
[364]106; DS:DI: Ptr to DPT for Single or Slave Drive
107; SI: Offset to Master DPT if Slave Drive present
[363]108; Zero if Slave Drive not present
109; Returns:
[364]110; BX: Best common PIO mode
111; CX: Slowest common PIO Cycle Time in nanosecs
[363]112; Corrupts registers:
113; Nothing
114;--------------------------------------------------------------------
[364]115AdvAtaInit_SelectSlowestCommonPioTimingsToBXandCXfromDSSIandDSDI:
[370]116 eMOVZX bx, [di+DPT_ADVANCED_ATA.bPioMode]
[364]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:
[363]123 ret
Note: See TracBrowser for help on using the repository browser.