add helper functions for reading and writing CMOS entries

This commit is contained in:
Stefan Lankes 2011-07-18 09:06:09 +02:00
parent 35ec905b7e
commit 36a8ed9e31

View file

@ -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