feat: reformatted code base to be more standard
This commit is contained in:
@@ -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)
|
||||
@@ -63,8 +64,8 @@ int init_timer(uint32_t freq) {
|
||||
register_interrupt_handler(IRQ0, timer_callback);
|
||||
|
||||
uint32_t divisor = 1193180 / freq;
|
||||
uint8_t low = (uint8_t)(divisor & 0xFF);
|
||||
uint8_t high = (uint8_t)((divisor >> 8) & 0xFF);
|
||||
uint8_t low = (uint8_t) (divisor & 0xFF);
|
||||
uint8_t high = (uint8_t) ((divisor >> 8) & 0xFF);
|
||||
port_byte_out(PORT_PIT_COMMAND,
|
||||
PIT_MODE_BIN | PIT_MODE_HARDWARE_SQUARE_WAVE_GENERATOR | PIT_ACCESS_MODE_LH | PIT_CHANNEL_0);
|
||||
port_byte_out(PORT_PIT_DATA_0, low);
|
||||
|
||||
@@ -2,25 +2,27 @@
|
||||
// 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>
|
||||
|
||||
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;
|
||||
#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;
|
||||
static struct elf32_section_header *elf_symtab = NULL;
|
||||
static struct elf32_section_header *elf_strtab = NULL;
|
||||
static uint32_t elf_header_cnt;
|
||||
|
||||
static const char* elf_name_symtab = ".symtab";
|
||||
static const char* elf_name_strtab = ".strtab";
|
||||
static const char *elf_name_symtab = ".symtab";
|
||||
static const char *elf_name_strtab = ".strtab";
|
||||
|
||||
struct stackframe {
|
||||
struct stackframe* ebp;
|
||||
struct stackframe *ebp;
|
||||
uint32_t eip;
|
||||
};
|
||||
|
||||
@@ -31,7 +33,7 @@ char *debug_get_shstrtab_entry(uint32_t ndx) {
|
||||
if (ndx > elf_shstrtab->sh_size) {
|
||||
return NULL;
|
||||
}
|
||||
return ((char*)elf_shstrtab->sh_addr + ndx);
|
||||
return ((char *) elf_shstrtab->sh_addr + 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) {
|
||||
return NULL;
|
||||
}
|
||||
return ((char*)elf_strtab->sh_addr + ndx);
|
||||
return ((char *) elf_strtab->sh_addr + ndx);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
for (uint32_t i = 0; i < num; ++i) {
|
||||
// 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) {
|
||||
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");
|
||||
char msg[1024] = {0};
|
||||
while (frame->ebp != 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>
|
||||
const char* printf_null_str = "NULL";
|
||||
#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 * -1;
|
||||
return val >= 0 ? val : (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,12 +2,11 @@
|
||||
// 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) {
|
||||
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"
|
||||
@@ -28,7 +29,7 @@ void syscall_yield_job() {
|
||||
}
|
||||
|
||||
void syscall_yield_irq(uint16_t irq) {
|
||||
syscall2(SYSCALL_YIELD_IRQ, irq );
|
||||
syscall2(SYSCALL_YIELD_IRQ, irq);
|
||||
}
|
||||
|
||||
void syscall_job_suspend() {
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -83,7 +83,7 @@ void task_lock_acquire() {
|
||||
}
|
||||
|
||||
void task_lock_free() {
|
||||
if (__sync_sub_and_fetch(&task_locked, 1) == UINT32_MAX) {
|
||||
if (__sync_sub_and_fetch(&task_locked, 1) == UINT32_MAX) {
|
||||
k_panics("To many task free's");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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