summaryrefslogtreecommitdiff
path: root/arch/i386/include/kernel
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--arch/i386/include/kernel/multiboot.h102
-rw-r--r--kernel/arch/x86/include/kernel/asm.h (renamed from arch/i386/include/kernel/asm.h)15
-rw-r--r--kernel/arch/x86/include/kernel/gdt.h (renamed from arch/i386/include/kernel/gdt.h)2
-rw-r--r--kernel/arch/x86/include/kernel/idt.h (renamed from arch/i386/include/kernel/idt.h)0
-rw-r--r--kernel/arch/x86/include/kernel/paging.h (renamed from arch/i386/include/kernel/paging.h)1
-rw-r--r--kernel/arch/x86/include/kernel/pic.h (renamed from arch/i386/include/kernel/pic.h)0
-rw-r--r--kernel/arch/x86/include/kernel/pmem.h (renamed from arch/i386/include/kernel/pmem.h)4
-rw-r--r--kernel/arch/x86/include/kernel/syscall.h (renamed from arch/i386/include/kernel/syscall.h)0
-rw-r--r--kernel/arch/x86/include/kernel/timer.h (renamed from arch/i386/include/kernel/timer.h)0
-rw-r--r--kernel/arch/x86/include/kernel/vmem.h (renamed from arch/i386/include/kernel/vmem.h)0
10 files changed, 16 insertions, 108 deletions
diff --git a/arch/i386/include/kernel/multiboot.h b/arch/i386/include/kernel/multiboot.h
deleted file mode 100644
index abbd8a9..0000000
--- a/arch/i386/include/kernel/multiboot.h
+++ /dev/null
@@ -1,102 +0,0 @@
-#ifndef I386_MULTIBOOT_H
-#define I386_MULTIBOOT_H
-
-#include <stdint.h>
-
-#define MBOOT_HEADER_MAGIC 0x1BADB002
-#define MBOOT_LOADER_MAGIC 0x2BADB002
-
-// Multiboot flags
-#define MBOOT_INFO_MMAP 0x00000001
-#define MBOOT_INFO_BOOTDEV 0x00000002
-#define MBOOT_INFO_CMDLINE 0x00000004
-#define MBOOT_INFO_MODS 0x00000008
-#define MBOOT_INFO_AOUT_SYMS 0x00000010
-#define MBOOT_INFO_ELF_HEADER 0x00000020
-#define MBOOT_INFO_MEM_MAP 0x00000040
-#define MBOOT_INFO_DRIVE_INFO 0x00000080
-#define MBOOT_INFO_CONFIG_TBL 0x00000100
-#define MBOOT_INFO_BL_NAME 0x00000200
-#define MBOOT_INFO_APM_TBL 0x00000400
-#define MBOOT_INFO_VBE 0x00000800
-#define MBOOT_INFO_FRAMEBUFFER 0x00001000
-
-// Memory types
-#define MBOOT_MEM_AVAILABLE 1
-#define MBOOT_MEM_RESERVED 2
-#define MBOOT_MEM_ACPI_REC 3
-#define MBOOT_MEM_NVS 4
-#define MBOOT_MEM_BADRAM 5
-
-struct aout_symbol_table {
- uint32_t tabsize;
- uint32_t strsize;
- uint32_t addr;
- uint32_t reserved;
-};
-
-struct elf_section_header {
- uint32_t num;
- uint32_t size;
- uint32_t addr;
- uint32_t shndx;
-};
-
-struct mboot_header {
- uint32_t magic;
- uint32_t flags;
- uint32_t checksum;
- uint32_t header_addr;
- uint32_t load_addr;
- uint32_t load_end_addr;
- uint32_t bss_end_addr;
- uint32_t entry_addr;
- uint32_t mode_type;
- uint32_t width;
- uint32_t height;
- uint32_t depth;
-};
-
-struct mboot_info {
- uint32_t flags;
- uint32_t mem_lower;
- uint32_t mem_upper;
- uint32_t boot_device;
- uint32_t cmdline;
- uint32_t mods_count;
- uint32_t mods_addr;
- union {
- struct aout_symbol_table aout_sym;
- struct elf_section_header elf_sec;
- } u;
- uint32_t mmap_length;
- uint32_t mmap_addr;
- uint32_t drives_length;
- uint32_t drives_addr;
- uint32_t config_table;
- uint32_t boot_loader_name;
- uint32_t apm_table;
- uint32_t vbe_control_info;
- uint32_t vbe_mode_info;
- uint16_t vbe_mode;
- uint16_t vbe_interface_seg;
- uint16_t vbe_interface_off;
- uint16_t vbe_interface_len;
- uint64_t framebuffer_addr;
- uint32_t framebuffer_pitch;
- uint32_t framebuffer_width;
- uint32_t framebuffer_height;
- uint8_t framebuffer_bpp;
- uint8_t framebuffer_type;
-};
-
-struct mboot_mmap_entry {
- uint32_t size;
- uint32_t addr_low;
- uint32_t addr_high;
- uint32_t len_low;
- uint32_t len_high;
- uint32_t type;
-} __attribute__((packed));
-
-#endif
diff --git a/arch/i386/include/kernel/asm.h b/kernel/arch/x86/include/kernel/asm.h
index cc570c5..18f53c4 100644
--- a/arch/i386/include/kernel/asm.h
+++ b/kernel/arch/x86/include/kernel/asm.h
@@ -3,6 +3,7 @@
#include <kernel/gdt.h>
#include <stdint.h>
+#include <cpuid.h>
#define PCI_CONFIG_ADDR 0xCF8
#define PCI_CONFIG_DATA 0xCFC
@@ -47,6 +48,12 @@ struct isr_frame {
uint32_t eflags;
} __attribute__((packed));
+struct cpuid_info {
+ char vendorID[12];
+ uint32_t feat_ecx;
+ uint32_t feat_edx;
+};
+
void isr_stub_0(void);
void isr_stub_1(void);
void isr_stub_2(void);
@@ -99,12 +106,14 @@ void irq_stub_15(void);
void isr_stub_128(void);
-void aquire_lock(int *lock);
-void release_lock(int *lock);
-
void enable_paging(uint32_t new_cr3);
+int cpuid_check(void);
void flush_gdt(void);
+static inline void cpuid(int code, uint32_t *ecx, uint32_t *ebx) {
+ __asm__ volatile("cpuid" : "=a"(*ecx), "=d"(*ebx) : "a"(code) : "ecx","ebx");
+}
+
static inline void outb(uint16_t port, uint8_t value) {
__asm__ volatile("outb %0, %1" : : "a"(value), "Nd"(port));
}
diff --git a/arch/i386/include/kernel/gdt.h b/kernel/arch/x86/include/kernel/gdt.h
index ec02719..aa05408 100644
--- a/arch/i386/include/kernel/gdt.h
+++ b/kernel/arch/x86/include/kernel/gdt.h
@@ -14,7 +14,7 @@ struct gdt_entry {
struct gdt_ptr {
uint16_t limit;
- uint32_t base;
+ uint64_t base;
} __attribute__((packed));
struct tss_entry {
diff --git a/arch/i386/include/kernel/idt.h b/kernel/arch/x86/include/kernel/idt.h
index 29ec39f..29ec39f 100644
--- a/arch/i386/include/kernel/idt.h
+++ b/kernel/arch/x86/include/kernel/idt.h
diff --git a/arch/i386/include/kernel/paging.h b/kernel/arch/x86/include/kernel/paging.h
index d8bb8f3..3a3c298 100644
--- a/arch/i386/include/kernel/paging.h
+++ b/kernel/arch/x86/include/kernel/paging.h
@@ -2,7 +2,6 @@
#define I386_PAGING_H
#include <kernel/asm.h>
-#include <kernel/multiboot.h>
#include <stdint.h>
#define PAGE_SIZE 4096
diff --git a/arch/i386/include/kernel/pic.h b/kernel/arch/x86/include/kernel/pic.h
index 187d553..187d553 100644
--- a/arch/i386/include/kernel/pic.h
+++ b/kernel/arch/x86/include/kernel/pic.h
diff --git a/arch/i386/include/kernel/pmem.h b/kernel/arch/x86/include/kernel/pmem.h
index e6e4f57..ea4fe29 100644
--- a/arch/i386/include/kernel/pmem.h
+++ b/kernel/arch/x86/include/kernel/pmem.h
@@ -1,7 +1,6 @@
#ifndef I386_PMEM_H
#define I386_PMEM_H
-#include <kernel/multiboot.h>
#include <stdint.h>
#include <stddef.h>
@@ -11,6 +10,9 @@ struct pfa_page {
void pfa_init(struct mboot_info *header);
+uintptr_t pfa_alloc_dma(size_t num_pages);
+uintptr_t pfa_alloc(size_t num_pages);
+
void pfa_free_dma(uintptr_t paddr, size_t num_pages);
void pfa_free(uintptr_t paddr, size_t num_pages);
diff --git a/arch/i386/include/kernel/syscall.h b/kernel/arch/x86/include/kernel/syscall.h
index a657527..a657527 100644
--- a/arch/i386/include/kernel/syscall.h
+++ b/kernel/arch/x86/include/kernel/syscall.h
diff --git a/arch/i386/include/kernel/timer.h b/kernel/arch/x86/include/kernel/timer.h
index c0b3a73..c0b3a73 100644
--- a/arch/i386/include/kernel/timer.h
+++ b/kernel/arch/x86/include/kernel/timer.h
diff --git a/arch/i386/include/kernel/vmem.h b/kernel/arch/x86/include/kernel/vmem.h
index 94aa32d..94aa32d 100644
--- a/arch/i386/include/kernel/vmem.h
+++ b/kernel/arch/x86/include/kernel/vmem.h