coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mc146818rtc.h File Reference
#include <arch/io.h>
#include <types.h>
Include dependency graph for mc146818rtc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RTC_BASE_PORT   0x70
 
#define RTC_PORT(x)   (RTC_BASE_PORT + (x))
 
#define RTC_REG_A   10
 
#define RTC_REG_B   11
 
#define RTC_REG_C   12
 
#define RTC_REG_D   13
 
#define RTC_FREQ_SELECT   RTC_REG_A
 
#define RTC_UIP   0x80
 
#define RTC_DIV_CTL   0x70
 
#define RTC_REF_CLCK_4MHZ   0x00
 
#define RTC_REF_CLCK_1MHZ   0x10
 
#define RTC_REF_CLCK_32KHZ   0x20
 
#define RTC_DIV_RESET1   0x60
 
#define RTC_DIV_RESET2   0x70
 
#define RTC_RATE_SELECT   0x0F
 
#define RTC_RATE_NONE   0x00
 
#define RTC_RATE_32786HZ   0x01
 
#define RTC_RATE_16384HZ   0x02
 
#define RTC_RATE_8192HZ   0x03
 
#define RTC_RATE_4096HZ   0x04
 
#define RTC_RATE_2048HZ   0x05
 
#define RTC_RATE_1024HZ   0x06
 
#define RTC_RATE_512HZ   0x07
 
#define RTC_RATE_256HZ   0x08
 
#define RTC_RATE_128HZ   0x09
 
#define RTC_RATE_64HZ   0x0a
 
#define RTC_RATE_32HZ   0x0b
 
#define RTC_RATE_16HZ   0x0c
 
#define RTC_RATE_8HZ   0x0d
 
#define RTC_RATE_4HZ   0x0e
 
#define RTC_RATE_2HZ   0x0f
 
#define RTC_CONTROL   RTC_REG_B
 
#define RTC_SET   0x80 /* disable updates for clock setting */
 
#define RTC_PIE   0x40 /* periodic interrupt enable */
 
#define RTC_AIE   0x20 /* alarm interrupt enable */
 
#define RTC_UIE   0x10 /* update-finished interrupt enable */
 
#define RTC_SQWE   0x08 /* enable square-wave output */
 
#define RTC_DM_BINARY   0x04 /* all time/date values are BCD if clear */
 
#define RTC_24H   0x02 /* 24 hour mode - else hours bit 7 means pm */
 
#define RTC_DST_EN   0x01 /* auto switch DST - works f. USA only */
 
#define RTC_INTR_FLAGS   RTC_REG_C
 
#define RTC_IRQF   0x80 /* any of the following 3 is active */
 
#define RTC_PF   0x40
 
#define RTC_AF   0x20
 
#define RTC_UF   0x10
 
#define RTC_VALID   RTC_REG_D
 
#define RTC_VRT   0x80 /* valid RAM and time */
 
#define RTC_CLK_SECOND   0
 
#define RTC_CLK_SECOND_ALARM   1
 
#define RTC_CLK_MINUTE   2
 
#define RTC_CLK_MINUTE_ALARM   3
 
#define RTC_CLK_HOUR   4
 
#define RTC_CLK_HOUR_ALARM   5
 
#define RTC_CLK_DAYOFWEEK   6
 
#define RTC_CLK_DAYOFMONTH   7
 
#define RTC_CLK_MONTH   8
 
#define RTC_CLK_YEAR   9
 
#define RTC_CLK_ALTCENTURY   0x32
 
#define PC_CKS_RANGE_START   16
 
#define PC_CKS_RANGE_END   45
 
#define PC_CKS_LOC   46
 
#define RTC_BOOT_BYTE   48
 
#define RTC_BOOT_NORMAL   0x1
 

Functions

static unsigned char cmos_read (unsigned char addr)
 
static void cmos_write_inner (unsigned char val, unsigned char addr)
 
static u8 cmos_disable_rtc (void)
 
static void cmos_restore_rtc (u8 control_state)
 
static void cmos_write (unsigned char val, unsigned char addr)
 
static u32 cmos_read32 (u8 offset)
 
static void cmos_write32 (u32 value, u8 offset)
 
void cmos_init (bool invalid)
 
void cmos_check_update_date (void)
 
int cmos_error (void)
 
