mc146818reg.h File Reference

Back to the index.

Macros | Typedefs | Functions
mc146818reg.h File Reference

Go to the source code of this file.

Macros

#define __P(x)   x
 
#define MC_SEC   0x0 /* Time of year: seconds (0-59) */
 
#define MC_ASEC   0x1 /* Alarm: seconds */
 
#define MC_MIN   0x2 /* Time of year: minutes (0-59) */
 
#define MC_AMIN   0x3 /* Alarm: minutes */
 
#define MC_HOUR   0x4 /* Time of year: hour (see above) */
 
#define MC_AHOUR   0x5 /* Alarm: hour */
 
#define MC_DOW   0x6 /* Time of year: day of week (1-7) */
 
#define MC_DOM   0x7 /* Time of year: day of month (1-31) */
 
#define MC_MONTH   0x8 /* Time of year: month (1-12) */
 
#define MC_YEAR   0x9 /* Time of year: year in century (0-99) */
 
#define MC_REGA   0xa /* Control register A */
 
#define MC_REGA_RSMASK   0x0f /* Interrupt rate select mask (see below) */
 
#define MC_REGA_DVMASK   0x70 /* Divisor select mask (see below) */
 
#define MC_REGA_UIP   0x80 /* Update in progress; read only. */
 
#define MC_REGB   0xb /* Control register B */
 
#define MC_REGB_DSE   0x01 /* Daylight Savings Enable */
 
#define MC_REGB_24HR   0x02 /* 24-hour mode (AM/PM mode when clear) */
 
#define MC_REGB_BINARY   0x04 /* Binary mode (BCD mode when clear) */
 
#define MC_REGB_SQWE   0x08 /* Square Wave Enable */
 
#define MC_REGB_UIE   0x10 /* Update End interrupt enable */
 
#define MC_REGB_AIE   0x20 /* Alarm interrupt enable */
 
#define MC_REGB_PIE   0x40 /* Periodic interrupt enable */
 
#define MC_REGB_SET   0x80 /* Allow time to be set; stops updates */
 
#define MC_REGC   0xc /* Control register C */
 
#define MC_REGC_UF   0x10 /* Update End interrupt flag */
 
#define MC_REGC_AF   0x20 /* Alarm interrupt flag */
 
#define MC_REGC_PF   0x40 /* Periodic interrupt flag */
 
#define MC_REGC_IRQF   0x80 /* Interrupt request pending flag */
 
#define MC_REGD   0xd /* Control register D */
 
#define MC_REGD_VRT   0x80 /* Valid RAM and Time bit */
 
#define MC_NREGS   0xe /* 14 registers; CMOS follows */
 
#define MC_NTODREGS   0xa /* 10 of those regs are for TOD and alarm */
 
#define MC_NVRAM_START   0xe /* start of NVRAM: offset 14 */
 
#define MC_NVRAM_SIZE   50 /* 50 bytes of NVRAM */
 
#define MC_RATE_NONE   0x0 /* No periodic interrupt */
 
#define MC_RATE_1   0x1 /* 256 Hz if MC_BASE_32_KHz, else 32768 Hz */
 
#define MC_RATE_2   0x2 /* 128 Hz if MC_BASE_32_KHz, else 16384 Hz */
 
#define MC_RATE_8192_Hz   0x3 /* 122.070 us period */
 
#define MC_RATE_4096_Hz   0x4 /* 244.141 us period */
 
#define MC_RATE_2048_Hz   0x5 /* 488.281 us period */
 
#define MC_RATE_1024_Hz   0x6 /* 976.562 us period */
 
#define MC_RATE_512_Hz   0x7 /* 1.953125 ms period */
 
#define MC_RATE_256_Hz   0x8 /* 3.90625 ms period */
 
#define MC_RATE_128_Hz   0x9 /* 7.8125 ms period */
 
#define MC_RATE_64_Hz   0xa /* 15.625 ms period */
 
#define MC_RATE_32_Hz   0xb /* 31.25 ms period */
 
#define MC_RATE_16_Hz   0xc /* 62.5 ms period */
 
