2 # Copyright (c) 2009 Nathan Whitehorn
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/param.h>
31 #include <sys/mutex.h>
32 #include <sys/systm.h>
35 #include <machine/platform.h>
36 #include <machine/platformvar.h>
37 #include <machine/smp.h>
38 #include <machine/vmparam.h>
41 * @defgroup PLATFORM platform - KObj methods for PowerPC platform
43 * @brief A set of methods required by all platform implementations.
44 * These are used to bring up secondary CPUs, supply the physical memory
52 # Default implementations
55 static void platform_null_attach(platform_t plat)
59 static int platform_null_smp_first_cpu(platform_t plat,
60 struct cpuref *cpuref)
62 cpuref->cr_hwref = -1;
66 static int platform_null_smp_next_cpu(platform_t plat,
67 struct cpuref *_cpuref)
71 static struct cpu_group *platform_null_smp_topo(platform_t plat)
74 return (smp_topo_none());
79 static vm_offset_t platform_null_real_maxaddr(platform_t plat)
81 return (VM_MAX_ADDRESS);
83 static void platform_null_smp_ap_init(platform_t plat)
87 static void platform_null_smp_probe_threads(void)
94 * @brief Probe for whether we are on this platform, returning the standard
95 * newbus probe codes. If we have Open Firmware or a flattened device tree,
96 * it is guaranteed to be available at this point.
104 * @brief Attach this platform module. This happens before the MMU is online,
105 * so the platform module can install its own high-priority MMU module at
110 } DEFAULT platform_null_attach;
114 * @brief Return the system's physical memory map.
116 * It shall provide the total and the available regions of RAM.
117 * The available regions need not take the kernel into account.
119 * @param _memp Array of physical memory chunks
120 * @param _memsz Number of physical memory chunks
121 * @param _availp Array of available physical memory chunks
122 * @param _availsz Number of available physical memory chunks
125 METHOD void mem_regions {
127 struct mem_region *_memp;
129 struct mem_region *_availp;
134 * @brief Return the maximum address accessible in real mode
135 * (for use with hypervisors)
137 METHOD vm_offset_t real_maxaddr {
139 } DEFAULT platform_null_real_maxaddr;
143 * @brief Get the CPU's timebase frequency, in ticks per second.
145 * @param _cpu CPU whose timebase to query
148 METHOD u_long timebase_freq {
156 * @brief Fill the first CPU's cpuref
160 METHOD int smp_first_cpu {
162 struct cpuref *_cpuref;
163 } DEFAULT platform_null_smp_first_cpu;
166 * @brief Fill the next CPU's cpuref
170 METHOD int smp_next_cpu {
172 struct cpuref *_cpuref;
173 } DEFAULT platform_null_smp_next_cpu;
176 * @brief Find the boot processor
180 METHOD int smp_get_bsp {
182 struct cpuref *_cpuref;
183 } DEFAULT platform_null_smp_first_cpu;
190 METHOD int smp_start_cpu {
199 METHOD void smp_ap_init {
201 } DEFAULT platform_null_smp_ap_init;
204 * @brief Probe mp_ncores and smp_threads_per_core for early MI code
206 METHOD void smp_probe_threads {
208 } DEFAULT platform_null_smp_probe_threads;
211 * @brief Return SMP topology
213 METHOD cpu_group_t smp_topo {
215 } DEFAULT platform_null_smp_topo;
218 * @brief Reset system
225 * @brief Suspend the CPU
232 * @brief Attempt to synchronize timebase of current CPU with others.
233 * Entered (approximately) simultaneously on all CPUs, including the BSP.
234 * Passed the timebase value on the BSP as of shortly before the call.
236 METHOD void smp_timebase_sync {