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 | |
| parent | 323fb9d3e09903d6fa43ef7e1f0cc8934414c8d4 (diff) | |
cleanup logging
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | driver/mouse.c | 7 | ||||
| -rw-r--r-- | driver/pci.c | 6 | ||||
| -rw-r--r-- | driver/vesa.c | 13 | ||||
| -rw-r--r-- | fs/elf.c | 55 | ||||
| -rw-r--r-- | fs/ext2.c | 31 | ||||
| -rw-r--r-- | fs/fs.c | 3 | ||||
| -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 | ||||
| -rw-r--r-- | xxx/inactive/floppy.c | 52 |
25 files changed, 272 insertions, 258 deletions
@@ -50,6 +50,7 @@ ASFLAGS+=-gstabs ########## verbosity ##################3 V = 0 CC = @echo "Compiling (i686-elf-gcc) $<..."; i686-elf-gcc +CC = i686-elf-gcc AS = @echo "Assembling (i686-elf-as) $<..."; i686-elf-as #CC_1 = $(CCC) #CC = $(CC_$(V)) diff --git a/driver/mouse.c b/driver/mouse.c index f70393c..958cdc4 100644 --- a/driver/mouse.c +++ b/driver/mouse.c @@ -1,3 +1,4 @@ +#include "kernel/kernel.h" //http://forum.osdev.org/viewtopic.php?t=10247 @@ -97,11 +98,11 @@ void mouse_init() void mouse_log() { - //log(FOOLOS_MODULE_NAME,5,"%02x / %02x / %02x ",mouse_byte[0], mouse_byte[1],mouse_byte[2]); + //klog("%02x / %02x / %02x ",mouse_byte[0], mouse_byte[1],mouse_byte[2]); //TODO: ignore last packet for 4packets mouse and resync if you get out of sync if(mouse_byte[0]&0x80||mouse_byte[0]&0x40)return; //skip packet on overflow - if(!(mouse_byte[0]&0x8))panic(FOOLOS_MODULE_NAME,"mouse packets out of sync!?"); // this bit is always 1, otherwise panic! + if(!(mouse_byte[0]&0x8))kpanic("mouse packets out of sync!?"); // this bit is always 1, otherwise panic! // if(mouse_byte[1]>127){ @@ -126,7 +127,7 @@ void mouse_log() if(mouse_x>800)mouse_x=800; if(mouse_y>600)mouse_y=600; - //log(FOOLOS_MODULE_NAME,5,"%d / %d / %02x ",mouse_x, mouse_y,mouse_byte[2]); + //klog("%d / %d / %02x ",mouse_x, mouse_y,mouse_byte[2]); if (mouse_byte[0] & 1)vesa_put_rect(mouse_x,600-mouse_y,10,10,0x00ffff); //else vesa_put_rect(mouse_x,600-mouse_y,10,10,0x0000ff); PutFont('X', mouse_x,600-mouse_y, 0xff0000); diff --git a/driver/pci.c b/driver/pci.c index 48aaff9..4ea01d1 100644 --- a/driver/pci.c +++ b/driver/pci.c @@ -65,7 +65,7 @@ void test_bar(uint8_t bus, uint8_t slot, uint8_t offset) pciConfigSet(bus,slot,0,offset,(bar_high<<16)+bar_low); - log("e1000",5,"%s bar: (0x%x 0x%x) size: 0x%x" ,bar_low&1?"i/o":"mem",bar_high, bar_low, size); + klog("%s bar: (0x%x 0x%x) size: 0x%x" ,bar_low&1?"i/o":"mem",bar_high, bar_low, size); } @@ -79,7 +79,7 @@ uint16_t pciCheck(uint8_t bus, uint8_t slot) if ((vendor = pciConfigReadWord(bus,slot,0,0)) != 0xFFFF) { device = pciConfigReadWord(bus,slot,0,2); - log(FOOLOS_MODULE_NAME,5,"[%d,%d]: vendor: 0x%x / device: 0x%x",bus,slot,vendor,device); + klog("[%d,%d]: vendor: 0x%x / device: 0x%x",bus,slot,vendor,device); // check for: E1000 (82540EM). PCI Ethernet Controller if(vendor==0x8086&&device==0x100e) @@ -111,7 +111,7 @@ uint16_t pciCheck(uint8_t bus, uint8_t slot) void pci_init() { - log(FOOLOS_MODULE_NAME,5,"scanning bus"); + klog("scanning bus"); // todo: recurse on pci to pci bridges! // todo: support multiple pci host controllers! // (check more funcitons of device 0:0) diff --git a/driver/vesa.c b/driver/vesa.c index 06c9f6f..090596c 100644 --- a/driver/vesa.c +++ b/driver/vesa.c @@ -1,3 +1,4 @@ +#include "kernel/kernel.h" //http://wiki.osdev.org/GUI #include <stdarg.h> @@ -138,18 +139,18 @@ uint32_t vesa_init(vbeinfo *info,vbemodeinfo *mode,foolfont *rawfont) console_lines=24; // vesa info - log(FOOLOS_MODULE_NAME,5,"vbe version: 0x%x / video mode ptr: 0x%x 0x%x", + klog("vbe version: 0x%x / video mode ptr: 0x%x 0x%x", info->VbeVersion, info->VideoModePtr[1], info->VideoModePtr[0]); // vesa info on selected mode: - log(FOOLOS_MODULE_NAME,5,"colors r:%d 0x%x g:%d 0x%x b:%d 0x%x", + klog("colors r:%d 0x%x g:%d 0x%x b:%d 0x%x", mode->red_position,mode->red_mask, mode->green_position,mode->green_mask, mode->blue_position,mode->blue_mask); - log(FOOLOS_MODULE_NAME,5,"res: %d * %d / banks: %d / attr: 0x%x", + klog("res: %d * %d / banks: %d / attr: 0x%x", mode->Xres, mode->Yres, mode->banks, mode->attributes); - log(FOOLOS_MODULE_NAME,5,"bpp: %d / physbase: 0x%x", + klog("bpp: %d / physbase: 0x%x", mode->bpp,mode->physbase); // vesa modes @@ -159,7 +160,7 @@ uint32_t vesa_init(vbeinfo *info,vbemodeinfo *mode,foolfont *rawfont) while(*modeptr!=0xffff&&*modeptr!=0) { - log(FOOLOS_MODULE_NAME,5,"mode supported : 0x%X", (*modeptr)); + klog("mode supported : 0x%X", (*modeptr)); modeptr++; } #endif @@ -315,7 +316,7 @@ void vesa_init_doublebuff() int blocks=800*600*2/4096+1; physbase=VbeModeInfoBlock->physbase; buffer=pmmngr_alloc_blocks(blocks); - log(FOOLOS_MODULE_NAME,5,"Init buffer of %d blocks at 0x%08X",blocks,buffer); + klog("Init buffer of %d blocks at 0x%08X",blocks,buffer); VbeModeInfoBlock->physbase=buffer; } @@ -1,3 +1,4 @@ +#include "kernel/kernel.h" #include <stdint.h> #include "ext2.h" @@ -79,41 +80,41 @@ uint32_t load_elf(char *name, uint32_t *alloc) //uint32_t vaddr=0x08000000; uint32_t vaddr=0x08048000; - log(FOOLOS_MODULE_NAME,5,"loading %s",name); + klog("loading %s",name); ext2_check(ext2_ramimage); ext2_inode_content(ext2_ramimage,inode_nr,vaddr,0x100000); // max ignored?? - log(FOOLOS_MODULE_NAME,20,"ELF File loaded to final destination."); + klog("ELF File loaded to final destination."); Elf32_Ehdr *elf; elf=vaddr; if(elf->e_ident[0]!=0x7f||elf->e_ident[1]!='E'||elf->e_ident[2]!='L'||elf->e_ident[3]!='F') - panic(FOOLOS_MODULE_NAME,"ELF mismatch!?"); + kpanic("ELF mismatch!?"); /* - log(FOOLOS_MODULE_NAME, 5, + klog( "elf id: class=%d, data=%d, version=%d osabi=%d abiv=%d ", elf->e_ident[4],elf->e_ident[5],elf->e_ident[6], elf->e_ident[7],elf->e_ident[8]); - log(FOOLOS_MODULE_NAME,5,"elf type: 0x%04x",elf->e_type); - log(FOOLOS_MODULE_NAME,5,"elf machine: 0x%04x",elf->e_machine); - log(FOOLOS_MODULE_NAME,5,"elf version: %d",elf->e_version); - log(FOOLOS_MODULE_NAME,5,"elf entry: 0x%08X",elf->e_entry); - log(FOOLOS_MODULE_NAME,5,"elf ph-offset: 0x%08X",elf->e_phoff); - log(FOOLOS_MODULE_NAME,5,"elf sh-offset: 0x%08X",elf->e_shoff); - log(FOOLOS_MODULE_NAME,5,"elf flags: 0x%08X",elf->e_flags); - log(FOOLOS_MODULE_NAME,5,"elf eh-size (bytes): %d",elf->e_ehsize); + klog("elf type: 0x%04x",elf->e_type); + klog("elf machine: 0x%04x",elf->e_machine); + klog("elf version: %d",elf->e_version); + klog("elf entry: 0x%08X",elf->e_entry); + klog("elf ph-offset: 0x%08X",elf->e_phoff); + klog("elf sh-offset: 0x%08X",elf->e_shoff); + klog("elf flags: 0x%08X",elf->e_flags); + klog("elf eh-size (bytes): %d",elf->e_ehsize); - log(FOOLOS_MODULE_NAME,5,"elf ph-ent-size(bytes): %d",elf->e_phentsize); - log(FOOLOS_MODULE_NAME,5,"elf ph-num: %d",elf->e_phnum); + klog("elf ph-ent-size(bytes): %d",elf->e_phentsize); + klog("elf ph-num: %d",elf->e_phnum); - log(FOOLOS_MODULE_NAME,5,"elf sh-ent-size(byte): %d",elf->e_shentsize); - log(FOOLOS_MODULE_NAME,5,"elf sh-num: %d",elf->e_shnum); + klog("elf sh-ent-size(byte): %d",elf->e_shentsize); + klog("elf sh-num: %d",elf->e_shnum); - log(FOOLOS_MODULE_NAME,5,"elf sh-strndx: %d",elf->e_shstrndx); + klog("elf sh-strndx: %d",elf->e_shstrndx); */ // iterate over section headers @@ -123,7 +124,7 @@ uint32_t load_elf(char *name, uint32_t *alloc) if(phidx==0) { - log(FOOLOS_MODULE_NAME,20,"text: 0x%08X-0x%08X",phdr->p_vaddr,phdr->p_vaddr+phdr->p_filesz); + klog("text: 0x%08X-0x%08X",phdr->p_vaddr,phdr->p_vaddr+phdr->p_filesz); } if(phidx==1) @@ -131,17 +132,17 @@ uint32_t load_elf(char *name, uint32_t *alloc) /* - log(FOOLOS_MODULE_NAME,5,"-- PROGRAMM HEADER %d --",phidx+1); - log(FOOLOS_MODULE_NAME,5,"p-type: %d",phdr->p_type); - log(FOOLOS_MODULE_NAME,5,"p-offset: 0x%08X",phdr->p_offset); - log(FOOLOS_MODULE_NAME,5,"p-vaddr: 0x%08X",phdr->p_vaddr); - log(FOOLOS_MODULE_NAME,5,"p-filesz: 0x%08X",phdr->p_filesz); - log(FOOLOS_MODULE_NAME,5,"p-memsz: 0x%08X",phdr->p_memsz); + klog("-- PROGRAMM HEADER %d --",phidx+1); + klog("p-type: %d",phdr->p_type); + klog("p-offset: 0x%08X",phdr->p_offset); + klog("p-vaddr: 0x%08X",phdr->p_vaddr); + klog("p-filesz: 0x%08X",phdr->p_filesz); + klog("p-memsz: 0x%08X",phdr->p_memsz); */ - log(FOOLOS_MODULE_NAME,20,"data: 0x%08X-0x%08X",phdr->p_vaddr,phdr->p_vaddr+phdr->p_filesz); - log(FOOLOS_MODULE_NAME,20,"bss: 0x%08X-0x%08X",phdr->p_vaddr+phdr->p_filesz,phdr->p_vaddr+phdr->p_memsz); + klog("data: 0x%08X-0x%08X",phdr->p_vaddr,phdr->p_vaddr+phdr->p_filesz); + klog("bss: 0x%08X-0x%08X",phdr->p_vaddr+phdr->p_filesz,phdr->p_vaddr+phdr->p_memsz); // let's copy the rw- data block // from right to left so we not overwrite ourselves!! @@ -167,7 +168,7 @@ uint32_t load_elf(char *name, uint32_t *alloc) } - log(FOOLOS_MODULE_NAME,20,"heap starts at: 0x%08X",*alloc); + klog("heap starts at: 0x%08X",*alloc); return elf->e_entry; } @@ -1,3 +1,4 @@ +#include "kernel/kernel.h" // ext2 minidriver // based on osdev wiki article: http://wiki.osdev.org/Ext2 @@ -118,8 +119,8 @@ int ext2_check(uint8_t *ram) ram_read(ptr,&super,sizeof(super),1); if(super.ext2_sig!=0xef53){ - log(FOOLOS_MODULE_NAME,5,"addr: 0x%08X",ram); - panic(FOOLOS_MODULE_NAME,"no ext2 signature found, where ram-image expected"); + klog("addr: 0x%08X",ram); + kpanic("no ext2 signature found, where ram-image expected"); } } @@ -135,8 +136,8 @@ ext2_inode ext2_get_inode(uint8_t *ram,int inode_num) ram_read(ptr,&super,sizeof(super),1); if(super.ext2_sig!=0xef53) { - log(FOOLOS_MODULE_NAME,5,"addr: 0x%08X",ram); - panic(FOOLOS_MODULE_NAME,"no ext2 signature found, where ram-image expected!"); + klog("addr: 0x%08X",ram); + kpanic("no ext2 signature found, where ram-image expected!"); } int block_group=(inode_num-1)/super.inodes_per_group; @@ -182,7 +183,7 @@ void* ext2_get_indirectstart_double(void *start, uint32_t block_size, uint32_t i int indirect1_idx=block_idx/(block_size/4); int idx=block_idx%(block_size/4); - //log(FOOLOS_MODULE_NAME,5,"bl: %d : %d / %d",block_idx,indirect1_idx, idx); + //klog("bl: %d : %d / %d",block_idx,indirect1_idx, idx); return ext2_get_indirectstart(start,block_size,dil[indirect1_idx],idx); } @@ -199,9 +200,9 @@ int ext2_inode_content(char *ram,int inode_nr,uint8_t *ramdest,int max) int sum=0; int count=0; - log(FOOLOS_MODULE_NAME,5,"Loading %d.%d bytes",inode.size_high, inode.size_low); + klog("Loading %d.%d bytes",inode.size_high, inode.size_low); - if(inode.size_high>0)panic(FOOLOS_MODULE_NAME,"inode with high.size unsupported, i am sorry."); + if(inode.size_high>0)kpanic("inode with high.size unsupported, i am sorry."); while(pos<inode.size_low) // TODO: use size high! { @@ -236,7 +237,7 @@ int ext2_inode_content(char *ram,int inode_nr,uint8_t *ramdest,int max) } else { - panic(FOOLOS_MODULE_NAME,"Triple Indirect Block Pointers not supported yet, file is too big to load, sorry!"); + kpanic("Triple Indirect Block Pointers not supported yet, file is too big to load, sorry!"); } @@ -246,7 +247,7 @@ int ext2_inode_content(char *ram,int inode_nr,uint8_t *ramdest,int max) } - log(FOOLOS_MODULE_NAME,5,"Fool Check Sum: 0x%08X for %d bytes",sum,count); + klog("Fool Check Sum: 0x%08X for %d bytes",sum,count); } @@ -264,7 +265,7 @@ int ext2_filename_to_inode_traverse(uint8_t *ram, char *path,int inode_start) if(*path==0)final=true; else(*path=0); - log(FOOLOS_MODULE_NAME,20,"looking for %s '%s' in inode: %d",final?"file":"dir",first,inode_start); + klog("looking for %s '%s' in inode: %d",final?"file":"dir",first,inode_start); fs_dirent dirs[25]; int count= ext2_read_dir(ram, inode_start,dirs,25); // get dir @@ -273,15 +274,15 @@ int ext2_filename_to_inode_traverse(uint8_t *ram, char *path,int inode_start) { if(!strcmp_l(first,dirs[i].name,0)) { - log(FOOLOS_MODULE_NAME,20,"found: %s (%s)",first,dirs[i].type==FS_FILE_TYPE_DIR?"dir":"file"); + klog("found: %s (%s)",first,dirs[i].type==FS_FILE_TYPE_DIR?"dir":"file"); if(final)return dirs[i].inode; return ext2_filename_to_inode_traverse(ram,last+1,dirs[i].inode); } - //log(FOOLOS_MODULE_NAME,5,"no match: %s",dirs[i].name); + //klog("no match: %s",dirs[i].name); } - log(FOOLOS_MODULE_NAME,5,"file not found!"); + klog("file not found!"); return -1; @@ -305,7 +306,7 @@ int ext2_filename_to_inode(uint8_t *ram, char *path) int ext2_read_dir(uint8_t *ram, int inode_nr,fs_dirent *dirs,int max) { - log(FOOLOS_MODULE_NAME,20,"read_dir : max: %d",max); + klog("read_dir : max: %d",max); ext2_inode inode=ext2_get_inode(ram,inode_nr); char buf[256]; @@ -353,7 +354,7 @@ int ext2_read_dir(uint8_t *ram, int inode_nr,fs_dirent *dirs,int max) i++; }while(buf[i-1]!=0); -// log(FOOLOS_MODULE_NAME,5,"name: %s\n",dirs[c].name); +// klog("name: %s\n",dirs[c].name); c++; @@ -1,3 +1,4 @@ +#include "kernel/kernel.h" // abstraction layer for filesystems #include "fs.h" @@ -26,7 +27,7 @@ void fs_mount(multiboot_information *info) multiboot_mod *mod=info->mods_addr; for(int i=0;i<info->mods_count;i++) { - log(FOOLOS_MODULE_NAME,5,"mounting mod from 0x%08X-0x%08X : %s", + klog("mounting mod from 0x%08X-0x%08X : %s", mod->mod_start,mod->mod_end, mod->string); //pmmngr_deinit_region(mod->mod_start,((uint32_t)mod->mod_end-(uint32_t)mod->mod_start)+1); 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); } diff --git a/xxx/inactive/floppy.c b/xxx/inactive/floppy.c index b7c2f55..842b7d9 100644 --- a/xxx/inactive/floppy.c +++ b/xxx/inactive/floppy.c @@ -57,7 +57,7 @@ void flpydsk_initialize_dma () { x86_outb (0x80, 0); //external page register = 0 x86_outb (0x0a, 0x02); //unmask dma channel 2 - log("dma",5,"initialized"); + klog("initialized"); } //! prepare the DMA for read transfer @@ -67,7 +67,7 @@ void flpydsk_dma_read () { x86_outb (0x0b, 0x56); //single transfer, address increment, autoinit, read, channel 2 x86_outb (0x0a, 0x02); //unmask dma channel 2 - log("dma",5,"configured for reading"); + klog("configured for reading"); } //! prepare the DMA for write transfer @@ -76,7 +76,7 @@ void flpydsk_dma_write () { x86_outb (0x0a, 0x06); //mask dma channel 2 x86_outb (0x0b, 0x5a); //single transfer, address increment, autoinit, write, channel 2 x86_outb (0x0a, 0x02); //unmask dma channel 2 - log("dma",5,"configured for writing"); + klog("configured for writing"); } // // @@ -169,7 +169,7 @@ void flpydsk_write_ccr (uint8_t val) { void flpydsk_motor_on() { - log(FOOLOS_MODULE_NAME,20,"starting motor..."); + klog("starting motor..."); //x86_outb (FLPYDSK_DOR, FLPYDSK_DOR_MASK_DRIVE0_MOTOR | FLPYDSK_DOR_MASK_RESET); x86_outb (FLPYDSK_DOR, 0x1c); sleep(10); // wait ~ 1/3 second @@ -177,7 +177,7 @@ void flpydsk_motor_on() void flpydsk_motor_off() { - log(FOOLOS_MODULE_NAME,20,"stopping motor..."); + klog("stopping motor..."); x86_outb (FLPYDSK_DOR, 0x0c); } @@ -188,7 +188,7 @@ int flpydsk_calibrate (uint32_t drive) { if (drive >= 4) { - log(FOOLOS_MODULE_NAME,5,"ERROR!"); + klog("ERROR!"); return -2; } @@ -198,7 +198,7 @@ int flpydsk_calibrate (uint32_t drive) { int i; for (i = 0; i < 10; i++) { - log(FOOLOS_MODULE_NAME,20,"calibrating"); + klog("calibrating"); //! send command flpydsk_send_command ( FDC_CMD_CALIBRATE ); flpydsk_send_command ( drive ); @@ -208,14 +208,14 @@ int flpydsk_calibrate (uint32_t drive) { //! did we fine cylinder 0? if so, we are done if (!cyl) { if(st0 & 0xC0) { - log(FOOLOS_MODULE_NAME,5,"calibrating FAILED!"); + klog("calibrating FAILED!"); } // flpydsk_control_motor (false); flpydsk_motor_off(); return 0; } } - log(FOOLOS_MODULE_NAME,5,"calibrating FAILED!"); + klog("calibrating FAILED!"); // flpydsk_control_motor (false); flpydsk_motor_off(); @@ -249,7 +249,7 @@ uint8_t flpydsk_read_data () { if ( flpydsk_read_status () & FLPYDSK_MSR_MASK_DATAREG ) return x86_inb (FLPYDSK_FIFO); - log(FOOLOS_MODULE_NAME,5,"reading data FAILED!"); + klog("reading data FAILED!"); } void flpydsk_send_command (uint8_t cmd) { @@ -261,7 +261,7 @@ void flpydsk_send_command (uint8_t cmd) { x86_outb(FLPYDSK_FIFO, cmd); return; } - log(FOOLOS_MODULE_NAME,5,"writing data FAILED!"); + klog("writing data FAILED!"); } void flpydsk_drive_data (uint32_t stepr, uint32_t loadt, uint32_t unloadt, int dma ) { @@ -282,7 +282,7 @@ void flpydsk_reset() uint32_t st0, cyl; //! reset the controller - log(FOOLOS_MODULE_NAME,20,"reset controller"); + klog("reset controller"); flpydsk_disable_controller (); flpydsk_enable_controller (); flpydsk_wait_irq (); @@ -316,7 +316,7 @@ void int_floppy_handler() void flpydsk_wait_irq() { - log(FOOLOS_MODULE_NAME,99,"waiting for irq6"); + klog("waiting for irq6"); while (1) { @@ -329,7 +329,7 @@ void flpydsk_wait_irq() _FloppyDiskIRQ = 0; x86_int_enable(); - log(FOOLOS_MODULE_NAME,99,"irq6 received"); + klog("irq6 received"); } void flpydsk_check_int (uint32_t* st0, uint32_t* cyl) { @@ -347,7 +347,7 @@ void flpydsk_write_sector_imp (uint8_t head, uint8_t track, uint8_t sector) { flpydsk_dma_write (); //flpydsk_drive_data (13, 1, 0xf, 0); - log(FOOLOS_MODULE_NAME,20,"writing head/track/sector"); + klog("writing head/track/sector"); uint32_t st0, cyl; @@ -390,7 +390,7 @@ void flpydsk_read_sector_imp (uint8_t head, uint8_t track, uint8_t sector) { flpydsk_dma_read (); //flpydsk_drive_data (13, 1, 0xf, 0); - log(FOOLOS_MODULE_NAME,20,"reading head/track/sector"); + klog("reading head/track/sector"); uint32_t st0, cyl; @@ -441,7 +441,7 @@ int flpydsk_seek ( uint32_t cyl, uint32_t head ) int i; for (i = 0; i < 10; i++ ) { - log(FOOLOS_MODULE_NAME,20,"seeking cyl: %d, head: %d",cyl,head); + klog("seeking cyl: %d, head: %d",cyl,head); //! send the command flpydsk_send_command (FDC_CMD_SEEK); @@ -477,7 +477,7 @@ void flpydsk_lba_to_chs (int lba,int *head,int *track,int *sector) { uint8_t* flpydsk_read_sector (int sectorLBA) { - log(FOOLOS_MODULE_NAME,20,"reading sector: %d",sectorLBA); + klog("reading sector: %d",sectorLBA); if (_CurrentDrive >= 4) @@ -508,7 +508,7 @@ uint8_t* flpydsk_read_sector (int sectorLBA) { uint8_t* flpydsk_write_sector (int sectorLBA) { - log(FOOLOS_MODULE_NAME,20,"writing sector: %d",sectorLBA); + klog("writing sector: %d",sectorLBA); if (_CurrentDrive >= 4) return 0; @@ -544,29 +544,29 @@ void floppy_init() _CurrentDrive=0; _FloppyDiskIRQ = 0; - log(FOOLOS_MODULE_NAME,5,"driver init (wathchdog: 0x%08X)",&_FloppyDiskIRQ); + klog("driver init (wathchdog: 0x%08X)",&_FloppyDiskIRQ); flpydsk_reset (); char *dma=0x0500; - log(FOOLOS_MODULE_NAME,5,"test reading"); + klog("test reading"); flpydsk_read_sector(65); - log(FOOLOS_MODULE_NAME,5,"finished reading"); + klog("finished reading"); flpydsk_reset (); flpydsk_read_sector(64); - log(FOOLOS_MODULE_NAME,5,"finished reading"); - log(FOOLOS_MODULE_NAME,5,"test read: %s",dma); + klog("finished reading"); + klog("test read: %s",dma); flpydsk_reset (); -// log(FOOLOS_MODULE_NAME,5,"test write (sector: 100)"); +// klog("test write (sector: 100)"); // flpydsk_write_sector(100); -// log(FOOLOS_MODULE_NAME,5,"finished writing"); +// klog("finished writing"); } |
