Fixes to x86 error and interrupt handling
authorJohn Hodge <[email protected]>
Fri, 2 Apr 2010 12:42:27 +0000 (20:42 +0800)
committerJohn Hodge <[email protected]>
Fri, 2 Apr 2010 12:42:27 +0000 (20:42 +0800)
- Fixed double fault handler so it actually works
- I (thePowersGang/John Hodge) am an idiot, As you will see from Kernel/arch/x86/desctab.asm
  I forgot to set the data segment selectors to kernel values when handling interrupts,
  this caused IRQs and faults that occured in vm8086 mode to triple fault.
- Other changes to logging, moving more log/notice messages to the Log_* functions
- Untested fixes to TCP's Acknowledgement number code
 > TODO Check wether to ACK a packet on arrival, or once it's added to the client buffer.
- Also fixed some bugs in the thread Sleep/Wake functions that were exposed by
  the vm8086 driver.

19 files changed:
Kernel/Doxyfile.api
Kernel/Makefile.BuildNum
Kernel/arch/x86/desctab.asm
Kernel/arch/x86/errors.c
Kernel/arch/x86/include/arch.h
Kernel/arch/x86/include/desctab.h [new file with mode: 0644]
Kernel/arch/x86/mm_virt.c
Kernel/arch/x86/proc.c
Kernel/arch/x86/vm8086.c
Kernel/debug.c
Kernel/drv/kb.c
Kernel/drv/pci.c
Kernel/drv/vterm.c
Kernel/system.c
Kernel/threads.c
Modules/Display/BochsGA/bochsvbe.c
Modules/IPStack/main.c
Modules/IPStack/tcp.c
Modules/USB/Makefile.tpl [new file with mode: 0644]

index 56b80d2..d445416 100644 (file)
@@ -572,7 +572,9 @@ INPUT                  = include/apidoc_mainpage.h \
                          include/vfs.h include/vfs_ext.h \
                                                 include/fs_devfs.h \
                          include/iocache.h \
                          include/vfs.h include/vfs_ext.h \
                                                 include/fs_devfs.h \
                          include/iocache.h \
-                         include/apidoc/arch_x86.h
+                         include/apidoc/arch_x86.h \
+                         include/tpl_drv_common.h \
+                         include/tpl_drv_video.h
 
 # This tag can be used to specify the character encoding of the source files 
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
 
 # This tag can be used to specify the character encoding of the source files 
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
index a571286..6bf24dd 100644 (file)
@@ -1 +1 @@
-BUILD_NUM = 1696
+BUILD_NUM = 1740
index 737570b..43bd8e4 100644 (file)
@@ -29,6 +29,7 @@ gGDTPtr:
        dd      gGDT
 ; IDT
 ALIGN 8
        dd      gGDT
 ; IDT
 ALIGN 8
+[global gIDT]
 gIDT:
        times   256     dd      0x00080000,0x00000F00
 [global gIDTPtr]
 gIDT:
        times   256     dd      0x00080000,0x00000F00
 [global gIDTPtr]
@@ -146,7 +147,6 @@ Isr%1:
 %macro DEF_IRQ 1
 [global Isr%1]
 Isr%1:
 %macro DEF_IRQ 1
 [global Isr%1]
 Isr%1:
-       ;cli    ; HACK!
        push    0
        push    %1
        jmp     IRQCommon
        push    0
        push    %1
        jmp     IRQCommon
@@ -212,6 +212,12 @@ ErrorCommon:
        push fs
        push gs
        
        push fs
        push gs
        
+       mov ax, 0x10
+       mov ds, ax
+       mov es, ax
+       mov fs, ax
+       mov gs, ax
+       
        push esp
        call ErrorHandler
        add esp, 4
        push esp
        call ErrorHandler
        add esp, 4
@@ -258,6 +264,12 @@ IRQCommon:
        push fs
        push gs
        
        push fs
        push gs
        
+       mov ax, 0x10
+       mov ds, ax
+       mov es, ax
+       mov fs, ax
+       mov gs, ax
+       
        push esp
        call IRQ_Handler
        add esp, 4
        push esp
        call IRQ_Handler
        add esp, 4
@@ -281,6 +293,12 @@ SchedulerBase:
        push fs
        push gs
        
        push fs
        push gs
        
+       mov ax, 0x10
+       mov ds, ax
+       mov es, ax
+       mov fs, ax
+       mov gs, ax
+       
        mov eax, [esp+12*4]     ; CPU Number
        push eax        ; Pus as argument
        
        mov eax, [esp+12*4]     ; CPU Number
        push eax        ; Pus as argument
        
