diff options
| -rw-r--r-- | Makefile | 9 | ||||
| -rw-r--r-- | driver/e1000.c | 15 | ||||
| -rw-r--r-- | driver/e1000.h | 1 | ||||
| -rw-r--r-- | driver/keyboard.c | 12 | ||||
| -rw-r--r-- | driver/mouse.c | 19 | ||||
| -rw-r--r-- | driver/timer.c | 10 | ||||
| -rw-r--r-- | fs/mount.c | 2 | ||||
| -rw-r--r-- | fs/sysfs.c | 2 | ||||
| -rw-r--r-- | kernel/apic.c | 6 | ||||
| -rw-r--r-- | kernel/interrupts.c | 62 | ||||
| -rw-r--r-- | kernel/interrupts.h | 11 | ||||
| -rw-r--r-- | kernel/kernel.c | 16 | ||||
| -rw-r--r-- | kernel/kernel.h | 4 | ||||
| -rw-r--r-- | kernel/kmalloc.c | 43 | ||||
| -rw-r--r-- | kernel/scheduler.c | 6 | ||||
| -rw-r--r-- | kernel/smp.c | 6 | ||||
| -rw-r--r-- | kernel/syscalls.c | 2 | ||||
| -rw-r--r-- | net/arp.c | 2 | ||||
| -rw-r--r-- | net/icmp.c | 10 | ||||
| -rw-r--r-- | net/ipv4.c | 6 |
20 files changed, 146 insertions, 98 deletions
@@ -10,6 +10,7 @@ GIT_REVISION=$(shell git rev-parse HEAD) QEMU=/home/miguel/git/EXT/qemu-3.0.0/i386-softmmu/qemu-system-i386 +QEMU=qemu-system-i386 #use our cross compiler CC=i686-foolos-gcc @@ -21,11 +22,15 @@ AS=i686-elf-as ############ compiler flags ############ + +#https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html + CFLAGS= -CFLAGS=-DGIT_REVISION=\"$(GIT_REVISION)\" +#CFLAGS+=-fvar-tracking +CFLAGS+=-DGIT_REVISION=\"$(GIT_REVISION)\" CFLAGS+=-ffreestanding # do we need this if using own compiler? CFLAGS+=-nostdlib -CFLAGS+=-O0 +CFLAGS+=-Og CFLAGS+=-I. CFLAGS+=-I/home/miguel/temp/foolos/usr/i686-foolos/include/ CFLAGS+=-I./asm diff --git a/driver/e1000.c b/driver/e1000.c index 2f50df4..5d0cbe6 100644 --- a/driver/e1000.c +++ b/driver/e1000.c @@ -3,11 +3,12 @@ //https://github.com/torvalds/linux/blob/master/drivers/net/ethernet/intel/e1000/e1000_hw.c //https://github.com/qemu/qemu/blob/master/hw/net/e1000.c //registers etc. verified from pdf at https://pdos.csail.mit.edu/6.828/2006/readings/hardware/8254x_GBe_SDM.pdf +#include "e1000.h" +#include "interrupts.h" #include <stdint.h> #include "log.h" -#include "e1000.h" #include "kmalloc.h" #include "netdev.h" #include "arp.h" @@ -427,8 +428,8 @@ void e1000_handleReceive() old_cur = rx_cur; rx_cur = (rx_cur + 1) % E1000_NUM_RX_DESC; writeCommand(REG_RDT, old_cur ); - klog("RDT %d",readCommand(REG_RDT)); - klog("RDH %d",readCommand(REG_RDH)); +// klog("RDT %d",readCommand(REG_RDT)); +// klog("RDH %d",readCommand(REG_RDH)); } } @@ -443,8 +444,8 @@ int e1000_sendPacket(const void * p_data, uint16_t p_len) uint8_t old_cur = tx_cur; tx_cur = (tx_cur + 1) % E1000_NUM_TX_DESC; writeCommand(REG_TDT, tx_cur); - klog("TDT %d",readCommand(REG_TDT)); - klog("TDH %d",readCommand(REG_TDH)); +// klog("TDT %d",readCommand(REG_TDT)); +// klog("TDH %d",readCommand(REG_TDH)); while(!(tx_descs[old_cur]->status & 0xff)); // TODO: seriously wait here!?!?!? return 0; } @@ -512,6 +513,7 @@ struct netdev e1000_init(uint32_t base) for(int i = 0; i < 0x80; i++)writeCommand(REG_MTA + i*4, 0); //e1000_linkup(); + interrupt_register(INTERRUPT_E1000,&e1000_interrupt); enableInterrupt(); @@ -523,7 +525,7 @@ struct netdev e1000_init(uint32_t base) return dev; } -void e1000_irq (int irq) +uint32_t e1000_interrupt (uint32_t esp) { // if ( p_interruptContext->getInteruptNumber() == pciConfigHeader->getIntLine()+IRQ0) // { @@ -555,4 +557,5 @@ void e1000_irq (int irq) */ if(status & 0x80)e1000_handleReceive(); //... + return esp; } diff --git a/driver/e1000.h b/driver/e1000.h index 27a052e..7eee572 100644 --- a/driver/e1000.h +++ b/driver/e1000.h @@ -5,3 +5,4 @@ int e1000_sendPacket(const void * p_data, uint16_t p_len); void e1000_irq (int irq); void e1000_linkup(); void e1000_linkdown(); +uint32_t e1000_interrupt (uint32_t esp); diff --git a/driver/keyboard.c b/driver/keyboard.c index b9a1dad..f667396 100644 --- a/driver/keyboard.c +++ b/driver/keyboard.c @@ -4,11 +4,14 @@ #include "log.h" #include "e1000.h" #include "kmalloc.h" +#include "interrupts.h" #include <stdbool.h> #include "inet.h" +ringbuffer kb_in; + static bool ctrl_l=false; static bool shift_l=false; static bool shift_r=false; @@ -31,8 +34,17 @@ static void put(uint8_t c) syscall_generic(SYSCALL_WRITE,kb_stream, (char *)&c , 1, 0); } +uint32_t keyboard_interrupt(uint32_t esp) +{ + + ringbuffer_put(&kb_in,x86_inb(0x60)); + return esp; +} + void keyboard_init(uint32_t s) { + kb_in=ringbuffer_init(1);// 4096 bytes ringbuffer; + interrupt_register(INTERRUPT_KEYBOARD,&keyboard_interrupt); kb_stream=s; } diff --git a/driver/mouse.c b/driver/mouse.c index 7ec5e68..cebafed 100644 --- a/driver/mouse.c +++ b/driver/mouse.c @@ -1,6 +1,9 @@ +#include "mouse.h" + +#include "ringbuffer.h" +#include "interrupts.h" #include "kernel/kernel.h" #include "log.h" -#include "mouse.h" #include "driver/vesa.h" //http://forum.osdev.org/viewtopic.php?t=10247 @@ -17,6 +20,8 @@ volatile int16_t mouse_x; volatile int16_t mouse_y; static volatile uint8_t mouse_a; +static ringbuffer mouse_in; + uint8_t mouse_read(); void mouse_wait(uint8_t a_type) //unsigned char @@ -67,8 +72,20 @@ int8_t mouse_get_y() return mouse_y; } +uint32_t mouse_interrupt(uint32_t esp) +{ + uint8_t b=x86_inb(0x60); + ringbuffer_put(&mouse_in,b); + //klog("%d",b); + return esp; +} + void mouse_init() { + + interrupt_register(INTERRUPT_MOUSE,&mouse_interrupt); + mouse_in=ringbuffer_init(1);// 4096 bytes ringbuffer; + mouse_x=mouse_y=0; mouse_cycle=0; diff --git a/driver/timer.c b/driver/timer.c index 30a30c6..4b8f050 100644 --- a/driver/timer.c +++ b/driver/timer.c @@ -1,6 +1,7 @@ +#include "timer.h" +#include "interrupts.h" #include "kernel.h" #include "log.h" -#include "timer.h" #include "asm_x86.h" #include "asm_pit.h" @@ -148,6 +149,11 @@ static uint64_t get_rtc_time() return epoch_seconds; } +uint32_t timer_interrupt(uint32_t esp) +{ + asm_pit_tick(); + return esp; +} // PIT uint64_t timer_init() @@ -156,7 +162,9 @@ uint64_t timer_init() task_system_clock_start=epoch_time*25; // since pit ticks 25times a second asm_pit_rate_40ms(); //tick at 25hz fixme("pit rate does only seem to work occasionally.. 1/25 seconds???" ); + interrupt_register(INTERRUPT_PIT_TIMER,&timer_interrupt); return epoch_time; + } uint64_t timer_get_ms() @@ -79,7 +79,7 @@ static char* get_mount_for_path(char *path,mount *mnt) mount *m=&mounts[i]; uint32_t len=check_match(path,m->path); - if(len>best_len&&len==strlen(m->path)) + if(len>best_len)//&&len==strlen(m->path)) { best=i; best_len=len; @@ -9,7 +9,7 @@ #include "lib/string/string.h" -static const char* names[] = {"mem","kmalloc","mount"}; +static const char* names[] = {"/mem","/kmalloc","/mount"}; static uint32_t map[]={mem_sysfs,mem_sysfs_set, kmalloc_sysfs,NULL, diff --git a/kernel/apic.c b/kernel/apic.c index 4bc2bb3..e48b19b 100644 --- a/kernel/apic.c +++ b/kernel/apic.c @@ -156,10 +156,10 @@ void ioapic_config() // ioapic_config_entry(2,0x90|0xa000,0x3<<24); // level trigger on low // CPU - ioapic_config_entry(2, INTERRUPT_PIT_TIMER, 0x0<<24); // pit +// ioapic_config_entry(2, INTERRUPT_PIT_TIMER, 0x0<<24); // pit ioapic_config_entry(1, INTERRUPT_KEYBOARD, 0x0<<24); // kb - ioapic_config_entry(12, INTERRUPT_MOUSE, 0x0<<24); // mouse - ioapic_config_entry(11, INTERRUPT_E1000|0x8000, 0x0<<24); // e1000 (level trigger on high) +// ioapic_config_entry(12, INTERRUPT_MOUSE, 0x0<<24); // mouse +// ioapic_config_entry(11, INTERRUPT_E1000|0x8000, 0x0<<24); // e1000 (level trigger on high) } /** startup other cpus*/ diff --git a/kernel/interrupts.c b/kernel/interrupts.c index b0a473a..5a788c8 100644 --- a/kernel/interrupts.c +++ b/kernel/interrupts.c @@ -13,15 +13,11 @@ #include "apic.h" #include "ringbuffer.h" -ringbuffer mouse_in; -ringbuffer kb_in; - -// - /** The size of our interrupts table */ #define INT_MAX 256 // 0-255 -static uint32_t handlers[INT_MAX]; // addresses of interrupt handlers. +/** Addresses of the registered interrupt handlers */ +static uint32_t handlers[INT_MAX]; /** The interrupt descriptor table */ struct int_desc @@ -53,7 +49,8 @@ static void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr) idt[irq].sel=sel; } -void interrupt_handler_register(uint32_t irq, uint32_t func_addr) +/** register an interrupt handler for given irq number */ +void interrupt_register(uint32_t irq, uint32_t func_addr) { if(irq<128||irq>160)kpanic("irq number out of range!"); if(handlers[irq]!=0)kpanic("handler already registered!"); @@ -62,41 +59,38 @@ void interrupt_handler_register(uint32_t irq, uint32_t func_addr) /* * Interrupt dispatcher - * * Remeber that we are inside an interrupt here! - * */ uint32_t interrupt_handler(uint32_t esp, uint32_t irq) { + uint32_t *stack; - // process irq - switch(irq) + if(handlers[irq]!=0) { - case INTERRUPT_PIT_TIMER: - asm_pit_tick(); - break; - - case INTERRUPT_KEYBOARD: - ringbuffer_put(&kb_in,x86_inb(0x60)); - break; + uint32_t (*f)(uint32_t esp)=handlers[irq]; + esp=f(esp); + apic_eoi(); + } + else if(irq!=INTERRUPT_SYSCALL&&irq!=INTERRUPT_IPI&&irq!=INTERRUPT_APIC_TIMER) + { + kpanic("unhandled interrupt %d",irq); + } - case INTERRUPT_MOUSE: - ringbuffer_put(&mouse_in,x86_inb(0x60)); - break; + // process IRQ + switch(irq) + { case INTERRUPT_SYSCALL: stack=esp; task_syscall(stack[11],stack[8],stack[10],stack[9]); //eax,ebx,ecx,edx + esp=scheduler_wake_worker(esp); break; - case INTERRUPT_E1000: - e1000_irq(INTERRUPT_E1000); - break; - - case INTERRUPT_APIC_TIMER: - case INTERRUPT_IPI: + case INTERRUPT_APIC_TIMER: // frequency is configured in smp.c + case INTERRUPT_IPI: // inter process interrupt esp=scheduler_run(esp,0); + apic_eoi(); break; case 255: // default or spurious @@ -107,29 +101,21 @@ uint32_t interrupt_handler(uint32_t esp, uint32_t irq) // reschedule to kernel worker on these if(irq==INTERRUPT_SYSCALL||irq==INTERRUPT_KEYBOARD||irq==INTERRUPT_MOUSE) { - esp=scheduler_wake_worker(esp); } - // ack all to LAPIC, except software syscalls - if(irq!=INTERRUPT_SYSCALL) - apic_eoi(); + // Ack all to LAPIC, except software syscalls return esp; + } /** - * init interrupt descriptor table + * init interrupt descriptor table (TODO; do we seriously have to hardcode this?) */ void interrupts_init() { - // TODO???? - klog("Initializing Mouse and Kb input buffers"); - fixme("use a regular pipe-file"); - kb_in=ringbuffer_init(1);// 4096 bytes ringbuffer; - mouse_in=ringbuffer_init(1);// 4096 bytes ringbuffer; klog("Initializing. IDT: 0x%08x, IDTD: 0x%08X",&idt,&idtd); - // // Default interrupt handling for(int i=0; i<INT_MAX; i++) diff --git a/kernel/interrupts.h b/kernel/interrupts.h index b3b8a93..31b0cc0 100644 --- a/kernel/interrupts.h +++ b/kernel/interrupts.h @@ -26,6 +26,10 @@ * ------------------- * * 0x81-0xA0 * + * Default + * ------- + * * 0xff + * * Usage * ----- * @@ -34,6 +38,10 @@ * interrupt_handler() and exception_handler() will be called accordingly from * the interrupt handlers this functionality is backed by. You can find them * in asm_int.h. The selector 0x08 is used. + * + * You can register handlers for specific interrupts via + * interrupt_register(). Remember that the interrupts are routed + * through the I/O APIC which has to be configured as well. */ #define INTERRUPT_SYSCALL 0x80 // can be called from user code / ring 3 @@ -46,9 +54,8 @@ #define INTERRUPT_E1000 0x93 #define INTERRUPT_APIC_TIMER 0x94 - void interrupts_init(); void interrupts_install(); -void interrupt_handler_register(uint32_t irq, uint32_t func_addr); +void interrupt_register(uint32_t irq, uint32_t func_addr); #endif diff --git a/kernel/kernel.c b/kernel/kernel.c index e4d7eba..f926139 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -1,7 +1,8 @@ #include "kernel.h" -#include "log.h" +#include "log.h" #include "serial.h" + #include "asm_pic.h" #include "multiboot.h" #include "acpi.h" @@ -53,10 +54,6 @@ void kernel_main(uint32_t eax,uint32_t ebx) klog("Version: git-commit: %s",GIT_REVISION); klog("======================================"); - // -- UNIT TESTING -- // - testing_kmalloc(); - testing_mount(); - // -- DISABLE LEGACY PIC -- // klog("Remapping & Disabling Programmable Interrupt Controller (PIC) ..."); fixme("io_wait & spurious interrupts"); @@ -65,7 +62,7 @@ void kernel_main(uint32_t eax,uint32_t ebx) // -- GET CONFIGS -- // klog("Read Multiboot Structures ..."); multiboot_information *cfg_multiboot; - cfg_multiboot=multiboot_read(eax, ebx,true); // true-silent + cfg_multiboot=multiboot_read(eax, ebx,true); // true for silent // elf_multiboot_read(cfg_multiboot); // just show kernel section headers klog("Read Advanced Power Configuration Interface (ACPI) Structures ..."); @@ -84,7 +81,6 @@ void kernel_main(uint32_t eax,uint32_t ebx) interrupts_install(); fixme("register interrupt callback funcs (instead hardcoded dispatcher)"); - // -- PCI SCAN --/ klog("PCI init ..."); uint32_t e1000_addr=pci_init(); @@ -109,8 +105,7 @@ void kernel_main(uint32_t eax,uint32_t ebx) klog("Mounting ... "); ext2_dump_info(VMEM_EXT2_RAMIMAGE); ext2_mount("/"); - sysfs_mount("/sys"); - pipe_mount("/pipes"); + sysfs_mount("/sys/"); // -- APIC -- // klog("Advanced Programmable Interrupt Controller (APIC) config ..."); @@ -145,6 +140,9 @@ void kernel_main(uint32_t eax,uint32_t ebx) uint64_t unixtime=timer_init(); klog("Unix Time = %u seconds",unixtime); + // -- E1000 INIT (TODO: only if present!) --/ + klog("E1000 init ..."); + fixme("do not hardcode address and allow paging somehwere else"); e1000_init(e1000_addr); klog("Symmetric Multi Processing (SMP) start ... "); diff --git a/kernel/kernel.h b/kernel/kernel.h index 07e5fda..d0c14f6 100644 --- a/kernel/kernel.h +++ b/kernel/kernel.h @@ -38,8 +38,8 @@ REFERENCES #define MAX_TASKS 100 #define MEM_PRINT_MEMORYMAP -#define KMALLOC_MEM_SIZE 1024*1024*8 // 8MB for in kernel-memory -#define KMALLOC_BLOCK_SIZE 1024*4 // 4096 per block +#define KMALLOC_MEM_SIZE (1024*1024*1) // 8MB for in kernel-memory +#define KMALLOC_BLOCK_SIZE (1024*4) // 4096 per block #define NUMBER_SPINLOCKS 16 #define SPINLOCK_LOG 0 diff --git a/kernel/kmalloc.c b/kernel/kmalloc.c index 061d68e..38db6fc 100644 --- a/kernel/kmalloc.c +++ b/kernel/kmalloc.c @@ -3,7 +3,7 @@ #include "spinlock.h" #include "log.h" -#define BLOCKS KMALLOC_MEM_SIZE/KMALLOC_BLOCK_SIZE +#define BLOCKS (KMALLOC_MEM_SIZE/KMALLOC_BLOCK_SIZE) // this is in .bss so we can assume it was zeroed! static uint8_t data[KMALLOC_MEM_SIZE] __attribute__((aligned (4096))); // bytes @@ -11,16 +11,12 @@ static uint8_t map[BLOCKS]; // static uint32_t data_addr; -static uint32_t next; -static uint32_t first; -static uint8_t init=0; - static uint32_t next_free(uint32_t start) { for(int i=start;i<BLOCKS;i++) { if(!map[i])return i; - return next_free(i+map[i]); + i+=map[i]-1; } return BLOCKS; // out of mem } @@ -44,7 +40,7 @@ static uint32_t free_cont(uint32_t blocks) { pos=next_free(pos); // klog("next_free:%d",pos); - if(pos==BLOCKS)return BLOCKS; // out of mem + if(pos+blocks>=BLOCKS)return BLOCKS; // out of mem uint32_t end=next_used(pos,blocks); // klog("next_used:%d",end); if(end-pos>=blocks)return pos; @@ -83,28 +79,27 @@ static void mark_free(uint32_t start,uint32_t blocks) // will be initialized on first call to kballoc() // static void kmallocinit() { - next=&(data[0]); - data_addr=next; - first=next; - if(next%4096)kpanic("kmalloc data not aligned properly."); + data_addr=data; + if(data_addr%4096)kpanic("kmalloc data not aligned properly."); - klog("In-Kernel Block Memory Allocation Initialized at: 0x%08X (free: %d x 4096KB BLOCKS)",next,BLOCKS); - init=1; + klog("In-Kernel Block Memory Allocation Initialized at: 0x%08X (free: %d x 4096KB BLOCKS)",data_addr,BLOCKS); } // kernel block memory allocation // uint32_t kballoc(uint32_t size) { + static bool init=false; if(size>255)kpanic("max supported size 255 blocks"); spinlock_spin(SPINLOCK_ALLOC); - if(!init)kmallocinit(); + if(!init){kmallocinit(); init=true;} uint32_t blk=free_cont(size); if(blk==BLOCKS)kpanic("out of mem"); mark_used(blk,size); spinlock_release(SPINLOCK_ALLOC); + klog("allocated %d blocks at 0x%08X",size,data_addr+blk*4096); return data_addr+blk*4096; } @@ -112,7 +107,7 @@ void kbfree(uint32_t pos) { uint32_t blk=(pos-data_addr)/4096; spinlock_spin(SPINLOCK_ALLOC); - klog("freeing %d blocks ad 0x%08X",map[blk],pos); + klog("freeing %d blocks at 0x%08X",map[blk],pos); mark_free(blk,map[blk]); spinlock_release(SPINLOCK_ALLOC); } @@ -121,14 +116,28 @@ void kmalloc_sysfs(ringbuffer *r,void (*f)(ringbuffer *r,char *fmt, ...)) { uint32_t free=0; uint32_t used=0; + + char cmap[BLOCKS]; + cmap[200]=0; + for(int i=0;i<BLOCKS;i++) { - if(map[i]) used++; - else free++; + if(map[i]) + { + cmap[i]='X'; + used++; + } + else + { + cmap[i]='_'; + free++; + } } f(r,"kernel blocks allocation/deallocation"); f(r,"total 4096kb blocks: %d (%d bytes)",BLOCKS,BLOCKS*4096); f(r,"used 4096kb blocks: %d (%d bytes)",used,used*4096); f(r,"free 4096kb blocks: %d (%d bytes)",free,free*4096); +// f(r,"%s",cmap); // TODO: watch out for buffer overflow in f + } diff --git a/kernel/scheduler.c b/kernel/scheduler.c index f6067e5..dfe1b25 100644 --- a/kernel/scheduler.c +++ b/kernel/scheduler.c @@ -81,7 +81,7 @@ volatile void scheduler_init(uint32_t cpu, void *dir) task_list[cpu][0].syscall=false; task_list[cpu][0].thread=false; task_list[cpu][0].vmem=dir; - task_list[cpu][0].esp = VMEM_CPU_STACK_TOP-0x200; + task_list[cpu][0].esp = VMEM_CPU_STACK_TOP-0x200-8; task_list[cpu][0].esp0 = 0; // esp0 not needed by kernel space tasks fd_init_std_streams(task_list[cpu][0].pid,0); @@ -92,7 +92,7 @@ volatile void scheduler_init(uint32_t cpu, void *dir) task_list[cpu][1].thread=false; task_list[cpu][1].syscall=false; task_list[cpu][1].vmem=dir; - task_list[cpu][1].esp = kballoc(4)+4*4096-0x200; // 4 pages stack + task_list[cpu][1].esp = kballoc(4)+4*4096-0x200-8; // 4 pages stack & prealign task_list[cpu][1].esp0 =kballoc(4)+4*4096; // esp0 not needed by kernel space tasks fd_init_std_streams(task_list[cpu][1].pid,0); @@ -104,7 +104,7 @@ volatile void scheduler_init(uint32_t cpu, void *dir) task_list[cpu][2].thread=false; task_list[cpu][2].syscall=false; task_list[cpu][2].vmem=dir; - task_list[cpu][2].esp = kballoc(4)+4*4096-0x200; // 4 pages stack + task_list[cpu][2].esp = kballoc(4)+4*4096-0x200-8; // 4 pages stack & prealign task_list[cpu][2].esp0 =kballoc(4)+4*4096; // esp0 not needed by kernel space tasks fd_init_std_streams(task_list[cpu][2].pid,0); diff --git a/kernel/smp.c b/kernel/smp.c index d9c994a..e204b32 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -16,6 +16,8 @@ #include "vesa.h" #include "syscalls.h" +void run_smp(); + // set cpu private value void smp_set(uint32_t offset, uint32_t value) { @@ -58,12 +60,12 @@ void smp_main() smp_main_generic(false); } -static void run_smp() +void run_smp() { apic_enable(); klog("Setup the LAPIC Timer on CPU with lapic_id=0x%x ...",apic_id()); - apic_init_timer(10);// freq 1HZ + apic_init_timer(2);// freq 2HZ klog("Enable Interrupts on CPU with lapic_id=0x%x ...",apic_id()); diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 2952c11..d289121 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -461,5 +461,5 @@ uint32_t syscall_generic(uint32_t nr,uint32_t p1, uint32_t p2, uint32_t p3, uint case SYSCALL_DUP2 : return syscall_dup2(p1,p2,p3,pid); } - kpanic("unknown syscall"); + kpanic("unknown syscall %d",nr); } @@ -117,7 +117,7 @@ void arp_incoming(struct netdev *netdev, struct eth_hdr *hdr) switch (arphdr->opcode) { case ARP_REQUEST: - klog("Arp Reply"); +// klog("Arp Reply"); arp_reply(netdev, hdr, arphdr); break; default: @@ -72,16 +72,16 @@ bool icmp_incoming(struct netdev *dev,struct eth_hdr *hdr) struct ipv4_hdr *ipv4=hdr->payload; struct icmp_v4 *data=(uint32_t *)ipv4+ipv4->ihl; - klog ("icmp type=%d",data->type); - klog ("icmp code=%d",data->code); - klog ("icmp csum=0x%04x",ntohs(data->csum)); +// klog ("icmp type=%d",data->type); +// klog ("icmp code=%d",data->code); +// klog ("icmp csum=0x%04x",ntohs(data->csum)); data->csum=0; - klog("expected checksum = 0x%04X",checksum(data,ntohs(ipv4->len)-ipv4->ihl*4)); +// klog("expected checksum = 0x%04X",checksum(data,ntohs(ipv4->len)-ipv4->ihl*4)); if(data->type==ICMP_ECHO_REQUEST) // echo request { struct icmp_v4_echo *echo=data->data; - klog ("received echo request id=%d, seq=%d, data=%d ",ntohs(echo->id),ntohs(echo->seq),echo->data); + //klog ("received echo request id=%d, seq=%d, data=%d ",ntohs(echo->id),ntohs(echo->seq),echo->data); icmp_reply(dev,hdr); /// TODO watchout that this is the memory managed by the network card we are dealing with!!. fix this later. } @@ -7,10 +7,10 @@ bool ipv4_incoming(struct netdev *dev,struct eth_hdr *hdr) { struct ipv4_hdr *ipv4=hdr->payload; - klog("ipv4 incoming with checksum: 0x%04X",ntohs(ipv4->csum)); +// klog("ipv4 incoming with checksum: 0x%04X",ntohs(ipv4->csum)); ipv4->csum=0; - klog("expected checksum: 0x%04X",checksum(ipv4,ntohs(ipv4->len))); - klog("ipv4 header len=%d",ipv4->ihl); +// klog("expected checksum: 0x%04X",checksum(ipv4,ntohs(ipv4->len))); +// klog("ipv4 header len=%d",ipv4->ihl); if(ipv4->proto==IPV4_P_ICMP) { |
