v2 initial commit
This commit is contained in:
parent
2c97dba9f7
commit
d2ef885e8d
118 changed files with 2420 additions and 9320 deletions
10
amd64/include/arch/msr.h
Normal file
10
amd64/include/arch/msr.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef _MSR_H_
|
||||
#define _MSR_H_
|
||||
|
||||
#include <kernel/types.h>
|
||||
|
||||
u64 rdmsr(u32 msr);
|
||||
void wrmsr(u32 msr, u64 val);
|
||||
|
||||
#endif /* _MSR_H_ */
|
||||
32
amd64/include/arch/page.h
Normal file
32
amd64/include/arch/page.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef _AMD64_PAGE_H_
|
||||
#define _AMD64_PAGE_H_
|
||||
|
||||
#include <kernel/page.h>
|
||||
|
||||
#define PAGE_SIZE 0x1000ull
|
||||
|
||||
#define PAGE_MASK_LOWER (~(PAGE_SIZE - 1))
|
||||
#define PAGE_MASK_UPPER ((PAGE_SIZE - 1))
|
||||
|
||||
#define PAGE_ALIGN (~(PAGE_SIZE - 1))
|
||||
|
||||
#define PAGE_PRESENT 0x001
|
||||
#define PAGE_RW 0x002
|
||||
#define PAGE_USER 0x004
|
||||
#define PAGE_WRITE_THRU 0x008
|
||||
#define PAGE_CACHE_DISABLE 0x010
|
||||
#define PAGE_ACCESSED 0x020
|
||||
#define PAGE_DIRTY 0x040
|
||||
#define PAGE_4MB_ENABLE 0x080
|
||||
|
||||
#define pgd_index(address) (((address) >> 39) & 0x1FF)
|
||||
#define pud_index(address) (((address) >> 30) & 0x1FF)
|
||||
#define pmd_index(address) (((address) >> 21) & 0x1FF)
|
||||
#define pte_index(address) (((address) >> 12) & 0x1FF)
|
||||
|
||||
void pgd_load(pgd_t *pgd);
|
||||
u64 *_pt_read(u64 *dir, size_t index, u64 *flags);
|
||||
void _pt_write(u64 *dir, size_t index, u64 *val, u64 flags);
|
||||
|
||||
#endif /* _AMD64_PAGE_H_ */
|
||||
44
amd64/include/drivers/apic.h
Normal file
44
amd64/include/drivers/apic.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef _APIC_H_
|
||||
#define _APIC_H_
|
||||
|
||||
#define MADT_LAPIC 0
|
||||
#define MADT_IOAPIC 1
|
||||
#define MADT_IOAPIC_OVRD 2
|
||||
#define MADT_IOAPIC_NMI 3
|
||||
#define MADT_LAPIC_NMI 4
|
||||
#define MADT_LAPIC_OVRD 5
|
||||
#define MADT_X2_LAPIC 9
|
||||
|
||||
#define LAPIC_ID 0x20
|
||||
#define LAPIC_VERSION 0x30
|
||||
#define LAPIC_TPR 0x80
|
||||
#define LAPIC_APR 0x90
|
||||
#define LAPIC_PPR 0xA0
|
||||
#define LAPIC_EOI 0xB0
|
||||
#define LAPIC_RRD 0xC0
|
||||
#define LAPIC_LDR 0xD0
|
||||
#define LAPIC_DFR 0xE0
|
||||
#define LAPIC_SIVR 0xF0
|
||||
#define LAPIC_ISR 0x100
|
||||
#define LAPIC_TMR 0x180
|
||||
#define LAPIC_IRR 0x200
|
||||
#define LAPIC_ERR 0x280
|
||||
#define LAPIC_CMCI 0x2F0
|
||||
#define LAPIC_ICR 0x300
|
||||
#define LAPIC_THERMAL 0x330
|
||||
#define LAPIC_LVT_PERF_MON_COUNT 0x340
|
||||
#define LAPIC_LVT_LINT0 0x350
|
||||
#define LAPIC_LVT_LINT1 0x360
|
||||
#define LAPIC_LVT_ERR 0x370
|
||||
#define LAPIC_INIT_COUNT 0x380
|
||||
#define LAPIC_CUR_COUNT 0x390
|
||||
|
||||
#define LAPIC_TIMER 0x320
|
||||
#define LAPIC_TIMER_DIV 0x3E0
|
||||
#define LAPIC_TIMER_INIT_COUNT 0x380
|
||||
#define MSR_IA32_APIC_BASE 0x1B
|
||||
|
||||
void apic_init();
|
||||
|
||||
#endif /* _APIC_H_ */
|
||||
13
amd64/include/drivers/pio.h
Normal file
13
amd64/include/drivers/pio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef _PIO_H_
|
||||
#define _PIO_H_
|
||||
|
||||
#include <kernel/common.h>
|
||||
|
||||
void outb(u16 port, u8 byte);
|
||||
u8 inb(u16 port);
|
||||
|
||||
void outw(u16 port, u16 word);
|
||||
u16 inw(u16 port);
|
||||
|
||||
#endif /* _PIO_H_ */
|
||||
14
amd64/include/drivers/serial.h
Normal file
14
amd64/include/drivers/serial.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef _SERIAL_H_
|
||||
#define _SERIAL_H_
|
||||
|
||||
#define COM1 0x3F8
|
||||
#define COM2 0x2F8
|
||||
|
||||
#define DEV_CLASS_NATIVE_SERIAL 0x9000
|
||||
|
||||
#include <kernel/device.h>
|
||||
|
||||
dev_t arch_serial_init();
|
||||
|
||||
#endif /* _SERIAL_H_ */
|
||||
12
amd64/include/kernel/spinlock.h
Normal file
12
amd64/include/kernel/spinlock.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef _SPINLOCK_H_
|
||||
#define _SPINLOCK_H_
|
||||
|
||||
#include <kernel/types.h>
|
||||
|
||||
typedef u64 spinlock_t;
|
||||
|
||||
void spinlock_acquire(spinlock_t *lock);
|
||||
void spinlock_release(spinlock_t *lock);
|
||||
|
||||
#endif /* _SPINLOCK_H_ */
|
||||
Loading…
Reference in a new issue