index b53807a..31c385f 100644 (file)
@@ -43,10 +43,14 @@ void __stack_chk_fail()
 void ErrorHandler(tRegs *Regs)
 {
        Uint    cr;
 void ErrorHandler(tRegs *Regs)
 {
        Uint    cr;
-       __asm__ __volatile__ ("cli");
        
        
+       //if( Regs && !(Regs->int_num == 13 && Regs->eflags & 0x20000) )
+       //      __asm__ __volatile__ ("xchg %bx, %bx");
+       //Log_Debug("X86", "Regs = %p", Regs);
        //Log_Debug("X86", "Error %i at 0x%08x", Regs->int_num, Regs->eip);
        
        //Log_Debug("X86", "Error %i at 0x%08x", Regs->int_num, Regs->eip);
        
+       __asm__ __volatile__ ("cli");
+       
        // Page Fault
        if(Regs->int_num == 14)
        {
        // Page Fault
        if(Regs->int_num == 14)
        {
@@ -65,7 +69,10 @@ void ErrorHandler(tRegs *Regs)
        Warning("CPU Error %i - %s, Code: 0x%x",
                Regs->int_num, csaERROR_NAMES[Regs->int_num], Regs->err_code);
        Warning(" CS:EIP = 0x%04x:%08x", Regs->cs, Regs->eip);
        Warning("CPU Error %i - %s, Code: 0x%x",
                Regs->int_num, csaERROR_NAMES[Regs->int_num], Regs->err_code);
        Warning(" CS:EIP = 0x%04x:%08x", Regs->cs, Regs->eip);
-       Warning(" SS:ESP = 0x%04x:%08x", Regs->ss, Regs->esp);
+       if(Regs->cs == 0x08)
+               Warning(" SS:ESP = 0x0010:%08x", 0x10, (Uint)Regs+sizeof(tRegs));
+       else
+               Warning(" SS:ESP = 0x%04x:%08x", Regs->ss, Regs->esp);
        Warning(" EFLAGS = 0x%08x", Regs->eflags);
        Warning(" EAX %08x ECX %08x EDX %08x EBX %08x",
                Regs->eax, Regs->ecx, Regs->edx, Regs->ebx);
        Warning(" EFLAGS = 0x%08x", Regs->eflags);
        Warning(" EAX %08x ECX %08x EDX %08x EBX %08x",
                Regs->eax, Regs->ecx, Regs->edx, Regs->ebx);
@@ -84,7 +91,7 @@ void ErrorHandler(tRegs *Regs)
        
        switch( Regs->int_num )
        {
        
        switch( Regs->int_num )
        {
-       case 6:
+       case 6: // #UD
                Warning(" Offending bytes: %02x %02x %02x %02x",
                        *(Uint8*)Regs->eip+0, *(Uint8*)Regs->eip+1,
                        *(Uint8*)Regs->eip+2, *(Uint8*)Regs->eip+3);
                Warning(" Offending bytes: %02x %02x %02x %02x",
                        *(Uint8*)Regs->eip+0, *(Uint8*)Regs->eip+1,
                        *(Uint8*)Regs->eip+2, *(Uint8*)Regs->eip+3);
index 996f418..4007a71 100644 (file)
@@ -98,18 +98,6 @@ typedef struct {
        Uint    Resvd4[1];      // SS
 } tSyscallRegs;
 
        Uint    Resvd4[1];      // SS
 } tSyscallRegs;
 
-typedef struct {
-       Uint16  LimitLow;
-       Uint16  BaseLow;
-       Uint8   BaseMid;
-       Uint8   Access;
-       struct {
-               unsigned LimitHi:       4;
-               unsigned Flags:         4;
-       } __attribute__ ((packed));
-       Uint8   BaseHi;
-} __attribute__ ((packed)) tGDT;
-
 typedef struct {
        #if USE_PAE
        Uint    PDPT[4];
 typedef struct {
        #if USE_PAE
        Uint    PDPT[4];
diff --git a/Kernel/arch/x86/include/desctab.h b/Kernel/arch/x86/include/desctab.h
new file mode 100644 (file)
index 0000000..47a462a
--- /dev/null
@@ -0,0 +1,25 @@
+/**
+ */
+#ifndef _DESCTAB_H_
+#define _DESCTAB_H_
+
+typedef struct {
+       Uint16  LimitLow;
+       Uint16  BaseLow;
+       Uint8   BaseMid;
+       Uint8   Access;
+       struct {
+               unsigned LimitHi:       4;
+               unsigned Flags:         4;
+       } __attribute__ ((packed));
+       Uint8   BaseHi;
+} __attribute__ ((packed)) tGDT;
+
+typedef struct {
+       Uint16  OffsetLo;
+       Uint16  CS;
+       Uint16  Flags;
+       Uint16  OffsetHi;
+} __attribute__ ((packed)) tIDT;
+
+#endif
index 6976c65..cf77b87 100644 (file)
@@ -9,7 +9,7 @@
  * 0xFE - Unused
  * 0xFF - System Calls / Kernel's User Code
  */
  * 0xFE - Unused
  * 0xFF - System Calls / Kernel's User Code
  */
-#define DEBUG  1
+#define DEBUG  0
 #define SANITY 1
 #include <acess.h>
 #include <mm_phys.h>
 #define SANITY 1
 #include <acess.h>
 #include <mm_phys.h>
@@ -208,7 +208,7 @@ void MM_PageFault(tVAddr Addr, Uint ErrorCode, tRegs *Regs)
                        (ErrorCode&1?"bad/locked":"non-present"),
                        (ErrorCode&16?" (Instruction Fetch)":"")
                        );
                        (ErrorCode&1?"bad/locked":"non-present"),
                        (ErrorCode&16?" (Instruction Fetch)":"")
                        );
-               Warning("User Pagefault: Instruction at %p accessed %p", Regs->eip, Addr);
+               Warning("User Pagefault: Instruction at %04x:%08x accessed %p", Regs->cs, Regs->eip, Addr);
                __asm__ __volatile__ ("sti");   // Restart IRQs
                Threads_SegFault(Addr);
                return ;
                __asm__ __volatile__ ("sti");   // Restart IRQs
                Threads_SegFault(Addr);
                return ;
index b2f7f8f..3b5ceb2 100644 (file)
@@ -4,6 +4,7 @@
  */
 #include <acess.h>
 #include <proc.h>
  */
 #include <acess.h>
 #include <proc.h>
+#include <desctab.h>
 #include <mm_virt.h>
 #include <errno.h>
 #if USE_MP
 #include <mm_virt.h>
 #include <errno.h>
 #if USE_MP
@@ -20,6 +21,7 @@
 
 // === IMPORTS ===
 extern tGDT    gGDT[];
 
 // === IMPORTS ===
 extern tGDT    gGDT[];
+extern tIDT    gIDT[];
 extern void APStartup();       // 16-bit AP startup code
 extern Uint    GetEIP();       // start.asm
 extern Uint32  gaInitPageDir[1024];    // start.asm
 extern void APStartup();       // 16-bit AP startup code
 extern Uint    GetEIP();       // start.asm
 extern Uint32  gaInitPageDir[1024];    // start.asm
@@ -36,7 +38,7 @@ extern tThread        *gDeleteThreads;
 extern tThread *Threads_GetNextToRun(int CPU);
 extern void    Threads_Dump();
 extern tThread *Threads_CloneTCB(Uint *Err, Uint Flags);
 extern tThread *Threads_GetNextToRun(int CPU);
 extern void    Threads_Dump();
 extern tThread *Threads_CloneTCB(Uint *Err, Uint Flags);
-extern void    Isr7();
+extern void    Isr8(); // Double Fault
 
 // === PROTOTYPES ===
 void   ArchThreads_Init();
 
 // === PROTOTYPES ===
 void   ArchThreads_Init();
@@ -72,7 +74,12 @@ char gaDoubleFaultStack[1024];
 tTSS   gDoubleFault_TSS = {
        .ESP0 = (Uint)&gaDoubleFaultStack[1023],
        .SS0 = 0x10,
 tTSS   gDoubleFault_TSS = {
        .ESP0 = (Uint)&gaDoubleFaultStack[1023],
        .SS0 = 0x10,
-       .EIP = (Uint)Isr7
+       .CR3 = (Uint)gaInitPageDir - KERNEL_BASE,
+       .EIP = (Uint)Isr8,
+       .ESP = (Uint)&gaDoubleFaultStack[1023],
+       .CS = 0x08,     .SS = 0x10,
+       .DS = 0x10,     .ES = 0x10,
+       .FS = 0x10,     .GS = 0x10,
 };
 
 // === CODE ===
 };
 
 // === CODE ===
@@ -277,6 +284,17 @@ void ArchThreads_Init()
        gGDT[5].BaseMid = (Uint)&gDoubleFault_TSS >> 16;
        gGDT[5].BaseHi = (Uint)&gDoubleFault_TSS >> 24;
        
        gGDT[5].BaseMid = (Uint)&gDoubleFault_TSS >> 16;
        gGDT[5].BaseHi = (Uint)&gDoubleFault_TSS >> 24;
        
+       Log_Debug("Proc", "gIDT[8] = {OffsetLo:%04x, CS:%04x, Flags:%04x, OffsetHi:%04x}", 
+               gIDT[8].OffsetLo, gIDT[8].CS, gIDT[8].Flags, gIDT[8].OffsetHi);
+       gIDT[8].OffsetLo = 0;
+       gIDT[8].CS = 5<<3;
+       gIDT[8].Flags = 0x8500;
+       gIDT[8].OffsetHi = 0;
+       Log_Debug("Proc", "gIDT[8] = {OffsetLo:%04x, CS:%04x, Flags:%04x, OffsetHi:%04x}", 
+               gIDT[8].OffsetLo, gIDT[8].CS, gIDT[8].Flags, gIDT[8].OffsetHi);
+       
+       //__asm__ __volatile__ ("xchg %bx, %bx");
+       
        #if USE_MP
        // Initialise Normal TSS(s)
        for(pos=0;pos<giNumCPUs;pos++)
        #if USE_MP
        // Initialise Normal TSS(s)
        for(pos=0;pos<giNumCPUs;pos++)
index abc08dc..c837475 100644 (file)
@@ -16,7 +16,9 @@ enum eVM8086_Opcodes
        VM8086_OP_PUSHF = 0x9C,
        VM8086_OP_POPF  = 0x9D,
        VM8086_OP_INT_I = 0xCD,
        VM8086_OP_PUSHF = 0x9C,
        VM8086_OP_POPF  = 0x9D,
        VM8086_OP_INT_I = 0xCD,
-       VM8086_OP_IRET  = 0xCF
+       VM8086_OP_IRET  = 0xCF,
+       VM8086_OP_IN_AD = 0xEC,
+       VM8086_OP_IN_ADX= 0xED
 };
 #define VM8086_PAGES_PER_INST  4
 
 };
 #define VM8086_PAGES_PER_INST  4
 
@@ -69,7 +71,7 @@ int VM8086_Install(char **Arguments)
                // Map ROM Area
                for(i=0xA0;i<0x100;i++) {
                        MM_Map( i * 0x1000, i * 0x1000 );
                // Map ROM Area
                for(i=0xA0;i<0x100;i++) {
                        MM_Map( i * 0x1000, i * 0x1000 );
-                       MM_SetFlags( i * 0x1000, MM_PFLAG_RO, MM_PFLAG_RO );    // Set Read Only
+                       //MM_SetFlags( i * 0x1000, MM_PFLAG_RO, MM_PFLAG_RO );  // Set Read Only
                }
                MM_Map( 0, 0 ); // IVT / BDA
                for(i=0x70;i<0x80;i++) {
                }
                MM_Map( 0, 0 ); // IVT / BDA
                for(i=0x70;i<0x80;i++) {
@@ -155,7 +157,7 @@ void VM8086_GPF(tRegs *Regs)
                        //Log_Log("VM8086", "gpVM8086_State = %p", gpVM8086_State);
                }
                
                        //Log_Log("VM8086", "gpVM8086_State = %p", gpVM8086_State);
                }
                
-               //Log_Log("VM8086", "We have a task");
+               //Log_Log("VM8086", "We have a task (%p)", gpVM8086_State);
                Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = VM8086_MAGIC_CS;
                Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = VM8086_MAGIC_IP;
                Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = gpVM8086_State->CS;
                Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = VM8086_MAGIC_CS;
                Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = VM8086_MAGIC_IP;
                Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = gpVM8086_State->CS;
@@ -211,7 +213,7 @@ void VM8086_GPF(tRegs *Regs)
                }
                break;
        
                }
                break;
        
-       case 0xCF:      //IRET
+       case VM8086_OP_IRET:    //IRET
                Regs->eip = *(Uint16*)( Regs->ss*16 + (Regs->esp&0xFFFF) );     Regs->esp += 2;
                Regs->cs  = *(Uint16*)( Regs->ss*16 + (Regs->esp&0xFFFF) );     Regs->esp += 2;
                #if TRACE_EMU
                Regs->eip = *(Uint16*)( Regs->ss*16 + (Regs->esp&0xFFFF) );     Regs->esp += 2;
                Regs->cs  = *(Uint16*)( Regs->ss*16 + (Regs->esp&0xFFFF) );     Regs->esp += 2;
                #if TRACE_EMU
@@ -219,6 +221,46 @@ void VM8086_GPF(tRegs *Regs)
                #endif
                break;
        
                #endif
                break;
        
+       
+       case VM8086_OP_IN_AD:   //IN AL, DX
+               Regs->eax &= 0xFFFFFF00;
+               Regs->eax |= inb(Regs->edx&0xFFFF);
+               #if TRACE_EMU
+               Log_Debug("VM8086", "Emulated IN AL, DX (Port 0x%x)\n", Regs->edx&0xFFFF);
+               #endif
+               break;
+       case VM8086_OP_IN_ADX:  //IN AX, DX
+               Regs->eax &= 0xFFFF0000;
+               Regs->eax |= inw(Regs->edx&0xFFFF);
+               #if TRACE_EMU
+               Log_Debug("VM8086", "Emulated IN AX, DX (Port 0x%x)\n", Regs->edx&0xFFFF);
+               #endif
+               break;
+               
+       case 0xEE:      //OUT DX, AL
+               outb(Regs->edx&0xFFFF, Regs->eax&0xFF);
+               #if TRACE_EMU
+               Log_Debug("VM8086", "Emulated OUT DX, AL (*0x%04x = 0x%02x)\n", Regs->edx&0xFFFF, Regs->eax&0xFF);
+               #endif
+               break;
+       case 0xEF:      //OUT DX, AX
+               outw(Regs->edx&0xFFFF, Regs->eax&0xFFFF);
+               #if TRACE_EMU
+               Log_Debug("VM8086", "Emulated OUT DX, AX (*0x%04x = 0x%04x)\n", Regs->edx&0xFFFF, Regs->eax&0xFFFF);
+               #endif
+               break;
+               
+       // TODO: Decide on allowing VM8086 Apps to enable/disable interrupts
+       case 0xFA:      //CLI
+               break;
+       case 0xFB:      //STI
+               break;
+       
+       case 0x66:
+               Log_Warning("VM8086", "Code at %04x:%04x attempted to use an operand override, ignored",
+                       Regs->cs, Regs->eip);
+               break;
+       
        default:
                Log_Error("VM8086", "Error - Unknown opcode %02x caused a GPF at %04x:%04x",
                        opcode, Regs->cs, Regs->eip);
        default:
                Log_Error("VM8086", "Error - Unknown opcode %02x caused a GPF at %04x:%04x",
                        opcode, Regs->cs, Regs->eip);
index f71e889..12adc22 100644 (file)
@@ -264,7 +264,7 @@ void Debug_SetKTerminal(char *File)
        if(giDebug_KTerm != -1)
                VFS_Close(giDebug_KTerm);
        giDebug_KTerm = VFS_Open(File, VFS_OPENFLAG_WRITE);
        if(giDebug_KTerm != -1)
                VFS_Close(giDebug_KTerm);
        giDebug_KTerm = VFS_Open(File, VFS_OPENFLAG_WRITE);
-       Log("Opened '%s' as 0x%x", File, giDebug_KTerm);
+       Log_Log("Debug", "Opened '%s' as 0x%x", File, giDebug_KTerm);
 }
 
 void Debug_Enter(char *FuncName, char *ArgTypes, ...)
 }
 
 void Debug_Enter(char *FuncName, char *ArgTypes, ...)
