diff options
| -rw-r--r-- | Makefile | 12 | ||||
| -rw-r--r-- | bochsrc | 2 | ||||
| -rw-r--r-- | kernel/interrupts.c | 29 | ||||
| -rw-r--r-- | kernel/interrupts.h | 2 | ||||
| -rw-r--r-- | kernel/kernel.c | 105 | ||||
| -rw-r--r-- | kernel/mem.c | 269 | ||||
| -rw-r--r-- | kernel/timer.c | 34 | ||||
| -rw-r--r-- | kernel/vesa.c | 15 | ||||
| -rw-r--r-- | lib/logger/log.c | 68 |
9 files changed, 220 insertions, 316 deletions
@@ -15,10 +15,6 @@ USB_STICK=/dev/sdg #take care! -MP_IMG_START=26112 #code for the other processors intialllly at 0x6600 - -FONT_DATA_START=26624 #fool font initially at 0x6800 - #here our kernel will be loaded by the bootloader. KERNEL_START=0x10000 @@ -48,7 +44,6 @@ KERNEL_ENTRY=./boot/kernel_entry.o MBR=./boot/mbr.bin - #multiprocessor binary entry MP_BIN=./boot/mp.bin @@ -63,7 +58,6 @@ FILLUP=./data/fill.bin all: FoolOS.img FoolData.img - ############ nasm assembling rules ############ %.o: %.asm @@ -90,17 +84,15 @@ binfont.bin: data/binfont.src # master boot record, kernel binary and fool-font -FoolOS.img: $(MBR) kernel.bin $(MP_BIN) binfont.img $(FILLUP) +FoolOS.img: $(MBR) kernel.bin $(FILLUP) cp $(FILLUP) $@ dd if=$(MBR) of=$@ bs=1 seek=0 conv=notrunc dd if=kernel.bin of=$@ bs=1 seek=512 conv=notrunc - dd if=$(MP_BIN) of=$@ bs=1 seek=$(MP_IMG_START) conv=notrunc - dd if=binfont.img of=$@ bs=1 seek=$(FONT_DATA_START) conv=notrunc binfont.img: binfont.bin cat $^ > $@ -FoolData.img: data/testdata +FoolData.img: binfont.bin cp $^ $@ ############ vm stuff ############ @@ -242,7 +242,7 @@ cpu: count=2, ips=10000000 #, reset_on_triple_fault=1, ignore_bad_msrs=1, msrs=" #optromimage3: file=optionalrom.bin, address=0xd2000 #optromimage4: file=optionalrom.bin, address=0xd3000 -optramimage1: file=FoolData.img, address=0x80400 +optramimage1: file=FoolData.img, address=0x90000 #optramimage2: file=/path/file2.img, address=0x0020000 #optramimage3: file=/path/file3.img, address=0x0030000 #optramimage4: file=/path/file4.img, address=0x0040000 diff --git a/kernel/interrupts.c b/kernel/interrupts.c index c6acf61..902538b 100644 --- a/kernel/interrupts.c +++ b/kernel/interrupts.c @@ -1,13 +1,17 @@ +#define FOOLOS_MODULE_NAME "interrupts" + +#include "lib/logger/log.h" // logger facilities + #include "interrupts.h" #include "lib/int/stdint.h" #include "x86.h" -#include "../lib/logger/log.h" // logger facilities -#define FOOLOS_MODULE_NAME "interrupts" +void int_clock_handler(); +void int_kb_handler(); +void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr); void int_default_handler(); -void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr); // the interrupt descriptor table static struct int_desc @@ -125,6 +129,25 @@ void int_init(uint16_t sel) int_install_ir(17, 0b10001110, 0x08,&int_irq17); int_install_ir(18, 0b10001110, 0x08,&int_irq18); + // setup some custom interrupts + // remember that we shifted all interrupts with the pic by 32 + + // install PIT interrupt handler (irq 0 => 32) + int_install_ir(32, 0b10001110, 0x08,&int_clock_handler); + + // install keyboard interrupt handler (irq 1 => 33) + int_install_ir(33, 0b10001110, 0x08,&int_kb_handler); + + #ifdef FOOLOS_COMPILE_FLOPPY + // install floppy interrupt handler (irq 6 => 38) + int_install_ir(38, 0b10001110, 0x08,&int_floppy_handler); + #endif + + int_install(); + + // now we can enable interrupts back again + x86_int_enable(); + } void int_install() diff --git a/kernel/interrupts.h b/kernel/interrupts.h index 6483347..16eb7a6 100644 --- a/kernel/interrupts.h +++ b/kernel/interrupts.h @@ -3,6 +3,4 @@ #define INT_MAX 255 // size of our interrupts table -int int_unhandled; // counting unhandled interrupts - #endif diff --git a/kernel/kernel.c b/kernel/kernel.c index 0b87b64..1688017 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -11,18 +11,10 @@ #include "floppy.h" #endif -/////// -// interrupt handler prototypes -// todo: move somewhere else!? -void int_clock_handler(); -void int_kb_handler(); - -uint32_t read_eip(); +// some multiprocessor shit that should move away uint32_t c1,c2,c3; - volatile uint8_t proc; - uint32_t cpu_counter[SMP_MAX_PROC]; void kernel_ap() @@ -31,6 +23,7 @@ void kernel_ap() uint8_t p=proc; while(1)cpu_counter[p]++; } + // // KERNEL MAIN @@ -52,29 +45,18 @@ void kernel_main(uint32_t initial_stack, int mp) proc=c1=c2=c3=0; for(int i=0;i<SMP_MAX_PROC;i++)cpu_counter[i]=0; + +/////////////////// BULLSHIT ABOVE THIS LINE: TODO: CLEANUP + // + // system time + // task_system_clock=0; - - // move the foolfont and aps code before it gets overwritten! - uint8_t *source=0x16600; - uint8_t *dest=0x80000; - - for(int i=0;i<2*512;i++) - { - dest[i]=source[i]; - } - - source=0x16400; - dest=0x9000; - for(int i=0;i<1*512;i++) - { - dest[i]=source[i]; - } - - - /////////////////// BULLSHIT ABOVE THIS LINE: TODO: CLEANUP - + // + // init system log ringbugger + // + log_init(); // // We want to get output to the screen as fast as possible! @@ -86,7 +68,7 @@ void kernel_main(uint32_t initial_stack, int mp) // // * the addresses of the vbeinfo struct // * the address of the vbemodeinfo struct (for selected mode). - // * the address of our Fool-Font binary data. + // * Fool Font loaded inside ramimage // // The first two paramters are hardcoded in [boot/mbr.asm], // while the last one is set in the Makefile. The font binary @@ -96,26 +78,20 @@ void kernel_main(uint32_t initial_stack, int mp) // our video memory // - //uint32_t vesa_physbase=vesa_init(0x8300,0x8400,0x7600); - uint32_t vesa_physbase=vesa_init(0x8300,0x8400,0x80000); - + uint32_t vesa_physbase=vesa_init(0x8300,0x8400,0x90000); - char *ramdisk=0x80400; - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"ramdisk: %s",ramdisk); + // self-log message of logger :P + log_log(); // // Print initial address of the esp stack pointer // - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"initial esp: 0x%08X",initial_stack); // // Setup PIC // - // Do we nee this when using APIC? - // - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"setting up PIC."); pic_setup(); @@ -123,42 +99,23 @@ void kernel_main(uint32_t initial_stack, int mp) // // Configuring the PIT timer. // - timer_init(); - // - // Interrupts + // Setup Interrupts (code segment: 0x08) // - - // init and interrupt decriptor table int_init(0x08); - // set default interrupts - int_install(); - - // setup some custom interrupts - // remember that we shifted all interrupts with the pic by 32 - - // install PIT interrupt handler (irq 0 => 32) - int_install_ir(32, 0b10001110, 0x08,&int_clock_handler); - - // install keyboard interrupt handler (irq 1 => 33) - int_install_ir(33, 0b10001110, 0x08,&int_kb_handler); - -#ifdef FOOLOS_COMPILE_FLOPPY - // install floppy interrupt handler (irq 6 => 38) - int_install_ir(38, 0b10001110, 0x08,&int_floppy_handler); -#endif - - // now we can enable interrupts back again - x86_int_enable(); // // Memory Init // + // after this is set up we can allocate and deallocate blocks + // of physical memory :) + // - // we know that here, the bootloader placed the mamory map! + // we know that here, the bootloader placed the mamory map and + // number of entries. mem_init(0x7c00+0x400,*((uint16_t *)(0x7c00+0x600))); @@ -174,13 +131,13 @@ void kernel_main(uint32_t initial_stack, int mp) panic(FOOLOS_MODULE_NAME,"ACPI and MP search failed! I do not want to continue!"); // Start the other Processors (also before paging !) - smp_start_aps(&procdata); + //smp_start_aps(&procdata); ///////////////////// // paging (pass the vesa physbase address for identity mapping) - //vmem_init(vesa_physbase); + // vmem_init(vesa_physbase); ////////////////////// @@ -190,17 +147,15 @@ void kernel_main(uint32_t initial_stack, int mp) // We are interested in the E1000 Network Adapter in particular // Its driver will be hopefully implemented one day ;) // - - pci_init(); + // pci_init(); // - // Initialize Floppy Disk - // - - #ifdef FOOLOS_COMPILE_FLOPPY - floppy_init(); - #endif + // Initialize Floppy Disk if activated in config.h + // + //#ifdef FOOLOS_COMPILE_FLOPPY + //floppy_init(); + //#endif // @@ -209,7 +164,6 @@ void kernel_main(uint32_t initial_stack, int mp) // Will process input from the keyboard but will be completely // redesigned soon. // - shell_init(); @@ -219,7 +173,6 @@ void kernel_main(uint32_t initial_stack, int mp) // For now this starts two tasks which are scheduled // round robin style. // - task_init(); diff --git a/kernel/mem.c b/kernel/mem.c index 9899822..0b9dab7 100644 --- a/kernel/mem.c +++ b/kernel/mem.c @@ -1,9 +1,9 @@ +#define FOOLOS_MODULE_NAME "mem" #define MEM_PRINT_MEMORYMAP #include "lib/int/stdint.h" #include "lib/logger/log.h" // logger facilities -#define FOOLOS_MODULE_NAME "mem" //! 8 blocks per byte #define PMMNGR_BLOCKS_PER_BYTE 8 @@ -14,14 +14,11 @@ //! block alignment #define PMMNGR_BLOCK_ALIGN PMMNGR_BLOCK_SIZE -#define MEM_BITMAP_SIZE 32768 -//#define MEM_BITMAP_SIZE 327 - -// memory map bit array. Each bit represents a memory block -//uint32_t _mmngr_memory_map[MEM_BITMAP_SIZE]; -uint32_t _mmngr_memory_map[MEM_BITMAP_SIZE]; +//memory map bit array. Each bit represents a 4KB memory block +static uint32_t *_mmngr_memory_map; static uint32_t mem_free_blocks; +static uint32_t mem_array_size; // bit funcs! void mmap_set(int bit) @@ -39,127 +36,79 @@ int mmap_test(int bit) return _mmngr_memory_map[bit / 32] & (1 << (bit % 32)); } -void mmap_show_free () +void pmmngr_init () { - - int last_pos=0; - uint32_t last=_mmngr_memory_map[0]; - - for (int i=1; i< MEM_BITMAP_SIZE ; i++) + // By default, all of memory is in use + for(int i=0;i<mem_array_size;i++) { - if (_mmngr_memory_map[i] != last||i==MEM_BITMAP_SIZE-1) - { - - if(last==0) - { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d -%d free",last_pos*32,i*32); - } - else if(last==0xffffffff) - { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d -%d full",last_pos*32,i*32); - } - else - { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d -%d some free",last_pos*32,i*32); - } - - last_pos=i; - last=_mmngr_memory_map[i]; - - - } + _mmngr_memory_map[i]=0xffffffff; } - } -// int mmap_first_free () { - //! find the first free bit uint32_t i; int j; - for (i=0; i< MEM_BITMAP_SIZE ; i++) + for (i=0; i< mem_array_size ; i++) if (_mmngr_memory_map[i] != 0xffffffff) for (j=0; j<32; j++) { //! test each bit in the dword - int bit = 1 << j; if (! (_mmngr_memory_map[i] & bit) ) return i*4*8+j; } return -1; - } - -void pmmngr_init () +void pmmngr_init_region (uint32_t base, uint32_t size) { - //! By default, all of memory is in use - // memset (_mmngr_memory_map, 0xf, 128 ); - int i; + uint32_t align = base / PMMNGR_BLOCK_SIZE; + uint32_t blocks = size / PMMNGR_BLOCK_SIZE; - for(i=0;i<MEM_BITMAP_SIZE;i++) + for (; blocks>0; blocks--) { - _mmngr_memory_map[i]=0xffffffff; + mmap_unset (align++); + mem_free_blocks++; } - - } -void pmmngr_init_region (uint32_t base, uint32_t size) +void pmmngr_deinit_region (uint32_t base, uint32_t size) { - - uint32_t align = base / PMMNGR_BLOCK_SIZE; uint32_t blocks = size / PMMNGR_BLOCK_SIZE; for (; blocks>0; blocks--) { - // hack to lock first ~4MB of memory - if(align<1000) - { - align++; - continue; - } - - - mmap_unset (align++); - mem_free_blocks++; - //_mmngr_used_blocks--; + mmap_set (align++); + mem_free_blocks--; } - //mmap_set (0); //first block is always set. This insures allocs cant be 0 } void* pmmngr_alloc_block () { - int frame = mmap_first_free (); - + if (frame == -1) { log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"OUT OF MEMORY"); return 0; //out of memory } -// scr_put_string_nl("MEM ALLOC OK!"); -// scr_put_hex32(frame); - // scr_put_string_nl(""); - mmap_set (frame); - + uint32_t addr = frame * PMMNGR_BLOCK_SIZE; mem_free_blocks--; - + return (void*)addr; } -void pmmngr_free_block (void* p) { - +void pmmngr_free_block (void* p) +{ uint32_t addr = (uint32_t*)p; int frame = addr / PMMNGR_BLOCK_SIZE; @@ -168,125 +117,121 @@ void pmmngr_free_block (void* p) { mmap_unset (frame); mem_free_blocks++; } - } -/* -void mem_test_3() +void mem_init(uint16_t *memmap,uint16_t entries) { - uint32_t *addr; - addr=pmmngr_alloc_block(); - scr_put_string("alloc 1: "); - scr_put_hex32(addr); - scr_put_string_nl(""); + // init free blocks counter + mem_free_blocks=0; - addr=pmmngr_alloc_block(); - scr_put_string("alloc 2: "); - scr_put_hex32(addr); - scr_put_string_nl(""); -} + // count available mem + uint32_t total_mem=0, highest_end=0, high_end_low=0; -void mem_test_2() -{ - //crossing 512MB boundary! - // (do not do this in real, coz it probably is reserved) - //mem_test(0x1fee1000,0x2000f000,0x800); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"the memory map contains %d entries.",entries); - int cnt=-1; - uint32_t *addr; - uint32_t *lastaddr; + // preserve pointer + uint16_t save=memmap; - do{ - lastaddr=addr; - addr=pmmngr_alloc_block(); - cnt++; - }while(addr!=0); + //print memory map and calc blocks. + for(int i=0;i<entries;i++) + { + uint32_t low_end=(((uint32_t)memmap[1])<<16)+memmap[0]; + uint32_t high_end=(((uint32_t)memmap[1])<<16)+memmap[0]-1 + +(((uint32_t)memmap[5])<<16)+memmap[4]; + #ifdef MEM_PRINT_MEMORYMAP + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"type: %02d / range: 0x%08x - 0x%08x", + memmap[8],low_end,high_end); + #endif - scr_put_string("no mem after : "); - scr_put_hex32(cnt); - scr_put_string_nl(""); + if(memmap[8]==1) + { + total_mem+=memmap[4]+(memmap[5]<<16); + } - pmmngr_free_block(lastaddr); + if(memmap[8]==1) + { + if(high_end>highest_end){ + highest_end=high_end; + high_end_low=low_end; + } + } + memmap+=12; + + } + // restore pointer + memmap=save; - cnt=-1; - do{ - lastaddr=addr; - addr=pmmngr_alloc_block(); - cnt++; - }while(addr!=0); + int blocks=highest_end/4096+1; + mem_array_size=blocks/32+1; - scr_put_string("no mem after : "); - scr_put_hex32(cnt); - scr_put_string_nl(""); -} - -void mem_test(int start, int end, int steps) -{ - int *p=start; - for(;p<end;p+=steps) + if(highest_end-high_end_low<mem_array_size*4) { - scr_put_string("testing memory at "); - scr_put_hex32(p); - - // - *p=p; - volatile x=*p; - if(x==p) scr_put_string(" OK"); - // - - scr_put_string_nl(""); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Highest end area: 0x%08X - 0x%08X",high_end_low,highest_end); + panic(FOOLOS_MODULE_NAME,"not enough space at high end :( sorry."); } -} -*/ - -void mem_init(uint16_t *memmap,uint16_t entries) -{ - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Initializing bitmap at: %08X",_mmngr_memory_map); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"the memory map contains %d entries.",entries); + _mmngr_memory_map=highest_end-mem_array_size*4; + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Initializing bitmap for 0x%X blocks at 0x%08X",blocks,_mmngr_memory_map); - // hardcoded memory bitmap!!??! - // todo: fix! - //_mmngr_memory_map=0x80000; - mem_free_blocks=0; pmmngr_init (); - // count available memory - uint32_t avail_mem=0; - int i; - //print memory map and init regions! - for(i=0;i<entries;i++) + for(int i=0;i<entries;i++) { + if(memmap[8]==1) + { + pmmngr_init_region(memmap[0]+(memmap[1]<<16),memmap[4]+((memmap[5])<<16)); + } + memmap+=12; + } + + // here is somewhere our kernel stuff ;) // todo!! better. + pmmngr_deinit_region(0x0,0xfffff); -// if(memmap[8]==0)break; + // and here is the memory map that we JUST created! + pmmngr_deinit_region(_mmngr_memory_map,mem_array_size*4); + + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Usable Mem: %d (0x%X) bytes. (~%d MB)",total_mem,total_mem,total_mem/1024/1024); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Currently Free 4K blocks: %d blocks.",mem_free_blocks); -#ifdef MEM_PRINT_MEMORYMAP - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"type: %02d / range: 0x%08x - 0x%08x", - memmap[8], - (((uint32_t)memmap[1])<<16)+memmap[0], - (((uint32_t)memmap[1])<<16)+memmap[0]-1 - +(((uint32_t)memmap[5])<<16)+memmap[4]); -#endif +} + +// analytics +void mmap_show_free () +{ + int last_pos=0; + uint32_t last=_mmngr_memory_map[0]; - if(memmap[8]==1) + for (int i=1; i< mem_array_size ; i++) + { + if (_mmngr_memory_map[i] != last||i==mem_array_size-1) { - avail_mem+=memmap[4]+(memmap[5]<<16); - pmmngr_init_region(memmap[0]+(memmap[1]<<16),memmap[4]+((memmap[5])<<16)); - } - memmap+=12; - - } + if(last==0) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d -%d free",last_pos*32,i*32); + } + else if(last==0xffffffff) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d -%d full",last_pos*32,i*32); + } + else + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d -%d some free",last_pos*32,i*32); + } + + last_pos=i; + last=_mmngr_memory_map[i]; + - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Available Mem: %d bytes. (~%d MB)",avail_mem,avail_mem/1024/1024); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Available 4K blocks: %d blocks.",mem_free_blocks); + } + } } diff --git a/kernel/timer.c b/kernel/timer.c index b713674..da9e6bd 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -1,4 +1,3 @@ - /// PIT /// Timer stuff /* @@ -37,39 +36,6 @@ #include "../lib/logger/log.h" // logger facilities #define FOOLOS_MODULE_NAME "timer" -static uint64_t timer64=0; -static uint8_t timer8=0; -uint16_t timer16=0; - -// clock handler -/* -void int_clock_handler() -{ - X86_IRQ_BEGIN; - - timer64++; - - timer8++; - - if(timer8==25) - { - timer16++; - } - - if(timer8==25) - { -#ifdef DEBUG - scr_put_string("."); -#endif - timer8=0; - task_switch(); - - } - - X86_IRQ_END; - -} -*/ void timer_init() { diff --git a/kernel/vesa.c b/kernel/vesa.c index 74d3435..f3b333c 100644 --- a/kernel/vesa.c +++ b/kernel/vesa.c @@ -52,18 +52,17 @@ typedef struct foolfont_struct static foolfont *deffont; static vbemodeinfo *VbeModeInfoBlock; -static console_x; -static console_y; +static int console_x; +static int console_y; -static console_lines; -static console_cols; +static int console_lines; +static int console_cols; void vesa_set_physbase(uint32_t addr) { VbeModeInfoBlock->physbase=addr; } - uint32_t vesa_init(vbeinfo *info,vbemodeinfo *mode,foolfont *rawfont) { //the only functionallu important init lines! (rest is log) @@ -165,13 +164,9 @@ void PutString(char *str, int x,int y, int color, va_list va) } -void PutConsole(char *str, int color, va_list va) +void PutConsole(char *str, int color) { - char buff[256]; - tfp_vsprintf(buff,str,va); - str=buff; - while((*str)!=0) { PutFont(*str, console_x*10,console_y*12, color); diff --git a/lib/logger/log.c b/lib/logger/log.c index c9bb652..4a510f9 100644 --- a/lib/logger/log.c +++ b/lib/logger/log.c @@ -1,44 +1,76 @@ -#include "log.h" +#define FOOLOS_MODULE_NAME "log" + +#include "lib/logger/log.h" #include <stdarg.h> + +#include "log.h" #include "lib/int/stdint.h" +#include "kernel/time.h" + +#define BUF_SIZE 4069 -void PutConsole(char *str, int color, va_list va); +static char buffer[BUF_SIZE]; +static int first; +static int last; -volatile uint64_t task_system_clock; // in task.c +void PutConsole(char *str, int color); void log(char *module_name, int log_level, char *format_string, ...) { - if(log_level<FOOLOS_LOG_INFO)return; - char buf[10]; + + char buf_info[256]; + char buf_log[256]; + char buf_time[20]; + uint32_t t=task_system_clock; uint32_t s=t/25; uint32_t ms=t*1000/25-1000*s; - tfp_sprintf(buf,"[%6d.%05d] ",s,ms); + tfp_sprintf(buf_time,"[%6d.%05d] ",s,ms); - PutConsole(buf,0b0111101111101111,task_system_clock); - PutConsole(module_name,0b1111100000000000,0); - PutConsole(": ",0b0000011111100000,0); va_list va; va_start(va,format_string); - //PutConsole(format_string, 0b11111, va); // blue - PutConsole(format_string, 0b0111101111111111, va); + tfp_vsprintf(buf_info,format_string,va); va_end(va); + + PutConsole(buf_time,0b0111101111101111); + PutConsole(module_name,0b1111100000000000); + PutConsole(": ",0b0000011111100000); + PutConsole(buf_info, 0b0111101111111111); PutConsoleNL(); - + tfp_sprintf(buf_log,"%s %s: %s\n",buf_time,module_name,buf_info); + + for(int i=0;buf_log[i]!=0;i++) + { + buffer[last]=buf_log[i]; + last=(last+1)%BUF_SIZE; + if(first<last)if(last-first>=BUF_SIZE)first=(first+1)%BUF_SIZE; + if(last>first)if(BUF_SIZE-last+first>=BUF_SIZE)first=(first+1)%BUF_SIZE; + } + + } void panic(char *module_name, char *format_string) { - - PutConsole("!! KERNEL PANIC !! ",0b1111100000000000,0); - PutConsole(module_name,0b1111100000000000,0); - PutConsole(" : ",0b0000011111100000,0); - PutConsole(format_string,0b1111100000000000,0); + PutConsole("!! KERNEL PANIC !! ",0b1111100000000000); + PutConsole(module_name,0b1111100000000000); + PutConsole(" : ",0b0000011111100000); + PutConsole(format_string,0b1111100000000000); while(1); // halt - } + +void log_init() +{ + first=last=0; +} + +void log_log() +{ + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"init buffer at: 0x%08X, first=%08X, last=%08X",buffer,&first,&last); +} + |
