grml...
[seabios.git] / src / cmos.h
1 // Definitions for X86 CMOS non-volatile memory access.
2 //
3 // Copyright (C) 2008  Kevin O'Connor <kevin@koconnor.net>
4 //
5 // This file may be distributed under the terms of the GNU LGPLv3 license.
6 #ifndef __CMOS_H
7 #define __CMOS_H
8
9 #define CMOS_RTC_SECONDS         0x00
10 #define CMOS_RTC_SECONDS_ALARM   0x01
11 #define CMOS_RTC_MINUTES         0x02
12 #define CMOS_RTC_MINUTES_ALARM   0x03
13 #define CMOS_RTC_HOURS           0x04
14 #define CMOS_RTC_HOURS_ALARM     0x05
15 #define CMOS_RTC_DAY_WEEK        0x06
16 #define CMOS_RTC_DAY_MONTH       0x07
17 #define CMOS_RTC_MONTH           0x08
18 #define CMOS_RTC_YEAR            0x09
19 #define CMOS_STATUS_A            0x0a
20 #define CMOS_STATUS_B            0x0b
21 #define CMOS_STATUS_C            0x0c
22 #define CMOS_STATUS_D            0x0d
23 #define CMOS_RESET_CODE          0x0f
24 #define CMOS_FLOPPY_DRIVE_TYPE   0x10
25 #define CMOS_DISK_DATA           0x12
26 #define CMOS_EQUIPMENT_INFO      0x14
27 #define CMOS_DISK_DRIVE1_TYPE    0x19
28 #define CMOS_DISK_DRIVE2_TYPE    0x1a
29 #define CMOS_DISK_DRIVE1_CYL     0x1b
30 #define CMOS_DISK_DRIVE2_CYL     0x24
31 #define CMOS_MEM_EXTMEM_LOW      0x30
32 #define CMOS_MEM_EXTMEM_HIGH     0x31
33 #define CMOS_CENTURY             0x32
34 #define CMOS_MEM_EXTMEM2_LOW     0x34
35 #define CMOS_MEM_EXTMEM2_HIGH    0x35
36 #define CMOS_BIOS_BOOTFLAG1      0x38
37 #define CMOS_BIOS_DISKTRANSFLAG  0x39
38 #define CMOS_BIOS_BOOTFLAG2      0x3d
39 #define CMOS_MEM_HIGHMEM_LOW     0x5b
40 #define CMOS_MEM_HIGHMEM_MID     0x5c
41 #define CMOS_MEM_HIGHMEM_HIGH    0x5d
42 #define CMOS_BIOS_SMP_COUNT      0x5f
43
44 // CMOS_FLOPPY_DRIVE_TYPE bitdefs
45 #define CFD_NO_DRIVE 0
46 #define CFD_360KB    1
47 #define CFD_12MB     2
48 #define CFD_720KB    3
49 #define CFD_144MB    4
50 #define CFD_288MB    5
51
52 #ifndef __ASSEMBLY__
53
54 #include "ioport.h" // inb, outb
55
56 static inline u8
57 inb_cmos(u8 reg)
58 {
59     reg |= NMI_DISABLE_BIT;
60     outb(reg, PORT_CMOS_INDEX);
61     return inb(PORT_CMOS_DATA);
62 }
63
64 static inline void
65 outb_cmos(u8 val, u8 reg)
66 {
67     reg |= NMI_DISABLE_BIT;
68     outb(reg, PORT_CMOS_INDEX);
69     outb(val, PORT_CMOS_DATA);
70 }
71
72 #endif // !__ASSEMBLY__
73
74 #endif // cmos.h