-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmos.c
39 lines (32 loc) · 822 Bytes
/
cmos.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stddef.h>
#include <stdint.h>
#include "cmos.h"
#include "clock.h"
#include "ports.h"
// Czy przerwania nmi mają był włączone
uint8_t nmi_enabled = 0;
// Odczytuja wartość z rejestru CMOS
uint8_t cmos_read_register(uint8_t address)
{
uint8_t byte1 = nmi_enabled << 7 | address;
outportb(CMOS_PORT1, byte1);
uint8_t value = inportb(CMOS_PORT2);
return value;
}
// Zapisuje wartość do rejestru CMOS
void cmos_write_register(uint8_t address, uint8_t value)
{
uint8_t byte1 = nmi_enabled << 7 | address;
outportb(CMOS_PORT1, byte1);
outportb(CMOS_PORT2, value);
}
// Włącza przerwania NMI - Not Maskable Interrupt
void cmos_enable_nmi(void)
{
nmi_enabled = 1;
}
// Wyłącza przerwania NMI - Not Maskable Interrupt
void cmos_disable_nmi(void)
{
nmi_enabled = 0;
}