1 | /** @file
|
---|
2 | PC/AT CMOS access routines
|
---|
3 |
|
---|
4 | Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #include <Library/PlatformInitLib.h>
|
---|
10 | #include <Library/DebugLib.h>
|
---|
11 | #include "Library/IoLib.h"
|
---|
12 |
|
---|
13 | /**
|
---|
14 | Reads 8-bits of CMOS data.
|
---|
15 |
|
---|
16 | Reads the 8-bits of CMOS data at the location specified by Index.
|
---|
17 | The 8-bit read value is returned.
|
---|
18 |
|
---|
19 | @param Index The CMOS location to read.
|
---|
20 |
|
---|
21 | @return The value read.
|
---|
22 |
|
---|
23 | **/
|
---|
24 | UINT8
|
---|
25 | EFIAPI
|
---|
26 | PlatformCmosRead8 (
|
---|
27 | IN UINTN Index
|
---|
28 | )
|
---|
29 | {
|
---|
30 | IoWrite8 (0x70, (UINT8)Index);
|
---|
31 | return IoRead8 (0x71);
|
---|
32 | }
|
---|
33 |
|
---|
34 | /**
|
---|
35 | Writes 8-bits of CMOS data.
|
---|
36 |
|
---|
37 | Writes 8-bits of CMOS data to the location specified by Index
|
---|
38 | with the value specified by Value and returns Value.
|
---|
39 |
|
---|
40 | @param Index The CMOS location to write.
|
---|
41 | @param Value The value to write to CMOS.
|
---|
42 |
|
---|
43 | @return The value written to CMOS.
|
---|
44 |
|
---|
45 | **/
|
---|
46 | UINT8
|
---|
47 | EFIAPI
|
---|
48 | PlatformCmosWrite8 (
|
---|
49 | IN UINTN Index,
|
---|
50 | IN UINT8 Value
|
---|
51 | )
|
---|
52 | {
|
---|
53 | IoWrite8 (0x70, (UINT8)Index);
|
---|
54 | IoWrite8 (0x71, Value);
|
---|
55 | return Value;
|
---|
56 | }
|
---|
57 |
|
---|
58 | /**
|
---|
59 | Dump the CMOS content
|
---|
60 | */
|
---|
61 | VOID
|
---|
62 | EFIAPI
|
---|
63 | PlatformDebugDumpCmos (
|
---|
64 | VOID
|
---|
65 | )
|
---|
66 | {
|
---|
67 | UINT32 Loop;
|
---|
68 |
|
---|
69 | DEBUG ((DEBUG_INFO, "CMOS:\n"));
|
---|
70 |
|
---|
71 | for (Loop = 0; Loop < 0x80; Loop++) {
|
---|
72 | if ((Loop % 0x10) == 0) {
|
---|
73 | DEBUG ((DEBUG_INFO, "%02x:", Loop));
|
---|
74 | }
|
---|
75 |
|
---|
76 | DEBUG ((DEBUG_INFO, " %02x", PlatformCmosRead8 (Loop)));
|
---|
77 | if ((Loop % 0x10) == 0xf) {
|
---|
78 | DEBUG ((DEBUG_INFO, "\n"));
|
---|
79 | }
|
---|
80 | }
|
---|
81 | }
|
---|