index 950f722..f6a7313 100644 (file)
@@ -84,7 +84,7 @@ void KB_IRQHandler()
        //if( inportb(0x64) & 0x20 )    return;
 
        scancode = inb(0x60); // Read from the keyboard's data buffer
        //if( inportb(0x64) & 0x20 )    return;
 
        scancode = inb(0x60); // Read from the keyboard's data buffer
-       Log_Debug("KB", "scancode = %02x");
+       //Log_Debug("Keyboard", "scancode = %02x", scancode);
 
        //Log("KB_IRQHandler: scancode = 0x%02x", scancode);
 
 
        //Log("KB_IRQHandler: scancode = 0x%02x", scancode);
 
@@ -126,7 +126,7 @@ void KB_IRQHandler()
        //keyNum = giKB_KeyLayer * 256 + scancode;
        // Check for unknown key
        if(!ch && !gbKB_KeyUp)
        //keyNum = giKB_KeyLayer * 256 + scancode;
        // Check for unknown key
        if(!ch && !gbKB_KeyUp)
-               Warning("UNK %i %x", giKB_KeyLayer, scancode);
+               Log_Warning("Keyboard", "UNK %i %x", giKB_KeyLayer, scancode);
 
        // Key Up?
        if (gbKB_KeyUp)
 
        // Key Up?
        if (gbKB_KeyUp)
