Trying to fix kheap...

This commit is contained in:
ice-bit
2019-09-26 17:45:46 +02:00
parent 8ff8d71af8
commit 3e0e8043d5
19 changed files with 383 additions and 701 deletions

View File

@@ -1,4 +1,4 @@
OBJS = stdio.o string.o
OBJS = stdio.o string.o assert.o
CC = i686-elf-gcc # cross-compiler
CFLAGS = -m32 -fno-stack-protector -ffreestanding -Wall -Wextra -Werror -g -c

31
kernel/libc/assert.c Normal file
View File

@@ -0,0 +1,31 @@
#include "assert.h"
// We panic when we find a critical error, this function is called by assert macro
extern void panic(const char *message, const char *file, uint32_t line) {
asm volatile("cli"); // Disable interrupts
kprint((uint8_t*)"PANIC(");
kprint((uint8_t*)message);
kprint((uint8_t*)") at ");
kprint((uint8_t*)file);
kprint((uint8_t*)":");
kprint_dec(line);
kprint((uint8_t*)"\n");
// Now hang on for ever
for(;;);
}
// Check for assertion failed, this function call by assert macro
extern void panic_assert(const char *file, uint32_t line, const char *desc) {
asm volatile("cli"); // Disable interrupts
kprint((uint8_t*)"ASSERTION-FAILED(");
kprint((uint8_t*)desc);
kprint((uint8_t*)") at ");
kprint((uint8_t*)file);
kprint((uint8_t*)":");
kprint_dec(line);
kprint((uint8_t*)"\n");
// Now hang on forever
for(;;);
}

21
kernel/libc/assert.h Normal file
View File

@@ -0,0 +1,21 @@
/**************************************
* iceOS Kernel *
* Developed by Marco 'icebit' Cetica *
* (c) 2019 *
* Released under GPLv3 *
* https://github.com/ice-bit/iceOS *
***************************************/
#ifndef ASSERT_H
#define ASSERT_H
#include <stdint.h>
#include "../drivers/tty.h"
// These functions are used for error checking
#define PANIC(msg) panic(msg, __FILE__, __LINE__);
#define ASSERT(b) ((b) ? (void)0 : panic_assert(__FILE__, __LINE__, #b))
extern void panic(const char *message, const char *file, uint32_t line);
extern void panic_assert(const char *file, uint32_t line, const char *desc);
#endif