blob: 4198e2a7df320aa661800b07542e3d74638c3835 [file] [log] [blame]
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05001// 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
Kevin O'Connor4b60c002008-02-25 22:29:55 -050017#define CMOS_RTC_DAY_WEEK 0x06
18#define CMOS_RTC_DAY_MONTH 0x07
19#define CMOS_RTC_MONTH 0x08
20#define CMOS_RTC_YEAR 0x09
21#define CMOS_STATUS_A 0x0a
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050022#define CMOS_STATUS_B 0x0b
Kevin O'Connor4b60c002008-02-25 22:29:55 -050023#define CMOS_STATUS_C 0x0c
24#define CMOS_STATUS_D 0x0d
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050025#define CMOS_RESET_CODE 0x0f
26#define CMOS_FLOPPY_DRIVE_TYPE 0x10
Kevin O'Connorbdce35f2008-02-26 21:33:14 -050027#define CMOS_DISK_DATA 0x12
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050028#define CMOS_EQUIPMENT_INFO 0x14
Kevin O'Connorbdce35f2008-02-26 21:33:14 -050029#define CMOS_DISK_DRIVE1_TYPE 0x19
30#define CMOS_DISK_DRIVE2_TYPE 0x1a
31#define CMOS_DISK_DRIVE1_CYL 0x1b
32#define CMOS_DISK_DRIVE2_CYL 0x24
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050033#define CMOS_BIOS_CONFIG 0x2d
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050034#define CMOS_EXTMEM_LOW 0x30
35#define CMOS_EXTMEM_HIGH 0x31
Kevin O'Connor4b60c002008-02-25 22:29:55 -050036#define CMOS_CENTURY 0x32
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050037#define CMOS_EXTMEM2_LOW 0x34
38#define CMOS_EXTMEM2_HIGH 0x35
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050039#define CMOS_BIOS_BOOTFLAG1 0x38
40#define CMOS_BIOS_BOOTFLAG2 0x3d
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050041
42// CMOS_STATUS_B bitdefs
43#define CSB_EN_ALARM_IRQ (1<<5)
44
45// CMOS_FLOPPY_DRIVE_TYPE bitdefs
46#define CFD_NO_DRIVE 0
47#define CFD_360KB 1
48#define CFD_12MB 2
49#define CFD_720KB 3
50#define CFD_144MB 4
51#define CFD_288MB 5
52
53static inline u8
54inb_cmos(u8 reg)
55{
56 outb(reg, PORT_CMOS_INDEX);
57 return inb(PORT_CMOS_DATA);
58}
59
60static inline void
61outb_cmos(u8 val, u8 reg)
62{
63 outb(reg, PORT_CMOS_INDEX);
64 outb(val, PORT_CMOS_DATA);
65}
66
67#endif // cmos.h