feat: reformatted code base to be more standard

This commit is contained in:
2021-03-10 22:01:13 +01:00
parent dc4bf71b5a
commit 586b8191b4
81 changed files with 431 additions and 338 deletions

8
include/errno.h Normal file
View 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

View File

@@ -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

View File

@@ -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

View File

@@ -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_ */

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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();

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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

View File

@@ -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);

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -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);

View File

@@ -7,7 +7,7 @@
#endif //NEW_KERNEL_KPRINT_H
#include <types.h>
#include <sys/types.h>
typedef void (*kprint_handler)(const char *);

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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);

View File

@@ -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
View 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
View 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

View File

@@ -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
View 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

View File

@@ -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
View 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
View 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