feat: added cross compiler and moved headers to include dir

This commit is contained in:
2021-03-09 19:45:20 +01:00
parent cefdb8ed90
commit dc4bf71b5a
77 changed files with 180 additions and 45 deletions

View File

@@ -1,20 +0,0 @@
//
// Created by rick on 22-02-21.
//
#ifndef NEW_KERNEL_CPU_H
#define NEW_KERNEL_CPU_H
#include <types.h>
typedef struct {
uint32_t edi, esi, ebx, ebp, eip;
} task_registers_t;
typedef struct {
uint32_t ds; // pushed in common handler
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; // pusha/popa
uint32_t int_no, err_code; // pushed by handlers
uint32_t eip, cs, eflags, useresp, ss; // isr/iret
} isr_registers_t;
#endif //NEW_KERNEL_CPU_H

View File

@@ -2,7 +2,7 @@
// Created by rick on 12-02-21.
//
#include "cpuidx.h"
#include <cpu/cpuidx.h>
#include <types.h>
#include <cpuid.h>

View File

@@ -1,139 +0,0 @@
//
// Created by rick on 12-02-21.
//
#ifndef NEW_KERNEL_CPUIDX_H
#define NEW_KERNEL_CPUIDX_H
#include <stdbool.h>
typedef struct {
bool sse3: 1;
bool pclmul: 1;
bool dtes64: 1;
bool monitor: 1;
bool ds_cpl: 1;
bool vmx: 1;
bool smx: 1;
bool est: 1;
bool tm2: 1;
bool ssse3: 1;
bool cid: 1;
bool reserved: 1;
bool fma: 1;
bool cx16: 1;
bool etprd: 1;
bool pdcm: 1;
bool pcide: 1;
bool dca: 1;
bool sse4_1: 1;
bool sse4_2: 1;
bool x2APIC: 1;
bool movbe: 1;
bool popcnt: 1;
bool reserved2: 1;
bool aes: 1;
bool xsave: 1;
bool osxsave: 1;
bool avx: 1;
} cpu_features_ecx ;
typedef struct {
bool fpu: 1;
bool vme: 1;
bool de: 1;
bool pse: 1;
bool tsc: 1;
bool msr: 1;
bool pae: 1;
bool mce: 1;
bool cx8: 1;
bool apic: 1;
bool reserved: 1;
bool sep: 1;
bool mtrr: 1;
bool pge: 1;
bool mca: 1;
bool cmov: 1;
bool pat: 1;
bool pse36: 1;
bool psn: 1;
bool clf: 1;
bool reserved2: 1;
bool dtes: 1;
bool acpi: 1;
bool mmx: 1;
bool fxsr: 1;
bool sse: 1;
bool sse2: 1;
bool ss: 1;
bool htt: 1;
bool tm1: 1;
bool ia64: 1;
bool pbe: 1;
} cpu_features_edx ;
enum cpu_features {
CPUID_FEAT_ECX_SSE3 = 1 << 0,
CPUID_FEAT_ECX_PCLMUL = 1 << 1,
CPUID_FEAT_ECX_DTES64 = 1 << 2,
CPUID_FEAT_ECX_MONITOR = 1 << 3,
CPUID_FEAT_ECX_DS_CPL = 1 << 4,
CPUID_FEAT_ECX_VMX = 1 << 5,
CPUID_FEAT_ECX_SMX = 1 << 6,
CPUID_FEAT_ECX_EST = 1 << 7,
CPUID_FEAT_ECX_TM2 = 1 << 8,
CPUID_FEAT_ECX_SSSE3 = 1 << 9,
CPUID_FEAT_ECX_CID = 1 << 10,
CPUID_FEAT_ECX_FMA = 1 << 12,
CPUID_FEAT_ECX_CX16 = 1 << 13,
CPUID_FEAT_ECX_ETPRD = 1 << 14,
CPUID_FEAT_ECX_PDCM = 1 << 15,
CPUID_FEAT_ECX_PCIDE = 1 << 17,
CPUID_FEAT_ECX_DCA = 1 << 18,
CPUID_FEAT_ECX_SSE4_1 = 1 << 19,
CPUID_FEAT_ECX_SSE4_2 = 1 << 20,
CPUID_FEAT_ECX_x2APIC = 1 << 21,
CPUID_FEAT_ECX_MOVBE = 1 << 22,
CPUID_FEAT_ECX_POPCNT = 1 << 23,
CPUID_FEAT_ECX_AES = 1 << 25,
CPUID_FEAT_ECX_XSAVE = 1 << 26,
CPUID_FEAT_ECX_OSXSAVE = 1 << 27,
CPUID_FEAT_ECX_AVX = 1 << 28,
CPUID_FEAT_EDX_FPU = 1 << 0,
CPUID_FEAT_EDX_VME = 1 << 1,
CPUID_FEAT_EDX_DE = 1 << 2,
CPUID_FEAT_EDX_PSE = 1 << 3,
CPUID_FEAT_EDX_TSC = 1 << 4,
CPUID_FEAT_EDX_MSR = 1 << 5,
CPUID_FEAT_EDX_PAE = 1 << 6,
CPUID_FEAT_EDX_MCE = 1 << 7,
CPUID_FEAT_EDX_CX8 = 1 << 8,
CPUID_FEAT_EDX_APIC = 1 << 9,
CPUID_FEAT_EDX_SEP = 1 << 11,
CPUID_FEAT_EDX_MTRR = 1 << 12,
CPUID_FEAT_EDX_PGE = 1 << 13,
CPUID_FEAT_EDX_MCA = 1 << 14,
CPUID_FEAT_EDX_CMOV = 1 << 15,
CPUID_FEAT_EDX_PAT = 1 << 16,
CPUID_FEAT_EDX_PSE36 = 1 << 17,
CPUID_FEAT_EDX_PSN = 1 << 18,
CPUID_FEAT_EDX_CLF = 1 << 19,
CPUID_FEAT_EDX_DTES = 1 << 21,
CPUID_FEAT_EDX_ACPI = 1 << 22,
CPUID_FEAT_EDX_MMX = 1 << 23,
CPUID_FEAT_EDX_FXSR = 1 << 24,
CPUID_FEAT_EDX_SSE = 1 << 25,
CPUID_FEAT_EDX_SSE2 = 1 << 26,
CPUID_FEAT_EDX_SS = 1 << 27,
CPUID_FEAT_EDX_HTT = 1 << 28,
CPUID_FEAT_EDX_TM1 = 1 << 29,
CPUID_FEAT_EDX_IA64 = 1 << 30,
CPUID_FEAT_EDX_PBE = 1 << 31
};
void cpuidx_print_info();
#endif //NEW_KERNEL_CPUIDX_H

