feat: gdt, attributes move, reorder

Added late gdt setup with initial tss
Moved attributes to include root
Reordered some imports
This commit is contained in:
2021-03-21 17:34:38 +01:00
parent 513693189e
commit 20ab9e1d6e
28 changed files with 351 additions and 121 deletions

19
include/attributes.h Normal file
View File

@@ -0,0 +1,19 @@
//
// Created by rick on 24-02-21.
//
#ifndef NEW_KERNEL_ATTRIBUTES_H
#define NEW_KERNEL_ATTRIBUTES_H
// generic
#define att_used __attribute((used))
// function
#define att_noreturn __attribute((noreturn))
#define att_cdecl __attribute((cdecl))
// structure
#define att_packed __attribute((packed))
// field
#define att_aligned(size) __attribute((aligned(size)))
#endif //NEW_KERNEL_ATTRIBUTES_H

View File

@@ -6,7 +6,7 @@
#define NEW_KERNEL_ELF_H
#include <sys/types.h>
#include <myke/attributes.h>
#include <attributes.h>
#define SHT_NULL 0
#define SHT_PROGBITS 1
@@ -59,7 +59,7 @@ struct elf32_section_header {
uint32_t sh_info;
uint32_t sh_addr_align;
uint32_t sh_ent_size;
} packed;
} att_packed;
struct elf32_symtab_entry {
uint32_t st_name;
@@ -68,6 +68,6 @@ struct elf32_symtab_entry {
uint8_t st_info;
uint8_t st_other;
uint16_t st_shndx;
} packed;
} att_packed;
#endif //NEW_KERNEL_ELF_H

View File

@@ -1,19 +0,0 @@
//
// Created by rick on 24-02-21.
//
#ifndef NEW_KERNEL_ATTRIBUTES_H
#define NEW_KERNEL_ATTRIBUTES_H
// generic
#define used __attribute((used))
// function
#define noreturn __attribute((noreturn))
#define cdecl __attribute((cdecl))
// structure
#define packed __attribute((packed))
// field
#define at_aligned(size) __attribute((aligned(size)))
#endif //NEW_KERNEL_ATTRIBUTES_H

10
include/myke/cpu/gdt.h Normal file
View File

@@ -0,0 +1,10 @@
//
// Created by rick on 19-03-21.
//
#ifndef NEW_KERNEL_GDT_H
#define NEW_KERNEL_GDT_H
void gdt_init();
#endif //NEW_KERNEL_GDT_H

View File

@@ -6,7 +6,7 @@
#ifndef MY_KERNEL_IDT_H
#define MY_KERNEL_IDT_H
#include <myke/attributes.h>
#include <attributes.h>
#define KERNEL_CS 0x08
@@ -22,12 +22,12 @@ typedef struct {
* Bits 3-0: bits 1110 = decimal 14 = "32 bit interrupt gate" */
uint8_t flags;
uint16_t high_offset; /* Higher 16 bits of handler function address */
} packed idt_gate_t;
} att_packed idt_gate_t;
typedef struct {
uint16_t limit;
uint32_t base;
} packed idt_register_t;
} att_packed idt_register_t;
#define IDT_REGISTERS 256

View File

@@ -5,7 +5,7 @@
#ifndef NEW_KERNEL_DRIVER_H
#define NEW_KERNEL_DRIVER_H
#include <myke/attributes.h>
#include <attributes.h>
#include <myke/preprocessor_format_zero.h>
#ifndef STRUCT_ALIGNMENT

View File

@@ -8,7 +8,7 @@
#include <sys/types.h>
#include <myke/driver.h>
#include <stdbool.h>
#include <myke/attributes.h>
#include <attributes.h>
#define PCI_CLASS_MASS_STORAGE 0x01
#define PCI_CLASS_BRIDGE 0x06
@@ -190,7 +190,7 @@ typedef union {
bool fast_b2b_enable: 1;
bool interrupt_disable: 1;
uint8_t reserved2: 5;
} packed command;
} att_packed command;
} pci_command_register_t;
typedef union {
@@ -209,7 +209,7 @@ typedef union {
bool received_master_abort: 1;
bool signaled_system_error: 1;
bool detected_parity_error: 1;
} packed status;
} att_packed status;
} pci_status_register_t;
void pci_print_info();

View File

@@ -5,7 +5,7 @@
#ifndef NEW_KERNEL_LIBK_H
#define NEW_KERNEL_LIBK_H
#include <myke/attributes.h>
#include <attributes.h>
#include <stdbool.h>
extern void *_kernel_start;
@@ -17,8 +17,8 @@ bool k_addr_in_kspace(void *addr);
void k_wait_for_interrupt();
void noreturn k_panics(const char *msg);
void att_noreturn k_panics(const char *msg);
void noreturn k_panic();
void att_noreturn k_panic();
#endif //NEW_KERNEL_LIBK_H

View File

@@ -6,14 +6,14 @@
#define NEW_KERNEL_SYSCALL_H
#include <sys/types.h>
#include <myke/attributes.h>
#include <attributes.h>
#define SYSCALL_START_SCHEDULER 0x01
#define SYSCALL_YIELD_JOB 0x02
#define SYSCALL_YIELD_IRQ 0x03
#define SYSCALL_SUSPEND 0x04
void noreturn syscall_start_scheduler();
void att_noreturn syscall_start_scheduler();
void syscall_yield_job();

View File

@@ -5,8 +5,8 @@
#ifndef NEW_KERNEL_POWER_H
#define NEW_KERNEL_POWER_H
#include <myke/attributes.h>
#include <attributes.h>
void noreturn power_shutdown();
void att_noreturn power_shutdown();
#endif //NEW_KERNEL_POWER_H