int cmos_lb_cks_valid (void)
 
int cmos_checksum_valid (int range_start, int range_end, int cks_loc)
 
void cmos_set_checksum (int range_start, int range_end, int cks_loc)
 

Macro Definition Documentation

◆ PC_CKS_LOC

#define PC_CKS_LOC   46

Definition at line 99 of file mc146818rtc.h.

◆ PC_CKS_RANGE_END

#define PC_CKS_RANGE_END   45

Definition at line 98 of file mc146818rtc.h.

◆ PC_CKS_RANGE_START

#define PC_CKS_RANGE_START   16

Definition at line 97 of file mc146818rtc.h.

◆ RTC_24H

#define RTC_24H   0x02 /* 24 hour mode - else hours bit 7 means pm */

Definition at line 67 of file mc146818rtc.h.

◆ RTC_AF

#define RTC_AF   0x20

Definition at line 75 of file mc146818rtc.h.

◆ RTC_AIE

#define RTC_AIE   0x20 /* alarm interrupt enable */

Definition at line 63 of file mc146818rtc.h.

◆ RTC_BASE_PORT

#define RTC_BASE_PORT   0x70

Definition at line 9 of file mc146818rtc.h.

◆ RTC_BOOT_BYTE

#define RTC_BOOT_BYTE   48

Definition at line 102 of file mc146818rtc.h.

◆ RTC_BOOT_NORMAL

#define RTC_BOOT_NORMAL   0x1

Definition at line 103 of file mc146818rtc.h.

◆ RTC_CLK_ALTCENTURY

#define RTC_CLK_ALTCENTURY   0x32

Definition at line 94 of file mc146818rtc.h.

◆ RTC_CLK_DAYOFMONTH

#define RTC_CLK_DAYOFMONTH   7

Definition at line 91 of file mc146818rtc.h.

◆ RTC_CLK_DAYOFWEEK

#define RTC_CLK_DAYOFWEEK   6

Definition at line 90 of file mc146818rtc.h.

◆ RTC_CLK_HOUR

#define RTC_CLK_HOUR   4

Definition at line 88 of file mc146818rtc.h.

◆ RTC_CLK_HOUR_ALARM

#define RTC_CLK_HOUR_ALARM   5

Definition at line 89 of file mc146818rtc.h.

◆ RTC_CLK_MINUTE

#define RTC_CLK_MINUTE   2

Definition at line 86 of file mc146818rtc.h.

◆ RTC_CLK_MINUTE_ALARM

#define RTC_CLK_MINUTE_ALARM   3

Definition at line 87 of file mc146818rtc.h.

◆ RTC_CLK_MONTH

#define RTC_CLK_MONTH   8

Definition at line 92 of file mc146818rtc.h.

◆ RTC_CLK_SECOND

#define RTC_CLK_SECOND   0

Definition at line 84 of file mc146818rtc.h.

◆ RTC_CLK_SECOND_ALARM

#define RTC_CLK_SECOND_ALARM   1

Definition at line 85 of file mc146818rtc.h.

◆ RTC_CLK_YEAR

#define RTC_CLK_YEAR   9

Definition at line 93 of file mc146818rtc.h.

◆ RTC_CONTROL

#define RTC_CONTROL   RTC_REG_B

Definition at line 60 of file mc146818rtc.h.

◆ RTC_DIV_CTL

#define RTC_DIV_CTL   0x70

Definition at line 30 of file mc146818rtc.h.

◆ RTC_DIV_RESET1

#define RTC_DIV_RESET1   0x60

Definition at line 36 of file mc146818rtc.h.

◆ RTC_DIV_RESET2

#define RTC_DIV_RESET2   0x70

Definition at line 37 of file mc146818rtc.h.

◆ RTC_DM_BINARY

#define RTC_DM_BINARY   0x04 /* all time/date values are BCD if clear */

Definition at line 66 of file mc146818rtc.h.

◆ RTC_DST_EN

#define RTC_DST_EN   0x01 /* auto switch DST - works f. USA only */

Definition at line 68 of file mc146818rtc.h.

◆ RTC_FREQ_SELECT

#define RTC_FREQ_SELECT   RTC_REG_A

Definition at line 23 of file mc146818rtc.h.

◆ RTC_INTR_FLAGS

