summaryrefslogtreecommitdiffstats
path: root/sys/powerpc/powerpc/platform_if.m
blob: a562b321a92b40785dbc110f96e25244f3ac5a3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#-
# Copyright (c) 2009 Nathan Whitehorn
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#

#include <sys/param.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/systm.h>
#include <sys/smp.h>

#include <machine/platform.h>
#include <machine/platformvar.h>
#include <machine/smp.h>
#include <machine/vmparam.h>

/**
 * @defgroup PLATFORM platform - KObj methods for PowerPC platform
 * implementations
 * @brief A set of methods required by all platform implementations.
 * These are used to bring up secondary CPUs, supply the physical memory
 * map, etc.
 *@{
 */

INTERFACE platform;

#
# Default implementations
#
CODE {
	static void platform_null_attach(platform_t plat)
	{
		return;
	}
	static int platform_null_smp_first_cpu(platform_t plat,
	    struct cpuref  *cpuref)
	{
		cpuref->cr_hwref = -1;
		cpuref->cr_cpuid = 0;
		return (0);
	}
	static int platform_null_smp_next_cpu(platform_t plat,
	    struct cpuref  *_cpuref)
	{
		return (ENOENT);
	}
	static struct cpu_group *platform_null_smp_topo(platform_t plat)
	{
#ifdef SMP
		return (smp_topo_none());
#else
		return (NULL);
#endif
	}
	static vm_offset_t platform_null_real_maxaddr(platform_t plat)
	{
		return (VM_MAX_ADDRESS);
	}
	static void platform_null_smp_ap_init(platform_t plat)
	{
		return;
	}
	static void platform_null_idle(platform_t plat, int cpu)
	{
		return;
	}
	static int platform_null_idle_wakeup(platform_t plat, int cpu)
	{
		return (0);
	}
};

/**
 * @brief Probe for whether we are on this platform, returning the standard
 * newbus probe codes. If we have Open Firmware or a flattened device tree,
 * it is guaranteed to be available at this point.
 */
METHOD int probe {
	platform_t	_plat;
};


/**
 * @brief Attach this platform module. This happens before the MMU is online,
 * so the platform module can install its own high-priority MMU module at
 * this point.
 */
METHOD int attach {
	platform_t	_plat;
} DEFAULT platform_null_attach;


/**
 * @brief Return the system's physical memory map.
 * 
 * It shall provide the total and the available regions of RAM.
 * The available regions need not take the kernel into account.
 *
 * @param _memp		Array of physical memory chunks
 * @param _memsz	Number of physical memory chunks
 * @param _availp	Array of available physical memory chunks
 * @param _availsz	Number of available physical memory chunks
 */

METHOD void mem_regions {
	platform_t	    _plat;
	struct mem_region  *_memp;
	int		   *_memsz;
	struct mem_region  *_availp;
	int		   *_availsz;
};

/**
 * @brief Return the maximum address accessible in real mode
 *   (for use with hypervisors)
 */
METHOD vm_offset_t real_maxaddr {
	platform_t	_plat;
} DEFAULT platform_null_real_maxaddr;


/**
 * @brief Get the CPU's timebase frequency, in ticks per second.
 *
 * @param _cpu		CPU whose timebase to query
 */

METHOD u_long timebase_freq {
	platform_t	_plat;
	struct cpuref  *_cpu;
};

# SMP bits 

/**
 * @brief Fill the first CPU's cpuref
 *
 * @param _cpuref	CPU
 */
METHOD int smp_first_cpu {
	platform_t	_plat;
	struct cpuref  *_cpuref;
} DEFAULT platform_null_smp_first_cpu;

/**
 * @brief Fill the next CPU's cpuref
 *
 * @param _cpuref	CPU
 */
METHOD int smp_next_cpu {
	platform_t	_plat;
	struct cpuref  *_cpuref;
} DEFAULT platform_null_smp_next_cpu;

/**
 * @brief Find the boot processor
 *
 * @param _cpuref	CPU
 */
METHOD int smp_get_bsp {
	platform_t	_plat;
	struct cpuref  *_cpuref;
} DEFAULT platform_null_smp_first_cpu;

/**
 * @brief Start a CPU
 *
 * @param _cpuref	CPU
 */
METHOD int smp_start_cpu {
	platform_t	_plat;
	struct pcpu	*_cpu;
};

/**
 * @brief Start a CPU
 *
 */
METHOD void smp_ap_init {
	platform_t	_plat;
} DEFAULT platform_null_smp_ap_init;

/**
 * @brief Return SMP topology
 */
METHOD cpu_group_t smp_topo {
	platform_t	_plat;
} DEFAULT platform_null_smp_topo;

/**
 * @brief Reset system
 */
METHOD void reset {
	platform_t	_plat;
};

/**
 * @brief Idle a CPU
 */
METHOD void idle {
	platform_t	_plat;
	int		_cpu;
} DEFAULT platform_null_idle;

/**
 * @brief Wake up an idle CPU
 */
METHOD int idle_wakeup {
	platform_t	_plat;
	int		_cpu;
} DEFAULT platform_null_idle_wakeup;

/**
 * @brief Suspend the CPU
 */
METHOD void sleep {
	platform_t	_plat;
};

OpenPOWER on IntegriCloud