Working LAPIC timer
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
#include "sys/types.h"
|
||||
|
||||
struct acpi_rsdp {
|
||||
char signature[8];
|
||||
uint8_t checksum;
|
||||
char oemid[6];
|
||||
uint8_t rev;
|
||||
uint32_t rsdt_address;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct acpi_rsdp_ext {
|
||||
struct acpi_rsdp rsdp;
|
||||
|
||||
uint32_t length;
|
||||
uint64_t xsdt_address;
|
||||
uint8_t ext_checksum;
|
||||
uint8_t reserved[3];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct acpi_header {
|
||||
char signature[4];
|
||||
uint32_t length;
|
||||
uint8_t rev;
|
||||
uint8_t checksum;
|
||||
char oemid[6];
|
||||
char oem_table_id[8];
|
||||
uint32_t oem_rev;
|
||||
char asl_id[4];
|
||||
uint32_t asl_rev;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct acpi_rsdt {
|
||||
struct acpi_header hdr;
|
||||
|
||||
uint32_t entry[];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct acpi_madt {
|
||||
struct acpi_header hdr;
|
||||
|
||||
uint32_t local_apic_addr;
|
||||
uint32_t flags;
|
||||
char entry[];
|
||||
} __attribute__((packed));
|
||||
|
||||
void amd64_acpi_init(void);
|
||||
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
#include "sys/amd64/hw/acpi.h"
|
||||
|
||||
void amd64_apic_init(struct acpi_madt *madt);
|
||||
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct {
|
||||
uint16_t limit_lo;
|
||||
uint16_t base_lo;
|
||||
uint8_t base_mi;
|
||||
uint8_t access;
|
||||
uint8_t flags;
|
||||
uint8_t base_hi;
|
||||
} amd64_gdt_entry_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t __res0;
|
||||
uint64_t rsp0;
|
||||
uint64_t rsp1;
|
||||
uint64_t rsp2;
|
||||
uint64_t __res1;
|
||||
uint64_t ist1;
|
||||
uint64_t ist2;
|
||||
uint64_t ist3;
|
||||
uint64_t ist4;
|
||||
uint64_t ist5;
|
||||
uint64_t ist6;
|
||||
uint64_t ist7;
|
||||
uint64_t __res2;
|
||||
uint16_t __res3;
|
||||
uint16_t iopb_base;
|
||||
}__attribute__((packed)) amd64_tss_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t size;
|
||||
uintptr_t offset;
|
||||
} __attribute__((packed)) amd64_gdt_ptr_t;
|
||||
|
||||
void amd64_gdt_init(void);
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
void amd64_idt_init(void);
|
||||
@@ -0,0 +1,34 @@
|
||||
/* vim: set ft=cpp.doxygen : */
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include "sys/amd64/loader/data.h"
|
||||
|
||||
/// The place where the kernel pages are virtually mapped to
|
||||
#define KERNEL_VIRT_BASE 0xFFFFFF0000000000
|
||||
|
||||
/// amd64 standard states that addresses' upper bits are copies of the 47th bit, so these need to be
|
||||
/// stripped down to only 48 bits
|
||||
#define AMD64_MM_STRIPSX(a) ((uintptr_t) (a) & 0xFFFFFFFFFFFF)
|
||||
#define AMD64_MM_ADDRSX(a) (((uintptr_t) (a) & (1ULL << 47)) ? \
|
||||
(0xFFFFFF0000000000 | ((uintptr_t) (a))) : \
|
||||
((uintptr_t) (a)))
|
||||
|
||||
#define MM_VIRTUALIZE(a) ((uintptr_t) (a) + 0xFFFFFF0000000000)
|
||||
#define MM_PHYS(a) ((uintptr_t) (a) - 0xFFFFFF0000000000)
|
||||
|
||||
/// Page map level 4
|
||||
typedef uint64_t *mm_pml4_t;
|
||||
/// Page directory pointer table
|
||||
typedef uint64_t *mm_pdpt_t;
|
||||
/// Page directory
|
||||
typedef uint64_t *mm_pagedir_t;
|
||||
/// Page table
|
||||
typedef uint64_t *mm_pagetab_t;
|
||||
|
||||
/// Virtual memory space
|
||||
typedef mm_pml4_t mm_space_t;
|
||||
|
||||
/// Kernel memory space
|
||||
extern mm_space_t mm_kernel;
|
||||
|
||||
void amd64_mm_init(struct amd64_loader_data *data);
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
void *memcpy(void *restrict dst, const void *restrict src, size_t cnt);
|
||||
void *memmove(void *dst, const void *src, size_t cnt);
|
||||
void *memset(void *dst, int v, size_t count);
|
||||
|
||||
size_t strlen(const char *s);
|
||||
int strncmp(const char *a, const char *b, size_t lim);
|
||||
|
||||
Reference in New Issue
Block a user