This commit is contained in:
rami 2024-05-26 01:33:18 -05:00
parent 7830b92f87
commit 8263d72e6c
30 changed files with 50 additions and 50 deletions

View File

@ -1,11 +1,11 @@
CC = i686-elf-gcc
INCLUDE = -I./include -I./lib
CFLAGS = -Wall -Wextra -Werror -ffreestanding $(INCLUDE)
LDFLAGS = -T kernel.ld -ffreestanding -O3 -nostdlib -lgcc
LDFLAGS = -T kernel/kernel.ld -ffreestanding -O3 -nostdlib -lgcc
BUILDDIR = build
KERNELSRC := $(shell find . -name '*.c' -o -name '*.asm')
KERNELSRC := $(shell find ./kernel -name '*.c' -o -name '*.asm')
KERNELOBJ := $(addprefix $(BUILDDIR)/, \
$(notdir \
$(patsubst %.c,%.o,\
@ -28,9 +28,9 @@ kernel: $(KERNELIMG)
$(KERNELIMG): $(KERNELOBJ)
$(CC) $^ -o $@ $(LDFLAGS)
$(BUILDDIR)/%.o: %.c
$(BUILDDIR)/%.o: */%.c
$(CC) $(CFLAGS) -c $^ -o $@
$(BUILDDIR)/%.o: %.asm
$(BUILDDIR)/%.o: */%.asm
nasm -felf32 $^ -o $@
qemu: kernel

View File

@ -2,7 +2,7 @@
#define RK_GDT_H_
#include <stdint.h>
#include <mem.h>
#include <kernel/mem.h>
#define GDT_NULL 0
#define GDT_KERNEL_CODE 1

View File

@ -1,8 +1,8 @@
#ifndef RK_KERNEL_H_
#define RK_KERNEL_H_
#include <multiboot.h>
#include <acpi.h>
#include <kernel/multiboot.h>
#include <kernel/acpi.h>
struct kernel_context {
struct rsdp *rsdp;

View File

@ -1,7 +1,7 @@
#ifndef RK_MEM_H_
#define RK_MEM_H_
#include <kernel.h>
#include <kernel/kernel.h>
#include <stdint.h>
#define KERNEL_START 0x1000000 // 1 MiB

View File

@ -2,7 +2,7 @@
#define RK_PCI_H_
#include <stdint.h>
#include <acpi.h>
#include <kernel/acpi.h>
#define PCI_ADDR(addr, bus, device, func) (addr + ((bus) << 20 | device << 15 | func << 12))

View File

@ -14,7 +14,7 @@
#define PIC_1_ICW3 0x04
#define PIC_2_ICW3 0x02
#include <io.h>
#include <kernel/io.h>
enum ICW1 {
ICW4_NEEDED = 0x01,

View File

@ -1,5 +1,5 @@
#include <acpi.h>
#include <strcmp.h>
#include <kernel/acpi.h>
#include <kernel/strcmp.h>
struct rsdp *acpi_locate_rsdp() {
char *ptr = (char *)BIOS_START;

View File

@ -1,4 +1,4 @@
#include <gdt.h>
#include <kernel/gdt.h>
void write_tss(struct tss_entry *tss, struct gdt_entry *gdt, int num, uint16_t ss0, uint32_t esp0) {
uint32_t base = (uint32_t)tss;

View File

@ -1,6 +1,6 @@
#include <ide.h>
#include <io.h>
#include <printf.h>
#include <kernel/ide.h>
#include <kernel/io.h>
#include <kernel/printf.h>
uint16_t ide_select_drive(uint8_t bus, uint8_t drive) {
if (bus == ATA_PRIMARY) {

View File

@ -1,6 +1,6 @@
#include <idt.h>
#include <vga.h>
#include <printf.h>
#include <kernel/idt.h>
#include <kernel/vga.h>
#include <kernel/printf.h>
void encode_idt_entry(struct idt_entry idt[], int i, uint32_t offset, uint16_t segment_selector, uint8_t attributes) {
idt[i].offset_lo = (uint16_t)(offset & 0xFFFF);

View File

@ -1,4 +1,4 @@
#include <io.h>
#include <kernel/io.h>
uint8_t inportb(uint16_t port) {
uint8_t result;

View File

@ -1,16 +1,16 @@
#include <kernel.h>
#include <multiboot.h>
#include <acpi.h>
#include <vga.h>
#include <pci.h>
#include <printf.h>
#include <strcmp.h>
#include <gdt.h>
#include <idt.h>
#include <pic8259.h>
#include <ps2.h>
#include <ide.h>
#include <mem.h>
#include <kernel/kernel.h>
#include <kernel/multiboot.h>
#include <kernel/acpi.h>
#include <kernel/vga.h>
#include <kernel/pci.h>
#include <kernel/printf.h>
#include <kernel/strcmp.h>
#include <kernel/gdt.h>
#include <kernel/idt.h>
#include <kernel/pic8259.h>
#include <kernel/ps2.h>
#include <kernel/ide.h>
#include <kernel/mem.h>
#define MAGIC_BREAKPOINT __asm__ volatile("xchgw %bx, %bx");
#define FD_STDOUT 0

View File

@ -1,5 +1,5 @@
#include <mem.h>
#include <printf.h>
#include <kernel/mem.h>
#include <kernel/printf.h>
// TODO: Fix this, it wastes memory when switching regions because the previous offset isnt being subtracted
// Should work fine for now?

View File

@ -1,4 +1,4 @@
#include <pci.h>
#include <kernel/pci.h>
struct pci_config_space *pcie_find_device(struct mcfg *mcfg, uint8_t class, uint8_t subclass) {
int entries = (mcfg->h.Length - 44) / 16;

View File

@ -1,4 +1,4 @@
#include <pic8259.h>
#include <kernel/pic8259.h>
void pic_send_eoi(uint8_t irq) {
if (irq > 7)

View File

@ -33,7 +33,7 @@
#include <stdbool.h>
#include <stdint.h>
#include "printf.h"
#include <kernel/printf.h>
// define this globally (e.g. gcc -DPRINTF_INCLUDE_CONFIG_H ...) to include the

View File

@ -1,11 +1,11 @@
#include <ps2.h>
#include <io.h>
#include <pic8259.h>
#include <vga.h>
#include <printf.h>
#include <strcmp.h>
#include <ide.h>
#include <mem.h>
#include <kernel/ps2.h>
#include <kernel/io.h>
#include <kernel/pic8259.h>
#include <kernel/vga.h>
#include <kernel/printf.h>
#include <kernel/strcmp.h>
#include <kernel/ide.h>
#include <kernel/mem.h>
#define cpu_relax asm volatile ("pause" ::);

View File

@ -1,4 +1,4 @@
#include <strcmp.h>
#include <kernel/strcmp.h>
int strcmp(const char *s1, const char *s2)
{

View File

@ -6,9 +6,9 @@
* @date 2024-02-03
*/
#include <vga.h>
#include <io.h>
#include <printf.h>
#include <kernel/vga.h>
#include <kernel/io.h>
#include <kernel/printf.h>
enum VGA_COLOR vga_color = VGA_COLOR_WHITE;