feat: added missing lapic code

This commit is contained in:
2021-08-30 19:58:50 +02:00
parent e37222c346
commit e693b12915
2 changed files with 53 additions and 0 deletions

30
kernel/cpu/lapic.c Normal file
View File

@@ -0,0 +1,30 @@
//
// Created by rick on 23-08-21.
//
#include <myke/cpu/lapic.h>
void *lapic = NULL;
void lapic_set_addr(uint32_t addr) {
lapic = (void *) addr;
}
void lapic_write(uint32_t offset, uint32_t value) {
*(volatile uint32_t *) ((uintptr_t) lapic + offset) = value;
}
uint32_t lapic_read(uint32_t offset) {
if (lapic == NULL) {
return UINT32_MAX;
}
return *(volatile uint32_t *) ((uintptr_t) lapic + offset);
}
uint32_t lapic_get_id() {
return lapic_read(LAPIC_REG_ID);
}
uint32_t lapic_get_version() {
return lapic_read(LAPIC_REG_VERSION);
}