#define FOOLOS_MODULE_NAME "log" #include #include #include "log.h" #include "kernel/kernel.h" #include "kernel/config.h" #include "kernel/timer.h" #include "kernel/fifo.h" #include "lib/string/string.h" static char buffer[LOG_BUF_SIZE]; static int first=0; static int last=0; static bool init=true;// static void log_string(char *str) { while(*str!=0) { fifo_put(&get_fool()->std_out,*(str++)); } } static char* whitelist[]={FOOLOS_LOG_WHITELIST}; void log(char *module_name, int log_level, char *format_string, ...) { #ifdef FOOLOS_LOG_OFF for(int i=0;i<3;i++) { if(!strcmp(module_name,whitelist[i]))break; if(!strcmp("",whitelist[i]))return; } #endif if(log_level=LOG_BUF_SIZE)first=(first+1)%LOG_BUF_SIZE; if(last>first)if(LOG_BUF_SIZE-last+first>=LOG_BUF_SIZE)first=(first+1)%LOG_BUF_SIZE; } } void panic(char *module_name, char *message) { char buf_log[256]; tfp_sprintf(buf_log,"\033[41;37m\n !! KERNEL PANIC !! %s: %s\n\n",module_name,message); log_string(buf_log); while(1) { asm volatile("cli"); asm volatile("hlt"); } }