#define RTC_INTR_FLAGS   RTC_REG_C

Definition at line 71 of file mc146818rtc.h.

◆ RTC_IRQF

#define RTC_IRQF   0x80 /* any of the following 3 is active */

Definition at line 73 of file mc146818rtc.h.

◆ RTC_PF

#define RTC_PF   0x40

Definition at line 74 of file mc146818rtc.h.

◆ RTC_PIE

#define RTC_PIE   0x40 /* periodic interrupt enable */

Definition at line 62 of file mc146818rtc.h.

◆ RTC_PORT

#define RTC_PORT (   x)    (RTC_BASE_PORT + (x))

Definition at line 11 of file mc146818rtc.h.

◆ RTC_RATE_1024HZ

#define RTC_RATE_1024HZ   0x06

Definition at line 48 of file mc146818rtc.h.

◆ RTC_RATE_128HZ

#define RTC_RATE_128HZ   0x09

Definition at line 51 of file mc146818rtc.h.

◆ RTC_RATE_16384HZ

#define RTC_RATE_16384HZ   0x02

Definition at line 44 of file mc146818rtc.h.

◆ RTC_RATE_16HZ

#define RTC_RATE_16HZ   0x0c

Definition at line 54 of file mc146818rtc.h.

◆ RTC_RATE_2048HZ

#define RTC_RATE_2048HZ   0x05

Definition at line 47 of file mc146818rtc.h.

◆ RTC_RATE_256HZ

#define RTC_RATE_256HZ   0x08

Definition at line 50 of file mc146818rtc.h.

◆ RTC_RATE_2HZ

#define RTC_RATE_2HZ   0x0f

Definition at line 57 of file mc146818rtc.h.

◆ RTC_RATE_32786HZ

#define RTC_RATE_32786HZ   0x01

Definition at line 43 of file mc146818rtc.h.

◆ RTC_RATE_32HZ

#define RTC_RATE_32HZ   0x0b

Definition at line 53 of file mc146818rtc.h.

◆ RTC_RATE_4096HZ

#define RTC_RATE_4096HZ   0x04

Definition at line 46 of file mc146818rtc.h.

◆ RTC_RATE_4HZ

#define RTC_RATE_4HZ   0x0e

Definition at line 56 of file mc146818rtc.h.

◆ RTC_RATE_512HZ

#define RTC_RATE_512HZ   0x07

Definition at line 49 of file mc146818rtc.h.

◆ RTC_RATE_64HZ

#define RTC_RATE_64HZ   0x0a

Definition at line 52 of file mc146818rtc.h.

◆ RTC_RATE_8192HZ

#define RTC_RATE_8192HZ   0x03

Definition at line 45 of file mc146818rtc.h.

◆ RTC_RATE_8HZ

#define RTC_RATE_8HZ   0x0d

Definition at line 55 of file mc146818rtc.h.

◆ RTC_RATE_NONE

#define RTC_RATE_NONE   0x00

Definition at line 42 of file mc146818rtc.h.

◆ RTC_RATE_SELECT

#define RTC_RATE_SELECT   0x0F

Definition at line 41 of file mc146818rtc.h.

◆ RTC_REF_CLCK_1MHZ

#define RTC_REF_CLCK_1MHZ   0x10

Definition at line 33 of file mc146818rtc.h.

◆ RTC_REF_CLCK_32KHZ

#define RTC_REF_CLCK_32KHZ   0x20

Definition at line 34 of file mc146818rtc.h.

◆ RTC_REF_CLCK_4MHZ

#define RTC_REF_CLCK_4MHZ   0x00

Definition at line 32 of file mc146818rtc.h.

◆ RTC_REG_A

#define RTC_REG_A   10

Definition at line 15 of file mc146818rtc.h.

◆ RTC_REG_B

#define RTC_REG_B   11

Definition at line 16 of file mc146818rtc.h.

◆ RTC_REG_C

#define RTC_REG_C   12

Definition at line 17 of file mc146818rtc.h.

◆ RTC_REG_D

#define RTC_REG_D   13

Definition at line 18 of file mc146818rtc.h.

◆ RTC_SET

#define RTC_SET   0x80 /* disable updates for clock setting */

Definition at line 61 of file mc146818rtc.h.

◆ RTC_SQWE

