├── .gitignore ├── Makefile ├── OVMF_CODE.fd ├── README.md ├── font.old ├── include ├── acpi │ └── acpi.h ├── arch │ └── x86 │ │ └── registers.h ├── assert.h ├── audio │ └── pcspk.h ├── bootloader.h ├── ctype.h ├── debugout.h ├── disks │ └── sata.h ├── forceInclude.h ├── fs │ └── ramfs.h ├── gdt │ └── gdt.h ├── gpt.h ├── idt │ ├── idt.h │ └── interrupts.h ├── init.h ├── io.h ├── kernel.h ├── kernelDefines.h ├── limine.h ├── math.h ├── memory │ ├── malloc.h │ └── mem.h ├── pci │ └── pci.h ├── stdio.h ├── string.h ├── time.h ├── tty.h ├── tty │ └── fbCon.h ├── userinput │ ├── cursor.h │ ├── keyboard.h │ └── mouse.h └── video │ ├── renderer.h │ └── video.h ├── kernel ├── acpi │ └── acpi.c ├── audio │ └── pcspk.c ├── boot │ ├── checkLoader.c │ └── limine │ │ ├── check.c │ │ └── framebuffer.c ├── disks │ └── sata.c ├── fs │ └── ramfs.c ├── gdt │ ├── gdt.c │ └── gdtasm.asm ├── gpt.c ├── idt │ ├── idt.c │ └── interrupts.c ├── init.c ├── io.c ├── kernel.c ├── log.c ├── memory │ ├── malloc.c │ └── mem.c ├── panic.c ├── pci │ ├── pci.c │ └── pciDesc.c ├── serial │ └── comout.c ├── string.c ├── time.c ├── tty.c ├── userinput │ ├── keyboard.c │ └── mouse.c └── video │ ├── ansi.c │ ├── fbcon.c │ ├── printf.c │ ├── printf.h │ ├── renderer.c │ └── video.c ├── limine.cfg ├── limine.h ├── linker.ld ├── rootfs ├── dev │ └── tmp ├── etc │ └── tmp ├── home │ ├── root │ │ ├── no.txt │ │ └── yes.txt │ └── tmp ├── usr │ └── tmp ├── var │ └── tmp └── yes.txt ├── tools ├── __pycache__ │ ├── misc.cpython-310.pyc │ └── misc.cpython-39.pyc ├── cursor.png ├── icontest ├── iso.sh ├── misc.py ├── navcc.perl ├── picsofbread.h └── picsofbread.png └── vgafont.f16 /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.d 3 | *.elf 4 | limine/ 5 | iso_root/ 6 | initramfs 7 | *.iso 8 | .vscode 9 | log.txt 10 | test.disk 11 | !kernel/boot/limine 12 | build/ -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # This is the name that our final kernel executable will have. 2 | # Change as needed. 3 | override KERNEL := bin/kernel.elf 4 | 5 | # Convenience macro to reliably declare overridable command variables. 6 | define DEFAULT_VAR = 7 | ifeq ($(origin $1),default) 8 | override $(1) := $(2) 9 | endif 10 | ifeq ($(origin $1),undefined) 11 | override $(1) := $(2) 12 | endif 13 | endef 14 | 15 | # It is highly recommended to use a custom built cross toolchain to build a kernel. 16 | # We are only using "cc" as a placeholder here. It may work by using 17 | # the host system's toolchain, but this is not guaranteed. 18 | $(eval $(call DEFAULT_VAR,CC,cc)) 19 | 20 | # Same thing for "ld" (the linker). 21 | $(eval $(call DEFAULT_VAR,LD,ld)) 22 | 23 | # User controllable CFLAGS. 24 | CFLAGS ?= -g -Wall -Wextra -pipe 25 | 26 | # User controllable preprocessor flags. We set none by default. 27 | #CPPFLAGS ?= -Wno-c++20-extensions -fno-threadsafe-statics 28 | 29 | # User controllable nasm flags. 30 | NASMFLAGS ?= -F dwarf -g 31 | 32 | # User controllable linker flags. We set none by default. 33 | LDFLAGS ?= 34 | 35 | # Internal C flags that should not be changed by the user. 36 | override CFLAGS += \ 37 | -std=gnu2x \ 38 | -I. \ 39 | -ffreestanding \ 40 | -fno-stack-protector \ 41 | -fno-stack-check \ 42 | -fno-pie \ 43 | -fno-pic \ 44 | -m64 \ 45 | -march=x86-64 \ 46 | -mabi=sysv \ 47 | -mno-80387 \ 48 | -mno-mmx \ 49 | -mno-sse \ 50 | -mno-sse2 \ 51 | -mno-red-zone \ 52 | -mcmodel=kernel \ 53 | -Iinclude/ \ 54 | -include include/forceInclude.h \ 55 | -Wno-unused-parameter \ 56 | -Wno-missing-field-initializers \ 57 | -Wno-address \ 58 | -Wno-int-to-pointer-cast \ 59 | -Wno-pointer-arith \ 60 | -Wno-write-strings \ 61 | -Wno-cast-function-type \ 62 | -Wno-return-type \ 63 | -nostdlib 64 | 65 | # Internal linker flags that should not be changed by the user. 66 | override LDFLAGS += \ 67 | -nostdlib \ 68 | -static \ 69 | -z max-page-size=0x1000 \ 70 | -T linker.ld 71 | 72 | # Internal nasm flags that should not be changed by the user. 73 | override NASMFLAGS += \ 74 | -f elf64 75 | 76 | # Use find to glob all *.c, *.S, and *.asm files in the directory and extract the object names. 77 | #override CPPFILES := $(shell cd kernel && find . -type f -name '*.cpp') 78 | override NASMFILES := $(shell cd kernel && find . -type f -name '*.asm') 79 | override CFILES := $(shell cd kernel && find . -type f -name '*.c') 80 | #override OBJ_CPP := $(subst .cpp,.o,$(CPPFILES)) 81 | override OBJ_C := $(subst .c,.o,$(CFILES)) 82 | override OBJ_ASM := $(subst .asm,.o,$(NASMFILES)) 83 | override OBJ := $(subst ./,build/kernel/,$(OBJ_ASM) $(OBJ_C)) build/font.f16.bin.o 84 | 85 | #test: 86 | # @echo $(OBJ) 87 | 88 | # Default target. 89 | .PHONY: all 90 | all: $(KERNEL) 91 | 92 | # Link rules for the final kernel executable. 93 | $(KERNEL): $(OBJ) 94 | @mkdir -p $(@D) 95 | @echo " LD $(subst build/,,$(subst ./,,$(subst kernel/,,$(OBJ)))) ==> $@" 96 | @$(LD) $(subst ./,build/,$(OBJ)) $(LDFLAGS) -o $@ 97 | 98 | # Compilation rules for *.c files. 99 | # build/%.o: %.cpp 100 | # @mkdir -p $(@D) 101 | # @echo " CXX $@" 102 | # @g++ $(CPPFLAGS) $(CFLAGS) -c $< -o $@ 103 | 104 | build/%.o: %.c 105 | @mkdir -p $(@D) 106 | @echo " CC $@" 107 | @gcc $(CFLAGS) -std=gnu2x -c $< -o $@ 108 | 109 | # Compilation rules for *.asm (nasm) files. 110 | build/%.o: %.asm 111 | @mkdir -p $(@D) 112 | @echo " NASM $@" 113 | @nasm $(NASMFLAGS) $< -o $@ 114 | 115 | build/font.f16.bin.o: vgafont.f16 116 | @$(info $s PERL vgafont.f16 ==> font.f16.c) 117 | @perl tools/navcc.perl vgafont.f16 > build/font.f16.c 118 | @$(info $s CC font.f16.c ==> font.bin.f16.o) 119 | @$(CC) -c -Wno-gnu-binary-literal -std=gnu2x build/font.f16.c -o build/font.f16.bin.o 120 | 121 | # Remove object files and the final executable. 122 | .PHONY: clean 123 | clean: 124 | @rm -rf $(KERNEL) $(OBJ) $(HEADER_DEPS) limine initramfs iso_root/ bin/* 125 | @echo "Cleaned!" 126 | 127 | initramfs: 128 | @tar -cf initramfs --format=ustar -C rootfs/ . 129 | 130 | limine.h: 131 | @wget https://raw.githubusercontent.com/limine-bootloader/limine/trunk/limine.h -q 132 | 133 | iso: $(kernel) 134 | @make limine.h 135 | @make 136 | @make initramfs 137 | @rm -rf limine/ 138 | @git clone https://github.com/limine-bootloader/limine.git --branch=v7.x-binary --depth=1 --quiet 139 | 140 | @mkdir -p iso_root 141 | 142 | @cp bin/kernel.elf initramfs limine.cfg limine/*.sys \ 143 | limine/*.bin iso_root/ 144 | 145 | @./tools/iso.sh 146 | 147 | test.disk: 148 | qemu-img create test.disk 1G 149 | 150 | run: iso test.disk 151 | @qemu-system-x86_64 -hda test.disk -cdrom bin/image.iso -bios ./OVMF_CODE.fd -debugcon stdio -m 1G -smp 3 --enable-kvm -M q35 152 | 153 | debug: iso test.disk 154 | @qemu-system-x86_64 -hda test.disk -cdrom bin/image.iso -bios ./OVMF_CODE.fd -debugcon stdio -m 1G -d int -D log.txt -no-reboot -no-shutdown -M q35 -------------------------------------------------------------------------------- /OVMF_CODE.fd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mine-man3000/SeshOS/9f307bc6d703e36771f8db8cd39e2d42709750d0/OVMF_CODE.fd -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## BUILDING 2 | 3 | install gcc, nasm, qemu-system-x86_64, qemu-uefi, xorriso, and make 4 | 5 | for the debian/ubuntu/distros with APT, run ``sudo apt install build-essential qemu-system-x86 xorriso nasm`` 6 | 7 | then run ``make run`` and it will build and run the OS. 8 | 9 | ## TODO 10 | - [X] Load an IDT so that exceptions and interrupts can be handled. 11 | - [X] Memory Management 12 | - [ ] Scheduler 13 | - [X] Start up the other CPU cores 14 | - [ ] VFS 15 | - [ ] Elf loader 16 | - [ ] Userland -------------------------------------------------------------------------------- /font.old: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mine-man3000/SeshOS/9f307bc6d703e36771f8db8cd39e2d42709750d0/font.old -------------------------------------------------------------------------------- /include/acpi/acpi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | typedef struct { 5 | char signature[8]; 6 | uint8_t checksum; 7 | char OEMId[6]; 8 | uint8_t revision; 9 | uint32_t RSDTAddress; 10 | } __attribute__ ((packed)) RSDPDescriptor; 11 | 12 | typedef struct { 13 | RSDPDescriptor firstPart; 14 | 15 | uint32_t len; 16 | uint64_t XSTDAddress; 17 | uint8_t extendedChecksum; 18 | uint8_t reserved[3]; 19 | } __attribute__ ((packed)) RSDPDescriptor20; 20 | 21 | typedef struct { 22 | char signature[4]; 23 | uint32_t length; 24 | uint8_t revision; 25 | uint8_t checksum; 26 | char OEMId[6]; 27 | char OEMTableID[8]; 28 | uint32_t OEMRevision; 29 | uint32_t creatorID; 30 | uint32_t creatorRevision; 31 | } __attribute__ ((packed)) ACPISDTHeader; 32 | typedef struct { 33 | ACPISDTHeader h; 34 | // (h.length - sizeof(h)) / 4 35 | uint32_t pointerToOtherSDT[]; 36 | } __attribute__ ((packed)) RSDT; 37 | 38 | typedef struct { 39 | ACPISDTHeader Header; 40 | uint64_t Reserved; 41 | }__attribute__((packed)) MCFGHeader; 42 | 43 | typedef struct { 44 | uint64_t BaseAddress; 45 | uint16_t PCISegGroup; 46 | uint8_t StartBus; 47 | uint8_t EndBus; 48 | uint32_t Reserved; 49 | }__attribute__((packed)) DeviceConfig; 50 | 51 | extern MCFGHeader* mcfg; 52 | extern void ACPI_Init(); -------------------------------------------------------------------------------- /include/arch/x86/registers.h: -------------------------------------------------------------------------------- 1 | /* 2 | ====================== 3 | The original version of this file is Copyright (C)Techflash Software, 2021 - 2023. 4 | This is code from "Techflash OS", the hobbyist operating system developed by Techflash. 5 | You may find the original code at https://github.com/techflashYT/Techflash-OS/blob/master/include/kernel/log.h 6 | ====================== 7 | */ 8 | 9 | #pragma once 10 | typedef struct { 11 | uint64_t rdi, rsi, rbp, rbx, rdx, rcx, rax; 12 | uint64_t r8, r9, r10, r11, r12, r13, r14, r15; 13 | uint64_t intNo, errCode; 14 | uint64_t rip, cs, rflags, rsp, ss; 15 | } __attribute__((packed)) registers_t; -------------------------------------------------------------------------------- /include/assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | ====================== 3 | The original version of this file is Copyright (C)Techflash Software, 2021 - 2023. 4 | This is code from "Techflash OS", the hobbyist operating system developed by Techflash. 5 | You may find the original code at https://github.com/techflashYT/Techflash-OS/blob/master/include/assert.h 6 | ====================== 7 | */ 8 | 9 | 10 | // #include 11 | #include 12 | // #ifdef NDEBUG 13 | #define assert(expr) ((void)0) 14 | /* 15 | #else 16 | #define assert(expr)\ 17 | if (!(expr)) {\ 18 | DUMPREGS;\ 19 | char __assertStr[100];\ 20 | sprintf(__assertStr, "Assertion `%s' failed in file " __FILE__ ":%d\r\n", #expr, __LINE__);\ 21 | panic(__assertStr, regs);\ 22 | } 23 | #endif*/ -------------------------------------------------------------------------------- /include/audio/pcspk.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | void playSound(uint32_t nFrequence); 5 | void noSound(); 6 | void beep(); -------------------------------------------------------------------------------- /include/bootloader.h: -------------------------------------------------------------------------------- 1 | /* 2 | ====================== 3 | The original version of this file is Copyright (C)Techflash Software, 2021 - 2023. 4 | This is code from "Techflash OS", the hobbyist operating system developed by Techflash. 5 | You may find the original code at https://github.com/techflashYT/Techflash-OS/blob/master/include/kernel/bootloader.h 6 | ====================== 7 | */ 8 | 9 | #include 10 | extern uint_fast8_t BOOT_LoaderID; 11 | extern char BOOT_LoaderName[64]; 12 | extern char BOOT_LoaderVersion[64]; 13 | 14 | #define BOOT_LoaderID_Unknown 0 15 | #define BOOT_LoaderID_LimineCompatible 1 16 | 17 | 18 | extern void BOOT_CheckLoader(); -------------------------------------------------------------------------------- /include/ctype.h: -------------------------------------------------------------------------------- 1 | extern int isdigit(int ch); 2 | -------------------------------------------------------------------------------- /include/debugout.h: -------------------------------------------------------------------------------- 1 | extern void comout(const char* input); 2 | extern void comout_num(uint64_t num); 3 | 4 | extern void COM_LogWrapper(const char ch, const uint16_t x, const uint16_t y, const uint32_t fgColor, const uint32_t bgColor); -------------------------------------------------------------------------------- /include/disks/sata.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | typedef enum { 7 | None = 0, 8 | SATA = 1, 9 | SEMB = 2, 10 | PM = 3, 11 | SATAPI = 4 12 | } PortType; 13 | 14 | typedef enum { 15 | FIS_TYPE_REG_H2D = 0x27, 16 | FIS_TYPE_REG_D2H = 0x34, 17 | FIS_TYPE_DMA_ACT = 0x39, 18 | FIS_TYPE_DMA_SETUP = 0x41, 19 | FIS_TYPE_DATA = 0x46, 20 | FIS_TYPE_BIST = 0x58, 21 | FIS_TYPE_PIO_SETUP = 0x5F, 22 | FIS_TYPE_DEV_BITS = 0xA1 23 | } FIS_TYPE; 24 | 25 | typedef struct { 26 | uint32_t commandListBase; 27 | uint32_t commandListBaseUpper; 28 | uint32_t fisBaseAddress; 29 | uint32_t fisBaseAddressUpper; 30 | uint32_t interruptStatus; 31 | uint32_t interruptEnable; 32 | uint32_t cmdSts; 33 | uint32_t rsv0; 34 | uint32_t taskFileData; 35 | uint32_t signature; 36 | uint32_t sataStatus; 37 | uint32_t sataControl; 38 | uint32_t sataError; 39 | uint32_t sataActive; 40 | uint32_t commandIssue; 41 | uint32_t sataNotification; 42 | uint32_t fisSwitchControl; 43 | uint32_t rsv1[11]; 44 | uint32_t vendor[4]; 45 | } HBAPort; 46 | 47 | typedef struct { 48 | uint32_t hostCapability; 49 | uint32_t globalHostControl; 50 | uint32_t interruptStatus; 51 | uint32_t portsImplemented; 52 | uint32_t version; 53 | uint32_t cccControl; 54 | uint32_t cccPorts; 55 | uint32_t enclosureManagementLocation; 56 | uint32_t enclosureManagementControl; 57 | uint32_t hostCapabilitiesExtended; 58 | uint32_t biosHandoffCtrlSts; 59 | uint8_t rsv0[0x74]; 60 | uint8_t vendor[0x60]; 61 | HBAPort ports[1]; 62 | } HBAMemory; 63 | 64 | typedef struct { 65 | uint8_t commandFISLength:5; 66 | uint8_t atapi:1; 67 | uint8_t write:1; 68 | uint8_t prefetchable:1; 69 | uint8_t reset:1; 70 | uint8_t bist:1; 71 | uint8_t clearBusy:1; 72 | uint8_t rsv0:1; 73 | uint8_t portMultiplier:4; 74 | uint16_t prdtLength; 75 | uint32_t prdbCount; 76 | uint32_t commandTableBaseAddress; 77 | uint32_t commandTableBaseAddressUpper; 78 | uint32_t rsv1[4]; 79 | } HBACommandHeader; 80 | 81 | typedef struct { 82 | uint32_t dataBaseAddress; 83 | uint32_t dataBaseAddressUpper; 84 | uint32_t rsv0; 85 | uint32_t byteCount:22; 86 | uint32_t rsv1:9; 87 | uint32_t interruptOnCompletion:1; 88 | } HBAPRDTEntry; 89 | 90 | typedef struct { 91 | uint8_t commandFIS[64]; 92 | uint8_t atapiCommand[16]; 93 | uint8_t rsv[48]; 94 | HBAPRDTEntry prdtEntry[]; 95 | } HBACommandTable; 96 | 97 | typedef struct { 98 | uint8_t fisType; 99 | uint8_t portMultiplier:4; 100 | uint8_t rsv0:3; 101 | uint8_t commandControl:1; 102 | uint8_t command; 103 | uint8_t featureLow; 104 | uint8_t lba0; 105 | uint8_t lba1; 106 | uint8_t lba2; 107 | uint8_t deviceRegister; 108 | uint8_t lba3; 109 | uint8_t lba4; 110 | uint8_t lba5; 111 | uint8_t featureHigh; 112 | uint8_t countLow; 113 | uint8_t countHigh; 114 | uint8_t isoCommandCompletion; 115 | uint8_t control; 116 | uint8_t rsv1[4]; 117 | } FIS_REG_H2D; 118 | 119 | typedef struct { 120 | HBAPort* hbaPort; 121 | PortType portType; 122 | uint8_t* buffer; 123 | uint8_t portNumber; 124 | } Port; 125 | 126 | typedef struct { 127 | PCIDeviceHeader* PCIBaseAddress; 128 | HBAMemory* ABAR; 129 | Port* ports[32]; 130 | uint8_t portCount; 131 | } AHCIDriver; 132 | 133 | void Configure(Port* port); 134 | void StartCMD(Port* port); 135 | void StopCMD(Port* port); 136 | int Read(Port* port, uint64_t sector, uint32_t sectorCount, void* buffer); 137 | 138 | AHCIDriver* AHCIDriver_Init(PCIDeviceHeader* pciBaseAddress); 139 | void AHCIDriver_Destroy(AHCIDriver* driver); 140 | void AHCIDriver_ProbePorts(AHCIDriver* driver); -------------------------------------------------------------------------------- /include/forceInclude.h: -------------------------------------------------------------------------------- 1 | /* 2 | ====================== 3 | The original version of this file is Copyright (C)Techflash Software, 2021 - 2023. 4 | This is code from "Techflash OS", the hobbyist operating system developed by Techflash. 5 | You may find the original code at https://github.com/techflashYT/Techflash-OS/blob/master/include/kernel/log.h 6 | Another portion of this code is from https://github.com/techflashYT/Techflash-OS/blob/master/include/misc/defines.h 7 | Another portion of this code is from https://github.com/techflashYT/Techflash-OS/blob/master/include/kernel/registers.h 8 | ====================== 9 | */ 10 | 11 | 12 | #include 13 | // info that will almost never be useful except for when initially creating the code. 14 | #define LOGLEVEL_VERBOSE 0 15 | // info that could potentially be useful if having issues 16 | #define LOGLEVEL_DEBUG 1 17 | // info that could potentially be useful to an average user 18 | #define LOGLEVEL_INFO 2 19 | // something unexpected happened, this is a warning the user 20 | #define LOGLEVEL_WARN 3 21 | // something bad happened, we need to tell the user 22 | #define LOGLEVEL_ERROR 4 23 | // something EXTREMELY bad happened, this will usually be extended info just before a kernel panic. 24 | #define LOGLEVEL_FATAL 5 25 | extern void _log(const char module[8], const char *msg, const uint8_t level); 26 | 27 | #define MODULE(x) static const char *MODNAME = (x) 28 | #define log(msg, level) _log(MODNAME, msg, level) 29 | 30 | #define errorColor 0xFFFF4444 31 | #define warningColor 0xFFFFD866 32 | 33 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) 34 | 35 | 36 | #ifdef __x86_64__ 37 | #include 38 | #endif 39 | 40 | static inline void DUMPREGS(registers_t *regs) { 41 | asm ("mov %%rax, %0" : "=r" (regs->rax)); 42 | asm ("mov %%rbx, %0" : "=r" (regs->rbx)); 43 | asm ("mov %%rcx, %0" : "=r" (regs->rcx)); 44 | asm ("mov %%rdx, %0" : "=r" (regs->rdx)); 45 | asm ("mov %%rdi, %0" : "=r" (regs->rdi)); 46 | asm ("mov %%rsi, %0" : "=r" (regs->rsi)); 47 | asm ("mov %%rbp, %0" : "=r" (regs->rbp)); 48 | asm ("mov %%rsp, %0" : "=r" (regs->rsp)); 49 | asm ("mov %%r8, %0" : "=r" (regs->r8)); 50 | asm ("mov %%r9, %0" : "=r" (regs->r9)); 51 | asm ("mov %%r10, %0" : "=r" (regs->r10)); 52 | asm ("mov %%r11, %0" : "=r" (regs->r11)); 53 | asm ("mov %%r12, %0" : "=r" (regs->r12)); 54 | asm ("mov %%r13, %0" : "=r" (regs->r13)); 55 | asm ("mov %%r14, %0" : "=r" (regs->r14)); 56 | asm ("mov %%r15, %0" : "=r" (regs->r15)); 57 | asm ("mov %%cs, %0" : "=r" (regs->cs)); 58 | asm ("mov %%ss, %0" : "=r" (regs->ss)); 59 | asm ("sub $8, %%rsp; pushfq; popq %0; add $8, %%rsp" : "=r" (regs->rflags)); 60 | asm ("lea (%%rip), %0" : "=r" (regs->rip)); 61 | regs->intNo = 0x0; 62 | regs->errCode = 0x0; 63 | } -------------------------------------------------------------------------------- /include/fs/ramfs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | /* 7 | | offset | size | Description 8 | | 0 | 100 | File name 9 | | 100 | 8 | File mode 10 | | 108 | 8 | Owner's numeric user ID 11 | | 116 | 8 | Group's numeric user ID 12 | | 124 | 12 | File size in bytes (octal base) 13 | | 136 | 12 | Last modification time in numeric Unix time format (octal) 14 | | 148 | 8 | Checksum for header record 15 | | 156 | 1 | Type flag 16 | | 157 | 100 | Name of linked file 17 | | 257 | 6 | UStar indicator "ustar" then NUL 18 | | 263 | 2 | UStar version "00" 19 | | 265 | 32 | Owner user name 20 | | 297 | 32 | Owner group name 21 | | 329 | 8 | Device major number 22 | | 337 | 8 | Device minor number 23 | | 345 | 155 | Filename prefix 24 | */ 25 | 26 | /* Typeflag field definitions */ 27 | #define REGTYPE '0' /* Regular file. */ 28 | #define LNKTYPE '1' /* Link. */ 29 | #define SYMTYPE '2' /* Symbolic link. */ 30 | #define CHRTYPE '3' /* Character special. */ 31 | #define BLKTYPE '4' /* Block special. */ 32 | #define DIRTYPE '5' /* Directory. */ 33 | #define FIFOTYPE '6' /* FIFO special. */ 34 | #define CONTTYPE '7' /* Reserved. */ 35 | /* Mode field bit definitions (octal) */ 36 | #define TSUID 04000 /* Set UID on execution. */ 37 | #define TSGID 02000 /* Set GID on execution. */ 38 | #define TSVTX 01000 /* On directories, restricted deletion flag. */ 39 | #define TUREAD 00400 /* Read by owner. */ 40 | #define TUWRITE 00200 /* Write by owner. */ 41 | #define TUEXEC 00100 /* Execute/search by owner. */ 42 | #define TGREAD 00040 /* Read by group. */ 43 | #define TGWRITE 00020 /* Write by group. */ 44 | #define TGEXEC 00010 /* Execute/search by group. */ 45 | #define TOREAD 00004 /* Read by other. */ 46 | #define TOWRITE 00002 /* Write by other. */ 47 | #define TOEXEC 00001 /* Execute/search by other. */ 48 | 49 | struct tar_header 50 | { 51 | char filename[100]; 52 | char mode[8]; 53 | char uid[8]; 54 | char gid[8]; 55 | char size[12]; 56 | char mtime[12]; 57 | char chksum[8]; 58 | char typeflag[1]; 59 | }; 60 | 61 | 62 | extern struct tar_header *headers[32]; 63 | unsigned int parse(); 64 | unsigned int getsize(const char *in); 65 | char *readFile(char* fileToReadName); 66 | void ls(); -------------------------------------------------------------------------------- /include/gdt/gdt.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef struct { 4 | uint16_t Size; 5 | uint64_t Offset; 6 | } __attribute__((packed)) GDTDescriptor; 7 | 8 | typedef struct { 9 | uint16_t Limit0; 10 | uint16_t Base0; 11 | uint8_t Base1; 12 | uint8_t AccessByte; 13 | uint8_t Limit1_Flags; 14 | uint8_t Base2; 15 | }__attribute__((packed)) GDTEntry; 16 | 17 | typedef struct { 18 | GDTEntry Null; //0x00 19 | GDTEntry KernelCode; //0x08 20 | GDTEntry KernelData; //0x10 21 | GDTEntry UserNull; 22 | GDTEntry UserCode; 23 | GDTEntry UserData; 24 | } __attribute__((packed)) 25 | __attribute((aligned(0x1000))) GDT; 26 | 27 | extern GDT DefaultGDT; 28 | 29 | void LoadGDT(GDTDescriptor* gdtDescriptor); -------------------------------------------------------------------------------- /include/gpt.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef struct { 4 | uint64_t signature; 5 | uint32_t revision; 6 | uint32_t headerSize; 7 | uint32_t checksum; 8 | uint32_t reserved; 9 | uint64_t LBA; 10 | uint64_t LBAAlt; 11 | uint64_t firstUsableBlock; 12 | uint64_t lastUsableBlock; 13 | uint64_t guidPartOne; 14 | uint64_t guidPartTwo; 15 | uint64_t startLBA; 16 | uint32_t numParts; 17 | uint32_t entrySize; 18 | uint32_t CRC32; 19 | uint8_t a[420]; //hehe... nice 20 | } GPTTable; -------------------------------------------------------------------------------- /include/idt/idt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #define int_ta_gate 0b10001110 5 | #define int_ta_call_gate 0b10001100 6 | #define int_ta_trap_gate 0b10001111 7 | 8 | void create_idt(); 9 | 10 | typedef struct 11 | { 12 | uint16_t offset_0; 13 | uint16_t selector; 14 | uint8_t stack_list_offset; 15 | uint8_t type_attribute; 16 | uint16_t offset_1; 17 | uint32_t offset_2; 18 | uint32_t ignore; 19 | } InterruptEntry; 20 | 21 | void set_interrupt_offset(InterruptEntry* int_ptr, uint64_t offset); 22 | uint64_t get_interrupt_offset(InterruptEntry* int_ptr); 23 | 24 | typedef struct __attribute__((packed)) 25 | { 26 | uint16_t limit; 27 | uint64_t offset; 28 | } IDT; 29 | 30 | extern IDT idt; -------------------------------------------------------------------------------- /include/idt/interrupts.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include