From ee30cdd0bf8fef723ebd91eae5b4dfa71d7dae68 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 31 Jul 2011 19:13:59 +0200 Subject: [PATCH 1/3] enable LWIP's raw ip for the ping example --- lwip/src/include/lwipopts.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index 44b7141a..46ac691a 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -13,7 +13,7 @@ * LWIP_RAW==1: Enable application layer to hook into the IP layer itself. * LWIP_RAW==0: speeds up input processing */ -#define LWIP_RAW 0 +#define LWIP_RAW 1 /** * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) From 27ee238684227f1c3bd0a09712af5debe6ca273f Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 31 Jul 2011 19:15:06 +0200 Subject: [PATCH 2/3] search MP table on all systems --- arch/x86/kernel/apic.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c index b996cb7b..0f0ee985 100644 --- a/arch/x86/kernel/apic.c +++ b/arch/x86/kernel/apic.c @@ -327,7 +327,6 @@ void smp_start(uint32_t id) } #endif -#if MAX_CORES > 1 static unsigned int* search_apic(unsigned int base, unsigned int limit) { uint32_t* ptr; @@ -341,6 +340,7 @@ static unsigned int* search_apic(unsigned int base, unsigned int limit) { return NULL; } +#if MAX_CORES > 1 int smp_init(void) { uint32_t i, j; @@ -362,22 +362,22 @@ int smp_init(void) */ bootaddr = (char*) SMP_SETUP_ADDR; memcpy(bootaddr, boot_code, sizeof(boot_code)); - for(j=0; j 1 apic_mp = (apic_mp_t*) search_apic(0xF0000, 0x100000); if (apic_mp) goto found_mp; @@ -577,7 +576,7 @@ static int apic_probe(void) if (mmap->type == MULTIBOOT_MEMORY_RESERVED) { addr = mmap->addr; - for(i=0; ilen; i++, addr++) { + for(i=0; ilen-sizeof(uint32_t); i++, addr++) { if (*((uint32_t*) addr) == MP_FLT_SIGNATURE) { apic_mp = (apic_mp_t*) addr; if (!(apic_mp->version > 4) && apic_mp->features[0]) @@ -591,7 +590,6 @@ static int apic_probe(void) } #endif found_mp: -#endif if (!apic_mp) goto no_mp; @@ -752,10 +750,12 @@ int apic_init(void) return ret; if (ioapic) { + uint32_t i; + // enable timer interrupt ioapic_inton(0, apic_processors[boot_processor]->id); // now lets turn everything else off - for(uint32_t i=1; i<24; i++) + for(i=1; i<24; i++) ioapic_intoff(i, apic_processors[boot_processor]->id); } #endif From a26f88c940df6c9e39427c43253e91f98d013c5d Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 31 Jul 2011 19:17:42 +0200 Subject: [PATCH 3/3] cosmetic changes --- arch/x86/include/asm/idt.h | 7 ++----- arch/x86/kernel/idt.c | 23 ++++++++++++----------- drivers/net/rtl8139.c | 6 +++--- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/arch/x86/include/asm/idt.h b/arch/x86/include/asm/idt.h index 28fde65a..a30cddb1 100644 --- a/arch/x86/include/asm/idt.h +++ b/arch/x86/include/asm/idt.h @@ -82,7 +82,6 @@ typedef struct { unsigned short base_hi; } __attribute__ ((packed)) idt_entry_t; - /** @brief Defines the idt pointer structure. * * This structure keeps information about @@ -95,8 +94,6 @@ typedef struct { unsigned int base; } __attribute__ ((packed)) idt_ptr_t; - - /** @brief Installs IDT * * The installation involves the following steps: @@ -113,7 +110,7 @@ void idt_install(void); * @param sel Segment the IDT will use * @param flags Flags this entry will have */ -void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, +void idt_set_gate(unsigned char num, size_t base, unsigned short sel, unsigned char flags); /** @brief Configures and returns a IDT entry with chosen attributes @@ -123,7 +120,7 @@ void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, * * @return a preconfigured idt descriptor */ -idt_entry_t configure_idt_entry(unsigned long base, unsigned short sel, +idt_entry_t configure_idt_entry(size_t base, unsigned short sel, unsigned char flags); #ifdef __cplusplus diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c index ae35b1f5..af7fec6f 100644 --- a/arch/x86/kernel/idt.c +++ b/arch/x86/kernel/idt.c @@ -41,17 +41,8 @@ */ static idt_entry_t idt[256] = {[0 ... 255] = {0, 0, 0, 0, 0}}; static idt_ptr_t idtp; -/* - * Use this function to set an entry in the IDT. Alot simpler - * than twiddling with the GDT ;) - */ -void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, - unsigned char flags) -{ - idt[num] = configure_idt_entry(base, sel, flags); -} -idt_entry_t configure_idt_entry(unsigned long base, unsigned short sel, +idt_entry_t configure_idt_entry(size_t base, unsigned short sel, unsigned char flags) { idt_entry_t desc; @@ -69,6 +60,16 @@ idt_entry_t configure_idt_entry(unsigned long base, unsigned short sel, return desc; } +/* + * Use this function to set an entry in the IDT. Alot simpler + * than twiddling with the GDT ;) + */ +void idt_set_gate(unsigned char num, size_t base, unsigned short sel, + unsigned char flags) +{ + idt[num] = configure_idt_entry(base, sel, flags); +} + extern void isrsyscall(void); /* Installs the IDT */ @@ -84,7 +85,7 @@ void idt_install(void) idtp.base = (unsigned int)&idt; /* Add any new ISRs to the IDT here using idt_set_gate */ - idt_set_gate(INT_SYSCALL, (unsigned int)isrsyscall, KERNEL_CODE_SELECTOR, + idt_set_gate(INT_SYSCALL, (size_t)isrsyscall, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING3|IDT_FLAG_32BIT|IDT_FLAG_TRAPGATE); } diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c index 4fbf150a..0ff112ea 100644 --- a/drivers/net/rtl8139.c +++ b/drivers/net/rtl8139.c @@ -237,7 +237,7 @@ static void rtl8139if_handler(struct state* s) uint16_t isr_contents; while (1) { - isr_contents = inportw(rtl8139if->iobase + ISR); + isr_contents = inportw(rtl8139if->iobase + ISR); if (isr_contents == 0) break; @@ -398,7 +398,7 @@ err_t rtl8139if_init(struct netif* netif) } if (!tmp16) { - // it seems not to work + // it seems not to work kprintf("RTL8139 reset failed\n"); return ERR_ARG; } @@ -416,7 +416,7 @@ err_t rtl8139if_init(struct netif* netif) outportb(rtl8139if->iobase + CONFIG1, (inportb(rtl8139if->iobase + CONFIG1) & ~(CONFIG1_DVRLOAD | CONFIG1_LWACT)) | CONFIG1_DVRLOAD); - // unlock config register + // unlock config register outportb(rtl8139if->iobase + CR9346, 0); /*