move arch include dir

This commit is contained in:
Matheus
2023-04-08 19:28:58 -03:00
parent 320cc13d75
commit 1555becce5
8 changed files with 9 additions and 1 deletions
+24
View File
@@ -0,0 +1,24 @@
#ifndef _CPU_H
#define _CPU_H
#include <stddef.h>
#include <stdint.h>
#include <arch/msr.h>
#include <arch/ist.h>
typedef struct {
uint64_t gdt[7];
ist_t ist;
int lapicid;
} cpu_t;
static inline cpu_t *_cpu() {
return (cpu_t *)rdmsr(MSR_GSBASE);
}
static inline void cpu_set(cpu_t *ptr) {
wrmsr(MSR_GSBASE, (uint64_t)ptr);
}
#endif
+7
View File
@@ -0,0 +1,7 @@
#ifndef _E9_H
#define _E9_H
void arch_e9_putc(char);
void arch_e9_puts(char *);
#endif
+6
View File
@@ -0,0 +1,6 @@
#ifndef _GDT_H
#define _GDT_H
void arch_gdt_reload();
#endif
+27
View File
@@ -0,0 +1,27 @@
#ifndef IO_H
#define IO_H
#include <stddef.h>
#include <stdint.h>
static inline void outd(uint16_t port, uint32_t data) {
asm volatile("out %%eax, %%dx" : : "a"(data), "d"(port));
}
static inline uint32_t ind(uint16_t port) {
uint32_t ret;
asm volatile("in %%dx, %%eax" : "=a"(ret) : "d"(port));
return ret;
}
static inline void outb(uint16_t port, uint8_t data) {
asm volatile("out %%al, %%dx" : : "a"(data), "d"(port));
}
static inline uint8_t inb(uint16_t port) {
uint8_t ret;
asm volatile ("in %%dx, %%al" : "=a"(ret) : "d"(port));
return ret;
}
#endif
+21
View File
@@ -0,0 +1,21 @@
#ifndef _IST_H
#define _IST_H
typedef struct {
uint32_t reserved;
uint64_t rsp0;
uint64_t rsp1;
uint64_t rsp2;
uint64_t reserved2;
uint64_t ist1;
uint64_t ist2;
uint64_t ist3;
uint64_t ist4;
uint64_t ist5;
uint64_t ist6;
uint64_t ist7;
uint32_t reserved3[3];
uint32_t iopb;
} __attribute__((packed)) ist_t;
#endif
+27
View File
@@ -0,0 +1,27 @@
#ifndef _MSR_H
#define _MSR_H
#include <stdint.h>
#define MSR_EFER 0xC0000080
#define MSR_STAR 0xC0000081
#define MSR_LSTAR 0xC0000082
#define MSR_CSTAR 0xC0000083
#define MSR_FMASK 0xC0000084
#define MSR_FSBASE 0xC0000100
#define MSR_GSBASE 0xC0000101
#define MSR_KERNELGSBASE 0xC0000102
static inline uint64_t rdmsr(uint32_t which) {
uint64_t low,high;
asm volatile("rdmsr" : "=a"(low), "=d"(high) : "c"(which));
return (high << 32) | low;
}
static inline void wrmsr(uint32_t which, uint64_t value) {
uint32_t low = value & 0xFFFFFFFF;
uint32_t high = (value >> 32) & 0xFFFFFFFF;
asm volatile("wrmsr" : : "a"(low), "d"(high), "c"(which));
}
#endif