diff options
| author | Miguel <m.i@gmx.at> | 2018-08-22 16:35:12 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-08-22 16:35:12 +0200 |
| commit | 98bf7b67543b36b6fe49f2b68c115ebeaf630603 (patch) | |
| tree | aad818381dfc42c4158b923d588bbe8d34f51e51 /kernel | |
| parent | 323fb9d3e09903d6fa43ef7e1f0cc8934414c8d4 (diff) | |
cleanup logging
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/acpi.c | 29 | ||||
| -rw-r--r-- | kernel/fifo.c | 2 | ||||
| -rw-r--r-- | kernel/gdt.c | 3 | ||||
| -rw-r--r-- | kernel/interrupts.c | 85 | ||||
| -rw-r--r-- | kernel/kernel.c | 12 | ||||
| -rw-r--r-- | kernel/kernel.h | 3 | ||||
| -rw-r--r-- | kernel/kmalloc.c | 8 | ||||
| -rw-r--r-- | kernel/log.c | 6 | ||||
| -rw-r--r-- | kernel/mem.c | 26 | ||||
| -rw-r--r-- | kernel/mp.c | 39 | ||||
| -rw-r--r-- | kernel/multiboot.c | 37 | ||||
| -rw-r--r-- | kernel/scheduler.c | 16 | ||||
| -rw-r--r-- | kernel/smashing.c | 3 | ||||
| -rw-r--r-- | kernel/smp.c | 15 | ||||
| -rw-r--r-- | kernel/spinlock.c | 4 | ||||
| -rw-r--r-- | kernel/syscalls.c | 42 | ||||
| -rw-r--r-- | kernel/vmem.c | 32 |
17 files changed, 185 insertions, 177 deletions
diff --git a/kernel/acpi.c b/kernel/acpi.c index 169aa84..c41e91f 100644 --- a/kernel/acpi.c +++ b/kernel/acpi.c @@ -1,3 +1,4 @@ +#include "kernel/kernel.h" // Advanced Configuration and Power Interface // http://wiki.xomb.org/index.php?title=ACPI_Tables @@ -56,17 +57,17 @@ typedef struct uint8_t *apci_get_next_entry(uint8_t *addr,smp_processors *procdata) { - log(FOOLOS_MODULE_NAME,20,"Examining MADT Entry at 0x%08X",addr); + klog("Examining MADT Entry at 0x%08X",addr); if(*addr==0) { - log(FOOLOS_MODULE_NAME,5,"MADT Entry: LocalAPIC"); + klog("MADT Entry: LocalAPIC"); // usable if(addr[4]&1) { if(procdata->processors>=SMP_MAX_PROC){ - panic(FOOLOS_MODULE_NAME,"we do not support that many processors. recompile with higher SMP_MAX_PROC."); + kpanic("we do not support that many processors. recompile with higher SMP_MAX_PROC."); } procdata->local_apic_id[procdata->processors]=addr[3]; @@ -76,10 +77,10 @@ uint8_t *apci_get_next_entry(uint8_t *addr,smp_processors *procdata) } else if(*addr==1) { - log(FOOLOS_MODULE_NAME,5,"MADT Entry: IO APIC"); + klog("MADT Entry: IO APIC"); } - else if(*addr==2)log(FOOLOS_MODULE_NAME,5,"MADT Entry: Interrupt Source Override"); - else log(FOOLOS_MODULE_NAME,5,"MADT Entry: type:0x%X",*addr); + else if(*addr==2)klog("MADT Entry: Interrupt Source Override"); + else klog("MADT Entry: type:0x%X",*addr); return addr+addr[1]; } @@ -89,10 +90,10 @@ void acpi_check_madt(uint32_t *madt,smp_processors *procdata) { acpi_madt *table=(acpi_madt *)*madt; - log(FOOLOS_MODULE_NAME,20,"Looking for MADT Table at %08X.",table); + klog("Looking for MADT Table at %08X.",table); if(!strcmp_l("APIC",table->sig,4)) { - log(FOOLOS_MODULE_NAME,5,"Found MADT Table at 0x%08X",table); + klog("Found MADT Table at 0x%08X",table); uint8_t *end=(uint8_t *)table; end+=table->length; @@ -112,17 +113,17 @@ void acpi_check_madt(uint32_t *madt,smp_processors *procdata) void acpi_read_rsdt(acpi_rsdt *rsdt,smp_processors *procdata) { - log(FOOLOS_MODULE_NAME,5,"Reading RSDT Table at 0x%08X",rsdt); + klog("Reading RSDT Table at 0x%08X",rsdt); if(strcmp_l("RSDT",rsdt->sig,4)) - panic(FOOLOS_MODULE_NAME,"Signature MISMATCH!"); + kpanic("Signature MISMATCH!"); int entries=(rsdt->length-sizeof(acpi_rsdt))/4; uint32_t *first=(uint32_t *)rsdt; first+=sizeof(acpi_rsdt)/4; - log(FOOLOS_MODULE_NAME,5,"Entries: %d",entries); - log(FOOLOS_MODULE_NAME,5,"Looking for MADT Table"); + klog("Entries: %d",entries); + klog("Looking for MADT Table"); for(int i=0;i<entries;i++) { @@ -138,7 +139,7 @@ void acpi_read_rsdt(acpi_rsdt *rsdt,smp_processors *procdata) bool acpi_find(smp_processors *procdata) { - log(FOOLOS_MODULE_NAME,5,"Looking for RSDP Table"); + klog("Looking for RSDP Table"); char *search=(char *)0x9f000; //will be 16 bit aligned; procdata->processors=0; procdata->boot=0; @@ -153,7 +154,7 @@ bool acpi_find(smp_processors *procdata) if(checksum==0) { - log(FOOLOS_MODULE_NAME,5,"RSDP Table found at 0x%08X",search); + klog("RSDP Table found at 0x%08X",search); acpi_rsdp *rsdp=(acpi_rsdp *)search; acpi_read_rsdt(rsdp->ptr_rsdt,procdata); return true; diff --git a/kernel/fifo.c b/kernel/fifo.c index 5366cef..73df8b1 100644 --- a/kernel/fifo.c +++ b/kernel/fifo.c @@ -26,7 +26,7 @@ bool fifo_has(fifo* f) fifo fifo_create_buffered(uint8_t size) { - if (ringbuffer_c>=FIFO_MAX_RINGBUFFERS) panic(FOOLOS_MODULE_NAME,"ran out of ringbuffers for fifos"); + if (ringbuffer_c>=FIFO_MAX_RINGBUFFERS) kpanic("ran out of ringbuffers for fifos"); fifo f; fifo_ringbuffers[ringbuffer_c]=ringbuffer_init(size); diff --git a/kernel/gdt.c b/kernel/gdt.c index 46bf61a..dc760f2 100644 --- a/kernel/gdt.c +++ b/kernel/gdt.c @@ -1,3 +1,4 @@ +#include "kernel/kernel.h" // http://wiki.osdev.org/GDT_Tutorial #include "usermode.h" @@ -50,7 +51,7 @@ void encodeGdtEntry(uint8_t *target, GDT source) // Check the limit to make sure that it can be encoded if ((source.limit > 65536) && (source.limit & 0xFFF) != 0xFFF) { - panic(FOOLOS_MODULE_NAME,"trying to set an invalid GDT source.limit!"); + kpanic("trying to set an invalid GDT source.limit!"); } if (source.limit > 65536) { // Adjust granularity if required diff --git a/kernel/interrupts.c b/kernel/interrupts.c index f9b80a8..51682b4 100644 --- a/kernel/interrupts.c +++ b/kernel/interrupts.c @@ -1,5 +1,4 @@ - - +#include "kernel/kernel.h" #include "asm/asm.h" #include "asm/pit.h" #include "driver/mouse.h" @@ -10,14 +9,14 @@ void errlog(uint32_t error_code) { - log(FOOLOS_MODULE_NAME,5,"error_code: 0x%08X",error_code); + klog("error_code: 0x%08X",error_code); } -void deflog(uint32_t eip, uint16_t cs, uint32_t flags) +void defklog(uint32_t eip, uint16_t cs, uint32_t flags) { - log(FOOLOS_MODULE_NAME,5,"eip: 0x%08X",eip); - log(FOOLOS_MODULE_NAME,5,"segment: 0x%08X",cs); - log(FOOLOS_MODULE_NAME,5,"eflags: 0x%08X",flags); + klog("eip: 0x%08X",eip); + klog("segment: 0x%08X",cs); + klog("eflags: 0x%08X",flags); } void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr); @@ -45,63 +44,63 @@ static struct idt_desc void exception_handle() { - panic(FOOLOS_MODULE_NAME,"exception interrupt"); + kpanic("exception interrupt"); } void int_default() { - log(FOOLOS_MODULE_NAME,5,"default handler"); - panic(FOOLOS_MODULE_NAME,"unhandled interrupt (is this a panic or should just iognore?)"); + klog("default handler"); + kpanic("unhandled interrupt (is this a panic or should just iognore?)"); } void show_error(uint32_t err) { - log(FOOLOS_MODULE_NAME,5,"interrupt error code: 0x%08x",err); - log(FOOLOS_MODULE_NAME,5,"External Event: %x",err&0b001); - log(FOOLOS_MODULE_NAME,5,"Location: %x",err&0b110); - log(FOOLOS_MODULE_NAME,5,"Selector: %x",err&0b1111111111111000); + klog("interrupt error code: 0x%08x",err); + klog("External Event: %x",err&0b001); + klog("Location: %x",err&0b110); + klog("Selector: %x",err&0b1111111111111000); } -void exception_handle_0(){ panic(FOOLOS_MODULE_NAME,"Divide by 0"); } -void exception_handle_1(){ panic(FOOLOS_MODULE_NAME,"Single step (debugger)"); } -void exception_handle_2(){ panic(FOOLOS_MODULE_NAME,"Non Maskable Interrupt"); } -void exception_handle_3(){ panic(FOOLOS_MODULE_NAME,"Breakpoint (debugger)"); } -void exception_handle_4(){ panic(FOOLOS_MODULE_NAME,"Overflow"); } -void exception_handle_5(){ panic(FOOLOS_MODULE_NAME,"Bounds check"); } -void exception_handle_6(){ panic(FOOLOS_MODULE_NAME,"Undefined OP Code"); } -void exception_handle_7(){ panic(FOOLOS_MODULE_NAME,"No coprocessor"); } -void exception_handle_8(){ panic(FOOLOS_MODULE_NAME,"Double Fault"); } -void exception_handle_9(){ panic(FOOLOS_MODULE_NAME,"Coprocessor Segment Overrun"); } -void exception_handle_10(){ panic(FOOLOS_MODULE_NAME,"Invalid TSS"); } -void exception_handle_11(){ panic(FOOLOS_MODULE_NAME,"Segment Not Present"); } -void exception_handle_12(){ panic(FOOLOS_MODULE_NAME,"Stack Segment Overrun"); } +void exception_handle_0(){ kpanic("Divide by 0"); } +void exception_handle_1(){ kpanic("Single step (debugger)"); } +void exception_handle_2(){ kpanic("Non Maskable Interrupt"); } +void exception_handle_3(){ kpanic("Breakpoint (debugger)"); } +void exception_handle_4(){ kpanic("Overflow"); } +void exception_handle_5(){ kpanic("Bounds check"); } +void exception_handle_6(){ kpanic("Undefined OP Code"); } +void exception_handle_7(){ kpanic("No coprocessor"); } +void exception_handle_8(){ kpanic("Double Fault"); } +void exception_handle_9(){ kpanic("Coprocessor Segment Overrun"); } +void exception_handle_10(){ kpanic("Invalid TSS"); } +void exception_handle_11(){ kpanic("Segment Not Present"); } +void exception_handle_12(){ kpanic("Stack Segment Overrun"); } void exception_handle_13(uint32_t error_code,uint32_t eip,uint16_t cs,uint16_t unused, uint32_t flags) { errlog(error_code); - deflog(eip,cs,flags); + defklog(eip,cs,flags); - panic(FOOLOS_MODULE_NAME,"Exception: Fault: General Protection Fault"); + kpanic("Exception: Fault: General Protection Fault"); } void exception_handle_14(uint32_t error_code,uint32_t eip,uint16_t cs,uint16_t unused, uint32_t flags) { errlog(error_code); - log(FOOLOS_MODULE_NAME,5,"error_code_P: %d",error_code&1?1:0); - log(FOOLOS_MODULE_NAME,5,"error_code_W/R: %d",error_code&2?1:0); - log(FOOLOS_MODULE_NAME,5,"error_code_U/S: %d",error_code&4?1:0); - log(FOOLOS_MODULE_NAME,5,"error_code_RSVD: %d",error_code&8?1:0); - log(FOOLOS_MODULE_NAME,5,"error_code_I/D: %d",error_code&16?1:0); - log(FOOLOS_MODULE_NAME,5,"at addr: 0x%08X",x86_get_cr(2)); + klog("error_code_P: %d",error_code&1?1:0); + klog("error_code_W/R: %d",error_code&2?1:0); + klog("error_code_U/S: %d",error_code&4?1:0); + klog("error_code_RSVD: %d",error_code&8?1:0); + klog("error_code_I/D: %d",error_code&16?1:0); + klog("at addr: 0x%08X",x86_get_cr(2)); - deflog(eip,cs,flags); - panic(FOOLOS_MODULE_NAME,"Exception: Fault: Page Fault"); + defklog(eip,cs,flags); + kpanic("Exception: Fault: Page Fault"); } -void exception_handle_15(){ panic(FOOLOS_MODULE_NAME,"Unassigned"); } -void exception_handle_16(){ panic(FOOLOS_MODULE_NAME,"Coprocessor error"); } -void exception_handle_17(){ panic(FOOLOS_MODULE_NAME,"Alignment Check"); } -void exception_handle_18(){ panic(FOOLOS_MODULE_NAME,"Machine Check"); } +void exception_handle_15(){ kpanic("Unassigned"); } +void exception_handle_16(){ kpanic("Coprocessor error"); } +void exception_handle_17(){ kpanic("Alignment Check"); } +void exception_handle_18(){ kpanic("Machine Check"); } //set a handler for a specific interrupt void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr) @@ -119,10 +118,10 @@ void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr) void interrupts_init(uint16_t sel) { // Setup PIC - log(FOOLOS_MODULE_NAME,5,"setting up PIC",&idt,&idtd); + klog("setting up PIC",&idt,&idtd); pic_setup(); - log(FOOLOS_MODULE_NAME,5,"initializing. IDT: 0x%08x, IDTD: 0x%08X",&idt,&idtd); + klog("initializing. IDT: 0x%08x, IDTD: 0x%08X",&idt,&idtd); for(int i=0; i<INT_MAX; i++) { diff --git a/kernel/kernel.c b/kernel/kernel.c index c2d85ba..7784e64 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -31,19 +31,19 @@ void kernel_main(uint32_t eax,uint32_t ebx) klog ("%s - BUILD: git-%s (%s %s)",KERNEL_NAME,GIT_REVISION,__DATE__,__TIME__); - log(FOOLOS_MODULE_NAME,5,"COM 1 - initialized"); + klog("COM 1 - initialized"); uint64_t epoch_time=timer_init(); - log(FOOLOS_MODULE_NAME,5,"PIT - initialized. %u seconds passed since 1970.",epoch_time); + klog("PIT - initialized. %u seconds passed since 1970.",epoch_time); keyboard_init(0); //sstdin - log(FOOLOS_MODULE_NAME,5,"Keyboard Initialized"); + klog("Keyboard Initialized"); mouse_init(); - log(FOOLOS_MODULE_NAME,5,"Mouse Initialized"); + klog("Mouse Initialized"); gdt_init(); - log(FOOLOS_MODULE_NAME,5,"GDT Initialized"); + klog("GDT Initialized"); // MULTIBOOT HEADER multiboot_information *info=get_multiboot(eax, ebx); @@ -53,7 +53,7 @@ void kernel_main(uint32_t eax,uint32_t ebx) // //if(!acpi_find(&procdata)) // if(!mp_find(&procdata)) - // panic(FOOLOS_MODULE_NAME,"ACPI and MP search failed! I do not want to continue!"); + // kpanic("ACPI and MP search failed! I do not want to continue!"); // MEMORY INIT (allows allocating and deaclloating physical memory) uint32_t kernel_blocks=mem_init(info); diff --git a/kernel/kernel.h b/kernel/kernel.h index ee71315..f1ce9d3 100644 --- a/kernel/kernel.h +++ b/kernel/kernel.h @@ -20,6 +20,7 @@ #define KMALLOC_MEM_SIZE 1024*1024*8 // 8MB for in kernel-memory #define NUMBER_SPINLOCKS 16 -#define klog(format, ...) log(__FILE__,10,format, __VA_ARGS__) +#define kpanic(...) log(__FILE__,0,__VA_ARGS__) +#define klog(...) log(__FILE__,10,__VA_ARGS__) #endif diff --git a/kernel/kmalloc.c b/kernel/kmalloc.c index 25c2006..ec714c4 100644 --- a/kernel/kmalloc.c +++ b/kernel/kmalloc.c @@ -24,7 +24,7 @@ static void kmallocinit() } // - log(FOOLOS_MODULE_NAME,5,"kmalloc_init: 0x%08X",next); + klog("kmalloc_init: 0x%08X",next); init=1; } @@ -40,16 +40,16 @@ uint32_t kballoc(uint32_t size) if(next>=first+KMALLOC_MEM_SIZE) { - panic(FOOLOS_MODULE_NAME,"kballoc ran out of memory! maybe increase KMALLOC_MEM_SIZE in kmalloc.c?"); + kpanic("kballoc ran out of memory! maybe increase KMALLOC_MEM_SIZE in kmalloc.c?"); } - log(FOOLOS_MODULE_NAME,5,"(%d) : 0x%08X (~%dKB left)",size,old,(KMALLOC_MEM_SIZE-next+first)/1024); + klog("(%d) : 0x%08X (~%dKB left)",size,old,(KMALLOC_MEM_SIZE-next+first)/1024); return old; } //TODO: allow freeing memory!! uint32_t kbfree(uint32_t pos) { - panic(FOOLOS_MODULE_NAME,"kbfree NOT IMPLEMENTED YET"); + kpanic("kbfree NOT IMPLEMENTED YET"); } diff --git a/kernel/log.c b/kernel/log.c index 95aa83c..3986592 100644 --- a/kernel/log.c +++ b/kernel/log.c @@ -18,7 +18,7 @@ static void log_string(char *str) } } -void log(char *module_name, int log_level, char *format_string, ...) +void log(char *module_name, int prio, char *format_string, ...) { #ifdef FOOLOS_LOG_OFF return; @@ -44,7 +44,8 @@ void log(char *module_name, int log_level, char *format_string, ...) log_string(buf_log); } -void panic(char *module_name, char *message) +/* +void panic(char *module_name, char *format_string) { char buf_log[256]; tfp_sprintf(buf_log,"\033[41;37m\n !! KERNEL PANIC !! %s: %s\n\n\033[37;40m",module_name,message); @@ -59,3 +60,4 @@ void panic(char *module_name, char *message) asm volatile("hlt"); } } +*/ diff --git a/kernel/mem.c b/kernel/mem.c index 7738af7..c5fe43f 100644 --- a/kernel/mem.c +++ b/kernel/mem.c @@ -111,7 +111,7 @@ void* pmmngr_alloc_block () if (frame == -1) { - panic(FOOLOS_MODULE_NAME,"OUT OF MEMORY (alloc_block)"); + kpanic("OUT OF MEMORY (alloc_block)"); return 0; //out of memory } @@ -119,7 +119,7 @@ void* pmmngr_alloc_block () mem_free_blocks--; uint32_t addr = frame * PMMNGR_BLOCK_SIZE; - log(FOOLOS_MODULE_NAME,99,"alloc block (%d) 0x%08X)",frame,addr); + klog("alloc block (%d) 0x%08X)",frame,addr); return (void*)addr; } @@ -137,12 +137,12 @@ void pmmngr_free_block (void* p) } else { - log(FOOLOS_MODULE_NAME,10,"free block (%d) 0x%08X)",frame,addr); - panic(FOOLOS_MODULE_NAME,"trying to free, free physical mem!"); + klog("free block (%d) 0x%08X)",frame,addr); + kpanic("trying to free, free physical mem!"); } - log(FOOLOS_MODULE_NAME,99,"free block (%d) 0x%08X)",frame,addr); + klog("free block (%d) 0x%08X)",frame,addr); } @@ -151,17 +151,17 @@ uint32_t mem_init(multiboot_information *info) { if(info->flags&&1<<6) { - log(FOOLOS_MODULE_NAME,5,"memory map of length %d provided by bootloader",info->mmap_length); + klog("memory map of length %d provided by bootloader",info->mmap_length); } - else panic(FOOLOS_MODULE_NAME,"Unable to continue without memory map, sorry!"); + else kpanic("Unable to continue without memory map, sorry!"); pmmngr_init (); //clear memmap uint64_t memmap=info->mmap_addr; uint64_t length=info->mmap_length; - log(FOOLOS_MODULE_NAME,5,"kernel loaded at: 0x%08X- 0x%08X",kernel_start,kernel_end); - log(FOOLOS_MODULE_NAME,5,"initial stack at: 0x%08X- 0x%08X",stack_top,stack_bottom); + klog("kernel loaded at: 0x%08X- 0x%08X",kernel_start,kernel_end); + klog("initial stack at: 0x%08X- 0x%08X",stack_top,stack_bottom); // count available mem and track high_end of usable memory uint32_t total_mem=0, highest_end; @@ -174,7 +174,7 @@ uint32_t mem_init(multiboot_information *info) uint64_t mem_end=mmap->base_addr+mmap->length; #ifdef MEM_PRINT_MEMORYMAP - log(FOOLOS_MODULE_NAME,5,"%08X - %08X / type: %s, (size: %d)", + klog("%08X - %08X / type: %s, (size: %d)", (uint32_t)mem_start, (uint32_t)mem_end, memmap_type_to_string[mmap->type-1], mmap->size); #endif @@ -201,7 +201,7 @@ uint32_t mem_init(multiboot_information *info) multiboot_mod *mod=(multiboot_mod *)info->mods_addr; for(int i=0;i<info->mods_count;i++) { - log(FOOLOS_MODULE_NAME,5,"mod 0x%08X-0x%08X : %s", + klog("mod 0x%08X-0x%08X : %s", mod->mod_start,mod->mod_end, mod->string); mem_min_block=mod->mod_end/PMMNGR_BLOCK_SIZE+1; @@ -218,9 +218,9 @@ uint32_t mem_init(multiboot_information *info) // we deinit everything below mem_min_block anyway pmmngr_deinit_region(0,mem_min_block*PMMNGR_BLOCK_SIZE); - log(FOOLOS_MODULE_NAME,5,"Usable ~%d / %d MB ",mem_free_blocks*4096/1024/1024,total_mem/1024/1024); + klog("Usable ~%d / %d MB ",mem_free_blocks*4096/1024/1024,total_mem/1024/1024); - log(FOOLOS_MODULE_NAME,5, + klog( "Free 4K blocks: %d (first free: %d)",mem_free_blocks,mem_min_block); return mem_min_block; diff --git a/kernel/mp.c b/kernel/mp.c index 8e5a7a6..e03f224 100644 --- a/kernel/mp.c +++ b/kernel/mp.c @@ -1,3 +1,4 @@ +#include "kernel/kernel.h" #include <stdbool.h> @@ -66,21 +67,21 @@ uint8_t *walk_mp_table(uint8_t *start_addr,smp_processors *smp) { if(*start_addr==0x0||*start_addr==0x2) - log(FOOLOS_MODULE_NAME,5,"entry type: %d",*start_addr); + klog("entry type: %d",*start_addr); // that is a processor if(*start_addr==0x00) { proc_entry *pro=start_addr; - log(FOOLOS_MODULE_NAME,5,"local apic id: %02X",pro->apic_id); - log(FOOLOS_MODULE_NAME,5,"cpu enabled bit: %s",pro->cpu_bits&1?"yes":"no"); - log(FOOLOS_MODULE_NAME,5,"bootstrap cpu bit: %s",pro->cpu_bits&2?"yes":"no"); + klog("local apic id: %02X",pro->apic_id); + klog("cpu enabled bit: %s",pro->cpu_bits&1?"yes":"no"); + klog("bootstrap cpu bit: %s",pro->cpu_bits&2?"yes":"no"); // that is a enabled processor if(pro->cpu_bits&1) { if(smp->processors>=SMP_MAX_PROC) - panic(FOOLOS_MODULE_NAME,"we do not support that many processors. recompile with higher SMP_MAX_PROC."); + kpanic("we do not support that many processors. recompile with higher SMP_MAX_PROC."); smp->local_apic_id[smp->processors]=pro->apic_id; // that is the bootstrap processor @@ -101,12 +102,12 @@ void do_mp_conf(mp_config *addr,smp_processors *procdata) uint32_t *buf_addr=buf; *buf_addr=addr->sig; - log(FOOLOS_MODULE_NAME,5,"mp_config table addr: %08X",addr); - log(FOOLOS_MODULE_NAME,5,"mp_config signature: %s",buf); - log(FOOLOS_MODULE_NAME,5,"mp_config version: %02X",addr->version); - log(FOOLOS_MODULE_NAME,5,"mp_config # of entries: %d",addr->entries); - log(FOOLOS_MODULE_NAME,5,"mp_config local apic addr: 0x%08X",addr->local_apic); - log(FOOLOS_MODULE_NAME,5,"mp_config tabel length: %d",addr->length); + klog("mp_config table addr: %08X",addr); + klog("mp_config signature: %s",buf); + klog("mp_config version: %02X",addr->version); + klog("mp_config # of entries: %d",addr->entries); + klog("mp_config local apic addr: 0x%08X",addr->local_apic); + klog("mp_config tabel length: %d",addr->length); uint8_t *start_addr=addr; start_addr+=44; @@ -134,12 +135,12 @@ bool do_mp_fps(mp_fps *addr,smp_processors *procdata) uint32_t *buf_addr=buf; *buf_addr=addr->sig; - log(FOOLOS_MODULE_NAME,5,"signature: %s",buf); - log(FOOLOS_MODULE_NAME,5,"conf: %08X",addr->conf); - log(FOOLOS_MODULE_NAME,5,"ver: %02X",addr->version); - log(FOOLOS_MODULE_NAME,5,"f1: %02X",addr->features1); + klog("signature: %s",buf); + klog("conf: %08X",addr->conf); + klog("ver: %02X",addr->version); + klog("f1: %02X",addr->features1); - if(addr->features1!=0)panic(FOOLOS_MODULE_NAME,"Intel default config not supported yet!"); + if(addr->features1!=0)kpanic("Intel default config not supported yet!"); do_mp_conf(addr->conf,procdata); return true; @@ -149,13 +150,13 @@ bool do_mp_fps(mp_fps *addr,smp_processors *procdata) bool mp_find(smp_processors *procdata) { - log(FOOLOS_MODULE_NAME,5,"Looking for Mp Floating Ponter Struct..."); + klog("Looking for Mp Floating Ponter Struct..."); uint8_t *addr=0x8000; while(addr<=0xfffff) { if(!strcmp_l("_MP_",addr,4)) { - // log(FOOLOS_MODULE_NAME,5,"Found at 0x%04X",addr); + // klog("Found at 0x%04X",addr); if(do_mp_fps(addr,procdata))return true; } addr++; @@ -166,7 +167,7 @@ bool mp_find(smp_processors *procdata) { if(!strcmp_l("_MP_",addr,4)) { - // log(FOOLOS_MODULE_NAME,5,"Found at 0x%04X",addr); + // klog("Found at 0x%04X",addr); if(do_mp_fps(addr,procdata))return true; } addr++; diff --git a/kernel/multiboot.c b/kernel/multiboot.c index d1ab07c..a705e81 100644 --- a/kernel/multiboot.c +++ b/kernel/multiboot.c @@ -1,3 +1,4 @@ +#include "kernel/kernel.h" //https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#Boot-information-format #include "multiboot.h" @@ -6,78 +7,78 @@ multiboot_information* get_multiboot(uint32_t eax, uint32_t ebx) { - if(eax!=0x2badb002)panic(FOOLOS_MODULE_NAME,"EAX was not set properly by your bootlaoder!"); + if(eax!=0x2badb002)kpanic("EAX was not set properly by your bootlaoder!"); multiboot_information *info; info=ebx; - log(FOOLOS_MODULE_NAME,5,"multiboot flags: 0x%08X",info->flags); + klog("multiboot flags: 0x%08X",info->flags); if(info->flags&&1<<0) { - log(FOOLOS_MODULE_NAME,5,"[0] mem_lower: %d KB",info->mem_lower); - log(FOOLOS_MODULE_NAME,5,"[0] mem_upper: %d KB",info->mem_upper); + klog("[0] mem_lower: %d KB",info->mem_lower); + klog("[0] mem_upper: %d KB",info->mem_upper); } if(info->flags&&1<<1) { - log(FOOLOS_MODULE_NAME,5,"[1] boot-device 0x%08X",info->boot_device); + klog("[1] boot-device 0x%08X",info->boot_device); } if(info->flags&&1<<2) { - log(FOOLOS_MODULE_NAME,5,"[2] cmdline: \"%s\"",info->cmdline); + klog("[2] cmdline: \"%s\"",info->cmdline); } if(info->flags&&1<<3) { - log(FOOLOS_MODULE_NAME,5,"[3] loaded modules count: %d",info->mods_count); + klog("[3] loaded modules count: %d",info->mods_count); } if(info->flags&&1<<4) { - log(FOOLOS_MODULE_NAME,5,"[4/5] a.out kernel image symbols found"); + klog("[4/5] a.out kernel image symbols found"); } if(info->flags&&1<<5) { - log(FOOLOS_MODULE_NAME,5,"[4/5] ELF table: %d entries (sized %d) at 0x%08X",info->syms[0],info->syms[1],info->syms[2]); + klog("[4/5] ELF table: %d entries (sized %d) at 0x%08X",info->syms[0],info->syms[1],info->syms[2]); } if(info->flags&&1<<6) { - log(FOOLOS_MODULE_NAME,5,"[6] Found memory map"); + klog("[6] Found memory map"); } if(info->flags&&1<<7) { - log(FOOLOS_MODULE_NAME,5,"[7] Found Drives map"); + klog("[7] Found Drives map"); } if(info->flags&&1<<8) { - log(FOOLOS_MODULE_NAME,5,"[8] ROM Configuration Table at: 0x%08X",info->config_table); + klog("[8] ROM Configuration Table at: 0x%08X",info->config_table); } if(info->flags&&1<<9) { - log(FOOLOS_MODULE_NAME,5,"[9] Loaded by: \"%s\"",info->boot_loader_name); + klog("[9] Loaded by: \"%s\"",info->boot_loader_name); } if(info->flags&&1<<10) { - log(FOOLOS_MODULE_NAME,5,"[10] APM Table present."); + klog("[10] APM Table present."); } if(info->flags&&1<<11) { - log(FOOLOS_MODULE_NAME,5,"[11] VBE control info: 0x%08X",info->vbe_control_info); - log(FOOLOS_MODULE_NAME,5,"[11] VBE mode info: 0x%08X",info->vbe_mode_info); - log(FOOLOS_MODULE_NAME,5,"[11] VBE current mode (spec V3.0): 0x%08X",info->vbe_mode); + klog("[11] VBE control info: 0x%08X",info->vbe_control_info); + klog("[11] VBE mode info: 0x%08X",info->vbe_mode_info); + klog("[11] VBE current mode (spec V3.0): 0x%08X",info->vbe_mode); } if(info->flags&&1<<12) { - log(FOOLOS_MODULE_NAME,5,"[12] Framebuffer (w:%d h:%d bpp:%d) at addr=0x%08X",info->framebuffer_width,info->framebuffer_height,info->framebuffer_bpp,info->framebuffer_addr); + klog("[12] Framebuffer (w:%d h:%d bpp:%d) at addr=0x%08X",info->framebuffer_width,info->framebuffer_height,info->framebuffer_bpp,info->framebuffer_addr); } return info; diff --git a/kernel/scheduler.c b/kernel/scheduler.c index 6cd63fe..5cc5508 100644 --- a/kernel/scheduler.c +++ b/kernel/scheduler.c @@ -45,7 +45,7 @@ volatile int add_task(uint32_t esp, uint32_t vmem) } } - panic(FOOLOS_MODULE_NAME,"out of task slots!"); + kpanic("out of task slots!"); } // @@ -75,7 +75,7 @@ volatile uint32_t my_scheduler(uint32_t oldesp) if(task_list[pid].active && !task_list[pid].waiting) { // if(current_task!=pid) -// log(FOOLOS_MODULE_NAME,5,"switch from %d to %d", current_task, pid); +// klog("switch from %d to %d", current_task, pid); current_task=pid; install_tss(task_list[pid].esp0); @@ -86,7 +86,7 @@ volatile uint32_t my_scheduler(uint32_t oldesp) } - panic(FOOLOS_MODULE_NAME,"nothing to schedule!"); + kpanic("nothing to schedule!"); } // this gets called by our clock interrupt regularly! @@ -105,19 +105,19 @@ volatile uint32_t task_exit(uint32_t oldesp) task_list[current_task].active=false; int parent_pid=task_list[current_task].parent; - log(FOOLOS_MODULE_NAME,5,"[%d] exit ", current_task); + klog("[%d] exit ", current_task); if(task_list[parent_pid].active) { if(task_list[parent_pid].waiting) { - log(FOOLOS_MODULE_NAME,5,"[%d] wake up", parent_pid); + klog("[%d] wake up", parent_pid); task_list[parent_pid].waiting=false; } else { - log(FOOLOS_MODULE_NAME,5,"[%d] skipwait", parent_pid); + klog("[%d] skipwait", parent_pid); task_list[parent_pid].skipwait=true; } @@ -131,7 +131,7 @@ volatile uint32_t task_exit(uint32_t oldesp) volatile uint32_t task_wait(uint32_t oldesp) { - log(FOOLOS_MODULE_NAME,5,"[%d] wait", current_task); + klog("[%d] wait", current_task); if(task_list[current_task].skipwait) { task_list[current_task].skipwait=false; @@ -146,7 +146,7 @@ volatile uint32_t task_wait(uint32_t oldesp) volatile uint32_t task_fork(uint32_t oldesp) { int pid=add_task(oldesp,vmem_new_space_dir(task_list[current_task].vmem)); - log(FOOLOS_MODULE_NAME,5,"[%d] forked -> [%d] (free blocks remaining: %d )", current_task, pid,mem_get_free_blocks_count()); + klog("[%d] forked -> [%d] (free blocks remaining: %d )", current_task, pid,mem_get_free_blocks_count()); return pid; } diff --git a/kernel/smashing.c b/kernel/smashing.c index 4757b71..005e784 100644 --- a/kernel/smashing.c +++ b/kernel/smashing.c @@ -1,3 +1,4 @@ +#include "kernel/kernel.h" #include <stdint.h> // CODE FOR Stack Smashing Protector. // Do not duplicate with userspace / sys.c @@ -16,6 +17,6 @@ uintptr_t __stack_chk_guard = STACK_CHK_GUARD; __attribute__((noreturn)) void __stack_chk_fail(void) { - panic(FOOLOS_MODULE_NAME,"Stack smashing detected"); + kpanic("Stack smashing detected"); } // diff --git a/kernel/smp.c b/kernel/smp.c index 6a1068c..d4bb6a1 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -1,3 +1,4 @@ +#include "kernel/kernel.h" // http://www.intel.com/content/dam/doc/specification-update/64-architecture-x2apic-specification.pdf // http://download.intel.com/design/chipsets/datashts/29056601.pdf // http://www.scs.stanford.edu/05au-cs240c/lab/ia32/IA32-3.pdf @@ -27,12 +28,12 @@ void smp_main() { x86_cli(); - log(FOOLOS_MODULE_NAME,5,"local apic_addr:0x%08X",local_apic_addr); + klog("local apic_addr:0x%08X",local_apic_addr); while(1); //TODO!!! uint32_t *reg=local_apic_addr+FOOLOS_APIC_ID; - // log(FOOLOS_MODULE_NAME,5,"local apic id: 0x%08X",(*reg)); + // klog("local apic id: 0x%08X",(*reg)); *reg=local_apic_addr+FOOLOS_APIC_SPUR_INT; *reg|=0x100;//0xffffffff; // all bits 1 and interrupt 255 @@ -67,7 +68,7 @@ void kernel_ap() cpu_counter[p]++; //lock_spin(0); - if(cpu_counter[p]%1000000==0)log(FOOLOS_MODULE_NAME,20,"cpu[%d] %d",p,cpu_counter[p]); + if(cpu_counter[p]%1000000==0)klog("cpu[%d] %d",p,cpu_counter[p]); //lock_release(0); } @@ -75,10 +76,10 @@ void kernel_ap() void smp_log_procdata(smp_processors *procdata) { - log(FOOLOS_MODULE_NAME,5,"---- smp -----"); + klog("---- smp -----"); for(int i=0;i<procdata->processors;i++) { - log(FOOLOS_MODULE_NAME,5,"cpu %d, apic_id: 0x%X, bps: %s, apic_addr:0x%08X",i,procdata->local_apic_id[i],i==procdata->boot?"yes":"no",procdata->local_apic_address); + klog("cpu %d, apic_id: 0x%X, bps: %s, apic_addr:0x%08X",i,procdata->local_apic_id[i],i==procdata->boot?"yes":"no",procdata->local_apic_address); } } @@ -101,13 +102,13 @@ void smp_start_aps(smp_processors *pros,char *path) // *reg=0; uint32_t *reg=local_apic_addr+FOOLOS_APIC_ID; - log(FOOLOS_MODULE_NAME,5,"local apic id: 0x%08X",(*reg)); + klog("local apic id: 0x%08X",(*reg)); for(int i=0;i<pros->processors;i++) { if(pros->boot==i)continue; - log(FOOLOS_MODULE_NAME,5,"starting cpu %d",i); + klog("starting cpu %d",i); uint8_t dest=pros->local_apic_id[i]; diff --git a/kernel/spinlock.c b/kernel/spinlock.c index 9c21d06..bbc68c0 100644 --- a/kernel/spinlock.c +++ b/kernel/spinlock.c @@ -11,9 +11,9 @@ static volatile uint32_t spinlocks[NUMBER_SPINLOCKS]; void check_spinlocks() { - log(FOOLOS_MODULE_NAME,5,"Spinlocks at 0x%08X ",spinlocks); + klog("Spinlocks at 0x%08X ",spinlocks); for(int i=0;i<NUMBER_SPINLOCKS;i++) - log(FOOLOS_MODULE_NAME,5,"%d",spinlocks[i]); + klog("%d",spinlocks[i]); } /* diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 25e41e6..9f8d136 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -31,7 +31,7 @@ int syscall_unhandled(int nr) { char msg[256]; tfp_sprintf(msg, "unhandled syscall : %d",nr); - panic(FOOLOS_MODULE_NAME,msg); + kpanic(msg); } int syscall_gettimeofday(struct timeval *tv, struct timezone *tz) @@ -55,10 +55,10 @@ int syscall_gettimeofday(struct timeval *tv, struct timezone *tz) int syscall_lseek(int file,int ptr,int dir) { #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,5,"lseek (file=%d, ptr=%d, dir=%d)", file,ptr,dir); + klog("lseek (file=%d, ptr=%d, dir=%d)", file,ptr,dir); #endif - panic(FOOLOS_MODULE_NAME,"unhandled syscall: lseek"); + kpanic("unhandled syscall: lseek"); return 0; } @@ -67,7 +67,7 @@ int syscall_lseek(int file,int ptr,int dir) int syscall_write(int file, char *buf, int len) { #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,5,"[%d] write(file=%d, buf=0x%08X, len=%d)", task_get_current_pid(),file,buf,len); + klog("[%d] write(file=%d, buf=0x%08X, len=%d)", task_get_current_pid(),file,buf,len); #endif for(int i=0;i<len;i++) @@ -81,7 +81,7 @@ int syscall_write(int file, char *buf, int len) int syscall_read(int file, char *buf, int len) { #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,5,"read(file=%d, buf=0x%08X, len=%d)", file,buf,len); + klog("read(file=%d, buf=0x%08X, len=%d)", file,buf,len); #endif //file 0 = stdin , file 1 = stdout , file 2 = stderr @@ -106,7 +106,7 @@ int syscall_read(int file, char *buf, int len) int syscall_readdir(const char *name,fs_dirent *dirs,int max) { #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,5,"readdir(name=0x%08X, dirs=0x%08X, %d)", name,dirs,max); + klog("readdir(name=0x%08X, dirs=0x%08X, %d)", name,dirs,max); #endif return fs_readdir(name,dirs,max); @@ -117,7 +117,7 @@ int syscall_poll(int file) { file=2; //workaround #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,5,"has data waiting?"); + klog("has data waiting?"); #endif return fd_has(&fds[file]); @@ -127,7 +127,7 @@ int syscall_poll(int file) int syscall_tune(int v1,int v2, int v3) { #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,5,"tuning request"); + klog("tuning request"); #endif // osbolete @@ -149,15 +149,15 @@ int syscall_tune(int v1,int v2, int v3) int copy_args(char **in, char **out) { - //log(FOOLOS_MODULE_NAME,5,"copy_args(0x%08x, 0x%08X)",in,out); + //klog("copy_args(0x%08x, 0x%08X)",in,out); int count=0; while(in[count]!=NULL) { -// log(FOOLOS_MODULE_NAME,5,"args(0x%08x: %s)",in[count],out); +// klog("args(0x%08x: %s)",in[count],out); count++; }; - // log(FOOLOS_MODULE_NAME,5,"copy_args : count: %d",count); + // klog("copy_args : count: %d",count); char **pos=out; pos+=sizeof(char **)*(count+1); @@ -179,7 +179,7 @@ int copy_args(char **in, char **out) int syscall_execve(char *name, char **argv, char **env) { #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,5,"execve (name=0x%08X(%s), argvs=0x%08X, env=0x%08X)", name,name,argv,env); + klog("execve (name=0x%08X(%s), argvs=0x%08X, env=0x%08X)", name,name,argv,env); #endif int arg_count=0; @@ -211,14 +211,14 @@ int syscall_execve(char *name, char **argv, char **env) if(!entry_global) { #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,5,"execve: bailing out!"); + klog("execve: bailing out!"); #endif return -1; // errror loading } /* try to move this to asm */ // asm volatile("jmp ."); // loop forever - //log(FOOLOS_MODULE_NAME,5,"returning to jump addy (0x%08X)", entry_global); + //klog("returning to jump addy (0x%08X)", entry_global); asm volatile("mov $0x8fff000,%esp"); // set stack at high end of process image @@ -247,10 +247,10 @@ int get_max_fd() int syscall_open(char *name, int flags, int mode) { #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,5,"open (name=0x%08X(\"%s\"), flags=%d, mode=%d)",name, name,flags,mode); + klog("open (name=0x%08X(\"%s\"), flags=%d, mode=%d)",name, name,flags,mode); #endif - if( next_fifo>=MAX_FIFOS || next_fd>=MAX_FD)panic(FOOLOS_MODULE_NAME,"we ran out of fd's or fifo's"); + if( next_fifo>=MAX_FIFOS || next_fd>=MAX_FD)kpanic("we ran out of fd's or fifo's"); if(0!=strcmp(name,"term")) { @@ -286,11 +286,11 @@ int syscall_open(char *name, int flags, int mode) int syscall_close(int file,int none1,int none2) { #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,5,"close (file=%d)", file); + klog("close (file=%d)", file); #endif //if(file!=0&&file!=1&&file!=2) - // panic(FOOLOS_MODULE_NAME,"unhandled syscall: close"); + // kpanic("unhandled syscall: close"); return -1; } @@ -299,7 +299,7 @@ int syscall_close(int file,int none1,int none2) int syscall_isatty(int file,int none1,int none2) { #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,5,"isatty (file=%d)", file); + klog("isatty (file=%d)", file); #endif return 1; @@ -317,7 +317,7 @@ uint32_t syscall_sbrk(int incr, int none1, int none2) task_set_brk(alloc); #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,5,"sbrk (incr=%d) = 0x%08X", incr,oldalloc); + klog("sbrk (incr=%d) = 0x%08X", incr,oldalloc); #endif return oldalloc; @@ -327,7 +327,7 @@ uint32_t syscall_sbrk(int incr, int none1, int none2) int syscall_stat(const char *path, struct stat *st,int none) { #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,5,"stat (path=0x%08X,stat=0x%08X)", path,st); + klog("stat (path=0x%08X,stat=0x%08X)", path,st); #endif st->st_mode = S_IFCHR; diff --git a/kernel/vmem.c b/kernel/vmem.c index 3d78cae..76421d0 100644 --- a/kernel/vmem.c +++ b/kernel/vmem.c @@ -249,8 +249,8 @@ pdirectory* vmem_new_space_dir(pdirectory *copy_dir) // pdirectory* dir = (pdirectory*) kballoc(1); - log(FOOLOS_MODULE_NAME,5,"new pdirectory: 0x%X",dir); - if (!dir)panic(FOOLOS_MODULE_NAME,"unable to alloc pdirectory"); + klog("new pdirectory: 0x%X",dir); + if (!dir)kpanic("unable to alloc pdirectory"); // first of all let's zero all the entries for(int i=0;i<1024;i++)dir->m_entries [i]=0; @@ -271,7 +271,7 @@ pdirectory* vmem_new_space_dir(pdirectory *copy_dir) { // alloc space for our new table table = (ptable*) kballoc(1); - if (!table)panic(FOOLOS_MODULE_NAME,"unable to alloc table"); + if (!table)kpanic("unable to alloc table"); //! idenitity mapping for (int i=0, frame=phys_addr, virt=virt_addr; i<1024; i++, frame+=4096, virt+=4096) @@ -323,7 +323,7 @@ pdirectory* vmem_new_space_dir(pdirectory *copy_dir) { // alloc space for our new table table = (ptable*) kballoc(1); - if (!table)panic(FOOLOS_MODULE_NAME,"unable to alloc table"); + if (!table)kpanic("unable to alloc table"); //! idenitity mapping for (int i=0, frame=phys_addr, virt=virt_addr; i<1024; i++, frame+=4096, virt+=4096) @@ -374,22 +374,22 @@ pdirectory* vmem_new_space_dir(pdirectory *copy_dir) oldentry=&(copy_dir->m_entries[PAGE_DIRECTORY_INDEX(virt_addr)]); oldtable=pd_entry_get_frame(oldentry); } - log(FOOLOS_MODULE_NAME,20,"oldtable at: 0x%08X",oldtable); + klog("oldtable at: 0x%08X",oldtable); - if (!table)panic(FOOLOS_MODULE_NAME,"unable to alloc table"); - log(FOOLOS_MODULE_NAME,20,"alloc table: %08X",table); + if (!table)kpanic("unable to alloc table"); + klog("alloc table: %08X",table); for (int i=0, virt=virt_addr; i<1024; i++, virt+=4096) { - //log(FOOLOS_MODULE_NAME,5,"i = %d",i); + //klog("i = %d",i); phys_addr=pmmngr_alloc_block(); // get free space from the memory manager - if (!phys_addr)panic(FOOLOS_MODULE_NAME,"unable to alloc spce for frame"); + if (!phys_addr)kpanic("unable to alloc spce for frame"); // if this is not init , copy contents from current space! if(copy_dir!=NULL) { uint32_t addr_old=pt_entry_get_frame(&oldtable->m_entries[PAGE_TABLE_INDEX(virt)]); - log(FOOLOS_MODULE_NAME,99,"physical memcpy(0x%08X,0x%08X,4096)",phys_addr, addr_old); + klog("physical memcpy(0x%08X,0x%08X,4096)",phys_addr, addr_old); memcpy(phys_addr,addr_old,4096); } @@ -434,21 +434,21 @@ pdirectory* vmem_new_space_dir(pdirectory *copy_dir) oldentry=&(copy_dir->m_entries[PAGE_DIRECTORY_INDEX(virt_addr)]); oldtable=pd_entry_get_frame(oldentry); } - log(FOOLOS_MODULE_NAME,20,"oldtable at: 0x%08X",oldtable); + klog("oldtable at: 0x%08X",oldtable); - if (!table)panic(FOOLOS_MODULE_NAME,"unable to alloc table"); - log(FOOLOS_MODULE_NAME,20,"alloc table: %08X",table); + if (!table)kpanic("unable to alloc table"); + klog("alloc table: %08X",table); for (int i=0, virt=virt_addr; i<1024; i++, virt+=4096) { phys_addr=pmmngr_alloc_block(); // get free space from the memory manager - if (!phys_addr)panic(FOOLOS_MODULE_NAME,"unable to alloc spce for frame"); + if (!phys_addr)kpanic("unable to alloc spce for frame"); // if this is not init , copy contents from current space! if(copy_dir!=NULL) { uint32_t addr_old=pt_entry_get_frame(&oldtable->m_entries[PAGE_TABLE_INDEX(virt)]); - log(FOOLOS_MODULE_NAME,99,"physical memcpy(0x%08X,0x%08X,4096)",phys_addr, addr_old); + klog("physical memcpy(0x%08X,0x%08X,4096)",phys_addr, addr_old); memcpy(phys_addr,addr_old,4096); } @@ -481,7 +481,7 @@ pdirectory* vmem_new_space_dir(pdirectory *copy_dir) if(copy_dir==NULL) // this happens only on init { - log(FOOLOS_MODULE_NAME,5,"initializing virtual memory (paging)"); + klog("initializing virtual memory (paging)"); x86_set_page_directory(dir); } |
