]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/powerpc/powerpc/platform_if.m
Merge ACPICA 20180105.
[FreeBSD/FreeBSD.git] / sys / powerpc / powerpc / platform_if.m
1 #-
2 # Copyright (c) 2009 Nathan Whitehorn
3 # All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
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.
13 #
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
24 # SUCH DAMAGE.
25 #
26 # $FreeBSD$
27 #
28
29 #include <sys/param.h>
30 #include <sys/lock.h>
31 #include <sys/mutex.h>
32 #include <sys/systm.h>
33 #include <sys/smp.h>
34
35 #include <machine/platform.h>
36 #include <machine/platformvar.h>
37 #include <machine/smp.h>
38 #include <machine/vmparam.h>
39
40 /**
41  * @defgroup PLATFORM platform - KObj methods for PowerPC platform
42  * implementations
43  * @brief A set of methods required by all platform implementations.
44  * These are used to bring up secondary CPUs, supply the physical memory
45  * map, etc.
46  *@{
47  */
48
49 INTERFACE platform;
50
51 #
52 # Default implementations
53 #
54 CODE {
55         static void platform_null_attach(platform_t plat)
56         {
57                 return;
58         }
59         static int platform_null_smp_first_cpu(platform_t plat,
60             struct cpuref  *cpuref)
61         {
62                 cpuref->cr_hwref = -1;
63                 cpuref->cr_cpuid = 0;
64                 return (0);
65         }
66         static int platform_null_smp_next_cpu(platform_t plat,
67             struct cpuref  *_cpuref)
68         {
69                 return (ENOENT);
70         }
71         static struct cpu_group *platform_null_smp_topo(platform_t plat)
72         {
73 #ifdef SMP
74                 return (smp_topo_none());
75 #else
76                 return (NULL);
77 #endif
78         }
79         static vm_offset_t platform_null_real_maxaddr(platform_t plat)
80         {
81                 return (VM_MAX_ADDRESS);
82         }
83         static void platform_null_smp_ap_init(platform_t plat)
84         {
85                 return;
86         }
87         static void platform_null_idle(platform_t plat, int cpu)
88         {
89                 return;
90         }
91         static int platform_null_idle_wakeup(platform_t plat, int cpu)
92         {
93                 return (0);
94         }
95 };
96
97 /**
98  * @brief Probe for whether we are on this platform, returning the standard
99  * newbus probe codes. If we have Open Firmware or a flattened device tree,
100  * it is guaranteed to be available at this point.
101  */
102 METHOD int probe {
103         platform_t      _plat;
104 };
105
106
107 /**
108  * @brief Attach this platform module. This happens before the MMU is online,
109  * so the platform module can install its own high-priority MMU module at
110  * this point.
111  */
112 METHOD int attach {
113         platform_t      _plat;
114 } DEFAULT platform_null_attach;
115
116
117 /**
118  * @brief Return the system's physical memory map.
119  * 
120  * It shall provide the total and the available regions of RAM.
121  * The available regions need not take the kernel into account.
122  *
123  * @param _memp         Array of physical memory chunks
124  * @param _memsz        Number of physical memory chunks
125  * @param _availp       Array of available physical memory chunks
126  * @param _availsz      Number of available physical memory chunks
127  */
128
129 METHOD void mem_regions {
130         platform_t          _plat;
131         struct mem_region  *_memp;
132         int                *_memsz;
133         struct mem_region  *_availp;
134         int                *_availsz;
135 };
136
137 /**
138  * @brief Return the maximum address accessible in real mode
139  *   (for use with hypervisors)
140  */
141 METHOD vm_offset_t real_maxaddr {
142         platform_t      _plat;
143 } DEFAULT platform_null_real_maxaddr;
144
145
146 /**
147  * @brief Get the CPU's timebase frequency, in ticks per second.
148  *
149  * @param _cpu          CPU whose timebase to query
150  */
151
152 METHOD u_long timebase_freq {
153         platform_t      _plat;
154         struct cpuref  *_cpu;
155 };
156
157 # SMP bits 
158
159 /**
160  * @brief Fill the first CPU's cpuref
161  *
162  * @param _cpuref       CPU
163  */
164 METHOD int smp_first_cpu {
165         platform_t      _plat;
166         struct cpuref  *_cpuref;
167 } DEFAULT platform_null_smp_first_cpu;
168
169 /**
170  * @brief Fill the next CPU's cpuref
171  *
172  * @param _cpuref       CPU
173  */
174 METHOD int smp_next_cpu {
175         platform_t      _plat;
176         struct cpuref  *_cpuref;
177 } DEFAULT platform_null_smp_next_cpu;
178
179 /**
180  * @brief Find the boot processor
181  *
182  * @param _cpuref       CPU
183  */
184 METHOD int smp_get_bsp {
185         platform_t      _plat;
186         struct cpuref  *_cpuref;
187 } DEFAULT platform_null_smp_first_cpu;
188
189 /**
190  * @brief Start a CPU
191  *
192  * @param _cpuref       CPU
193  */
194 METHOD int smp_start_cpu {
195         platform_t      _plat;
196         struct pcpu     *_cpu;
197 };
198
199 /**
200  * @brief Start a CPU
201  *
202  */
203 METHOD void smp_ap_init {
204         platform_t      _plat;
205 } DEFAULT platform_null_smp_ap_init;
206
207 /**
208  * @brief Return SMP topology
209  */
210 METHOD cpu_group_t smp_topo {
211         platform_t      _plat;
212 } DEFAULT platform_null_smp_topo;
213
214 /**
215  * @brief Reset system
216  */
217 METHOD void reset {
218         platform_t      _plat;
219 };
220
221 /**
222  * @brief Idle a CPU
223  */
224 METHOD void idle {
225         platform_t      _plat;
226         int             _cpu;
227 } DEFAULT platform_null_idle;
228
229 /**
230  * @brief Wake up an idle CPU
231  */
232 METHOD int idle_wakeup {
233         platform_t      _plat;
234         int             _cpu;
235 } DEFAULT platform_null_idle_wakeup;
236
237 /**
238  * @brief Suspend the CPU
239  */
240 METHOD void sleep {
241         platform_t      _plat;
242 };
243
244 /**
245  * @brief Attempt to synchronize timebase of current CPU with others.
246  * Entered (approximately) simultaneously on all CPUs, including the BSP.
247  * Passed the timebase value on the BSP as of shortly before the call.
248  */
249 METHOD void smp_timebase_sync {
250         platform_t      _plat;
251         u_long          _tb;
252         int             _ap;
253 };
254