SMP Work (APs now start, just seem to lock up on lgdt, or whatever is at that address)
authorJohn Hodge <tpg@prelude.(none)>
Fri, 1 Jan 2010 13:47:57 +0000 (21:47 +0800)
committerJohn Hodge <tpg@prelude.(none)>
Fri, 1 Jan 2010 13:47:57 +0000 (21:47 +0800)
- Also added support for setting the build architecture in the environment
- Included the Doxygen layout file

Kernel/DoxygenLayout.xml [new file with mode: 0644]
Kernel/Makefile.BuildNum
Kernel/arch/x86/desctab.asm
Kernel/arch/x86/include/mp.h
Kernel/arch/x86/mm_virt.c
Kernel/arch/x86/proc.c
Kernel/arch/x86/start.asm
Makefile.cfg

diff --git a/Kernel/DoxygenLayout.xml b/Kernel/DoxygenLayout.xml
new file mode 100644 (file)
index 0000000..3796b58
--- /dev/null
@@ -0,0 +1,186 @@
+<doxygenlayout version="1.0">
+  <!-- Navigation index tabs for HTML output -->
+  <navindex>
+    <tab type="mainpage" visible="yes" title=""/>
+    <tab type="pages" visible="yes" title=""/>
+       <!--
+    <tab type="modules" visible="yes" title=""/>
+    <tab type="namespaces" visible="yes" title="">
+      <tab type="namespaces" visible="yes" title=""/>
+      <tab type="namespacemembers" visible="yes" title=""/>
+    </tab>
+    <tab type="classes" visible="yes" title="">
+      <tab type="classes" visible="yes" title=""/>
+      <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/> 
+      <tab type="hierarchy" visible="yes" title=""/>
+      <tab type="classmembers" visible="yes" title=""/>
+    </tab>
+       -->
+    <tab type="files" visible="yes" title="">
+      <tab type="files" visible="yes" title=""/>
+      <tab type="globals" visible="no" title=""/>
+    </tab>
+    <tab type="dirs" visible="yes" title=""/>
+    <tab type="examples" visible="yes" title=""/>  
+  </navindex>
+
+  <!-- Layout definition for a class page -->
+  <class>
+    <briefdescription visible="yes"/>
+    <includes visible="$SHOW_INCLUDE_FILES"/>
+    <inheritancegraph visible="$CLASS_GRAPH"/>
+    <collaborationgraph visible="$COLLABORATION_GRAPH"/>
+    <allmemberslink visible="yes"/>
+    <memberdecl>
+      <nestedclasses visible="yes" title=""/>
+      <publictypes title=""/>
+      <publicslots title=""/>
+      <signals title=""/>
+      <publicmethods title=""/>
+      <publicstaticmethods title=""/>
+      <publicattributes title=""/>
+      <publicstaticattributes title=""/>
+      <protectedtypes title=""/>
+      <protectedslots title=""/>
+      <protectedmethods title=""/>
+      <protectedstaticmethods title=""/>
+      <protectedattributes title=""/>
+      <protectedstaticattributes title=""/>
+      <packagetypes title=""/>
+      <packagemethods title=""/>
+      <packagestaticmethods title=""/>
+      <packageattributes title=""/>
+      <packagestaticattributes title=""/>
+      <properties title=""/>
+      <events title=""/>
+      <privatetypes title=""/>
+      <privateslots title=""/>
+      <privatemethods title=""/>
+      <privatestaticmethods title=""/>
+      <privateattributes title=""/>
+      <privatestaticattributes title=""/>
+      <friends title=""/>
+      <related title="" subtitle=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <detaileddescription title=""/>
+    <memberdef>
+      <typedefs title=""/>
+      <enums title=""/>
+      <constructors title=""/>
+      <functions title=""/>
+      <related title=""/>
+      <variables title=""/>
+      <properties title=""/>
+      <events title=""/>
+    </memberdef>
+    <usedfiles visible="$SHOW_USED_FILES"/>
+    <authorsection visible="yes"/>
+  </class>
+
+  <!-- Layout definition for a namespace page -->
+  <namespace>
+    <briefdescription visible="yes"/>
+    <memberdecl>
+      <nestednamespaces visible="yes" title=""/>
+      <classes visible="yes" title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <detaileddescription title=""/>
+    <memberdef>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+    </memberdef>
+    <authorsection visible="yes"/>
+  </namespace>
+
+  <!-- Layout definition for a file page -->
+  <file>
+    <briefdescription visible="no"/>
+    <detaileddescription title=""/>
+    <!-- <includes visible="$SHOW_INCLUDE_FILES"/> -->
+    <includegraph visible="$INCLUDE_GRAPH"/>
+    <includedbygraph visible="$INCLUDED_BY_GRAPH"/>
+    <sourcelink visible="yes"/>
+    <memberdecl>
+      <classes visible="yes" title=""/>
+      <namespaces visible="yes" title=""/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <memberdef>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+    </memberdef>
+    <authorsection/>
+  </file>
+
+  <!-- Layout definition for a group page -->
+  <group>
+    <briefdescription visible="yes"/>
+    <groupgraph visible="$GROUP_GRAPHS"/>
+    <memberdecl>
+      <classes visible="yes" title=""/>
+      <namespaces visible="yes" title=""/>
+      <dirs visible="yes" title=""/>
+      <nestedgroups visible="yes" title=""/>
+      <files visible="yes" title=""/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <enumvalues title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <signals title=""/>
+      <publicslots title=""/>
+      <protectedslots title=""/>
+      <privateslots title=""/>
+      <events title=""/>
+      <properties title=""/>
+      <friends title=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <detaileddescription title=""/>
+    <memberdef>
+      <pagedocs/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <enumvalues title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <signals title=""/>
+      <publicslots title=""/>
+      <protectedslots title=""/>
+      <privateslots title=""/>
+      <events title=""/>
+      <properties title=""/>
+      <friends title=""/>
+    </memberdef>
+    <authorsection visible="yes"/>
+  </group>
+
+  <!-- Layout definition for a directory page -->
+  <directory>
+    <briefdescription visible="yes"/>
+    <directorygraph visible="yes"/>
+    <memberdecl>
+      <dirs visible="yes"/>
+      <files visible="yes"/>
+    </memberdecl>
+    <detaileddescription title=""/>
+  </directory>
+</doxygenlayout>
index 96e78f4..40dbf54 100644 (file)
@@ -1 +1 @@
-BUILD_NUM = 39
+BUILD_NUM = 57
index bc37711..b5d060d 100644 (file)
@@ -13,7 +13,6 @@ GDT_SIZE      equ     (1+2*2+1+MAX_CPUS)*8
 [section .data]
 ; GDT
 [global gGDT]