@@ -173,11 +173,11 @@ void KB_IRQHandler()
        #if USE_KERNEL_MAGIC
        if(ch == KEY_LCTRL) {
                gbKB_MagicState |= 1;
        #if USE_KERNEL_MAGIC
        if(ch == KEY_LCTRL) {
                gbKB_MagicState |= 1;
-               Log_Log("KB", "Kernel Magic LCTRL Down\n");
+               //Log_Log("Keyboard", "Kernel Magic LCTRL Down\n");
        }
        if(ch == KEY_LALT) {
                gbKB_MagicState |= 2;
        }
        if(ch == KEY_LALT) {
                gbKB_MagicState |= 2;
-               Log_Log("KB", "Kernel Magic LALT Down\n");
+               //Log_Log("Keyboard", "Kernel Magic LALT Down\n");
        }
        if(gbKB_MagicState == 3)
        {
        }
        if(gbKB_MagicState == 3)
        {
index dfbc8ca..e205d4f 100644 (file)
@@ -116,7 +116,7 @@ int PCI_Install(char **Arguments)
                                if(devInfo.oc == PCI_OC_PCIBRIDGE)\r
                                {\r
                                        #if LIST_DEVICES\r
                                if(devInfo.oc == PCI_OC_PCIBRIDGE)\r
                                {\r
                                        #if LIST_DEVICES\r
-                                       Log("[PCI  ] Bridge @ %i,%i:%i (0x%x:0x%x)",\r
+                                       Log_Log("PCI", "Bridge @ %i,%i:%i (0x%x:0x%x)",\r
                                                bus, dev, fcn, devInfo.vendor, devInfo.device);\r
                                        #endif\r
                                        giPCI_BusCount++;\r
                                                bus, dev, fcn, devInfo.vendor, devInfo.device);\r
                                        #endif\r
                                        giPCI_BusCount++;\r
@@ -124,7 +124,7 @@ int PCI_Install(char **Arguments)
                                else\r
                                {\r
                                        #if LIST_DEVICES\r
                                else\r
                                {\r
                                        #if LIST_DEVICES\r
-                                       Log("[PCI  ] Device %i,%i:%i %04x => 0x%04x:0x%04x",\r
+                                       Log_Log("PCI", "Device %i,%i:%i %04x => 0x%04x:0x%04x",\r
                                                bus, dev, fcn, devInfo.oc, devInfo.vendor, devInfo.device);\r
                                        #endif\r
                                }\r
                                                bus, dev, fcn, devInfo.oc, devInfo.vendor, devInfo.device);\r
                                        #endif\r
                                }\r
@@ -156,7 +156,7 @@ int PCI_Install(char **Arguments)
                return MODULE_ERR_MALLOC;\r
        gPCI_Devices = tmpPtr;\r
        \r
                return MODULE_ERR_MALLOC;\r
        gPCI_Devices = tmpPtr;\r
        \r
-       // Complete Driver Structure    \r
+       // Complete Driver Structure\r
        gPCI_DriverStruct.RootNode.Size = giPCI_DeviceCount;\r
        \r
        // And add to DevFS\r
        gPCI_DriverStruct.RootNode.Size = giPCI_DeviceCount;\r
        \r
        // And add to DevFS\r
index cedcb33..ff116f3 100644 (file)
@@ -157,8 +157,8 @@ int VT_Install(char **Arguments)
        if(!gsVT_OutputDevice)  gsVT_OutputDevice = "/Devices/"DEFAULT_OUTPUT;
        if(!gsVT_InputDevice)   gsVT_InputDevice = "/Devices/"DEFAULT_INPUT;
        
        if(!gsVT_OutputDevice)  gsVT_OutputDevice = "/Devices/"DEFAULT_OUTPUT;
        if(!gsVT_InputDevice)   gsVT_InputDevice = "/Devices/"DEFAULT_INPUT;
        
-       LOG("Using '%s' as output", gsVT_OutputDevice);
-       LOG("Using '%s' as input", gsVT_InputDevice);
+       Log_Log("VTerm", "Using '%s' as output", gsVT_OutputDevice);
+       Log_Log("VTerm", "Using '%s' as input", gsVT_InputDevice);
        
        // Create Nodes
        for( i = 0; i < NUM_VTS; i++ )
        
        // Create Nodes
        for( i = 0; i < NUM_VTS; i++ )
@@ -474,7 +474,7 @@ void VT_SetTerminal(int ID)
        VFS_IOCtl( giVT_OutputDevHandle, VIDEO_IOCTL_GETSETMODE, &modeNum );
        
        // Update current terminal ID
        VFS_IOCtl( giVT_OutputDevHandle, VIDEO_IOCTL_GETSETMODE, &modeNum );
        
        // Update current terminal ID
-       Log("Changed terminal from %i to %i", giVT_CurrentTerminal, ID);
+       Log_Log("VTerm", "Changed terminal from %i to %i", giVT_CurrentTerminal, ID);
        giVT_CurrentTerminal = ID;
        
        // Update the screen
        giVT_CurrentTerminal = ID;
        
        // Update the screen
index 8b1cb8e..2097f9b 100644 (file)
@@ -48,7 +48,7 @@ void System_Init(char *ArgString)
        System_ParseCommandLine(ArgString);
        
        // - Execute the Config Script
        System_ParseCommandLine(ArgString);
        
        // - Execute the Config Script
-       Log_Log("CFG", "Executing config script...");
+       Log_Log("Config", "Executing config script...");
        System_ExecuteScript();
 }
 
        System_ExecuteScript();
 }
 
@@ -63,7 +63,7 @@ void System_ParseCommandLine(char *ArgString)
         int    i;
        char    *str;
        
         int    i;
        char    *str;
        
-       Log_Log("CFG", "Kernel Invocation \"%s\"", ArgString);
+       Log_Log("Config", "Kernel Invocation \"%s\"", ArgString);
        
        // --- Get Arguments ---
        str = ArgString;
        
        // --- Get Arguments ---
        str = ArgString;
@@ -114,7 +114,7 @@ void System_ParseVFS(char *Arg)
        
        // Check if the equals was found
        if( *value == '\0' ) {
        
        // Check if the equals was found
        if( *value == '\0' ) {
-               Log_Warning("CFG", "Expected '=' in the string '%s'", Arg);
+               Log_Warning("Config", "Expected '=' in the string '%s'", Arg);
                return ;
        }
        
                return ;
        }
        
@@ -125,7 +125,7 @@ void System_ParseVFS(char *Arg)
        // - Symbolic Link <link>=<destination>
        if(value[0] == '/')
        {
        // - Symbolic Link <link>=<destination>
        if(value[0] == '/')
        {
-               Log_Log("CFG", "Symbolic link '%s' pointing to '%s'", Arg, value);
+               Log_Log("Config", "Symbolic link '%s' pointing to '%s'", Arg, value);
                VFS_Symlink(Arg, value);
        }
        // - Mount <mountpoint>=<fs>:<device>
                VFS_Symlink(Arg, value);
        }
        // - Mount <mountpoint>=<fs>:<device>
@@ -140,13 +140,13 @@ void System_ParseVFS(char *Arg)
                }
                // Create Mountpoint
                if( (fd = VFS_Open(Arg, 0)) == -1 ) {
                }
                // Create Mountpoint
                if( (fd = VFS_Open(Arg, 0)) == -1 ) {
-                       Log_Log("CFG", "Creating directory '%s'", Arg, value);
+                       Log_Log("Config", "Creating directory '%s'", Arg, value);
                        VFS_MkDir( Arg );
                } else {
                        VFS_Close(fd);
                }
                // Mount
                        VFS_MkDir( Arg );
                } else {
                        VFS_Close(fd);
                }
                // Mount