#define MC_RATE_8_Hz   0xd /* 125 ms period */
 
#define MC_RATE_4_Hz   0xe /* 250 ms period */
 
#define MC_RATE_2_Hz   0xf /* 500 ms period */
 
#define MC_BASE_4_MHz   0x00 /* 4MHz crystal */
 
#define MC_BASE_1_MHz   0x10 /* 1MHz crystal */
 
#define MC_BASE_32_KHz   0x20 /* 32KHz crystal */
 
#define MC_BASE_NONE   0x60 /* actually, both of these reset */
 
#define MC_BASE_RESET   0x70
 
#define MC146818_GETTOD(sc, regs)
 
#define MC146818_PUTTOD(sc, regs)
 

Typedefs

typedef u_int mc_todregs[MC_NTODREGS]
 

Functions

u_int mc146818_read __P ((void *sc, u_int reg))
 
void mc146818_write __P ((void *sc, u_int reg, u_int datum))
 

Macro Definition Documentation

◆ __P

#define __P (   x)    x

Definition at line 5 of file mc146818reg.h.

◆ MC146818_GETTOD

#define MC146818_GETTOD (   sc,
  regs 
)
Value:
do { \
int i; \
\
/* update in progress; spin loop */ \
while (mc146818_read(sc, MC_REGA) & MC_REGA_UIP) \
; \
\
/* read all of the tod/alarm regs */ \
for (i = 0; i < MC_NTODREGS; i++) \
(*regs)[i] = mc146818_read(sc, i); \
} while (0);

Definition at line 169 of file mc146818reg.h.

◆ MC146818_PUTTOD

#define MC146818_PUTTOD (   sc,
  regs 
)
Value:
do { \
int i; \
\
/* stop updates while setting */ \
mc146818_write(sc, MC_REGB, \
mc146818_read(sc, MC_REGB) | MC_REGB_SET); \
\
/* write all of the tod/alarm regs */ \
for (i = 0; i < MC_NTODREGS; i++) \
mc146818_write(sc, i, (*regs)[i]); \
\
/* reenable updates */ \
mc146818_write(sc, MC_REGB, \
mc146818_read(sc, MC_REGB) & ~MC_REGB_SET); \
} while (0);

Definition at line 186 of file mc146818reg.h.

◆ MC_AHOUR

#define MC_AHOUR   0x5 /* Alarm: hour */

Definition at line 80 of file mc146818reg.h.

◆ MC_AMIN

#define MC_AMIN   0x3 /* Alarm: minutes */

Definition at line 78 of file mc146818reg.h.

◆ MC_ASEC

#define MC_ASEC   0x1 /* Alarm: seconds */

Definition at line 76 of file mc146818reg.h.

◆ MC_BASE_1_MHz

#define MC_BASE_1_MHz   0x10 /* 1MHz crystal */

Definition at line 147 of file mc146818reg.h.

◆ MC_BASE_32_KHz

#define MC_BASE_32_KHz   0x20 /* 32KHz crystal */

Definition at line 148 of file mc146818reg.h.

◆ MC_BASE_4_MHz

#define MC_BASE_4_MHz   0x00 /* 4MHz crystal */

Definition at line 146 of file mc146818reg.h.

◆ MC_BASE_NONE

#define MC_BASE_NONE   0x60 /* actually, both of these reset */

Definition at line 149 of file mc146818reg.h.

◆ MC_BASE_RESET

#define MC_BASE_RESET   0x70

Definition at line 150 of file mc146818reg.h.

◆ MC_DOM

#define MC_DOM   0x7 /* Time of year: day of month (1-31) */

Definition at line 82 of file mc146818reg.h.

◆ MC_DOW

#define MC_DOW   0x6 /* Time of year: day of week (1-7) */

Definition at line 81 of file mc146818reg.h.

◆ MC_HOUR

#define MC_HOUR   0x4 /* Time of year: hour (see above) */

Definition at line 79 of file mc146818reg.h.

◆ MC_MIN