-[global gGDTptr]
 gGDT:
        ; PL0 - Kernel
        ; PL3 - User
@@ -24,22 +23,25 @@ gGDT:
        dd 0x0000FFFF, 0x00CFF200       ; 20 PL3 Data
        dd 26*4-1, 0x00408900   ; Double Fault TSS
        times MAX_CPUS  dd 26*4-1, 0x00408900
-gGDTptr:
+[global gGDTPtr]
+gGDTPtr:
        dw      GDT_SIZE-1
        dd      gGDT
 ; IDT
 ALIGN 8
 gIDT:
        times   256     dd      0x00080000,0x00000F00
+[global gIDTPtr]
 gIDTPtr:
        dw      256 * 16 - 1    ; Limit
        dd      gIDT            ; Base
 
 [section .text]
+
 [global Desctab_Install]
 Desctab_Install:
        ; Set GDT
-       lgdt [gGDTptr]
+       lgdt [gGDTPtr]
        mov ax, 0x10    ; PL0 Data
        mov ss, ax
        mov ds, ax
index 45d2472..30b2780 100644 (file)
@@ -80,13 +80,26 @@ typedef struct sMPTable {
 } tMPTable;
 
 typedef volatile struct {
-       Uint8   Addr;
-       Uint8   Resvd[3];
-       Uint32  Resvd2[3];
+       Uint32  Addr;
+       Uint32  Resvd1[3];
        union {
                Uint8   Byte;
+               Uint16  Word;
                Uint32  DWord;
        }       Value;
+       Uint32  Resvd2[3];
 }      tIOAPIC;
 
