From 36a8ed9e315bd35d54e14411f78dbc3a9f2b5747 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 18 Jul 2011 09:06:09 +0200 Subject: [PATCH] add helper functions for reading and writing CMOS entries --- arch/x86/include/asm/io.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 8765b7cc..0a97a187 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -32,6 +32,13 @@ extern "C" { #endif +#ifndef CMOS_PORT_ADDRESS +#define CMOS_PORT_ADDRESS 0x70 +#endif +#ifndef CMOS_PORT_DATA +#define CMOS_PORT_DATA 0x71 +#endif + /** @brief Read a byte from an IO port * * @param _port The port you want to read from @@ -98,6 +105,28 @@ inline static void uart_putchar(unsigned char _data) outportb(0x2F8, _data); } +/** + * read a byte from CMOS + * @param offset CMOS offset + * @return value you want to read + */ +inline static uint8_t cmos_read(uint8_t offset) +{ + outportb(CMOS_PORT_ADDRESS, offset); + return inportb(CMOS_PORT_DATA); +} + +/** + * write a byte in CMOS + * @param offset CMOS offset + * @param val the value you want wto write + */ +inline static void cmos_write(uint8_t offset, uint8_t val) +{ + outportb(CMOS_PORT_ADDRESS, offset); + outportb(CMOS_PORT_DATA, val); +} + #ifdef __cplusplus } #endif