View File

@@ -2,7 +2,7 @@
// Created by rick on 8/18/19.
//
#include "idt.h"
#include <cpu/idt.h>
idt_gate_t idt[IDT_REGISTERS];
idt_register_t idt_reg;

View File

@@ -1,37 +0,0 @@
//
// Created by rick on 8/18/19.
//
#include <types.h>
#ifndef MY_KERNEL_IDT_H
#define MY_KERNEL_IDT_H
#include <attributes.h>
#define KERNEL_CS 0x08
/* How every interrupt gate (handler) is defined */
typedef struct {
uint16_t low_offset; /* Lower 16 bits of handler function address */
uint16_t sel; /* Kernel segment selector */
uint8_t always0;
/* First byte
* Bit 7: "Interrupt is present"
* Bits 6-5: Privilege level of caller (0=kernel..3=user)
* Bit 4: Set to 0 for interrupt gates
* 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;
typedef struct {
uint16_t limit;
uint32_t base;
} packed idt_register_t;
#define IDT_REGISTERS 256
void set_idt_gate(int n, uint32_t handler);
void set_idt();
#endif //MY_KERNEL_IDT_H

View File

@@ -2,7 +2,7 @@
// Created by rick on 8/18/19.
//
#include "isr.h"
#include <cpu/isr.h>
#include <debug/debug.h>
#include <cpu/idt.h>

View File

@@ -1,137 +0,0 @@
//
// Created by rick on 8/18/19.
//
#include <types.h>
#ifndef MY_KERNEL_ISR_H
#define MY_KERNEL_ISR_H
#include <cpu/cpu.h>
/* ISRs reserved for CPU exceptions */
extern void isr0();
extern void isr1();
extern void isr2();
extern void isr3();
extern void isr4();
extern void isr5();
extern void isr6();
extern void isr7();
extern void isr8();
extern void isr9();
extern void isr10();
extern void isr11();
extern void isr12();
extern void isr13();
extern void isr14();
extern void isr15();
extern void isr16();
extern void isr17();
extern void isr18();
extern void isr19();
extern void isr20();
extern void isr21();
extern void isr22();
extern void isr23();
extern void isr24();
extern void isr25();
extern void isr26();
extern void isr27();
extern void isr28();
extern void isr29();
extern void isr30();
extern void isr31();
/* IRQ definitions */
extern void irq0();
extern void irq1();
extern void irq2();
extern void irq3();
extern void irq4();
extern void irq5();
extern void irq6();
extern void irq7();
extern void irq8();
extern void irq9();
extern void irq10();
extern void irq11();
extern void irq12();
extern void irq13();
extern void irq14();
extern void irq15();
extern void isr128();
#define IRQ0 32
#define IRQ1 33
#define IRQ2 34
#define IRQ3 35
#define IRQ4 36
#define IRQ5 37
#define IRQ6 38
#define IRQ7 39
#define IRQ8 40
#define IRQ9 41
#define IRQ10 42
#define IRQ11 43
#define IRQ12 44
#define IRQ13 45
#define IRQ14 46
#define IRQ15 47
typedef void (*isr_t)(isr_registers_t*);
void register_interrupt_handler(uint8_t n, isr_t handler);
void isr_install();
void isr_handler(isr_registers_t r);
#endif //MY_KERNEL_ISR_H

View File

@@ -2,7 +2,7 @@
// Created by rick on 24-02-21.
//
#include "syscall_handler.h"
#include <cpu/syscall_handler.h>
#include <libk/syscall.h>
#include <tasks/task.h>

View File

@@ -1,11 +0,0 @@
//
// Created by rick on 24-02-21.
//
#ifndef NEW_KERNEL_SYSCALL_HANDLER_H
#define NEW_KERNEL_SYSCALL_HANDLER_H
#include <cpu/cpu.h>
void syscall_handle(isr_registers_t *registers);
#endif //NEW_KERNEL_SYSCALL_HANDLER_H

View File

@@ -2,7 +2,7 @@
// Created by rick on 9/22/19.
//
#include "timer.h"
#include <cpu/timer.h>
#include <drivers/ports.h>
#include <cpu/isr.h>
@@ -63,8 +63,8 @@ int init_timer(uint32_t freq) {
register_interrupt_handler(IRQ0, timer_callback);
uint32_t divisor = 1193180 / freq;
uint8_t low = (uint8_t) (divisor & 0xFF);
uint8_t high = (uint8_t) ((divisor >> 8) & 0xFF);
uint8_t low = (uint8_t)(divisor & 0xFF);
uint8_t high = (uint8_t)((divisor >> 8) & 0xFF);
port_byte_out(PORT_PIT_COMMAND,
PIT_MODE_BIN | PIT_MODE_HARDWARE_SQUARE_WAVE_GENERATOR | PIT_ACCESS_MODE_LH | PIT_CHANNEL_0);
port_byte_out(PORT_PIT_DATA_0, low);

View File

@@ -1,18 +0,0 @@
//
// Created by rick on 9/22/19.
//
#ifndef MY_KERNEL_TIMER_H
#define MY_KERNEL_TIMER_H
#include <types.h>
int init_timer(uint32_t freq);
void print_current_tick();
uint32_t timer_get_tick();
void sleep(uint32_t milliseconds);
#endif //MY_KERNEL_TIMER_H