#define MC_MIN   0x2 /* Time of year: minutes (0-59) */

Definition at line 77 of file mc146818reg.h.

◆ MC_MONTH

#define MC_MONTH   0x8 /* Time of year: month (1-12) */

Definition at line 83 of file mc146818reg.h.

◆ MC_NREGS

#define MC_NREGS   0xe /* 14 registers; CMOS follows */

Definition at line 117 of file mc146818reg.h.

◆ MC_NTODREGS

#define MC_NTODREGS   0xa /* 10 of those regs are for TOD and alarm */

Definition at line 118 of file mc146818reg.h.

◆ MC_NVRAM_SIZE

#define MC_NVRAM_SIZE   50 /* 50 bytes of NVRAM */

Definition at line 121 of file mc146818reg.h.

◆ MC_NVRAM_START

#define MC_NVRAM_START   0xe /* start of NVRAM: offset 14 */

Definition at line 120 of file mc146818reg.h.

◆ MC_RATE_1

#define MC_RATE_1   0x1 /* 256 Hz if MC_BASE_32_KHz, else 32768 Hz */

Definition at line 127 of file mc146818reg.h.

◆ MC_RATE_1024_Hz

#define MC_RATE_1024_Hz   0x6 /* 976.562 us period */

Definition at line 132 of file mc146818reg.h.

◆ MC_RATE_128_Hz

#define MC_RATE_128_Hz   0x9 /* 7.8125 ms period */

Definition at line 135 of file mc146818reg.h.

◆ MC_RATE_16_Hz

#define MC_RATE_16_Hz   0xc /* 62.5 ms period */

Definition at line 138 of file mc146818reg.h.

◆ MC_RATE_2

#define MC_RATE_2   0x2 /* 128 Hz if MC_BASE_32_KHz, else 16384 Hz */

Definition at line 128 of file mc146818reg.h.

◆ MC_RATE_2048_Hz

#define MC_RATE_2048_Hz   0x5 /* 488.281 us period */

Definition at line 131 of file mc146818reg.h.

◆ MC_RATE_256_Hz

#define MC_RATE_256_Hz   0x8 /* 3.90625 ms period */

Definition at line 134 of file mc146818reg.h.

◆ MC_RATE_2_Hz

#define MC_RATE_2_Hz   0xf /* 500 ms period */

Definition at line 141 of file mc146818reg.h.

◆ MC_RATE_32_Hz

#define MC_RATE_32_Hz   0xb /* 31.25 ms period */

Definition at line 137 of file mc146818reg.h.

◆ MC_RATE_4096_Hz

#define MC_RATE_4096_Hz   0x4 /* 244.141 us period */

Definition at line 130 of file mc146818reg.h.

◆ MC_RATE_4_Hz

#define MC_RATE_4_Hz   0xe /* 250 ms period */

Definition at line 140 of file mc146818reg.h.

◆ MC_RATE_512_Hz

#define MC_RATE_512_Hz   0x7 /* 1.953125 ms period */

Definition at line 133 of file mc146818reg.h.

◆ MC_RATE_64_Hz

#define MC_RATE_64_Hz   0xa /* 15.625 ms period */

Definition at line 136 of file mc146818reg.h.

◆ MC_RATE_8192_Hz

#define MC_RATE_8192_Hz   0x3 /* 122.070 us period */

Definition at line 129 of file mc146818reg.h.

◆ MC_RATE_8_Hz

#define MC_RATE_8_Hz   0xd /* 125 ms period */

Definition at line 139 of file mc146818reg.h.

◆ MC_RATE_NONE

#define MC_RATE_NONE   0x0 /* No periodic interrupt */

Definition at line 126 of file mc146818reg.h.

◆ MC_REGA

#define MC_REGA   0xa /* Control register A */

Definition at line 86 of file mc146818reg.h.

◆ MC_REGA_DVMASK

#define MC_REGA_DVMASK   0x70 /* Divisor select mask (see below) */

Definition at line 89 of file mc146818reg.h.

◆ MC_REGA_RSMASK

