Added alloc function(heap)
This commit is contained in:
31
kernel/cpu/assert.c
Normal file
31
kernel/cpu/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("PANIC(");
|
||||
kprint(message);
|
||||
kprint(") at ");
|
||||
kprint(file);
|
||||
kprint(":");
|
||||
kprint_dec(line);
|
||||
kprint("\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("ASSERTION-FAILED(");
|
||||
kprint(desc);
|
||||
kprint(") at ");
|
||||
kprint(file);
|
||||
kprint(":");
|
||||
kprint_dec(line);
|
||||
kprint("\n");
|
||||
// Now hang on forever
|
||||
for(;;);
|
||||
}
|
||||
21
kernel/cpu/assert.h
Normal file
21
kernel/cpu/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