-               Log_Log("CFG", "Mounting '%s' to '%s' ('%s')", dev, Arg, value);
+               Log_Log("Config", "Mounting '%s' to '%s' ('%s')", dev, Arg, value);
                VFS_Mount(dev, Arg, value, "");
        }
 }
                VFS_Mount(dev, Arg, value, "");
        }
 }
@@ -168,7 +168,7 @@ void System_ParseSetting(char *Arg)
        {
                //if(strcmp(Arg, "") == 0) {
                //} else {
        {
                //if(strcmp(Arg, "") == 0) {
                //} else {
-                       Log_Warning("CFG", "Kernel flag '%s' is not recognised", Arg);
+                       Log_Warning("Config", "Kernel flag '%s' is not recognised", Arg);
                //}
        }
        else
                //}
        }
        else
@@ -177,10 +177,10 @@ void System_ParseSetting(char *Arg)
                value ++;       // and eat it's position
                
                if(strcmp(Arg, "SCRIPT") == 0) {
                value ++;       // and eat it's position
                
                if(strcmp(Arg, "SCRIPT") == 0) {
-                       Log_Log("CFG", "Config Script: '%s'", value);
+                       Log_Log("Config", "Config Script: '%s'", value);
                        gsConfigScript = value;
                } else {
                        gsConfigScript = value;
                } else {
-                       Log_Warning("CFG", "Kernel config setting '%s' is not recognised", Arg);
+                       Log_Warning("Config", "Kernel config setting '%s' is not recognised", Arg);
                }
                
        }
                }
                
        }
