feat: reformatted code base to be more standard
This commit is contained in:
@@ -22,6 +22,8 @@ FILE(GLOB_RECURSE kernel_src kernel/**.c)
|
||||
FILE(GLOB_RECURSE kernel_asm kernel/**.S)
|
||||
FILE(GLOB_RECURSE boot_asm boot/boot.S)
|
||||
|
||||
add_compile_definitions(__kernel__)
|
||||
|
||||
# Run IDE in DMA mode if available (NYI)
|
||||
#add_compile_definitions(IDE_ENABLE_INTERRUPT)
|
||||
# Run the kernel shell as the main task
|
||||
|
||||
8
include/errno.h
Normal file
8
include/errno.h
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by rick on 10-03-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_ERRNO_H
|
||||
#define NEW_KERNEL_ERRNO_H
|
||||
|
||||
#endif //NEW_KERNEL_ERRNO_H
|
||||
@@ -1,8 +0,0 @@
|
||||
//
|
||||
// Created by rick on 07-02-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_FAT_H
|
||||
#define NEW_KERNEL_FAT_H
|
||||
|
||||
#endif //NEW_KERNEL_FAT_H
|
||||
@@ -1,12 +0,0 @@
|
||||
//
|
||||
// Created by rick on 06-02-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_KPRINTF_H
|
||||
#define NEW_KERNEL_KPRINTF_H
|
||||
|
||||
int printf(const char *fmt, ...);
|
||||
|
||||
int sprintf(char *target, const char *fmt, ...);
|
||||
|
||||
#endif //NEW_KERNEL_KPRINTF_H
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* libc.h
|
||||
*
|
||||
* Created on: Oct 11, 2018
|
||||
* Author: rick
|
||||
*/
|
||||
|
||||
#ifndef KERNEL_LIBC_LIBC_H_
|
||||
#define KERNEL_LIBC_LIBC_H_
|
||||
|
||||
#include <types.h>
|
||||
|
||||
int memcpy(uint8_t *dst, const uint8_t *src, int amount);
|
||||
|
||||
int memset(uint8_t *dst, char data, int amount);
|
||||
|
||||
char *itoa(int value, char *buffer, int base);
|
||||
|
||||
int abs(int val);
|
||||
|
||||
int maxi(int a, int b);
|
||||
|
||||
int mini(int a, int b);
|
||||
|
||||
#endif /* KERNEL_LIBC_LIBC_H_ */
|
||||
@@ -1,11 +0,0 @@
|
||||
//
|
||||
// Created by rick on 06-03-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_SORT_H
|
||||
#define NEW_KERNEL_SORT_H
|
||||
#include <types.h>
|
||||
|
||||
void qsort(void *base, size_t num, size_t size, int (*compar)(const void *, const void *));
|
||||
|
||||
#endif //NEW_KERNEL_SORT_H
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#ifndef NEW_KERNEL_CPU_H
|
||||
#define NEW_KERNEL_CPU_H
|
||||
#include <types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct {
|
||||
uint32_t edi, esi, ebx, ebp, eip;
|
||||
@@ -1,11 +1,11 @@
|
||||
//
|
||||
// Created by rick on 8/18/19.
|
||||
//
|
||||
#include <types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef MY_KERNEL_IDT_H
|
||||
#define MY_KERNEL_IDT_H
|
||||
#include <attributes.h>
|
||||
#include <myke/attributes.h>
|
||||
|
||||
#define KERNEL_CS 0x08
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
// Created by rick on 8/18/19.
|
||||
//
|
||||
|
||||
#include <types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef MY_KERNEL_ISR_H
|
||||
#define MY_KERNEL_ISR_H
|
||||
|
||||
#include <cpu/cpu.h>
|
||||
#include <myke/cpu/cpu.h>
|
||||
|
||||
/* ISRs reserved for CPU exceptions */
|
||||
extern void isr0();
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#ifndef NEW_KERNEL_SYSCALL_HANDLER_H
|
||||
#define NEW_KERNEL_SYSCALL_HANDLER_H
|
||||
#include <cpu/cpu.h>
|
||||
#include <myke/cpu/cpu.h>
|
||||
|
||||
void syscall_handle(isr_registers_t *registers);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef MY_KERNEL_TIMER_H
|
||||
#define MY_KERNEL_TIMER_H
|
||||
|
||||
#include <types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int init_timer(uint32_t freq);
|
||||
|
||||
@@ -4,10 +4,14 @@
|
||||
|
||||
#ifndef NEW_KERNEL_DEBUG_H
|
||||
#define NEW_KERNEL_DEBUG_H
|
||||
#include <multiboot.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef DEBUG_INIT
|
||||
#include <multiboot.h>
|
||||
|
||||
void debug_store_info(struct multiboot_info *info);
|
||||
#endif
|
||||
|
||||
void debug_backtrace(bool do_sync);
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#ifndef NEW_KERNEL_DRIVER_H
|
||||
#define NEW_KERNEL_DRIVER_H
|
||||
#include <attributes.h>
|
||||
#include <preprocessor_format_zero.h>
|
||||
#include <myke/attributes.h>
|
||||
#include <myke/preprocessor_format_zero.h>
|
||||
|
||||
#ifndef STRUCT_ALIGNMENT
|
||||
#define STRUCT_ALIGNMENT 16
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef NEW_KERNEL_IDE_H
|
||||
#define NEW_KERNEL_IDE_H
|
||||
|
||||
#include <types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
uint8_t ide_access(uint8_t direction, uint8_t drive, uint32_t lba, uint8_t numsects, void *target);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef MY_KERNEL_KEYBOARD_H
|
||||
#define MY_KERNEL_KEYBOARD_H
|
||||
|
||||
#include <types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct KeyEvent_t {
|
||||
// KeyCode key;
|
||||
@@ -5,10 +5,10 @@
|
||||
#ifndef NEW_KERNEL_PCI_H
|
||||
#define NEW_KERNEL_PCI_H
|
||||
|
||||
#include <types.h>
|
||||
#include <driver.h>
|
||||
#include <sys/types.h>
|
||||
#include <myke/driver.h>
|
||||
#include <stdbool.h>
|
||||
#include <attributes.h>
|
||||
#include <myke/attributes.h>
|
||||
|
||||
#define PCI_CLASS_MASS_STORAGE 0x01
|
||||
#define PCI_CLASS_BRIDGE 0x06
|
||||
@@ -4,7 +4,7 @@
|
||||
#ifndef NEW_KERNEL_PCI_DEVICES_H
|
||||
#define NEW_KERNEL_PCI_DEVICES_H
|
||||
|
||||
#include <types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct pci_device_info_t {
|
||||
uint8_t code;
|
||||
@@ -5,8 +5,8 @@
|
||||
#ifndef NEW_KERNEL_ELF_H
|
||||
#define NEW_KERNEL_ELF_H
|
||||
|
||||
#include <types.h>
|
||||
#include <attributes.h>
|
||||
#include <sys/types.h>
|
||||
#include <myke/attributes.h>
|
||||
|
||||
#define SHT_NULL 0
|
||||
#define SHT_PROGBITS 1
|
||||
@@ -5,8 +5,8 @@
|
||||
#ifndef NEW_KERNEL_BLOCKDEV_H
|
||||
#define NEW_KERNEL_BLOCKDEV_H
|
||||
|
||||
#include <types.h>
|
||||
#include <driver.h>
|
||||
#include <sys/types.h>
|
||||
#include <myke/driver.h>
|
||||
|
||||
#define BLOCK_DEV_ACCESS_OK 0
|
||||
#define BLOCK_DEV_ACCESS_ERR 1
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef NEW_KERNEL_MBR_H
|
||||
#define NEW_KERNEL_MBR_H
|
||||
|
||||
#include <types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
void mbr_read_from_ide(uint8_t ide_drive);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef NEW_KERNEL_RINGQUEUE_H
|
||||
#define NEW_KERNEL_RINGQUEUE_H
|
||||
|
||||
#include <types.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void *create_buffer(int count, int object_size);
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#endif //NEW_KERNEL_KPRINT_H
|
||||
|
||||
#include <types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef void (*kprint_handler)(const char *);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#ifndef NEW_KERNEL_LIBK_H
|
||||
#define NEW_KERNEL_LIBK_H
|
||||
#include <attributes.h>
|
||||
#include <myke/attributes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
extern void* _kernel_start;
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#ifndef NEW_KERNEL_SYSCALL_H
|
||||
#define NEW_KERNEL_SYSCALL_H
|
||||
#include <types.h>
|
||||
#include <attributes.h>
|
||||
#include <sys/types.h>
|
||||
#include <myke/attributes.h>
|
||||
|
||||
#define SYSCALL_START_SCHEDULER 0x01
|
||||
#define SYSCALL_YIELD_JOB 0x02
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef NEW_KERNEL_MALLOC_H
|
||||
#define NEW_KERNEL_MALLOC_H
|
||||
// retrieved from https://github.com/blanham/liballoc
|
||||
#include <types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
void *malloc(size_t);
|
||||
|
||||
@@ -15,6 +15,8 @@ void *calloc(size_t, size_t);
|
||||
|
||||
void free(void *);
|
||||
|
||||
#ifndef INCLUDE_STDLIB
|
||||
void print_malloc_info();
|
||||
#endif
|
||||
|
||||
#endif //NEW_KERNEL_MALLOC_H
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#ifndef NEW_KERNEL_PMM_H
|
||||
#define NEW_KERNEL_PMM_H
|
||||
#include <types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// 4k blocks
|
||||
#define PAGE_SIZE 4096
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef NEW_KERNEL_LOCKING_H
|
||||
#define NEW_KERNEL_LOCKING_H
|
||||
|
||||
#include <types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct semaphore semaphore_t;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef NEW_KERNEL_TASK_H
|
||||
#define NEW_KERNEL_TASK_H
|
||||
|
||||
#include <cpu/cpu.h>
|
||||
#include <myke/cpu/cpu.h>
|
||||
|
||||
typedef void (*task_entrypoint)(void *entry_data);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#ifndef NEW_KERNEL_POWER_H
|
||||
#define NEW_KERNEL_POWER_H
|
||||
#include <attributes.h>
|
||||
#include <myke/attributes.h>
|
||||
|
||||
void noreturn power_shutdown();
|
||||
|
||||
46
include/stdio.h
Normal file
46
include/stdio.h
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// Created by rick on 10-03-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_STDIO_H
|
||||
#define NEW_KERNEL_STDIO_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define SEEK_SET 0
|
||||
|
||||
// todo
|
||||
typedef struct {
|
||||
int unused;
|
||||
} FILE;
|
||||
extern FILE *stderr;
|
||||
// todo
|
||||
#define stderr stderr
|
||||
|
||||
void fclose(FILE *);
|
||||
|
||||
void fflush(FILE *);
|
||||
|
||||
FILE *fopen(const char *, const char *);
|
||||
|
||||
void fprintf(FILE *, const char *, ...);
|
||||
|
||||
size_t fread(void *, size_t, size_t, FILE *);
|
||||
|
||||
int fseek(FILE *, long, int);
|
||||
|
||||
long ftell(FILE *);
|
||||
|
||||
size_t fwrite(const void *, size_t, size_t, FILE *);
|
||||
|
||||
void sebuf(FILE *, char *);
|
||||
|
||||
int vfprintf(FILE *, const char *, va_list);
|
||||
|
||||
int printf(const char *fmt, ...);
|
||||
|
||||
int sprintf(char *target, const char *fmt, ...);
|
||||
|
||||
|
||||
#endif //NEW_KERNEL_STDIO_H
|
||||
36
include/stdlib.h
Normal file
36
include/stdlib.h
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Created by rick on 10-03-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_STDLIB_H
|
||||
#define NEW_KERNEL_STDLIB_H
|
||||
|
||||
#ifdef __kernel__
|
||||
#define INCLUDE_STDLIB
|
||||
|
||||
#include <myke/mem/malloc.h>
|
||||
|
||||
#undef INCLUDE_STDLIB
|
||||
#else
|
||||
#error "Userspace not implemented"
|
||||
#endif
|
||||
|
||||
void abort();
|
||||
|
||||
int atexit(void (*)(void));
|
||||
|
||||
int atoi(const char *);
|
||||
|
||||
char *itoa(int value, char *buffer, int base);
|
||||
|
||||
char *getenv(const char *);
|
||||
|
||||
int abs(int val);
|
||||
|
||||
long labs(long val);
|
||||
|
||||
long long llabs(long long val);
|
||||
|
||||
void qsort(void *base, size_t num, size_t size, int (*compar)(const void *, const void *));
|
||||
|
||||
#endif //NEW_KERNEL_STDLIB_H
|
||||
@@ -5,9 +5,15 @@
|
||||
#ifndef NEW_KERNEL_STRING_H
|
||||
#define NEW_KERNEL_STRING_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
int memcpy(void *dst, const void *src, size_t amount);
|
||||
|
||||
int memset(void *dst, int data, size_t amount);
|
||||
|
||||
int strcpy(char *dst, char *src);
|
||||
|
||||
int strlen(const char *str);
|
||||
size_t strlen(const char *str);
|
||||
|
||||
const char *strchr(const char *s, char c);
|
||||
|
||||
11
include/sys/param.h
Normal file
11
include/sys/param.h
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// Created by rick on 10-03-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_PARAM_H
|
||||
#define NEW_KERNEL_PARAM_H
|
||||
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
#endif //NEW_KERNEL_PARAM_H
|
||||
@@ -11,4 +11,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef int pid_t;
|
||||
|
||||
#endif /* KERNEL_LIBC_TYPES_H_ */
|
||||
8
include/time.h
Normal file
8
include/time.h
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by rick on 10-03-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_TIME_H
|
||||
#define NEW_KERNEL_TIME_H
|
||||
|
||||
#endif //NEW_KERNEL_TIME_H
|
||||
15
include/unistd.h
Normal file
15
include/unistd.h
Normal file
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Created by rick on 10-03-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_UNISTD_H
|
||||
#define NEW_KERNEL_UNISTD_H
|
||||
#include <sys/types.h>
|
||||
|
||||
int execv(const char*, char* const[]);
|
||||
int execve(const char*, char* const[], char* const[]);
|
||||
int execvp(const char*, char* const[]);
|
||||
|
||||
pid_t fork(void);
|
||||
|
||||
#endif //NEW_KERNEL_UNISTD_H
|
||||
@@ -1,25 +1,23 @@
|
||||
//
|
||||
// Created by rick on 23-02-21.
|
||||
//
|
||||
|
||||
#include <command.h>
|
||||
#include "libk/kprint.h"
|
||||
#include "libk/libk.h"
|
||||
#include <types.h>
|
||||
#include <libc/kprintf.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <libc/string.h>
|
||||
#include <mem/mem.h>
|
||||
#include <mem/malloc.h>
|
||||
#include <cpu/timer.h>
|
||||
#include <drivers/pci.h>
|
||||
#include <drivers/ide.h>
|
||||
#include <fs/blockdev.h>
|
||||
#include <fs/mbr.h>
|
||||
#include <libc/readline.h>
|
||||
#include <libc/libc.h>
|
||||
#include <attributes.h>
|
||||
#include <util/power.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <myke/command.h>
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/mem/mem.h>
|
||||
#include <myke/mem/malloc.h>
|
||||
#include <myke/cpu/timer.h>
|
||||
#include <myke/drivers/pci.h>
|
||||
#include <myke/drivers/ide.h>
|
||||
#include <myke/fs/blockdev.h>
|
||||
#include <myke/fs/mbr.h>
|
||||
#include <readline/readline.h>
|
||||
#include <myke/attributes.h>
|
||||
#include <myke/util/power.h>
|
||||
|
||||
#define BOOTLOADER_NAME_MAX_LENGTH 64
|
||||
#define CMDLINE_MAX_LENGTH 256
|
||||
@@ -77,7 +75,7 @@ void print_bootinfo() {
|
||||
|
||||
|
||||
void help(const char *arg) {
|
||||
kprint("Available commands:\n");
|
||||
printf("Available commands:\n");
|
||||
int index = 0;
|
||||
while (true) {
|
||||
if (cmd_handlers[index].cmd == NULL) {
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// Created by rick on 12-02-21.
|
||||
//
|
||||
|
||||
#include <cpu/cpuidx.h>
|
||||
|
||||
#include <types.h>
|
||||
#include <cpuid.h>
|
||||
#include <libc/kprintf.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <myke/cpu/cpuidx.h>
|
||||
|
||||
union cpu_name {
|
||||
uint32_t parts[3];
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by rick on 8/18/19.
|
||||
//
|
||||
|
||||
#include <cpu/idt.h>
|
||||
#include <myke/cpu/idt.h>
|
||||
|
||||
idt_gate_t idt[IDT_REGISTERS];
|
||||
idt_register_t idt_reg;
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
// Created by rick on 8/18/19.
|
||||
//
|
||||
|
||||
#include <cpu/isr.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <debug/debug.h>
|
||||
#include <cpu/idt.h>
|
||||
#include <cpu/syscall_handler.h>
|
||||
#include <libc/libc.h>
|
||||
#include <drivers/ports.h>
|
||||
#include <libc/kprintf.h>
|
||||
#include <libk/libk.h>
|
||||
#include <tasks/task.h>
|
||||
#include <myke/cpu/isr.h>
|
||||
#include <myke/debug/debug.h>
|
||||
#include <myke/cpu/idt.h>
|
||||
#include <myke/cpu/syscall_handler.h>
|
||||
#include <myke/drivers/ports.h>
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/tasks/task.h>
|
||||
|
||||
#define PIC_END_OF_INTERRUPT 0x20
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// Created by rick on 24-02-21.
|
||||
//
|
||||
|
||||
#include <cpu/syscall_handler.h>
|
||||
#include <libk/syscall.h>
|
||||
#include <tasks/task.h>
|
||||
#include <myke/cpu/syscall_handler.h>
|
||||
#include <myke/libk/syscall.h>
|
||||
#include <myke/tasks/task.h>
|
||||
|
||||
void syscall_handle(isr_registers_t *registers) {
|
||||
switch (registers->eax) {
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
// Created by rick on 9/22/19.
|
||||
//
|
||||
|
||||
#include <cpu/timer.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <drivers/ports.h>
|
||||
#include <cpu/isr.h>
|
||||
#include <libc/libc.h>
|
||||
#include <libk/libk.h>
|
||||
#include <libk/kprint.h>
|
||||
#include <tasks/task.h>
|
||||
#include <myke/cpu/timer.h>
|
||||
#include <myke/drivers/ports.h>
|
||||
#include <myke/cpu/isr.h>
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/libk/kprint.h>
|
||||
#include <myke/tasks/task.h>
|
||||
|
||||
// https://wiki.osdev.org/PIT
|
||||
#define PIT_MODE_BIN_BCD (1 << 0)
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
// Created by rick on 08-03-21.
|
||||
//
|
||||
|
||||
#include <debug/debug.h>
|
||||
#include <elf.h>
|
||||
#include <libk/libk.h>
|
||||
#include <libc/libc.h>
|
||||
#include <libc/kprintf.h>
|
||||
#include <libc/string.h>
|
||||
#include <libk/kprint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define DEBUG_INIT
|
||||
|
||||
#include <myke/debug/debug.h>
|
||||
#include <myke/elf.h>
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/libk/kprint.h>
|
||||
|
||||
static struct elf32_section_header *elf_headers = NULL;
|
||||
static struct elf32_section_header *elf_shstrtab = NULL;
|
||||
|
||||
@@ -3,19 +3,20 @@
|
||||
//
|
||||
// https://wiki.osdev.org/PCI_IDE_Controller
|
||||
|
||||
#include <drivers/ide.h>
|
||||
#include <debug/debug.h>
|
||||
#include <drivers/ports.h>
|
||||
#include <types.h>
|
||||
#include <libk/kprint.h>
|
||||
#include <drivers/pci.h>
|
||||
#include <stdbool.h>
|
||||
#include <libk/libk.h>
|
||||
#include <cpu/timer.h>
|
||||
#include <libc/kprintf.h>
|
||||
#include <fs/blockdev.h>
|
||||
#include <mem/malloc.h>
|
||||
#include <tasks/locking.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <myke/drivers/ide.h>
|
||||
#include <myke/debug/debug.h>
|
||||
#include <myke/drivers/ports.h>
|
||||
#include <myke/libk/kprint.h>
|
||||
#include <myke/drivers/pci.h>
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/cpu/timer.h>
|
||||
#include <myke/fs/blockdev.h>
|
||||
#include <myke/tasks/locking.h>
|
||||
|
||||
#define ATA_SR_BSY 0x80 // Busy
|
||||
#define ATA_SR_DRDY 0x40 // Drive ready
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
//
|
||||
// Created by rick on 23-03-20.
|
||||
//
|
||||
#include <drivers/keyboard.h>
|
||||
|
||||
#include <drivers/ports.h>
|
||||
#include <cpu/isr.h>
|
||||
#include <libc/ringqueue.h>
|
||||
#include <libk/libk.h>
|
||||
#include <mem/malloc.h>
|
||||
#include <libk/syscall.h>
|
||||
#include <stdlib.h>
|
||||
#include <myke/drivers/keyboard.h>
|
||||
#include <myke/drivers/ports.h>
|
||||
#include <myke/cpu/isr.h>
|
||||
#include <myke/libc/ringqueue.h>
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/libk/syscall.h>
|
||||
|
||||
|
||||
const char scancode_map_lowercase[] = {
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
//
|
||||
// https://wiki.osdev.org/PCI
|
||||
|
||||
#include <drivers/pci.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <types.h>
|
||||
#include <drivers/ports.h>
|
||||
#include <libk/libk.h>
|
||||
#include <libc/kprintf.h>
|
||||
#include <myke/drivers/pci.h>
|
||||
#include <myke/drivers/ports.h>
|
||||
#include <myke/libk/libk.h>
|
||||
|
||||
#ifdef ENABLE_PCIPP
|
||||
|
||||
#include <drivers/pci_devices.h>
|
||||
#include <myke/drivers/pci_devices.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <drivers/ports.h>
|
||||
#include <myke/drivers/ports.h>
|
||||
|
||||
/**
|
||||
* Read a byte from the specified port
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// Created by rick on 28-01-21.
|
||||
//
|
||||
|
||||
#include <drivers/serial.h>
|
||||
#include <types.h>
|
||||
#include <drivers/ports.h>
|
||||
#include <myke/drivers/serial.h>
|
||||
#include <sys/types.h>
|
||||
#include <myke/drivers/ports.h>
|
||||
|
||||
#define SERIAL_INTERRUPT_DATA_AVAILABLE (1 << 0)
|
||||
#define SERIAL_INTERRUPT_TRANSMITTER_EMPTY (1 << 1)
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Created by rick on 8/18/19.
|
||||
//
|
||||
|
||||
#include <drivers/vgascreen.h>
|
||||
#include <string.h>
|
||||
#include <myke/drivers/vgascreen.h>
|
||||
|
||||
#include <libc/libc.h>
|
||||
#include <drivers/ports.h>
|
||||
#include <myke/drivers/ports.h>
|
||||
|
||||
char *_vga_character_memory = (char *) VGA_CHARACTER_MEMORY_LOCATION;
|
||||
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
// Created by rick on 06-02-21.
|
||||
//
|
||||
|
||||
#include <libc/libc.h>
|
||||
#include <libk/libk.h>
|
||||
#include <libc/kprintf.h>
|
||||
#include <mem/malloc.h>
|
||||
#include <tasks/task.h>
|
||||
#include <tasks/locking.h>
|
||||
#include <attributes.h>
|
||||
#include <fs/blockdev.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/tasks/task.h>
|
||||
#include <myke/tasks/locking.h>
|
||||
#include <myke/attributes.h>
|
||||
#include <myke/fs/blockdev.h>
|
||||
|
||||
#define MAX_BLOCK_DEVS 64
|
||||
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
// Created by rick on 07-02-21.
|
||||
//
|
||||
|
||||
#include <fs/fat.h>
|
||||
#include <fs/blockdev.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <types.h>
|
||||
#include <libc/libc.h>
|
||||
#include <libc/kprintf.h>
|
||||
#include <mem/malloc.h>
|
||||
#include <attributes.h>
|
||||
#include <myke/fs/blockdev.h>
|
||||
#include <sys/types.h>
|
||||
#include <myke/attributes.h>
|
||||
|
||||
#define FAT_TYPE_12 1
|
||||
#define FAT_TYPE_16 2
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
// Created by rick on 06-02-21.
|
||||
//
|
||||
|
||||
#include <fs/mbr.h>
|
||||
#include <types.h>
|
||||
#include <drivers/ide.h>
|
||||
#include <libc/kprintf.h>
|
||||
#include <fs/blockdev.h>
|
||||
#include <libc/libc.h>
|
||||
#include <mem/malloc.h>
|
||||
#include <attributes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <myke/fs/mbr.h>
|
||||
#include <myke/drivers/ide.h>
|
||||
#include <myke/fs/blockdev.h>
|
||||
#include <myke/attributes.h>
|
||||
|
||||
typedef struct {
|
||||
uint8_t bootable;
|
||||
@@ -36,7 +37,8 @@ typedef struct {
|
||||
uint32_t start_lba;
|
||||
} mbr_block_driver_info;
|
||||
|
||||
uint8_t mbr_block_dev_access(const block_device *device, uint8_t direction, uint32_t lba, uint8_t sectors, void *target) {
|
||||
uint8_t
|
||||
mbr_block_dev_access(const block_device *device, uint8_t direction, uint32_t lba, uint8_t sectors, void *target) {
|
||||
if (!device->flags.present || lba > device->num_lba) {
|
||||
return BLOCK_DEV_ACCESS_ERR;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
#include <drivers/vgascreen.h>
|
||||
#include <cpu/isr.h>
|
||||
#include <cpu/timer.h>
|
||||
#include <drivers/keyboard.h>
|
||||
#include <mem/mem.h>
|
||||
#include <stdio.h>
|
||||
#include <multiboot.h>
|
||||
#include <drivers/serial.h>
|
||||
#include <libk/kprint.h>
|
||||
#include <libk/libk.h>
|
||||
#include <drivers/pci.h>
|
||||
#include <libc/kprintf.h>
|
||||
#include <fs/blockdev.h>
|
||||
#include <cpu/cpuidx.h>
|
||||
#include <tasks/task.h>
|
||||
#include <libk/syscall.h>
|
||||
#include <command.h>
|
||||
#include <attributes.h>
|
||||
#include <debug/debug.h>
|
||||
|
||||
#define DEBUG_INIT
|
||||
|
||||
#include <myke/cpu/cpuidx.h>
|
||||
#include <myke/cpu/isr.h>
|
||||
#include <myke/cpu/timer.h>
|
||||
#include <myke/debug/debug.h>
|
||||
#include <myke/drivers/keyboard.h>
|
||||
#include <myke/drivers/pci.h>
|
||||
#include <myke/drivers/serial.h>
|
||||
#include <myke/drivers/vgascreen.h>
|
||||
#include <myke/fs/blockdev.h>
|
||||
#include <myke/libk/kprint.h>
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/libk/syscall.h>
|
||||
#include <myke/mem/mem.h>
|
||||
#include <myke/tasks/task.h>
|
||||
#include <myke/attributes.h>
|
||||
#include <myke/command.h>
|
||||
|
||||
const int version_major = 0,
|
||||
version_minor = 0,
|
||||
|
||||
@@ -2,14 +2,17 @@
|
||||
// Created by rick on 06-02-21.
|
||||
//
|
||||
|
||||
#include <libc/kprintf.h>
|
||||
#include <libc/libc.h>
|
||||
#include <libc/string.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <libk/kprint.h>
|
||||
#include <libk/libk.h>
|
||||
#include <types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <myke/libk/kprint.h>
|
||||
#include <myke/libk/libk.h>
|
||||
|
||||
const char *printf_null_str = "NULL";
|
||||
|
||||
/*
|
||||
* Integer to string
|
||||
*/
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
// Created by rick on 01-02-21.
|
||||
//
|
||||
|
||||
#include <libc/readline.h>
|
||||
#include <libc/libc.h>
|
||||
#include <types.h>
|
||||
#include <libk/kprint.h>
|
||||
#include <drivers/keyboard.h>
|
||||
#include <mem/malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <readline/readline.h>
|
||||
|
||||
#include <myke/libk/kprint.h>
|
||||
#include <myke/drivers/keyboard.h>
|
||||
|
||||
#define RESULT_SIZE 256
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// Created by rick on 30-01-21.
|
||||
//
|
||||
|
||||
#include <libc/ringqueue.h>
|
||||
#include <libc/libc.h>
|
||||
#include <mem/malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <myke/libc/ringqueue.h>
|
||||
|
||||
#define calc_pos(buffer, index) ((buffer->object_size) * (index))
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// Created by rick on 06-03-21.
|
||||
//
|
||||
|
||||
#include <libc/sort.h>
|
||||
#include <libc/libc.h>
|
||||
#include <types.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// taken from https://github.com/DevSolar/pdclib/blob/master/functions/stdlib/qsort.c
|
||||
|
||||
|
||||
@@ -5,28 +5,23 @@
|
||||
* Author: rick
|
||||
*/
|
||||
|
||||
#include <types.h>
|
||||
#include <libc/libc.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int memcpy(uint8_t *dst, const uint8_t *src, int amount) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* everything of stdlib is implemented in this file except for:
|
||||
* - qsort
|
||||
**/
|
||||
|
||||
int memset(uint8_t *dst, char data, int amount) {
|
||||
for (int i = 0; i < amount; ++i) {
|
||||
dst[i] = data;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int abs(int val) {
|
||||
if (val >= 0) {
|
||||
return val;
|
||||
return val >= 0 ? val : (val * -1);
|
||||
}
|
||||
return val * -1;
|
||||
|
||||
long labs(long val) {
|
||||
return val >= 0 ? val : (val * -1);
|
||||
}
|
||||
|
||||
long long llabs(long long val) {
|
||||
return val >= 0 ? val : (val * -1);
|
||||
}
|
||||
|
||||
// next stolen form https://www.techiedelight.com/implement-itoa-function-in-c/
|
||||
@@ -81,17 +76,3 @@ char *itoa(int value, char *buffer, int base) {
|
||||
// reverse the string and return it
|
||||
return reverse(buffer, 0, i - 1);
|
||||
}
|
||||
|
||||
int maxi(int a, int b) {
|
||||
if (a >= b) {
|
||||
return a;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
int mini(int a, int b) {
|
||||
if (a <= b) {
|
||||
return a;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
@@ -2,16 +2,29 @@
|
||||
// Created by rick on 01-02-21.
|
||||
//
|
||||
|
||||
#include <libc/string.h>
|
||||
#include <stdbool.h>
|
||||
#include <libc/libc.h>
|
||||
#include <types.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
int memcpy(void *dst, const void *src, size_t amount) {
|
||||
for (size_t i = 0; i < amount; i++) {
|
||||
((char *) dst)[i] = ((const char *) src)[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int memset(void *dst, int data, size_t amount) {
|
||||
for (size_t i = 0; i < amount; ++i) {
|
||||
((char *) dst)[i] = (char) data;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int strcpy(char *dst, char *src) {
|
||||
return memcpy(dst, src, strlen(src) + 1);
|
||||
}
|
||||
|
||||
int strlen(const char *str) {
|
||||
size_t strlen(const char *str) {
|
||||
int length = 0;
|
||||
while (str[length] != 0) {
|
||||
length++;
|
||||
@@ -22,12 +35,12 @@ int strlen(const char *str) {
|
||||
int strcmp(const char *s1, const char *s2) {
|
||||
int len1 = strlen(s1);
|
||||
int len2 = strlen(s2);
|
||||
return strncmp(s1, s2, maxi(len1, len2));
|
||||
return strncmp(s1, s2, MAX(len1, len2));
|
||||
}
|
||||
|
||||
const char *strchr(const char *s, char c) {
|
||||
int index = 0;
|
||||
while (true) {
|
||||
while (1) {
|
||||
if (s[index] == c) {
|
||||
return &s[index];
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
// Created by rick on 28-01-21.
|
||||
//
|
||||
|
||||
#include <util/stream.h>
|
||||
#include <libc/string.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <attributes.h>
|
||||
#include <tasks/task.h>
|
||||
#include <libc/libc.h>
|
||||
#include <libk/kprint.h>
|
||||
|
||||
#include <myke/util/stream.h>
|
||||
#include <myke/attributes.h>
|
||||
#include <myke/tasks/task.h>
|
||||
#include <myke/libk/kprint.h>
|
||||
|
||||
#define MAX_HANDLERS 8
|
||||
#define STREAM_SIZE (32*1024)
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
// Created by rick on 02-02-21.
|
||||
//
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <libk/kprint.h>
|
||||
#include <attributes.h>
|
||||
#include <libk/libk.h>
|
||||
#include <myke/libk/kprint.h>
|
||||
#include <myke/attributes.h>
|
||||
#include <myke/libk/libk.h>
|
||||
|
||||
bool k_addr_in_kspace(void *addr) {
|
||||
return addr > kernel_start && addr < kernel_end;
|
||||
@@ -23,7 +22,7 @@ void noreturn k_panics(const char *msg) {
|
||||
|
||||
void noreturn k_panic() {
|
||||
kprint_sync("PANIC!");
|
||||
while (true) {
|
||||
while (1) {
|
||||
__asm__ __volatile__("cli;"
|
||||
"hlt;");
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
// Created by rick on 22-02-21.
|
||||
//
|
||||
|
||||
#include <libk/syscall.h>
|
||||
#include <types.h>
|
||||
#include <attributes.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <myke/libk/syscall.h>
|
||||
#include <myke/attributes.h>
|
||||
|
||||
void syscall1(uint32_t arg1) {
|
||||
__asm__("int $0x80"
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
// Created by rick on 23-02-21.
|
||||
//
|
||||
|
||||
#include <libc/kprintf.h>
|
||||
#include <tasks/task.h>
|
||||
#include <mem/malloc.h>
|
||||
#include <mem/pmm.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <myke/tasks/task.h>
|
||||
#include <myke/mem/malloc.h>
|
||||
#include <myke/mem/pmm.h>
|
||||
|
||||
// retrieved from https://github.com/blanham/liballoc
|
||||
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
// Created by rick on 22-04-20.
|
||||
//
|
||||
|
||||
#include <mem/pmm.h>
|
||||
#include <types.h>
|
||||
#include <mem/mem.h>
|
||||
#include <libc/kprintf.h>
|
||||
#include <libk/libk.h>
|
||||
#include <attributes.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <myke/mem/pmm.h>
|
||||
#include <myke/mem/mem.h>
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/attributes.h>
|
||||
|
||||
#define MEMMAP_ENTRIES 16
|
||||
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
// Created by rick on 21-02-21.
|
||||
//
|
||||
|
||||
#include <mem/paging.h>
|
||||
#include <types.h>
|
||||
#include <stdbool.h>
|
||||
#include <attributes.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <myke/mem/paging.h>
|
||||
#include <myke/attributes.h>
|
||||
|
||||
#define TABLE_ADDR_MASK 0xFFFFF000
|
||||
#define DIRECTORY_SIZE 1024
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
//
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <libc/libc.h>
|
||||
#include <libk/libk.h>
|
||||
#include <mem/pmm.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/mem/pmm.h>
|
||||
|
||||
#define NUM_PAGING_INFOS 16
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
// Created by rick on 27-02-21.
|
||||
//
|
||||
|
||||
#include <tasks/locking.h>
|
||||
#include <mem/malloc.h>
|
||||
#include <tasks/task.h>
|
||||
#include <libk/syscall.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <libc/kprintf.h>
|
||||
#include <libc/libc.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <myke/tasks/locking.h>
|
||||
#include <myke/tasks/task.h>
|
||||
#include <myke/libk/syscall.h>
|
||||
|
||||
typedef struct lock_fifo_entry {
|
||||
uint32_t tid;
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
// Created by rick on 22-02-21.
|
||||
//
|
||||
|
||||
#include <tasks/task.h>
|
||||
#include <cpu/cpu.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <libc/libc.h>
|
||||
#include <mem/malloc.h>
|
||||
#include <mem/pmm.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <attributes.h>
|
||||
#include <libk/libk.h>
|
||||
#include <myke/tasks/task.h>
|
||||
#include <myke/cpu/cpu.h>
|
||||
#include <myke/mem/pmm.h>
|
||||
#include <myke/attributes.h>
|
||||
#include <myke/libk/libk.h>
|
||||
|
||||
#define stack_end(task) ((task)->stack + ((task)->stack_page_count * PAGE_SIZE))
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Created by rick on 03-03-21.
|
||||
//
|
||||
|
||||
#include <drivers/ports.h>
|
||||
#include <attributes.h>
|
||||
#include <libk/libk.h>
|
||||
#include <util/power.h>
|
||||
#include <myke/drivers/ports.h>
|
||||
#include <myke/attributes.h>
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/util/power.h>
|
||||
|
||||
void noreturn power_shutdown() {
|
||||
port_word_out(PORT_ACPI, PORT_ACPI_SHUTDOWN);
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
// Created by rick on 02-03-21.
|
||||
//
|
||||
|
||||
#include <mem/malloc.h>
|
||||
#include <libc/libc.h>
|
||||
#include <tasks/locking.h>
|
||||
#include <util/stream.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <myke/tasks/locking.h>
|
||||
#include <myke/util/stream.h>
|
||||
|
||||
struct stream {
|
||||
uint8_t *data;
|
||||
|
||||
Reference in New Issue
Block a user