1 | ; Project name : XTIDE Universal BIOS |
---|
2 | ; Description : Common functions for initializing different |
---|
3 | ; VLB and PCI IDE Controllers. |
---|
4 | |
---|
5 | ; Section containing code |
---|
6 | SECTION .text |
---|
7 | |
---|
8 | ;-------------------------------------------------------------------- |
---|
9 | ; AdvAtaInit_DetectControllerForIdeBaseInDX |
---|
10 | ; Parameters: |
---|
11 | ; DX: IDE Controller base port |
---|
12 | ; Returns: |
---|
13 | ; AX: ID WORD specific for detected controller |
---|
14 | ; Zero if no controller detected |
---|
15 | ; CX: Controller base port (not IDE) |
---|
16 | ; CF: Set if controller detected |
---|
17 | ; Cleared if no controller |
---|
18 | ; Corrupts registers: |
---|
19 | ; BX |
---|
20 | ;-------------------------------------------------------------------- |
---|
21 | AdvAtaInit_DetectControllerForIdeBaseInDX: |
---|
22 | call Vision_DetectAndReturnIDinAXandPortInCXifControllerPresent |
---|
23 | jne SHORT .NoAdvancedControllerForPortDX |
---|
24 | call Vision_DoesIdePortInDXbelongToControllerWithIDinAX |
---|
25 | jne SHORT .NoAdvancedControllerForPortDX |
---|
26 | |
---|
27 | stc ; Advanced Controller found for port DX |
---|
28 | ret |
---|
29 | |
---|
30 | .NoAdvancedControllerForPortDX: |
---|
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 (if CF set) |
---|
41 | ; CF: Set if PIO limit necessary |
---|
42 | ; Cleared if no need to limit timings |
---|
43 | ; Corrupts registers: |
---|
44 | ; Nothing |
---|
45 | ;-------------------------------------------------------------------- |
---|
46 | AdvAtaInit_GetControllerMaxPioModeToAL equ Vision_GetMaxPioModeToAL |
---|
47 | |
---|
48 | |
---|
49 | ;-------------------------------------------------------------------- |
---|
50 | ; AdvAtaInit_InitializeControllerForDPTinDSDI |
---|
51 | ; Parameters: |
---|
52 | ; DS:DI: Ptr to DPT for Single or Slave Drive |
---|
53 | ; Returns: |
---|
54 | ; CF: Cleared if success or no controller to initialize |
---|
55 | ; Set if error |
---|
56 | ; Corrupts registers: |
---|
57 | ; AX, BX, CX, DX |
---|
58 | ;-------------------------------------------------------------------- |
---|
59 | AdvAtaInit_InitializeControllerForDPTinDSDI: |
---|
60 | push ds |
---|
61 | push si |
---|
62 | push di |
---|
63 | |
---|
64 | ; PIO and Advanced Controller variables are stored to BOOTMENUINFO |
---|
65 | ; to keep the DPTs as small as possible. |
---|
66 | call GetMasterAndSlaveBootMenuInfosToSIandDI |
---|
67 | cmp WORD [BOOTVARS.wMagicWord], BOOTVARS_MAGIC_WORD |
---|
68 | clc |
---|
69 | jne SHORT .BootMenuInfosAreNoLongerAvailable |
---|
70 | |
---|
71 | ; Call Controller Specific initialization function |
---|
72 | mov ax, [si+BOOTMENUINFO.wControllerID] |
---|
73 | test ax, ax |
---|
74 | jz SHORT .NoAdvancedController |
---|
75 | call Vision_InitializeWithIDinAHandConfigInAL ; The only we support at the moment |
---|
76 | |
---|
77 | .BootMenuInfosAreNoLongerAvailable: |
---|
78 | .NoAdvancedController: |
---|
79 | pop di |
---|
80 | pop si |
---|
81 | pop ds |
---|
82 | ret |
---|
83 | |
---|
84 | |
---|
85 | ;-------------------------------------------------------------------- |
---|
86 | ; AdvAtaInit_GetMasterAndSlaveBootMenuInfosToSIandDI |
---|
87 | ; Parameters: |
---|
88 | ; DS:DI: Ptr to DPT for Single or Slave Drive |
---|
89 | ; Returns: |
---|
90 | ; DS:SI: Ptr to Single or Master Drive BOOTMENUINFO |
---|
91 | ; DI: Offset to Slave Drive BOOTMENUINFO |
---|
92 | ; Zero if Slave Drive not present |
---|
93 | ; Corrupts registers: |
---|
94 | ; BX, DX, (DS will change!) |
---|
95 | ;-------------------------------------------------------------------- |
---|
96 | GetMasterAndSlaveBootMenuInfosToSIandDI: |
---|
97 | call BootMenuInfo_ConvertDPTtoBX |
---|
98 | LOAD_BDA_SEGMENT_TO ds, di, ! ; Zero DI to assume no Slave Drive present |
---|
99 | |
---|
100 | mov dx, [bx+BOOTMENUINFO.wIdeBasePort] ; Load IDE Port from Single or Slave Drive |
---|
101 | lea si, [bx+BOOTMENUINFO_size] ; SI points to Slave Drive if present |
---|
102 | cmp dx, [si+BOOTMENUINFO.wIdeBasePort] |
---|
103 | jne SHORT .BootMenuInfoForSingleDriveInDSBX |
---|
104 | |
---|
105 | mov di, si ; Slave Drive detected, copy pointer to DS:DI |
---|
106 | .BootMenuInfoForSingleDriveInDSBX: |
---|
107 | mov si, bx |
---|
108 | ret |
---|
109 | |
---|
110 | |
---|
111 | ;-------------------------------------------------------------------- |
---|
112 | ; AdvAtaInit_SelectSlowestTimingsToBXandCX |
---|
113 | ; Parameters: |
---|
114 | ; DS:SI: Ptr to BOOTMENUINFO for Master or Single Drive |
---|
115 | ; DI: Offset to BOOTMENUINFO for Slave Drive |
---|
116 | ; Zero if Slave Drive not present |
---|
117 | ; Returns: |
---|
118 | ; BX: Min Active Time in nanosecs |
---|
119 | ; CX: Min Recovery Time in nanosecs |
---|
120 | ; Corrupts registers: |
---|
121 | ; Nothing |
---|
122 | ;-------------------------------------------------------------------- |
---|
123 | AdvAtaInit_SelectSlowestTimingsToBXandCX: |
---|
124 | mov bx, [si+BOOTMENUINFO.wMinPioActiveTimeNs] |
---|
125 | mov cx, [si+BOOTMENUINFO.wMinPioRecoveryTimeNs] |
---|
126 | test di, di |
---|
127 | jz SHORT .ReturnSlowestTimingInBXandCX ; No Slave Drive |
---|
128 | |
---|
129 | ; If Active Time is greater, then must be the Recovery Time as well |
---|
130 | cmp bx, [di+BOOTMENUINFO.wMinPioActiveTimeNs] |
---|
131 | jbe SHORT .ReturnSlowestTimingInBXandCX |
---|
132 | mov bx, [di+BOOTMENUINFO.wMinPioActiveTimeNs] |
---|
133 | mov cx, [di+BOOTMENUINFO.wMinPioRecoveryTimeNs] |
---|
134 | .ReturnSlowestTimingInBXandCX: |
---|
135 | ret |
---|