1/*
2 * Copyright 2019-2022, Haiku, Inc. All rights reserved.
3 * Released under the terms of the MIT License.
4*/
5
6
7#include "arch_smp.h"
8
9#include <string.h>
10
11#include <KernelExport.h>
12
13#include <kernel.h>
14#include <safemode.h>
15#include <boot/platform.h>
16#include <boot/stage2.h>
17#include <boot/menu.h>
18
19
20//#define TRACE_SMP
21#ifdef TRACE_SMP
22#	define TRACE(x) dprintf x
23#else
24#	define TRACE(x) ;
25#endif
26
27
28static platform_cpu_info sCpus[SMP_MAX_CPUS];
29uint32 sCpuCount = 0;
30
31
32void
33arch_smp_register_cpu(platform_cpu_info** cpu)
34{
35	dprintf("arch_smp_register_cpu()\n");
36	uint32 newCount = sCpuCount + 1;
37	if (newCount > SMP_MAX_CPUS) {
38		*cpu = NULL;
39		return;
40	}
41	*cpu = &sCpus[sCpuCount];
42	sCpuCount = newCount;
43}
44
45
46int
47arch_smp_get_current_cpu(void)
48{
49	// One cpu for now.
50	return 0;
51}
52
53
54void
55arch_smp_init_other_cpus(void)
56{
57	// One cpu for now.
58	gKernelArgs.num_cpus = 1;
59	return;
60}
61
62
63void
64arch_smp_boot_other_cpus(uint32 pml4, uint64 kernelEntry, addr_t virtKernelArgs)
65{
66	// One cpu for now.
67}
68
69
70void
71arch_smp_add_safemode_menus(Menu *menu)
72{
73	MenuItem *item;
74
75	if (gKernelArgs.num_cpus < 2)
76		return;
77
78	item = new(nothrow) MenuItem("Disable SMP");
79	menu->AddItem(item);
80	item->SetData(B_SAFEMODE_DISABLE_SMP);
81	item->SetType(MENU_ITEM_MARKABLE);
82	item->SetHelpText("Disables all but one CPU core.");
83}
84
85
86void
87arch_smp_init(void)
88{
89	// One cpu for now.
90}
91