1a99a0c00SNick Smallbone /*
2a99a0c00SNick Smallbone * Copyright 2008, Dustin Howett, dustin.howett@gmail.com. All rights reserved.
3a99a0c00SNick Smallbone * Copyright 2004-2010, Axel Dörfler, axeld@pinc-software.de.
4a99a0c00SNick Smallbone * Distributed under the terms of the MIT License.
5a99a0c00SNick Smallbone *
6a99a0c00SNick Smallbone * Copyright 2001, Travis Geiselbrecht. All rights reserved.
7a99a0c00SNick Smallbone * Distributed under the terms of the NewOS License.
8a99a0c00SNick Smallbone */
9a99a0c00SNick Smallbone
10a99a0c00SNick Smallbone
11a99a0c00SNick Smallbone #include "smp.h"
12a99a0c00SNick Smallbone
13a99a0c00SNick Smallbone #include <string.h>
14a99a0c00SNick Smallbone
15a99a0c00SNick Smallbone #include <KernelExport.h>
16a99a0c00SNick Smallbone
17a99a0c00SNick Smallbone #include <kernel.h>
18a99a0c00SNick Smallbone #include <safemode.h>
19a99a0c00SNick Smallbone #include <boot/platform.h>
20a99a0c00SNick Smallbone #include <boot/stage2.h>
21a99a0c00SNick Smallbone #include <boot/menu.h>
22a99a0c00SNick Smallbone
237c32619cSAlexander von Gluck IV #include "arch_smp.h"
24a99a0c00SNick Smallbone
25a99a0c00SNick Smallbone
26a99a0c00SNick Smallbone #define NO_SMP 0
27a99a0c00SNick Smallbone
28a99a0c00SNick Smallbone //#define TRACE_SMP
29a99a0c00SNick Smallbone #ifdef TRACE_SMP
30a99a0c00SNick Smallbone # define TRACE(x) dprintf x
31a99a0c00SNick Smallbone #else
32a99a0c00SNick Smallbone # define TRACE(x) ;
33a99a0c00SNick Smallbone #endif
34a99a0c00SNick Smallbone
35a99a0c00SNick Smallbone
36a99a0c00SNick Smallbone int
smp_get_current_cpu(void)37a99a0c00SNick Smallbone smp_get_current_cpu(void)
38a99a0c00SNick Smallbone {
397c32619cSAlexander von Gluck IV return arch_smp_get_current_cpu();
40a99a0c00SNick Smallbone }
41a99a0c00SNick Smallbone
42a99a0c00SNick Smallbone
43a99a0c00SNick Smallbone void
smp_init_other_cpus(void)44a99a0c00SNick Smallbone smp_init_other_cpus(void)
45a99a0c00SNick Smallbone {
467c32619cSAlexander von Gluck IV arch_smp_init_other_cpus();
47a99a0c00SNick Smallbone }
48a99a0c00SNick Smallbone
49a99a0c00SNick Smallbone
50a99a0c00SNick Smallbone void
smp_boot_other_cpus(addr_t pageTable,addr_t kernelEntry,addr_t virtKernelArgs)51*fdb45913SDavid Karoly smp_boot_other_cpus(addr_t pageTable,
52*fdb45913SDavid Karoly addr_t kernelEntry, addr_t virtKernelArgs)
53a99a0c00SNick Smallbone {
54a99a0c00SNick Smallbone if (gKernelArgs.num_cpus < 2)
55a99a0c00SNick Smallbone return;
56a99a0c00SNick Smallbone
57*fdb45913SDavid Karoly arch_smp_boot_other_cpus(pageTable,
58*fdb45913SDavid Karoly kernelEntry, virtKernelArgs);
59a99a0c00SNick Smallbone }
60a99a0c00SNick Smallbone
61a99a0c00SNick Smallbone
62a99a0c00SNick Smallbone void
smp_add_safemode_menus(Menu * menu)63a99a0c00SNick Smallbone smp_add_safemode_menus(Menu *menu)
64a99a0c00SNick Smallbone {
657c32619cSAlexander von Gluck IV arch_smp_add_safemode_menus(menu);
66a99a0c00SNick Smallbone }
67a99a0c00SNick Smallbone
68a99a0c00SNick Smallbone
69a99a0c00SNick Smallbone void
smp_init(void)70a99a0c00SNick Smallbone smp_init(void)
71a99a0c00SNick Smallbone {
72a99a0c00SNick Smallbone #if NO_SMP
73a99a0c00SNick Smallbone gKernelArgs.num_cpus = 1;
74a99a0c00SNick Smallbone return;
75a99a0c00SNick Smallbone #endif
76a99a0c00SNick Smallbone
777c32619cSAlexander von Gluck IV arch_smp_init();
78a99a0c00SNick Smallbone }
79