*
* FMH
*/
+
+static const int i8254_control_reg = 3;
+
static inline int i8254_load(unsigned long base_address,
unsigned int counter_number, unsigned int count, unsigned int mode)
{
unsigned int byte;
- static const int counter_control = 3;
if(counter_number > 2) return -1;
if(count > 0xffff) return -1;
byte = counter_number << 6;
byte |= 0x30; // load low then high byte
byte |= (mode << 1); // set counter mode
- outb(byte, base_address + counter_control);
+ outb(byte, base_address + i8254_control_reg);
byte = count & 0xff; // lsb of counter value
outb(byte, base_address + counter_number);
byte = (count >> 8) & 0xff; // msb of counter value
unsigned int counter_number, unsigned int count, unsigned int mode)
{
unsigned int byte;
- static const int counter_control = 3;
if(counter_number > 2) return -1;
if(count > 0xffff) return -1;
byte = counter_number << 6;
byte |= 0x30; // load low then high byte
byte |= (mode << 1); // set counter mode
- writeb(byte, base_address + counter_control);
+ writeb(byte, base_address + i8254_control_reg);
byte = count & 0xff; // lsb of counter value
writeb(byte, base_address + counter_number);
byte = (count >> 8) & 0xff; // msb of counter value
{
unsigned int byte;
int ret;
- static const int counter_control = 3;
if(counter_number > 2) return -1;
// latch counter
byte = counter_number << 6;
- outb(byte, base_address + counter_control);
+ outb(byte, base_address + i8254_control_reg);
// read lsb
ret = inb(base_address + counter_number);
return ret;
}
+
+static inline int i8254_status(unsigned long base_address, int counter_number)
+{
+ outb(0xE0 | (2 << counter_number), base_address + i8254_control_reg);
+ return inb(base_address + counter_number);
+}
+
#endif
#endif