source: xtideuniversalbios/trunk/Assembly_Library/Src/Util/CMOS.asm@ 609

Last change on this file since 609 was 601, checked in by Krister Nordvall, 6 years ago

Changes:

  • Building the BIOS now works again.
  • Added a new IDE device type/transfer mode for use only with XT-IDE rev 2+ (or Chuck(G)-modded rev 1) cards installed in any of the following machines: Olivetti M24, AT&T PC6300, Xerox 6060 and Logabax Persona 1600. This new transfer mode is slightly faster than the regular XT-IDE rev 1 device type and requires that the card is configured for High Speed mode (or, in case of the card being a rev 1 card, has the Chuck(G) mod done). The new device type is called "XTIDE rev 2 (Olivetti M24)" in XTIDECFG.
  • Made some minor improvements to the library code that handles 'Drive Not Ready' errors in XTIDECFG.
  • Optimizations.
File size: 3.9 KB
Line 
1; Project name : Assembly Library
2; Description : Functions for accessing CMOS.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2018 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20
21;--------------------------------------------------------------------
22; CMOS_WriteALtoIndexInDL
23; Parameters:
24; AL: Byte to write
25; DL: CMOS address to write to
26; Returns:
27; Interrupts enabled and NMI disabled
28; Corrupts registers:
29; Nothing
30;--------------------------------------------------------------------
31CMOS_WriteALtoIndexInDL:
32 push ax
33 call SetDLtoIndexRegister
34 pop ax
35 out CMOS_DATA_REGISTER, al
36 sti
37 ret
38
39
40;--------------------------------------------------------------------
41; CMOS_ReadFromIndexInDLtoAL
42; Parameters:
43; DL: CMOS address to read from
44; Returns:
45; AL: Byte read from CMOS
46; Interrupts enabled and NMI disabled
47; Corrupts registers:
48; Nothing
49;--------------------------------------------------------------------
50CMOS_ReadFromIndexInDLtoAL:
51 call SetDLtoIndexRegister
52 in al, CMOS_DATA_REGISTER
53 sti
54 ret
55
56
57;--------------------------------------------------------------------
58; SetDLtoIndexRegister
59; Parameters:
60; DL: CMOS address to select
61; Returns:
62; Interrupts disabled and NMI disabled
63; Corrupts registers:
64; AL
65;--------------------------------------------------------------------
66SetDLtoIndexRegister:
67 mov al, dl
68 or al, FLG_CMOS_INDEX_NMI_DISABLE ; Disable NMI
69 cli
70 out CMOS_INDEX_REGISTER, al
71 ret ; Return works as I/O delay
72
73
74;--------------------------------------------------------------------
75; CMOS_Verify10hTo2Dh
76; Parameters:
77; Nothing
78; Returns:
79; ZF: Set if valid checksum
80; Interrupts disabled and NMI disabled
81; Corrupts registers:
82; AX, CX, DX
83;--------------------------------------------------------------------
84CMOS_Verify10hTo2Dh:
85 ; Get checksum WORD from CMOS
86 mov dl, CHECKSUM_OF_BYTES_10hTo2Dh_HIGH
87 call CMOS_ReadFromIndexInDLtoAL
88 xchg ah, al
89 inc dx ; CHECKSUM_OF_BYTES_10hTo2Dh_LOW
90 call CMOS_ReadFromIndexInDLtoAL
91 push ax ; Store checksum word
92
93 ; Verify checksum
94 call GetSumOfBytes10hto2DhtoCX
95 pop ax
96 cmp ax, cx ; ZF set if checksum verified
97 ret
98
99
100;--------------------------------------------------------------------
101; CMOS_StoreNewChecksumFor10hto2Dh
102; Parameters:
103; Nothing
104; Returns:
105; Interrupts disabled and NMI disabled
106; Corrupts registers:
107; AX, CX, DX
108;--------------------------------------------------------------------
109CMOS_StoreNewChecksumFor10hto2Dh:
110 call GetSumOfBytes10hto2DhtoCX
111
112 ; Write it to CMOS
113 xchg ax, cx
114 mov dl, CHECKSUM_OF_BYTES_10hTo2Dh_LOW
115 call CMOS_WriteALtoIndexInDL
116 xchg al, ah
117 dec dx ; CHECKSUM_OF_BYTES_10hTo2Dh_HIGH
118 jmp SHORT CMOS_WriteALtoIndexInDL
119
120
121;--------------------------------------------------------------------
122; GetSumOfBytes10hto2DhtoCX
123; Parameters:
124; Nothing
125; Returns:
126; CX: Sum of CMOS bytes 10h to 2Dh
127; Interrupts disabled and NMI disabled
128; Corrupts registers:
129; AX, DX
130;--------------------------------------------------------------------
131GetSumOfBytes10hto2DhtoCX:
132 xor cx, cx ; Sum
133 mov dl, 10h ; First index
134 xor ah, ah
135
136.AddNextByte:
137 call CMOS_ReadFromIndexInDLtoAL
138 add cx, ax
139 inc dx
140 cmp dl, 2Dh ; Last index
141 jbe SHORT .AddNextByte
142 ret
Note: See TracBrowser for help on using the repository browser.