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

Last change on this file since 389 was 376, checked in by gregli@…, 12 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 4.7 KB
RevLine 
[363]1; Project name : XTIDE Universal BIOS
2; Description : Common functions for initializing different
3; VLB and PCI IDE Controllers.
4
[376]5;
6; XTIDE Universal BIOS and Associated Tools
7; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
8;
9; This program is free software; you can redistribute it and/or modify
10; it under the terms of the GNU General Public License as published by
11; the Free Software Foundation; either version 2 of the License, or
12; (at your option) any later version.
13;
14; This program is distributed in the hope that it will be useful,
15; but WITHOUT ANY WARRANTY; without even the implied warranty of
16; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17; GNU General Public License for more details.
18; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19;
20
[363]21; Section containing code
22SECTION .text
23
24;--------------------------------------------------------------------
[364]25; AdvAtaInit_DetectControllerForIdeBaseInBX
[363]26; Parameters:
[364]27; BX: IDE Controller base port
[363]28; Returns:
29; AX: ID WORD specific for detected controller
30; Zero if no controller detected
[364]31; DX: Controller base port (not IDE)
[363]32; CF: Set if controller detected
33; Cleared if no controller
34; Corrupts registers:
35; BX
36;--------------------------------------------------------------------
[364]37AdvAtaInit_DetectControllerForIdeBaseInBX:
38 call Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent
39 jne SHORT .NoAdvancedControllerForPortBX
40 call Vision_DoesIdePortInBXbelongToControllerWithIDinAX
41 jne SHORT .NoAdvancedControllerForPortBX
[363]42
[364]43 stc ; Advanced Controller found for port BX
[363]44 ret
45
[364]46.NoAdvancedControllerForPortBX:
[363]47 xor ax, ax
48 ret
49
50
51;--------------------------------------------------------------------
52; AdvAtaInit_GetControllerMaxPioModeToAL
53; Parameters:
54; AX: ID WORD specific for detected controller
55; Returns:
[364]56; AL: Max supported PIO mode
57; AH: FLGH_DPT_IORDY if IORDY supported, zero otherwise
[363]58; CF: Set if PIO limit necessary
59; Cleared if no need to limit timings
60; Corrupts registers:
[364]61; (AX if CF cleared)
[363]62;--------------------------------------------------------------------
63AdvAtaInit_GetControllerMaxPioModeToAL equ Vision_GetMaxPioModeToAL
64
65
66;--------------------------------------------------------------------
67; AdvAtaInit_InitializeControllerForDPTinDSDI
68; Parameters:
69; DS:DI: Ptr to DPT for Single or Slave Drive
70; Returns:
71; CF: Cleared if success or no controller to initialize
72; Set if error
73; Corrupts registers:
74; AX, BX, CX, DX
75;--------------------------------------------------------------------
76AdvAtaInit_InitializeControllerForDPTinDSDI:
[364]77 push bp
[363]78 push si
79
80 ; Call Controller Specific initialization function
[364]81 mov ax, [di+DPT_ADVANCED_ATA.wControllerID]
[363]82 test ax, ax
[364]83 jz SHORT .NoAdvancedController ; Return with CF cleared
[363]84
[364]85 ; We only support Vision at the moment so no need to identify ID
86 call AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI
87 call Vision_InitializeWithIDinAHandConfigInAL
88
[363]89.NoAdvancedController:
90 pop si
[364]91 pop bp
[363]92 ret
93
94
95;--------------------------------------------------------------------
[364]96; AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI
[363]97; Parameters:
98; DS:DI: Ptr to DPT for Single or Slave Drive
99; Returns:
[364]100; DS:DI: Ptr to DPT for Single or Slave Drive
101; SI: Offset to Master DPT if Slave Drive present
[363]102; Zero if Slave Drive not present
103; Corrupts registers:
[364]104; AX
[363]105;--------------------------------------------------------------------
[364]106AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI:
107 ; Must be Slave Drive if previous DPT has same IDEVARS offset
108 lea si, [di-LARGEST_DPT_SIZE] ; DS:SI points to previous DPT
109 mov al, [di+DPT.bIdevarsOffset]
110 cmp al, [si+DPT.bIdevarsOffset]
111 je SHORT .MasterAndSlaveDrivePresent
[363]112
[364]113 ; We only have single drive so zero SI
114 xor si, si
115.MasterAndSlaveDrivePresent:
[363]116 ret
117
118
119;--------------------------------------------------------------------
[364]120; AdvAtaInit_SelectSlowestCommonPioTimingsToBXandCXfromDSSIandDSDI
[363]121; Parameters:
[364]122; DS:DI: Ptr to DPT for Single or Slave Drive
123; SI: Offset to Master DPT if Slave Drive present
[363]124; Zero if Slave Drive not present
125; Returns:
[364]126; BX: Best common PIO mode
127; CX: Slowest common PIO Cycle Time in nanosecs
[363]128; Corrupts registers:
129; Nothing
130;--------------------------------------------------------------------
[364]131AdvAtaInit_SelectSlowestCommonPioTimingsToBXandCXfromDSSIandDSDI:
[370]132 eMOVZX bx, [di+DPT_ADVANCED_ATA.bPioMode]
[364]133 mov cx, [di+DPT_ADVANCED_ATA.wMinPioCycleTime]
134 test si, si
135 jz SHORT .PioTimingsLoadedToAXandCX
136 MIN_U bl, [si+DPT_ADVANCED_ATA.bPioMode]
137 MAX_U cx, [si+DPT_ADVANCED_ATA.wMinPioCycleTime]
138.PioTimingsLoadedToAXandCX:
[363]139 ret
Note: See TracBrowser for help on using the repository browser.