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 kernel_asm kernel/**.S)
|
||||||
FILE(GLOB_RECURSE boot_asm boot/boot.S)
|
FILE(GLOB_RECURSE boot_asm boot/boot.S)
|
||||||
|
|
||||||
|
add_compile_definitions(__kernel__)
|
||||||
|
|
||||||
# Run IDE in DMA mode if available (NYI)
|
# Run IDE in DMA mode if available (NYI)
|
||||||
#add_compile_definitions(IDE_ENABLE_INTERRUPT)
|
#add_compile_definitions(IDE_ENABLE_INTERRUPT)
|
||||||
# Run the kernel shell as the main task
|
# 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
|
#ifndef NEW_KERNEL_CPU_H
|
||||||
#define NEW_KERNEL_CPU_H
|
#define NEW_KERNEL_CPU_H
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t edi, esi, ebx, ebp, eip;
|
uint32_t edi, esi, ebx, ebp, eip;
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
//
|
//
|
||||||
// Created by rick on 8/18/19.
|
// Created by rick on 8/18/19.
|
||||||
//
|
//
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#ifndef MY_KERNEL_IDT_H
|
#ifndef MY_KERNEL_IDT_H
|
||||||
#define MY_KERNEL_IDT_H
|
#define MY_KERNEL_IDT_H
|
||||||
#include <attributes.h>
|
#include <myke/attributes.h>
|
||||||
|
|
||||||
#define KERNEL_CS 0x08
|
#define KERNEL_CS 0x08
|
||||||
|
|
||||||
@@ -2,12 +2,12 @@
|
|||||||
// Created by rick on 8/18/19.
|
// Created by rick on 8/18/19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#ifndef MY_KERNEL_ISR_H
|
#ifndef MY_KERNEL_ISR_H
|
||||||
#define MY_KERNEL_ISR_H
|
#define MY_KERNEL_ISR_H
|
||||||
|
|
||||||
#include <cpu/cpu.h>
|
#include <myke/cpu/cpu.h>
|
||||||
|
|
||||||
/* ISRs reserved for CPU exceptions */
|
/* ISRs reserved for CPU exceptions */
|
||||||
extern void isr0();
|
extern void isr0();
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#ifndef NEW_KERNEL_SYSCALL_HANDLER_H
|
#ifndef NEW_KERNEL_SYSCALL_HANDLER_H
|
||||||
#define 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);
|
void syscall_handle(isr_registers_t *registers);
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef MY_KERNEL_TIMER_H
|
#ifndef MY_KERNEL_TIMER_H
|
||||||
#define MY_KERNEL_TIMER_H
|
#define MY_KERNEL_TIMER_H
|
||||||
|
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
int init_timer(uint32_t freq);
|
int init_timer(uint32_t freq);
|
||||||
|
|
||||||
@@ -4,10 +4,14 @@
|
|||||||
|
|
||||||
#ifndef NEW_KERNEL_DEBUG_H
|
#ifndef NEW_KERNEL_DEBUG_H
|
||||||
#define NEW_KERNEL_DEBUG_H
|
#define NEW_KERNEL_DEBUG_H
|
||||||
#include <multiboot.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#ifdef DEBUG_INIT
|
||||||
|
#include <multiboot.h>
|
||||||
|
|
||||||
void debug_store_info(struct multiboot_info *info);
|
void debug_store_info(struct multiboot_info *info);
|
||||||
|
#endif
|
||||||
|
|
||||||
void debug_backtrace(bool do_sync);
|
void debug_backtrace(bool do_sync);
|
||||||
|
|
||||||
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#ifndef NEW_KERNEL_DRIVER_H
|
#ifndef NEW_KERNEL_DRIVER_H
|
||||||
#define NEW_KERNEL_DRIVER_H
|
#define NEW_KERNEL_DRIVER_H
|
||||||
#include <attributes.h>
|
#include <myke/attributes.h>
|
||||||
#include <preprocessor_format_zero.h>
|
#include <myke/preprocessor_format_zero.h>
|
||||||
|
|
||||||
#ifndef STRUCT_ALIGNMENT
|
#ifndef STRUCT_ALIGNMENT
|
||||||
#define STRUCT_ALIGNMENT 16
|
#define STRUCT_ALIGNMENT 16
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef NEW_KERNEL_IDE_H
|
#ifndef NEW_KERNEL_IDE_H
|
||||||
#define 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);
|
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
|
#ifndef MY_KERNEL_KEYBOARD_H
|
||||||
#define MY_KERNEL_KEYBOARD_H
|
#define MY_KERNEL_KEYBOARD_H
|
||||||
|
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
typedef struct KeyEvent_t {
|
typedef struct KeyEvent_t {
|
||||||
// KeyCode key;
|
// KeyCode key;
|
||||||
@@ -5,10 +5,10 @@
|
|||||||
#ifndef NEW_KERNEL_PCI_H
|
#ifndef NEW_KERNEL_PCI_H
|
||||||
#define NEW_KERNEL_PCI_H
|
#define NEW_KERNEL_PCI_H
|
||||||
|
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
#include <driver.h>
|
#include <myke/driver.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <attributes.h>
|
#include <myke/attributes.h>
|
||||||
|
|
||||||
#define PCI_CLASS_MASS_STORAGE 0x01
|
#define PCI_CLASS_MASS_STORAGE 0x01
|
||||||
#define PCI_CLASS_BRIDGE 0x06
|
#define PCI_CLASS_BRIDGE 0x06
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#ifndef NEW_KERNEL_PCI_DEVICES_H
|
#ifndef NEW_KERNEL_PCI_DEVICES_H
|
||||||
#define NEW_KERNEL_PCI_DEVICES_H
|
#define NEW_KERNEL_PCI_DEVICES_H
|
||||||
|
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
typedef struct pci_device_info_t {
|
typedef struct pci_device_info_t {
|
||||||
uint8_t code;
|
uint8_t code;
|
||||||
@@ -5,8 +5,8 @@
|
|||||||
#ifndef NEW_KERNEL_ELF_H
|
#ifndef NEW_KERNEL_ELF_H
|
||||||
#define NEW_KERNEL_ELF_H
|
#define NEW_KERNEL_ELF_H
|
||||||
|
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
#include <attributes.h>
|
#include <myke/attributes.h>
|
||||||
|
|
||||||
#define SHT_NULL 0
|
#define SHT_NULL 0
|
||||||
#define SHT_PROGBITS 1
|
#define SHT_PROGBITS 1
|
||||||
@@ -5,8 +5,8 @@
|
|||||||
#ifndef NEW_KERNEL_BLOCKDEV_H
|
#ifndef NEW_KERNEL_BLOCKDEV_H
|
||||||
#define NEW_KERNEL_BLOCKDEV_H
|
#define NEW_KERNEL_BLOCKDEV_H
|
||||||
|
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
#include <driver.h>
|
#include <myke/driver.h>
|
||||||
|
|
||||||
#define BLOCK_DEV_ACCESS_OK 0
|
#define BLOCK_DEV_ACCESS_OK 0
|
||||||
#define BLOCK_DEV_ACCESS_ERR 1
|
#define BLOCK_DEV_ACCESS_ERR 1
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef NEW_KERNEL_MBR_H
|
#ifndef NEW_KERNEL_MBR_H
|
||||||
#define 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);
|
void mbr_read_from_ide(uint8_t ide_drive);
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef NEW_KERNEL_RINGQUEUE_H
|
#ifndef NEW_KERNEL_RINGQUEUE_H
|
||||||
#define NEW_KERNEL_RINGQUEUE_H
|
#define NEW_KERNEL_RINGQUEUE_H
|
||||||
|
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
void *create_buffer(int count, int object_size);
|
void *create_buffer(int count, int object_size);
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#endif //NEW_KERNEL_KPRINT_H
|
#endif //NEW_KERNEL_KPRINT_H
|
||||||
|
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
typedef void (*kprint_handler)(const char *);
|
typedef void (*kprint_handler)(const char *);
|
||||||
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#ifndef NEW_KERNEL_LIBK_H
|
#ifndef NEW_KERNEL_LIBK_H
|
||||||
#define NEW_KERNEL_LIBK_H
|
#define NEW_KERNEL_LIBK_H
|
||||||
#include <attributes.h>
|
#include <myke/attributes.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
extern void* _kernel_start;
|
extern void* _kernel_start;
|
||||||
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#ifndef NEW_KERNEL_SYSCALL_H
|
#ifndef NEW_KERNEL_SYSCALL_H
|
||||||
#define NEW_KERNEL_SYSCALL_H
|
#define NEW_KERNEL_SYSCALL_H
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
#include <attributes.h>
|
#include <myke/attributes.h>
|
||||||
|
|
||||||
#define SYSCALL_START_SCHEDULER 0x01
|
#define SYSCALL_START_SCHEDULER 0x01
|
||||||
#define SYSCALL_YIELD_JOB 0x02
|
#define SYSCALL_YIELD_JOB 0x02
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef NEW_KERNEL_MALLOC_H
|
#ifndef NEW_KERNEL_MALLOC_H
|
||||||
#define NEW_KERNEL_MALLOC_H
|
#define NEW_KERNEL_MALLOC_H
|
||||||
// retrieved from https://github.com/blanham/liballoc
|
// retrieved from https://github.com/blanham/liballoc
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
void *malloc(size_t);
|
void *malloc(size_t);
|
||||||
|
|
||||||
@@ -15,6 +15,8 @@ void *calloc(size_t, size_t);
|
|||||||
|
|
||||||
void free(void *);
|
void free(void *);
|
||||||
|
|
||||||
|
#ifndef INCLUDE_STDLIB
|
||||||
void print_malloc_info();
|
void print_malloc_info();
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif //NEW_KERNEL_MALLOC_H
|
#endif //NEW_KERNEL_MALLOC_H
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#ifndef NEW_KERNEL_PMM_H
|
#ifndef NEW_KERNEL_PMM_H
|
||||||
#define NEW_KERNEL_PMM_H
|
#define NEW_KERNEL_PMM_H
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
// 4k blocks
|
// 4k blocks
|
||||||
#define PAGE_SIZE 4096
|
#define PAGE_SIZE 4096
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef NEW_KERNEL_LOCKING_H
|
#ifndef NEW_KERNEL_LOCKING_H
|
||||||
#define NEW_KERNEL_LOCKING_H
|
#define NEW_KERNEL_LOCKING_H
|
||||||
|
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
typedef struct semaphore semaphore_t;
|
typedef struct semaphore semaphore_t;
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef NEW_KERNEL_TASK_H
|
#ifndef NEW_KERNEL_TASK_H
|
||||||
#define 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);
|
typedef void (*task_entrypoint)(void *entry_data);
|
||||||
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#ifndef NEW_KERNEL_POWER_H
|
#ifndef NEW_KERNEL_POWER_H
|
||||||
#define NEW_KERNEL_POWER_H
|
#define NEW_KERNEL_POWER_H
|
||||||
#include <attributes.h>
|
#include <myke/attributes.h>
|
||||||
|
|
||||||
void noreturn power_shutdown();
|
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
|
#ifndef NEW_KERNEL_STRING_H
|
||||||
#define 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 strcpy(char *dst, char *src);
|
||||||
|
|
||||||
int strlen(const char *str);
|
size_t strlen(const char *str);
|
||||||
|
|
||||||
const char *strchr(const char *s, char c);
|
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 <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
typedef int pid_t;
|
||||||
|
|
||||||
#endif /* KERNEL_LIBC_TYPES_H_ */
|
#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.
|
// Created by rick on 23-02-21.
|
||||||
//
|
//
|
||||||
|
#include <stdio.h>
|
||||||
#include <command.h>
|
|
||||||
#include "libk/kprint.h"
|
|
||||||
#include "libk/libk.h"
|
|
||||||
#include <types.h>
|
|
||||||
#include <libc/kprintf.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <libc/string.h>
|
#include <string.h>
|
||||||
#include <mem/mem.h>
|
#include <sys/types.h>
|
||||||
#include <mem/malloc.h>
|
|
||||||
#include <cpu/timer.h>
|
#include <myke/command.h>
|
||||||
#include <drivers/pci.h>
|
#include <myke/libk/libk.h>
|
||||||
#include <drivers/ide.h>
|
#include <myke/mem/mem.h>
|
||||||
#include <fs/blockdev.h>
|
#include <myke/mem/malloc.h>
|
||||||
#include <fs/mbr.h>
|
#include <myke/cpu/timer.h>
|
||||||
#include <libc/readline.h>
|
#include <myke/drivers/pci.h>
|
||||||
#include <libc/libc.h>
|
#include <myke/drivers/ide.h>
|
||||||
#include <attributes.h>
|
#include <myke/fs/blockdev.h>
|
||||||
#include <util/power.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 BOOTLOADER_NAME_MAX_LENGTH 64
|
||||||
#define CMDLINE_MAX_LENGTH 256
|
#define CMDLINE_MAX_LENGTH 256
|
||||||
@@ -77,7 +75,7 @@ void print_bootinfo() {
|
|||||||
|
|
||||||
|
|
||||||
void help(const char *arg) {
|
void help(const char *arg) {
|
||||||
kprint("Available commands:\n");
|
printf("Available commands:\n");
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (cmd_handlers[index].cmd == NULL) {
|
if (cmd_handlers[index].cmd == NULL) {
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
// Created by rick on 12-02-21.
|
// Created by rick on 12-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <cpu/cpuidx.h>
|
|
||||||
|
|
||||||
#include <types.h>
|
|
||||||
#include <cpuid.h>
|
#include <cpuid.h>
|
||||||
#include <libc/kprintf.h>
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <myke/cpu/cpuidx.h>
|
||||||
|
|
||||||
union cpu_name {
|
union cpu_name {
|
||||||
uint32_t parts[3];
|
uint32_t parts[3];
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 8/18/19.
|
// Created by rick on 8/18/19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <cpu/idt.h>
|
#include <myke/cpu/idt.h>
|
||||||
|
|
||||||
idt_gate_t idt[IDT_REGISTERS];
|
idt_gate_t idt[IDT_REGISTERS];
|
||||||
idt_register_t idt_reg;
|
idt_register_t idt_reg;
|
||||||
|
|||||||
@@ -2,16 +2,15 @@
|
|||||||
// Created by rick on 8/18/19.
|
// Created by rick on 8/18/19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <cpu/isr.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <debug/debug.h>
|
#include <myke/cpu/isr.h>
|
||||||
#include <cpu/idt.h>
|
#include <myke/debug/debug.h>
|
||||||
#include <cpu/syscall_handler.h>
|
#include <myke/cpu/idt.h>
|
||||||
#include <libc/libc.h>
|
#include <myke/cpu/syscall_handler.h>
|
||||||
#include <drivers/ports.h>
|
#include <myke/drivers/ports.h>
|
||||||
#include <libc/kprintf.h>
|
#include <myke/libk/libk.h>
|
||||||
#include <libk/libk.h>
|
#include <myke/tasks/task.h>
|
||||||
#include <tasks/task.h>
|
|
||||||
|
|
||||||
#define PIC_END_OF_INTERRUPT 0x20
|
#define PIC_END_OF_INTERRUPT 0x20
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
// Created by rick on 24-02-21.
|
// Created by rick on 24-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <cpu/syscall_handler.h>
|
#include <myke/cpu/syscall_handler.h>
|
||||||
#include <libk/syscall.h>
|
#include <myke/libk/syscall.h>
|
||||||
#include <tasks/task.h>
|
#include <myke/tasks/task.h>
|
||||||
|
|
||||||
void syscall_handle(isr_registers_t *registers) {
|
void syscall_handle(isr_registers_t *registers) {
|
||||||
switch (registers->eax) {
|
switch (registers->eax) {
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
// Created by rick on 9/22/19.
|
// Created by rick on 9/22/19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <cpu/timer.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <drivers/ports.h>
|
#include <myke/cpu/timer.h>
|
||||||
#include <cpu/isr.h>
|
#include <myke/drivers/ports.h>
|
||||||
#include <libc/libc.h>
|
#include <myke/cpu/isr.h>
|
||||||
#include <libk/libk.h>
|
#include <myke/libk/libk.h>
|
||||||
#include <libk/kprint.h>
|
#include <myke/libk/kprint.h>
|
||||||
#include <tasks/task.h>
|
#include <myke/tasks/task.h>
|
||||||
|
|
||||||
// https://wiki.osdev.org/PIT
|
// https://wiki.osdev.org/PIT
|
||||||
#define PIT_MODE_BIN_BCD (1 << 0)
|
#define PIT_MODE_BIN_BCD (1 << 0)
|
||||||
@@ -63,8 +64,8 @@ int init_timer(uint32_t freq) {
|
|||||||
register_interrupt_handler(IRQ0, timer_callback);
|
register_interrupt_handler(IRQ0, timer_callback);
|
||||||
|
|
||||||
uint32_t divisor = 1193180 / freq;
|
uint32_t divisor = 1193180 / freq;
|
||||||
uint8_t low = (uint8_t)(divisor & 0xFF);
|
uint8_t low = (uint8_t) (divisor & 0xFF);
|
||||||
uint8_t high = (uint8_t)((divisor >> 8) & 0xFF);
|
uint8_t high = (uint8_t) ((divisor >> 8) & 0xFF);
|
||||||
port_byte_out(PORT_PIT_COMMAND,
|
port_byte_out(PORT_PIT_COMMAND,
|
||||||
PIT_MODE_BIN | PIT_MODE_HARDWARE_SQUARE_WAVE_GENERATOR | PIT_ACCESS_MODE_LH | PIT_CHANNEL_0);
|
PIT_MODE_BIN | PIT_MODE_HARDWARE_SQUARE_WAVE_GENERATOR | PIT_ACCESS_MODE_LH | PIT_CHANNEL_0);
|
||||||
port_byte_out(PORT_PIT_DATA_0, low);
|
port_byte_out(PORT_PIT_DATA_0, low);
|
||||||
|
|||||||
@@ -2,25 +2,27 @@
|
|||||||
// Created by rick on 08-03-21.
|
// Created by rick on 08-03-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <debug/debug.h>
|
#include <stdio.h>
|
||||||
#include <elf.h>
|
#include <string.h>
|
||||||
#include <libk/libk.h>
|
|
||||||
#include <libc/libc.h>
|
|
||||||
#include <libc/kprintf.h>
|
|
||||||
#include <libc/string.h>
|
|
||||||
#include <libk/kprint.h>
|
|
||||||
|
|
||||||
static struct elf32_section_header* elf_headers = NULL;
|
#define DEBUG_INIT
|
||||||
static struct elf32_section_header* elf_shstrtab = NULL;
|
|
||||||
static struct elf32_section_header* elf_symtab = NULL;
|
#include <myke/debug/debug.h>
|
||||||
static struct elf32_section_header* elf_strtab = NULL;
|
#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;
|
||||||
|
static struct elf32_section_header *elf_symtab = NULL;
|
||||||
|
static struct elf32_section_header *elf_strtab = NULL;
|
||||||
static uint32_t elf_header_cnt;
|
static uint32_t elf_header_cnt;
|
||||||
|
|
||||||
static const char* elf_name_symtab = ".symtab";
|
static const char *elf_name_symtab = ".symtab";
|
||||||
static const char* elf_name_strtab = ".strtab";
|
static const char *elf_name_strtab = ".strtab";
|
||||||
|
|
||||||
struct stackframe {
|
struct stackframe {
|
||||||
struct stackframe* ebp;
|
struct stackframe *ebp;
|
||||||
uint32_t eip;
|
uint32_t eip;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -31,7 +33,7 @@ char *debug_get_shstrtab_entry(uint32_t ndx) {
|
|||||||
if (ndx > elf_shstrtab->sh_size) {
|
if (ndx > elf_shstrtab->sh_size) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return ((char*)elf_shstrtab->sh_addr + ndx);
|
return ((char *) elf_shstrtab->sh_addr + ndx);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *debug_get_strtab_entry(uint32_t ndx) {
|
char *debug_get_strtab_entry(uint32_t ndx) {
|
||||||
@@ -41,7 +43,7 @@ char *debug_get_strtab_entry(uint32_t ndx) {
|
|||||||
if (ndx > elf_strtab->sh_size) {
|
if (ndx > elf_strtab->sh_size) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return ((char*)elf_strtab->sh_addr + ndx);
|
return ((char *) elf_strtab->sh_addr + ndx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void debug_find_sections(uint32_t shndx) {
|
void debug_find_sections(uint32_t shndx) {
|
||||||
@@ -76,11 +78,11 @@ void debug_store_info(struct multiboot_info *info) {
|
|||||||
debug_find_sections(info->u.elf_sec.shndx);
|
debug_find_sections(info->u.elf_sec.shndx);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct elf32_symtab_entry* debug_get_entry_for_addr(uint32_t addr) {
|
struct elf32_symtab_entry *debug_get_entry_for_addr(uint32_t addr) {
|
||||||
if (elf_symtab == NULL) {
|
if (elf_symtab == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
struct elf32_symtab_entry* first = (struct elf32_symtab_entry *) elf_symtab->sh_addr;
|
struct elf32_symtab_entry *first = (struct elf32_symtab_entry *) elf_symtab->sh_addr;
|
||||||
uint32_t num = elf_symtab->sh_size / sizeof(struct elf32_symtab_entry);
|
uint32_t num = elf_symtab->sh_size / sizeof(struct elf32_symtab_entry);
|
||||||
for (uint32_t i = 0; i < num; ++i) {
|
for (uint32_t i = 0; i < num; ++i) {
|
||||||
// only functions for now
|
// only functions for now
|
||||||
@@ -96,7 +98,7 @@ struct elf32_symtab_entry* debug_get_entry_for_addr(uint32_t addr) {
|
|||||||
|
|
||||||
void debug_backtrace(bool do_sync) {
|
void debug_backtrace(bool do_sync) {
|
||||||
struct stackframe *frame = __builtin_frame_address(0);
|
struct stackframe *frame = __builtin_frame_address(0);
|
||||||
void (*printer)(const char*) = do_sync ? kprint_sync : kprint;
|
void (*printer)(const char *) = do_sync ? kprint_sync : kprint;
|
||||||
printer("\n\n## Stack Trace ##\n");
|
printer("\n\n## Stack Trace ##\n");
|
||||||
char msg[1024] = {0};
|
char msg[1024] = {0};
|
||||||
while (frame->ebp != NULL) {
|
while (frame->ebp != NULL) {
|
||||||
|
|||||||
@@ -3,19 +3,20 @@
|
|||||||
//
|
//
|
||||||
// https://wiki.osdev.org/PCI_IDE_Controller
|
// 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 <stdbool.h>
|
||||||
#include <libk/libk.h>
|
#include <stdlib.h>
|
||||||
#include <cpu/timer.h>
|
#include <sys/types.h>
|
||||||
#include <libc/kprintf.h>
|
#include <stdio.h>
|
||||||
#include <fs/blockdev.h>
|
|
||||||
#include <mem/malloc.h>
|
#include <myke/drivers/ide.h>
|
||||||
#include <tasks/locking.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_BSY 0x80 // Busy
|
||||||
#define ATA_SR_DRDY 0x40 // Drive ready
|
#define ATA_SR_DRDY 0x40 // Drive ready
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
//
|
//
|
||||||
// Created by rick on 23-03-20.
|
// Created by rick on 23-03-20.
|
||||||
//
|
//
|
||||||
#include <drivers/keyboard.h>
|
#include <stdlib.h>
|
||||||
|
#include <myke/drivers/keyboard.h>
|
||||||
#include <drivers/ports.h>
|
#include <myke/drivers/ports.h>
|
||||||
#include <cpu/isr.h>
|
#include <myke/cpu/isr.h>
|
||||||
#include <libc/ringqueue.h>
|
#include <myke/libc/ringqueue.h>
|
||||||
#include <libk/libk.h>
|
#include <myke/libk/libk.h>
|
||||||
#include <mem/malloc.h>
|
#include <myke/libk/syscall.h>
|
||||||
#include <libk/syscall.h>
|
|
||||||
|
|
||||||
|
|
||||||
const char scancode_map_lowercase[] = {
|
const char scancode_map_lowercase[] = {
|
||||||
|
|||||||
@@ -3,16 +3,16 @@
|
|||||||
//
|
//
|
||||||
// https://wiki.osdev.org/PCI
|
// https://wiki.osdev.org/PCI
|
||||||
|
|
||||||
#include <drivers/pci.h>
|
#include <sys/types.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <types.h>
|
#include <myke/drivers/pci.h>
|
||||||
#include <drivers/ports.h>
|
#include <myke/drivers/ports.h>
|
||||||
#include <libk/libk.h>
|
#include <myke/libk/libk.h>
|
||||||
#include <libc/kprintf.h>
|
|
||||||
|
|
||||||
#ifdef ENABLE_PCIPP
|
#ifdef ENABLE_PCIPP
|
||||||
|
|
||||||
#include <drivers/pci_devices.h>
|
#include <myke/drivers/pci_devices.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <drivers/ports.h>
|
#include <myke/drivers/ports.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a byte from the specified port
|
* Read a byte from the specified port
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
// Created by rick on 28-01-21.
|
// Created by rick on 28-01-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <drivers/serial.h>
|
#include <myke/drivers/serial.h>
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
#include <drivers/ports.h>
|
#include <myke/drivers/ports.h>
|
||||||
|
|
||||||
#define SERIAL_INTERRUPT_DATA_AVAILABLE (1 << 0)
|
#define SERIAL_INTERRUPT_DATA_AVAILABLE (1 << 0)
|
||||||
#define SERIAL_INTERRUPT_TRANSMITTER_EMPTY (1 << 1)
|
#define SERIAL_INTERRUPT_TRANSMITTER_EMPTY (1 << 1)
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
// Created by rick on 8/18/19.
|
// Created by rick on 8/18/19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <drivers/vgascreen.h>
|
#include <string.h>
|
||||||
|
#include <myke/drivers/vgascreen.h>
|
||||||
|
|
||||||
#include <libc/libc.h>
|
#include <myke/drivers/ports.h>
|
||||||
#include <drivers/ports.h>
|
|
||||||
|
|
||||||
char *_vga_character_memory = (char *) VGA_CHARACTER_MEMORY_LOCATION;
|
char *_vga_character_memory = (char *) VGA_CHARACTER_MEMORY_LOCATION;
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
// Created by rick on 06-02-21.
|
// Created by rick on 06-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <libc/libc.h>
|
#include <stdlib.h>
|
||||||
#include <libk/libk.h>
|
#include <string.h>
|
||||||
#include <libc/kprintf.h>
|
#include <stdio.h>
|
||||||
#include <mem/malloc.h>
|
|
||||||
#include <tasks/task.h>
|
#include <myke/libk/libk.h>
|
||||||
#include <tasks/locking.h>
|
#include <myke/tasks/task.h>
|
||||||
#include <attributes.h>
|
#include <myke/tasks/locking.h>
|
||||||
#include <fs/blockdev.h>
|
#include <myke/attributes.h>
|
||||||
|
#include <myke/fs/blockdev.h>
|
||||||
|
|
||||||
#define MAX_BLOCK_DEVS 64
|
#define MAX_BLOCK_DEVS 64
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,13 @@
|
|||||||
// Created by rick on 07-02-21.
|
// Created by rick on 07-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <fs/fat.h>
|
#include <stdlib.h>
|
||||||
#include <fs/blockdev.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <types.h>
|
#include <myke/fs/blockdev.h>
|
||||||
#include <libc/libc.h>
|
#include <sys/types.h>
|
||||||
#include <libc/kprintf.h>
|
#include <myke/attributes.h>
|
||||||
#include <mem/malloc.h>
|
|
||||||
#include <attributes.h>
|
|
||||||
|
|
||||||
#define FAT_TYPE_12 1
|
#define FAT_TYPE_12 1
|
||||||
#define FAT_TYPE_16 2
|
#define FAT_TYPE_16 2
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
// Created by rick on 06-02-21.
|
// Created by rick on 06-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <fs/mbr.h>
|
#include <stdlib.h>
|
||||||
#include <types.h>
|
#include <string.h>
|
||||||
#include <drivers/ide.h>
|
#include <stdio.h>
|
||||||
#include <libc/kprintf.h>
|
#include <sys/types.h>
|
||||||
#include <fs/blockdev.h>
|
|
||||||
#include <libc/libc.h>
|
#include <myke/fs/mbr.h>
|
||||||
#include <mem/malloc.h>
|
#include <myke/drivers/ide.h>
|
||||||
#include <attributes.h>
|
#include <myke/fs/blockdev.h>
|
||||||
|
#include <myke/attributes.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t bootable;
|
uint8_t bootable;
|
||||||
@@ -36,7 +37,8 @@ typedef struct {
|
|||||||
uint32_t start_lba;
|
uint32_t start_lba;
|
||||||
} mbr_block_driver_info;
|
} 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) {
|
if (!device->flags.present || lba > device->num_lba) {
|
||||||
return BLOCK_DEV_ACCESS_ERR;
|
return BLOCK_DEV_ACCESS_ERR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,24 @@
|
|||||||
#include <drivers/vgascreen.h>
|
#include <stdio.h>
|
||||||
#include <cpu/isr.h>
|
|
||||||
#include <cpu/timer.h>
|
|
||||||
#include <drivers/keyboard.h>
|
|
||||||
#include <mem/mem.h>
|
|
||||||
#include <multiboot.h>
|
#include <multiboot.h>
|
||||||
#include <drivers/serial.h>
|
|
||||||
#include <libk/kprint.h>
|
#define DEBUG_INIT
|
||||||
#include <libk/libk.h>
|
|
||||||
#include <drivers/pci.h>
|
#include <myke/cpu/cpuidx.h>
|
||||||
#include <libc/kprintf.h>
|
#include <myke/cpu/isr.h>
|
||||||
#include <fs/blockdev.h>
|
#include <myke/cpu/timer.h>
|
||||||
#include <cpu/cpuidx.h>
|
#include <myke/debug/debug.h>
|
||||||
#include <tasks/task.h>
|
#include <myke/drivers/keyboard.h>
|
||||||
#include <libk/syscall.h>
|
#include <myke/drivers/pci.h>
|
||||||
#include <command.h>
|
#include <myke/drivers/serial.h>
|
||||||
#include <attributes.h>
|
#include <myke/drivers/vgascreen.h>
|
||||||
#include <debug/debug.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,
|
const int version_major = 0,
|
||||||
version_minor = 0,
|
version_minor = 0,
|
||||||
|
|||||||
@@ -2,14 +2,17 @@
|
|||||||
// Created by rick on 06-02-21.
|
// Created by rick on 06-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <libc/kprintf.h>
|
#include <string.h>
|
||||||
#include <libc/libc.h>
|
|
||||||
#include <libc/string.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <libk/kprint.h>
|
#include <stdlib.h>
|
||||||
#include <libk/libk.h>
|
#include <stdio.h>
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
const char* printf_null_str = "NULL";
|
|
||||||
|
#include <myke/libk/kprint.h>
|
||||||
|
#include <myke/libk/libk.h>
|
||||||
|
|
||||||
|
const char *printf_null_str = "NULL";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Integer to string
|
* Integer to string
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
// Created by rick on 01-02-21.
|
// Created by rick on 01-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <libc/readline.h>
|
#include <stdlib.h>
|
||||||
#include <libc/libc.h>
|
#include <string.h>
|
||||||
#include <types.h>
|
|
||||||
#include <libk/kprint.h>
|
#include <readline/readline.h>
|
||||||
#include <drivers/keyboard.h>
|
|
||||||
#include <mem/malloc.h>
|
#include <myke/libk/kprint.h>
|
||||||
|
#include <myke/drivers/keyboard.h>
|
||||||
|
|
||||||
#define RESULT_SIZE 256
|
#define RESULT_SIZE 256
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
// Created by rick on 30-01-21.
|
// Created by rick on 30-01-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <libc/ringqueue.h>
|
#include <stdlib.h>
|
||||||
#include <libc/libc.h>
|
#include <string.h>
|
||||||
#include <mem/malloc.h>
|
#include <myke/libc/ringqueue.h>
|
||||||
|
|
||||||
#define calc_pos(buffer, index) ((buffer->object_size) * (index))
|
#define calc_pos(buffer, index) ((buffer->object_size) * (index))
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
// Created by rick on 06-03-21.
|
// Created by rick on 06-03-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <libc/sort.h>
|
#include <stdlib.h>
|
||||||
#include <libc/libc.h>
|
#include <string.h>
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
// taken from https://github.com/DevSolar/pdclib/blob/master/functions/stdlib/qsort.c
|
// taken from https://github.com/DevSolar/pdclib/blob/master/functions/stdlib/qsort.c
|
||||||
|
|
||||||
|
|||||||
@@ -5,28 +5,23 @@
|
|||||||
* Author: rick
|
* Author: rick
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <types.h>
|
#include <stdlib.h>
|
||||||
#include <libc/libc.h>
|
|
||||||
|
|
||||||
int memcpy(uint8_t *dst, const uint8_t *src, int amount) {
|
/* everything of stdlib is implemented in this file except for:
|
||||||
for (int i = 0; i < amount; i++) {
|
* - qsort
|
||||||
dst[i] = src[i];
|
**/
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
int abs(int val) {
|
||||||
if (val >= 0) {
|
return val >= 0 ? val : (val * -1);
|
||||||
return val;
|
}
|
||||||
}
|
|
||||||
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/
|
// 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
|
// reverse the string and return it
|
||||||
return reverse(buffer, 0, i - 1);
|
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.
|
// Created by rick on 01-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <libc/string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <sys/param.h>
|
||||||
#include <libc/libc.h>
|
|
||||||
#include <types.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) {
|
int strcpy(char *dst, char *src) {
|
||||||
return memcpy(dst, src, strlen(src) + 1);
|
return memcpy(dst, src, strlen(src) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int strlen(const char *str) {
|
size_t strlen(const char *str) {
|
||||||
int length = 0;
|
int length = 0;
|
||||||
while (str[length] != 0) {
|
while (str[length] != 0) {
|
||||||
length++;
|
length++;
|
||||||
@@ -22,12 +35,12 @@ int strlen(const char *str) {
|
|||||||
int strcmp(const char *s1, const char *s2) {
|
int strcmp(const char *s1, const char *s2) {
|
||||||
int len1 = strlen(s1);
|
int len1 = strlen(s1);
|
||||||
int len2 = strlen(s2);
|
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) {
|
const char *strchr(const char *s, char c) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (true) {
|
while (1) {
|
||||||
if (s[index] == c) {
|
if (s[index] == c) {
|
||||||
return &s[index];
|
return &s[index];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
// Created by rick on 28-01-21.
|
// Created by rick on 28-01-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <util/stream.h>
|
#include <string.h>
|
||||||
#include <libc/string.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <attributes.h>
|
|
||||||
#include <tasks/task.h>
|
#include <myke/util/stream.h>
|
||||||
#include <libc/libc.h>
|
#include <myke/attributes.h>
|
||||||
#include <libk/kprint.h>
|
#include <myke/tasks/task.h>
|
||||||
|
#include <myke/libk/kprint.h>
|
||||||
|
|
||||||
#define MAX_HANDLERS 8
|
#define MAX_HANDLERS 8
|
||||||
#define STREAM_SIZE (32*1024)
|
#define STREAM_SIZE (32*1024)
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
// Created by rick on 02-02-21.
|
// Created by rick on 02-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <myke/libk/kprint.h>
|
||||||
#include <libk/kprint.h>
|
#include <myke/attributes.h>
|
||||||
#include <attributes.h>
|
#include <myke/libk/libk.h>
|
||||||
#include <libk/libk.h>
|
|
||||||
|
|
||||||
bool k_addr_in_kspace(void* addr) {
|
bool k_addr_in_kspace(void *addr) {
|
||||||
return addr > kernel_start && addr < kernel_end;
|
return addr > kernel_start && addr < kernel_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@ void noreturn k_panics(const char *msg) {
|
|||||||
|
|
||||||
void noreturn k_panic() {
|
void noreturn k_panic() {
|
||||||
kprint_sync("PANIC!");
|
kprint_sync("PANIC!");
|
||||||
while (true) {
|
while (1) {
|
||||||
__asm__ __volatile__("cli;"
|
__asm__ __volatile__("cli;"
|
||||||
"hlt;");
|
"hlt;");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,10 @@
|
|||||||
// Created by rick on 22-02-21.
|
// Created by rick on 22-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <libk/syscall.h>
|
#include <sys/types.h>
|
||||||
#include <types.h>
|
|
||||||
#include <attributes.h>
|
#include <myke/libk/syscall.h>
|
||||||
|
#include <myke/attributes.h>
|
||||||
|
|
||||||
void syscall1(uint32_t arg1) {
|
void syscall1(uint32_t arg1) {
|
||||||
__asm__("int $0x80"
|
__asm__("int $0x80"
|
||||||
@@ -28,7 +29,7 @@ void syscall_yield_job() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void syscall_yield_irq(uint16_t irq) {
|
void syscall_yield_irq(uint16_t irq) {
|
||||||
syscall2(SYSCALL_YIELD_IRQ, irq );
|
syscall2(SYSCALL_YIELD_IRQ, irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
void syscall_job_suspend() {
|
void syscall_job_suspend() {
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
// Created by rick on 23-02-21.
|
// Created by rick on 23-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <libc/kprintf.h>
|
#include <stdio.h>
|
||||||
#include <tasks/task.h>
|
|
||||||
#include <mem/malloc.h>
|
#include <myke/tasks/task.h>
|
||||||
#include <mem/pmm.h>
|
#include <myke/mem/malloc.h>
|
||||||
|
#include <myke/mem/pmm.h>
|
||||||
|
|
||||||
// retrieved from https://github.com/blanham/liballoc
|
// retrieved from https://github.com/blanham/liballoc
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
// Created by rick on 22-04-20.
|
// Created by rick on 22-04-20.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <mem/pmm.h>
|
#include <stdio.h>
|
||||||
#include <types.h>
|
#include <sys/types.h>
|
||||||
#include <mem/mem.h>
|
|
||||||
#include <libc/kprintf.h>
|
#include <myke/mem/pmm.h>
|
||||||
#include <libk/libk.h>
|
#include <myke/mem/mem.h>
|
||||||
#include <attributes.h>
|
#include <myke/libk/libk.h>
|
||||||
|
#include <myke/attributes.h>
|
||||||
|
|
||||||
#define MEMMAP_ENTRIES 16
|
#define MEMMAP_ENTRIES 16
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
// Created by rick on 21-02-21.
|
// Created by rick on 21-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <mem/paging.h>
|
|
||||||
#include <types.h>
|
|
||||||
#include <stdbool.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 TABLE_ADDR_MASK 0xFFFFF000
|
||||||
#define DIRECTORY_SIZE 1024
|
#define DIRECTORY_SIZE 1024
|
||||||
|
|||||||
@@ -3,9 +3,10 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <libc/libc.h>
|
#include <string.h>
|
||||||
#include <libk/libk.h>
|
|
||||||
#include <mem/pmm.h>
|
#include <myke/libk/libk.h>
|
||||||
|
#include <myke/mem/pmm.h>
|
||||||
|
|
||||||
#define NUM_PAGING_INFOS 16
|
#define NUM_PAGING_INFOS 16
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
// Created by rick on 27-02-21.
|
// Created by rick on 27-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <tasks/locking.h>
|
#include <stdlib.h>
|
||||||
#include <mem/malloc.h>
|
#include <stdio.h>
|
||||||
#include <tasks/task.h>
|
|
||||||
#include <libk/syscall.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <libc/kprintf.h>
|
#include <string.h>
|
||||||
#include <libc/libc.h>
|
|
||||||
|
#include <myke/tasks/locking.h>
|
||||||
|
#include <myke/tasks/task.h>
|
||||||
|
#include <myke/libk/syscall.h>
|
||||||
|
|
||||||
typedef struct lock_fifo_entry {
|
typedef struct lock_fifo_entry {
|
||||||
uint32_t tid;
|
uint32_t tid;
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
// Created by rick on 22-02-21.
|
// Created by rick on 22-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <tasks/task.h>
|
#include <stdlib.h>
|
||||||
#include <cpu/cpu.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <libc/libc.h>
|
#include <string.h>
|
||||||
#include <mem/malloc.h>
|
|
||||||
#include <mem/pmm.h>
|
|
||||||
|
|
||||||
#include <attributes.h>
|
#include <myke/tasks/task.h>
|
||||||
#include <libk/libk.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))
|
#define stack_end(task) ((task)->stack + ((task)->stack_page_count * PAGE_SIZE))
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
// Created by rick on 03-03-21.
|
// Created by rick on 03-03-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <drivers/ports.h>
|
#include <myke/drivers/ports.h>
|
||||||
#include <attributes.h>
|
#include <myke/attributes.h>
|
||||||
#include <libk/libk.h>
|
#include <myke/libk/libk.h>
|
||||||
#include <util/power.h>
|
#include <myke/util/power.h>
|
||||||
|
|
||||||
void noreturn power_shutdown() {
|
void noreturn power_shutdown() {
|
||||||
port_word_out(PORT_ACPI, PORT_ACPI_SHUTDOWN);
|
port_word_out(PORT_ACPI, PORT_ACPI_SHUTDOWN);
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
// Created by rick on 02-03-21.
|
// Created by rick on 02-03-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <mem/malloc.h>
|
#include <stdlib.h>
|
||||||
#include <libc/libc.h>
|
#include <string.h>
|
||||||
#include <tasks/locking.h>
|
|
||||||
#include <util/stream.h>
|
#include <myke/tasks/locking.h>
|
||||||
|
#include <myke/util/stream.h>
|
||||||
|
|
||||||
struct stream {
|
struct stream {
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
|
|||||||
Reference in New Issue
Block a user