#define RTC_SQWE   0x08 /* enable square-wave output */

Definition at line 65 of file mc146818rtc.h.

◆ RTC_UF

#define RTC_UF   0x10

Definition at line 76 of file mc146818rtc.h.

◆ RTC_UIE

#define RTC_UIE   0x10 /* update-finished interrupt enable */

Definition at line 64 of file mc146818rtc.h.

◆ RTC_UIP

#define RTC_UIP   0x80

Definition at line 29 of file mc146818rtc.h.

◆ RTC_VALID

#define RTC_VALID   RTC_REG_D

Definition at line 79 of file mc146818rtc.h.

◆ RTC_VRT

#define RTC_VRT   0x80 /* valid RAM and time */

Definition at line 80 of file mc146818rtc.h.

Function Documentation

◆ cmos_check_update_date()

void cmos_check_update_date ( void  )

Definition at line 192 of file mc146818rtc.c.

References cmos_date_invalid(), cmos_read(), cmos_reset_date(), CONFIG, RTC_CLK_ALTCENTURY, RTC_CLK_YEAR, wait_uip(), and year.

Referenced by lpc_init(), and rtc_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmos_checksum_valid()

int cmos_checksum_valid ( int  range_start,
int  range_end,
int  cks_loc 
)

Definition at line 31 of file mc146818rtc.c.

References cmos_read(), and CONFIG.

Referenced by __cmos_init(), and cmos_lb_cks_valid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmos_disable_rtc()

static u8 cmos_disable_rtc ( void  )
inlinestatic

Definition at line 127 of file mc146818rtc.h.

References cmos_read(), cmos_write_inner(), RTC_CONTROL, and RTC_SET.

Referenced by __cmos_init(), cmos_write(), and sanitize_cmos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmos_error()

int cmos_error ( void  )

Definition at line 60 of file mc146818rtc.c.

References cmos_read(), RTC_VALID, and RTC_VRT.

Referenced by __cmos_init(), do_normal_boot(), and sanitize_cmos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmos_init()

void cmos_init ( bool  invalid)

Definition at line 156 of file mc146818rtc.c.

References __cmos_init(), cmos_init_vbnv(), CONFIG, and ENV_SMM.

Referenced by i82801dx_rtc_init(), i82801gx_rtc_init(), i82801ix_rtc_init(), i82801jx_rtc_init(), isa_init(), lpc_init(), pch_rtc_init(), rtc_init(), sb_rtc_init(), sc_init(), soc_rtc_init(), and verify_psp_transfer_buf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmos_lb_cks_valid()

int cmos_lb_cks_valid ( void  )

Definition at line 194 of file option.c.

References cmos_checksum_valid().

Referenced by __cmos_init(), do_normal_boot(), and sanitize_cmos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmos_read()

◆ cmos_read32()

static u32 cmos_read32 ( u8  offset)
inlinestatic

Definition at line 157 of file mc146818rtc.h.

References cmos_read(), offset, and value.

Referenced by cmos_post_previous_boot(), and prepare_mrc_cache().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmos_restore_rtc()

static void cmos_restore_rtc ( u8  control_state)
inlinestatic

Definition at line 135 of file mc146818rtc.h.

References cmos_write_inner(), RTC_CONTROL, and RTC_SET.

Referenced by cmos_write(), and sanitize_cmos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmos_set_checksum()

void cmos_set_checksum ( int  range_start,
int  range_end,
int  cks_loc 
)

Definition at line 47 of file mc146818rtc.c.

References cmos_read(), and cmos_write().

Referenced by __cmos_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmos_write()

◆ cmos_write32()

static void cmos_write32 ( u32  value,
u8  offset 
)
inlinestatic

Definition at line 166 of file mc146818rtc.h.

References cmos_write(), offset, and value.

Referenced by cmos_post_extra(), cmos_post_init(), and save_mrc_data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmos_write_inner()

static void cmos_write_inner ( unsigned char  val,
unsigned char  addr 
)
inlinestatic

Definition at line 116 of file mc146818rtc.h.

References addr, outb(), RTC_BASE_PORT, and val.

Referenced by cmos_disable_rtc(), cmos_restore_rtc(), cmos_write(), and sanitize_cmos().

Here is the call graph for this function:
Here is the caller graph for this function: