Files
x86-bare-metal-examples/in_rtc.S
Ciro Santilli 173111e0d0 rtc
2015-09-29 23:55:54 +02:00

74 lines
1.2 KiB
ArmAsm

/*
TODO http://wiki.osdev.org/RTC
Kenrel 4.2 usage: https://github.com/torvalds/linux/blob/v4.2/arch/x86/kernel/rtc.c#L121
http://stackoverflow.com/questions/1465927/how-can-i-access-system-time-using-nasm
*/
#include "common.h"
BEGIN
.equ RTCaddress, 0x70
.equ RTCdata, 0x71
update_in_progress:
mov $10, %al
out %al, $RTCaddress
in $RTCdata, %al
testb $0x80, %al
jne update_in_progress
/* Second. */
mov $0, %al
out %al, $RTCaddress
in $RTCdata, %al
/* Only print if second changed. */
cmp %al, %cl
je update_in_progress
mov %al, %cl
PRINT_HEX(%al)
PUTC($0x20)
/* Minute. */
mov $0x02, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX(%al)
PUTC($0x20)
/* Hour. */
mov $0x04, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX(%al)
PUTC($0x20)
/* Day. */
mov $0x07, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX(%al)
PUTC($0x20)
/* Month. */
mov $0x08, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX(%al)
PUTC($0x20)
/* Year. */
mov $0x09, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX(%al)
PRINT_NEWLINE
jmp update_in_progress
hlt
END