Rename rtc functions
This commit is contained in:
parent
76037c1c18
commit
e8b2c1ae56
3 changed files with 11 additions and 5 deletions
|
|
@ -21,12 +21,17 @@ static inline void mmio_write32(uintptr_t addr, uint32_t value) {
|
|||
*(volatile uint32_t *)addr = value;
|
||||
}
|
||||
|
||||
uint64_t rtc_read_time(void) {
|
||||
uint64_t rtc_time_read(void) {
|
||||
uint32_t low = mmio_read32(VIRT_RTC_BASE + RTC_TIME_LOW);
|
||||
uint32_t high = mmio_read32(VIRT_RTC_BASE + RTC_TIME_HIGH);
|
||||
return ((uint64_t)high << 32) | low;
|
||||
}
|
||||
|
||||
void rtc_time_set(uint64_t ns) {
|
||||
mmio_write32(VIRT_RTC_BASE + RTC_TIME_LOW, ns);
|
||||
mmio_write32(VIRT_RTC_BASE + RTC_TIME_HIGH, ns);
|
||||
}
|
||||
|
||||
void rtc_alarm_set(uint64_t ns) {
|
||||
mmio_write32(VIRT_RTC_BASE + RTC_ALARM_HIGH, ns >> 32);
|
||||
mmio_write32(VIRT_RTC_BASE + RTC_ALARM_LOW, ns & 0xffffffff);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
uint64_t rtc_read_time(void);
|
||||
uint64_t rtc_time_read(void);
|
||||
void rtc_time_set(uint64_t ns);
|
||||
|
||||
void rtc_alarm_set(uint64_t ns);
|
||||
uint64_t rtc_alarm_read(void);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ void start() {
|
|||
memory_sweep(heap_start, heap_end);
|
||||
buddy_init(heap_start, heap_end);
|
||||
spinlock_init(&sl);
|
||||
sbadrand(rtc_read_time() ^ swap64(rtc_read_time()));
|
||||
sbadrand(rtc_time_read() ^ swap64(rtc_time_read()));
|
||||
for (int i = 0; i < banner_len; i++) uart_putc(banner[i]);
|
||||
__sync_synchronize();
|
||||
hold = 0;
|
||||
|
|
@ -83,8 +83,8 @@ void start() {
|
|||
buddy_free(mem);
|
||||
}
|
||||
{
|
||||
uint64_t time = rtc_read_time();
|
||||
time = rtc_read_time();
|
||||
uint64_t time = rtc_time_read();
|
||||
time = rtc_time_read();
|
||||
rtc_alarm_set(time + 3000000000);
|
||||
uint64_t alrm = rtc_alarm_read();
|
||||
assert(alrm > time);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue