BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / 6217f0db2c8f2513994f4cc773aaa4171a049963 / kernel / acpi

// Related

Nucleus

Barry Kernel threads + threads share address space 6217f0d (3 years, 1 month ago)
diff --git a/kernel/acpi/apic.c b/kernel/acpi/apic.c
index 6051636..7f9935c 100644
--- a/kernel/acpi/apic.c
+++ b/kernel/acpi/apic.c
@@ -58,6 +58,7 @@ int apic = 0;
 size_t ncpus = 1;
 uintptr_t lapicPtr, ioapicPtr;
 cpu_t lapicIds[MAX_CPUS], lapicNums[MAX_CPUS];
+extern uintptr_t stacks[];
 
 /* Enable APIC */
 static void
@@ -176,10 +177,11 @@ init_apic(struct SDTHeader *header)
 	uint32_t i, j;
 	uintptr_t apTrampoline = 0x1000, stack;
 	memcpy((void *) apTrampoline, &ap_trampoline, PAGE_SIZE);
+	*((uint32_t *) (apTrampoline + 0xFFC)) = (uintptr_t) stacks;
 	for (i = 1; i < ncpus; i++) {
 		/* Give each processor a separate stack */
-		stack = alloc_frame() + PAGE_SIZE - sizeof(uintptr_t);
-		*((uint32_t *) (apTrampoline + 0xF00 + i)) = stack;
+		stacks[i] = alloc_frame() + PAGE_SIZE;
+//		*((uint32_t *) (apTrampoline + 0xC00) + i) = stacks[i];
 		/* Send INIT IPI */
 		LAPIC(0x280) = 0;
 		LAPIC(0x310) = (LAPIC(0x310) & 0x00FFFFFF)
@@ -239,5 +241,5 @@ send_ipi(cpu_t target, uint8_t num)
 	             | (lapicIds[target] << 24);
 	LAPIC(0x300) = (LAPIC(0x300) & 0xFFF32000)
 	             | (0x5000 + num + 48);
-	while ((LAPIC(0x300) >> 12) & 1);
+	do asm("pause":::"memory"); while (LAPIC(0x300) & (1 << 12));
 }
diff --git a/kernel/acpi/trampoline.S b/kernel/acpi/trampoline.S
index 3230e85..c807524 100644
--- a/kernel/acpi/trampoline.S
+++ b/kernel/acpi/trampoline.S
@@ -48,9 +48,8 @@ ap_pm:
 	incl %eax
 	movl %eax, apId
 
-	movl $0x1F00, %esi
-	movl (%esi,%eax), %ebx
-	movl %ebx, %esp
+	movl 0x1FFC, %esi
+	movl (%esi,%eax,4), %esp
 	movl %esp, %ebp
 
 	sti