Files
x86-bare-metal-examples/rtc.S
Junming Liu 14a32f8e29 refine rtc.s
1. Add description of used register to remove TODO.
2. Refine all registers addr to HEX format.
2020-05-03 00:10:01 +08:00

80 lines
1.6 KiB
ArmAsm
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* https://github.com/cirosantilli/x86-bare-metal-examples#rct */
/*
* Reference: https://wiki.osdev.org/CMOS
Register Contents Range
0x00 Seconds 059
0x02 Minutes 059
0x04 Hours 023 in 24-hour mode,
112 in 12-hour mode, highest bit set if pm
0x07 Day of Month 131
0x08 Month 112
0x09 Year 099
0x0A Status Register A
RTC has an "Update in progress" flag (bit 7 of Status Register A).
To read the time and date properly you have to wait until
the "Update in progress" flag goes from "set" to "clear".
*/
.equ RTCaddress, 0x70
.equ RTCdata, 0x71
#include "common.h"
BEGIN
update_in_progress:
mov $0x0A, %al
out %al, $RTCaddress
in $RTCdata, %al
testb $0x80, %al
jne update_in_progress
/* Second. */
mov $0x00, %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
/* Minute. */
mov $0x02, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX <%al>
PUTC
/* Hour. */
mov $0x04, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX <%al>
PUTC
/* Day. */
mov $0x07, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX <%al>
PUTC
/* Month. */
mov $0x08, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX <%al>
PUTC
/* Year. */
mov $0x09, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX <%al>
PRINT_NEWLINE
jmp update_in_progress