The Pedigree Project  0.1
x64/Multiprocessor.cc
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #if defined(MULTIPROCESSOR)
21 
22 #include "../x86_common/Multiprocessor.h"
23 #include "InterruptManager.h"
24 #include "SyscallManager.h"
25 #include "gdt.h"
26 #include "machine/mach_pc/Pc.h"
27 #include "pedigree/kernel/Spinlock.h"
28 #include "pedigree/kernel/process/initialiseMultitasking.h"
29 #include "pedigree/kernel/processor/NMFaultHandler.h"
30 #include "pedigree/kernel/processor/Processor.h"
31 
32 void Multiprocessor::applicationProcessorStartup()
33 {
34  // Enable Write-Protect on the AP early so we don't have any problems with
35  // the rest of the kernel.
36  asm volatile("mov %%cr0, %%rax; or $0x10000, %%rax; mov %%rax, %%cr0" ::
37  : "rax");
38 
39  // Initialise this processor's interrupt handling
41 
42  // Signal the Bootstrap processor that this processor is started and the BSP
43  // can continue to boot up other processors
44  m_ProcessorLock1.release();
45 
46  // Wait until the GDT is initialised and the first 4MB identity mapping
47  // removed
48  m_ProcessorLock2.acquire(false, false);
49  m_ProcessorLock2.release();
50 
51  // Initialise this processor's syscall handling
53 
54  // Load the GDT
56 
57  // Configure floating point.
59 
60  // Invalidate the first 4MB identity mapping
62 
63  // Initialise the machine-specific interface
64  Pc::instance().initialiseProcessor();
65 
66  // We need to synchronize the -init section invalidation
68  Processor::invalidate(reinterpret_cast<void *>(0x200000));
69 
70  // Start up the kernel process and idle thread for this processor.
71  initialiseMultitaskingPerProcessor();
72 
73  // Call the per-processor code in main.cc
74  apMain();
75 }
76 
77 #endif
static NMFaultHandler & instance()
static void initialiseProcessor() INITIALISATION_ONLY
static void initialiseProcessor() INITIALISATION_ONLY
static void initialiseProcessor() INITIALISATION_ONLY
Definition: x64/gdt.cc:85
static void invalidate(void *pAddress)