Initial checkin.
[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 GPLv3 license.
6 #ifndef __CMOS_H
7 #define __CMOS_H
8
9 #include "ioport.h" // inb, outb
10
11 #define CMOS_RTC_SECONDS         0x00
12 #define CMOS_RTC_SECONDS_ALARM   0x01
13 #define CMOS_RTC_MINUTES         0x02
14 #define CMOS_RTC_MINUTES_ALARM   0x03
15 #define CMOS_RTC_HOURS           0x04
16 #define CMOS_RTC_HOURS_ALARM     0x05
17 #define CMOS_STATUS_B            0x0b
18 #define CMOS_RESET_CODE          0x0f
19 #define CMOS_FLOPPY_DRIVE_TYPE   0x10
20 #define CMOS_EQUIPMENT_INFO      0x14
21 #define CMOS_EXTMEM_LOW          0x30
22 #define CMOS_EXTMEM_HIGH         0x31
23 #define CMOS_EXTMEM2_LOW         0x34
24 #define CMOS_EXTMEM2_HIGH        0x35
25
26 // CMOS_STATUS_B bitdefs
27 #define CSB_EN_ALARM_IRQ (1<<5)
28
29 // CMOS_FLOPPY_DRIVE_TYPE bitdefs
30 #define CFD_NO_DRIVE 0
31 #define CFD_360KB    1
32 #define CFD_12MB     2
33 #define CFD_720KB    3
34 #define CFD_144MB    4
35 #define CFD_288MB    5
36
37 static inline u8
38 inb_cmos(u8 reg)
39 {
40     outb(reg, PORT_CMOS_INDEX);
41     return inb(PORT_CMOS_DATA);
42 }
43
44 static inline void
45 outb_cmos(u8 val, u8 reg)
46 {
47     outb(reg, PORT_CMOS_INDEX);
48     outb(val, PORT_CMOS_DATA);
49 }
50
51 #endif // cmos.h