@@ -201,7 +201,7 @@ void System_ExecuteScript()
        // Open Script
        fp = VFS_Open(gsConfigScript, VFS_OPENFLAG_READ);
        if(fp == -1) {
        // Open Script
        fp = VFS_Open(gsConfigScript, VFS_OPENFLAG_READ);
        if(fp == -1) {
-               Log_Warning("CFG", "Passed script '%s' does not exist", gsConfigScript);
+               Log_Warning("Config", "Passed script '%s' does not exist", gsConfigScript);
                return;
        }
        
                return;
        }
        
@@ -229,11 +229,11 @@ void System_ExecuteScript()
                if( strcmp(line->Parts[0], "mount") == 0 )
                {
                        if( line->nParts != 4 ) {
                if( strcmp(line->Parts[0], "mount") == 0 )
                {
                        if( line->nParts != 4 ) {
-                               Log_Warning("CFG", "Configuration command 'mount' requires 3 arguments, %i given",
+                               Log_Warning("Config", "Configuration command 'mount' requires 3 arguments, %i given",
                                        line->nParts-1);
                                continue;
                        }
                                        line->nParts-1);
                                continue;
                        }
-                       //Log_Log("CFG", "Mount '%s' to '%s' (%s)",
+                       //Log_Log("Config", "Mount '%s' to '%s' (%s)",
                        //      line->Parts[1], line->Parts[2], line->Parts[3]);
                        //! \todo Use an optional 4th argument for the options string
                        VFS_Mount(line->Parts[1], line->Parts[2], line->Parts[3], "");
                        //      line->Parts[1], line->Parts[2], line->Parts[3]);
                        //! \todo Use an optional 4th argument for the options string
                        VFS_Mount(line->Parts[1], line->Parts[2], line->Parts[3], "");
@@ -256,33 +256,33 @@ void System_ExecuteScript()
                else if(strcmp(line->Parts[0], "udimod") == 0)
                {
                        if( line->nParts != 2 ) {
                else if(strcmp(line->Parts[0], "udimod") == 0)
                {
                        if( line->nParts != 2 ) {
-                               Log_Warning("CFG", "Configuration command 'udimod' requires 1 argument, %i given",
+                               Log_Warning("Config", "Configuration command 'udimod' requires 1 argument, %i given",
                                        line->nParts-1);
                                continue;
                        }
                                        line->nParts-1);
                                continue;
                        }
-                       Log_Log("CFG", "Load UDI Module '%s'", line->Parts[1]);
+                       Log_Log("Config", "Load UDI Module '%s'", line->Parts[1]);
                        Module_LoadFile(line->Parts[1], "");
                }
                // Load a EDI Module
                else if(strcmp(line->Parts[0], "edimod") == 0)
                {
                        if( line->nParts != 2 ) {
                        Module_LoadFile(line->Parts[1], "");
                }
                // Load a EDI Module
                else if(strcmp(line->Parts[0], "edimod") == 0)
                {
                        if( line->nParts != 2 ) {
-                               Log_Warning("CFG", "Configuration command 'edimod' requires 1 argument, %i given",
+                               Log_Warning("Config", "Configuration command 'edimod' requires 1 argument, %i given",
                                        line->nParts-1);
                                continue;
                        }
                                        line->nParts-1);
                                continue;
                        }
-                       Log_Log("CFG", "Load EDI Module '%s'", line->Parts[1]);
+                       Log_Log("Config", "Load EDI Module '%s'", line->Parts[1]);
                        Module_LoadFile(line->Parts[1], "");
                }
                // Create a Symbolic Link
                else if(strcmp(line->Parts[0], "symlink") == 0)
                {
                        if( line->nParts != 3 ) {
                        Module_LoadFile(line->Parts[1], "");
                }
                // Create a Symbolic Link
                else if(strcmp(line->Parts[0], "symlink") == 0)
                {
                        if( line->nParts != 3 ) {
-                               Log_Warning("CFG", "Configuration command 'symlink' requires 2 arguments, %i given",
+                               Log_Warning("Config", "Configuration command 'symlink' requires 2 arguments, %i given",
                                        line->nParts-1);
                                continue;
                        }
                                        line->nParts-1);
                                continue;
                        }
-                       Log_Log("CFG", "Symlink '%s' pointing to '%s'",
+                       Log_Log("Config", "Symlink '%s' pointing to '%s'",
                                line->Parts[1], line->Parts[2]);
                        VFS_Symlink(line->Parts[1], line->Parts[2]);
                }
                                line->Parts[1], line->Parts[2]);
                        VFS_Symlink(line->Parts[1], line->Parts[2]);
                }
@@ -290,26 +290,26 @@ void System_ExecuteScript()
                else if(strcmp(line->Parts[0], "mkdir") == 0)
                {
                        if( line->nParts != 2 ) {
                else if(strcmp(line->Parts[0], "mkdir") == 0)
                {
                        if( line->nParts != 2 ) {
-                               Log_Warning("CFG", "Configuration command 'mkdir' requires 1 argument, %i given",
+                               Log_Warning("Config", "Configuration command 'mkdir' requires 1 argument, %i given",
                                        line->nParts-1);
                                continue;
                        }
                                        line->nParts-1);
                                continue;
                        }
-                       Log_Log("CFG", "New Directory '%s'", line->Parts[1]);
+                       Log_Log("Config", "New Directory '%s'", line->Parts[1]);
                        VFS_MkDir(line->Parts[1]);
                }
                // Spawn a process
                else if(strcmp(line->Parts[0], "spawn") == 0)
                {
                        if( line->nParts != 2 ) {
                        VFS_MkDir(line->Parts[1]);
                }
                // Spawn a process
                else if(strcmp(line->Parts[0], "spawn") == 0)
                {
                        if( line->nParts != 2 ) {
-                               Log_Warning("CFG", "Configuration command 'spawn' requires 1 argument, %i given",
+                               Log_Warning("Config", "Configuration command 'spawn' requires 1 argument, %i given",
                                        line->nParts-1);
                                continue;
                        }
                                        line->nParts-1);
                                continue;
                        }
-                       Log_Log("CFG", "Starting '%s' as a new task", line->Parts[1]);
+                       Log_Log("Config", "Starting '%s' as a new task", line->Parts[1]);
                        Proc_Spawn(line->Parts[1]);
                }
                else {
                        Proc_Spawn(line->Parts[1]);
                }
                else {
-                       Log_Warning("CFG", "Unknown configuration command '%s' on line %i",
+                       Log_Warning("Config", "Unknown configuration command '%s' on line %i",
                                line->Parts[0],
                                line->TrueLine
                                );
                                line->Parts[0],
                                line->TrueLine
                                );
index 1ab7029..96a38da 100644 (file)
@@ -468,7 +468,7 @@ void Threads_Sleep()
        tThread *cur = Proc_GetCurThread();
        tThread *thread;
        
        tThread *cur = Proc_GetCurThread();
        tThread *thread;
        
-       Log_Log("Threads", "%i going to sleep", cur->TID);
+       //Log_Log("Threads", "%i going to sleep", cur->TID);
        
        // Acquire Spinlock
        LOCK( &giThreadListLock );
        
        // Acquire Spinlock
        LOCK( &giThreadListLock );
@@ -507,9 +507,7 @@ void Threads_Sleep()
        // Release Spinlock
        RELEASE( &giThreadListLock );
        
        // Release Spinlock
        RELEASE( &giThreadListLock );
        
-       while(cur->Status == THREAD_STAT_SLEEPING)      HALT();
-       //HALT();
-       Log_Debug("VM8086", "What a lovely sleep");
+       while(cur->Status != THREAD_STAT_ACTIVE)        HALT();
 }
 
 
 }
 
 
@@ -524,7 +522,7 @@ void Threads_Wake(tThread *Thread)
        {
        case THREAD_STAT_ACTIVE:        break;
        case THREAD_STAT_SLEEPING:
        {
        case THREAD_STAT_ACTIVE:        break;
        case THREAD_STAT_SLEEPING:
-               Log_Log("Threads", "Waking %i (%p) from sleeping", Thread->TID, Thread);
+               //Log_Log("Threads", "Waking %i (%p) from sleeping", Thread->TID, Thread);
                LOCK( &giThreadListLock );
                prev = Threads_int_GetPrev(&gSleepingThreads, Thread);
                prev->Next = Thread->Next;      // Remove from sleeping queue
                LOCK( &giThreadListLock );
                prev = Threads_int_GetPrev(&gSleepingThreads, Thread);
                prev->Next = Thread->Next;      // Remove from sleeping queue
index d1d78a5..1ed46cc 100644 (file)
@@ -1,7 +1,6 @@
 /**\r
  * \file drv_bochsvbe.c\r
 /**\r
  * \file drv_bochsvbe.c\r
- * \brief BGA (Bochs Graphic Adapter) Driver\r
- * \note for Acess2\r
+ * \brief BGA (Bochs Graphic Adapter) Driver for Acess2\r
  * \warning This driver does NOT support the Bochs PCI VGA driver\r
 */\r
 #define DEBUG  0\r
  * \warning This driver does NOT support the Bochs PCI VGA driver\r
 */\r
 #define DEBUG  0\r
index 9b132ec..6fe92f4 100644 (file)
@@ -97,7 +97,7 @@ int IPStack_Install(char **Arguments)
  */
 int IPStack_AddFile(tSocketFile *File)
 {
  */
 int IPStack_AddFile(tSocketFile *File)
 {
-       Log("IPStack_AddFile: %s", File->Name);
+       Log_Log("IPStack", "Added file '%s'", File->Name);
        File->Next = gIP_FileTemplates;
        gIP_FileTemplates = File;
        return 0;
        File->Next = gIP_FileTemplates;
        gIP_FileTemplates = File;
        return 0;
index 9c26767..741ec14 100644 (file)
@@ -339,7 +339,10 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head
        {
                // Ooh, Goodie! Add it to the recieved list
                TCP_INT_AppendRecieved(Connection, pkt);
        {
                // Ooh, Goodie! Add it to the recieved list
                TCP_INT_AppendRecieved(Connection, pkt);
-               Connection->NextSequenceRcv ++;
+               if(dataLen)
+                       Connection->NextSequenceRcv += dataLen;
+               else
+                       Connection->NextSequenceRcv += 1;
                
                // TODO: This should be moved out of the watcher thread,
                // so that a single lost packet on one connection doesn't cause
                
                // TODO: This should be moved out of the watcher thread,
                // so that a single lost packet on one connection doesn't cause
@@ -348,7 +351,7 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head
        }
        
        // TODO: Check ACK code validity
        }
        
        // TODO: Check ACK code validity
-       Header->AcknowlegementNumber = ntohl(pkt->Sequence);
+       Header->AcknowlegementNumber = ntohl(pkt->Sequence) + dataLen;
        Header->SequenceNumber = ntohl(Connection->NextSequenceSend);
        Header->Flags &= TCP_FLAG_SYN;
        Header->Flags = TCP_FLAG_ACK;
        Header->SequenceNumber = ntohl(Connection->NextSequenceSend);
        Header->Flags &= TCP_FLAG_SYN;
        Header->Flags = TCP_FLAG_ACK;
diff --git a/Modules/USB/Makefile.tpl b/Modules/USB/Makefile.tpl
new file mode 100644 (file)
index 0000000..8df7098
--- /dev/null
@@ -0,0 +1,3 @@
+CATEGORY = USB
+
+-include ../../Makefile.tpl

UCC git Repository :: git.ucc.asn.au