#define MC_REGA_RSMASK   0x0f /* Interrupt rate select mask (see below) */

Definition at line 88 of file mc146818reg.h.

◆ MC_REGA_UIP

#define MC_REGA_UIP   0x80 /* Update in progress; read only. */

Definition at line 90 of file mc146818reg.h.

◆ MC_REGB

#define MC_REGB   0xb /* Control register B */

Definition at line 92 of file mc146818reg.h.

◆ MC_REGB_24HR

#define MC_REGB_24HR   0x02 /* 24-hour mode (AM/PM mode when clear) */

Definition at line 95 of file mc146818reg.h.

◆ MC_REGB_AIE

#define MC_REGB_AIE   0x20 /* Alarm interrupt enable */

Definition at line 99 of file mc146818reg.h.

◆ MC_REGB_BINARY

#define MC_REGB_BINARY   0x04 /* Binary mode (BCD mode when clear) */

Definition at line 96 of file mc146818reg.h.

◆ MC_REGB_DSE

#define MC_REGB_DSE   0x01 /* Daylight Savings Enable */

Definition at line 94 of file mc146818reg.h.

◆ MC_REGB_PIE

#define MC_REGB_PIE   0x40 /* Periodic interrupt enable */

Definition at line 100 of file mc146818reg.h.

◆ MC_REGB_SET

#define MC_REGB_SET   0x80 /* Allow time to be set; stops updates */

Definition at line 101 of file mc146818reg.h.

◆ MC_REGB_SQWE

#define MC_REGB_SQWE   0x08 /* Square Wave Enable */

Definition at line 97 of file mc146818reg.h.

◆ MC_REGB_UIE

#define MC_REGB_UIE   0x10 /* Update End interrupt enable */

Definition at line 98 of file mc146818reg.h.

◆ MC_REGC

#define MC_REGC   0xc /* Control register C */

Definition at line 103 of file mc146818reg.h.

◆ MC_REGC_AF

#define MC_REGC_AF   0x20 /* Alarm interrupt flag */

Definition at line 107 of file mc146818reg.h.

◆ MC_REGC_IRQF

#define MC_REGC_IRQF   0x80 /* Interrupt request pending flag */

Definition at line 109 of file mc146818reg.h.

◆ MC_REGC_PF

#define MC_REGC_PF   0x40 /* Periodic interrupt flag */

Definition at line 108 of file mc146818reg.h.

◆ MC_REGC_UF

#define MC_REGC_UF   0x10 /* Update End interrupt flag */

Definition at line 106 of file mc146818reg.h.

◆ MC_REGD

#define MC_REGD   0xd /* Control register D */

Definition at line 111 of file mc146818reg.h.

◆ MC_REGD_VRT

#define MC_REGD_VRT   0x80 /* Valid RAM and Time bit */

Definition at line 114 of file mc146818reg.h.

◆ MC_SEC

#define MC_SEC   0x0 /* Time of year: seconds (0-59) */

Definition at line 75 of file mc146818reg.h.

◆ MC_YEAR

#define MC_YEAR   0x9 /* Time of year: year in century (0-99) */

Definition at line 84 of file mc146818reg.h.

Typedef Documentation

◆ mc_todregs

typedef u_int mc_todregs[MC_NTODREGS]

Definition at line 163 of file mc146818reg.h.

Function Documentation

◆ __P() [1/2]

u_int mc146818_read __P ( (void *sc, u_int reg )

◆ __P() [2/2]

void mc146818_write __P ( (void *sc, u_int reg, u_int datum)  )
MC_NTODREGS
#define MC_NTODREGS
Definition: mc146818reg.h:118
MC_REGB
#define MC_REGB
Definition: mc146818reg.h:92
MC_REGA
#define MC_REGA
Definition: mc146818reg.h:86
MC_REGB_SET
#define MC_REGB_SET
Definition: mc146818reg.h:101
MC_REGA_UIP
#define MC_REGA_UIP
Definition: mc146818reg.h:90

Generated on Tue Mar 24 2020 14:04:48 for GXemul by doxygen 1.8.17