Trying to fix kheap...
This commit is contained in:
@@ -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
31
kernel/libc/assert.c
Normal 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
21
kernel/libc/assert.h
Normal 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
|
||||
Reference in New Issue
Block a user