+typedef struct {
+       Uint32  Val;
+       Uint32  Padding[3];
+}      tReg;
+
+typedef volatile struct {
+       tReg    _unused;
+       tReg    _unused2;
+       tReg    ID;
+       tReg    Version;
+}      tAPIC;
+
 #endif
index 5afc86f..0ef6771 100644 (file)
@@ -105,10 +105,10 @@ Uint32    gWorkerStacks[(NUM_WORKER_STACKS+31)/32];
 void MM_PreinitVirtual()
 {
        #if USE_PAE
-       gaInitPDPT[ 0 ] = 0;
+       //gaInitPDPT[ 0 ] = 0;
        gaInitPageDir[ ((PAGE_TABLE_ADDR >> TAB)-3*512+3)*2 ] = ((tTabEnt)&gaInitPageDir - KERNEL_BASE) | 3;
        #else
-       gaInitPageDir[ 0 ] = 0;
+       //gaInitPageDir[ 0 ] = 0;       // Needed for SMP startup code
        gaInitPageDir[ PAGE_TABLE_ADDR >> 22 ] = ((tTabEnt)&gaInitPageDir - KERNEL_BASE) | 3;
        #endif
        INVLPG( PAGE_TABLE_ADDR );
index 98ba7e0..9ad06a5 100644 (file)
@@ -53,7 +53,7 @@ void  Proc_Scheduler();
 // --- Multiprocessing ---
 #if USE_MP
 tMPInfo        *gMPFloatPtr = NULL;
-tIOAPIC        *gpMP_LocalAPIC = NULL;
+tAPIC  *gpMP_LocalAPIC = NULL;
 Uint8  gaAPIC_to_CPU[256] = {0};
 tCPU   gaCPUs[MAX_CPUS];
 #else
@@ -176,6 +176,12 @@ void ArchThreads_Init()
                                Log("\t.CPUSignature = 0x%08x", ents->Proc.CPUSignature);
                                Log("\t.FeatureFlags = 0x%08x", ents->Proc.FeatureFlags);
                                
+                               
+                               if( !(ents->Proc.CPUFlags & 1) ) {
+                                       Log("DISABLED");
+                                       break;
+                               }
+                               
                                // Check if there is too many processors
                                if(giNumCPUs >= MAX_CPUS) {
                                        giNumCPUs ++;   // If `giNumCPUs` > MAX_CPUS later, it will be clipped
@@ -189,7 +195,10 @@ void ArchThreads_Init()
                                giNumCPUs ++;
                                
                                // Send IPI
-                               MP_StartAP( giNumCPUs-1 );
+                               if( !(ents->Proc.CPUFlags & 2) )
+                               {
+                                       MP_StartAP( giNumCPUs-1 );
+                               }
                                
                                break;
                        case 1: // Bus
@@ -320,9 +329,17 @@ void MP_StartAP(int CPU)
 
 void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode)
 {
-       Uint32  addr = (Uint)gpMP_LocalAPIC + 0x20 + (APICID<<3);
-       
-       *(Uint32*)addr = ((DeliveryMode & 7) << 8) | (Vector & 0xFF);
+       Uint32  addr = (Uint)gpMP_LocalAPIC + 0x300;
+       Uint32  val;
+       
+       // Hi
+       val = (Uint)APICID << 24;
+       Log("*%p = 0x%08x", addr+0x10, val);
+       *(Uint32*)(addr+0x10) = val;
+       // Low (and send)
+       val = ((DeliveryMode & 7) << 8) | (Vector & 0xFF);
+       Log("*%p = 0x%08x", addr, val);
+       *(Uint32*)addr = val;
 }
 #endif
 
@@ -343,8 +360,7 @@ void Proc_Start()
 tThread *Proc_GetCurThread()
 {
        #if USE_MP
-       gpMP_LocalAPIC->Addr = 0;
-       return gaCPUs[ gaAPIC_to_CPU[gpMP_LocalAPIC->Value.Byte] ].Current;
+       return gaCPUs[ gaAPIC_to_CPU[gpMP_LocalAPIC->ID.Val&0xFF] ].Current;
        #else
        return gCurrentThread;
        #endif
@@ -679,7 +695,7 @@ void Proc_Scheduler(int CPU)
        #if USE_MP
        thread = gaCPUs[CPU].Current;
        #else
-       curThread = gCurrentThread;
+       thread = gCurrentThread;
        #endif
        
        // Reduce remaining quantum and continue timeslice if non-zero
index 4dd7603..ebf69f4 100644 (file)
@@ -39,8 +39,6 @@ start:
        jmp ecx\r
 .higherHalf:\r
 \r
-       mov DWORD [gaInitPageDir], 0\r
-\r
        ; Call the kernel\r
        push ebx        ; Multiboot Info\r
        push eax        ; Multiboot Magic Value\r
@@ -56,22 +54,27 @@ start:
 ; Multiprocessing AP Startup Code (Must be within 0x10FFF0)\r
 ;\r
 %if USE_MP\r
-[extern gGDTptr]\r
+[extern gGDT]\r
+[extern gGDTPtr]\r
+[extern gIDTPtr]\r
 [extern gpMP_LocalAPIC]\r
 [extern gaAPIC_to_CPU]\r
 [extern gaCPUs]\r
-[global APStartup]\r
+lGDTPtr:       ; Local GDT Pointer\r
+       dw      2*8-1\r
+       dd      gGDT-KERNEL_BASE\r
 \r
 [bits 16]\r
+[global APStartup]\r
 APStartup:\r
        xchg bx, bx     ; MAGIC BREAK!\r
        mov ax, 0xFFFF\r
        mov ds, ax\r
-       lgdt [DWORD ds:gGDTptr-0xFFFF0]\r
+       lgdt [DWORD ds:lGDTPtr-KERNEL_BASE-0xFFFF0]\r
        mov eax, cr0\r
        or      al, 1\r
        mov     cr0, eax\r
-       jmp 08h:DWORD .ProtectedMode\r
+       jmp 08h:DWORD .ProtectedMode-KERNEL_BASE\r
 [bits 32]\r
 .ProtectedMode:\r
        ; Start Paging\r
@@ -84,6 +87,10 @@ APStartup:
        lea eax, [.higherHalf]\r
        jmp eax\r
 .higherHalf:\r
+       ; Load True GDT & IDT\r
+       lgdt [gGDTPtr]\r
+       lidt [gIDTPtr]\r
+\r
        mov eax, [gpMP_LocalAPIC]\r
        mov DWORD [eax], 0\r
        xor ecx, ecx\r
@@ -93,6 +100,7 @@ APStartup:
        ; CL is now the CPU ID\r
        mov BYTE [gaCPUs+ecx*8+1], 1\r
        ; CPU is now marked as initialised\r
+       sti\r
 .hlt:\r
        hlt\r
        jmp .hlt\r
index 14ce84b..604f861 100644 (file)
@@ -16,8 +16,12 @@ xMKDIR = mmd
 xRMDIR = mdeltree
 xRM = mdel
 
-ARCH = i486
-ARCHDIR = x86
+ifeq ($(ARCH),)
+       ARCH = i386
+endif
+ifeq ($(ARCHDIR),)
+       ARCHDIR = x86
+endif
 
 FILESYSTEMS = fat
 DRIVERS = ata_x86

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