]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/powerpc/powerpc/platform_if.m
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.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
34 #include <machine/platform.h>
35 #include <machine/platformvar.h>
36 #include <machine/smp.h>
37
38 /**
39  * @defgroup PLATFORM platform - KObj methods for PowerPC platform
40  * implementations
41  * @brief A set of methods required by all platform implementations.
42  * These are used to bring up secondary CPUs, supply the physical memory
43  * map, etc.
44  *@{
45  */
46
47 INTERFACE platform;
48
49 #
50 # Default implementations
51 #
52 CODE {
53         static void platform_null_attach(platform_t plat)
54         {
55                 return;
56         }
57         static int platform_null_smp_first_cpu(platform_t plat,
58             struct cpuref  *cpuref)
59         {
60                 cpuref->cr_hwref = -1;
61                 cpuref->cr_cpuid = 0;
62                 return (0);
63         }
64         static int platform_null_smp_next_cpu(platform_t plat,
65             struct cpuref  *_cpuref)
66         {
67                 return (ENOENT);
68         }
69 };
70
71 /**
72  * @brief Probe for whether we are on this platform, returning the standard
73  * newbus probe codes. If we have Open Firmware or a flattened device tree,
74  * it is guaranteed to be available at this point.
75  */
76 METHOD int probe {
77         platform_t      _plat;
78 };
79
80
81 /**
82  * @brief Attach this platform module. This happens before the MMU is online,
83  * so the platform module can install its own high-priority MMU module at
84  * this point.
85  */
86 METHOD int attach {
87         platform_t      _plat;
88 } DEFAULT platform_null_attach;
89
90
91 /**
92  * @brief Return the system's physical memory map.
93  * 
94  * It shall provide the total and the available regions of RAM.
95  * The available regions need not take the kernel into account.
96  *
97  * @param _memp         Array of physical memory chunks
98  * @param _memsz        Number of physical memory chunks
99  * @param _availp       Array of available physical memory chunks
100  * @param _availsz      Number of available physical memory chunks
101  */
102
103 METHOD void mem_regions {
104         platform_t          _plat;
105         struct mem_region **_memp;
106         int                *_memsz;
107         struct mem_region **_availp;
108         int                *_availsz;
109 };
110
111 /**
112  * @brief Get the CPU's timebase frequency, in ticks per second.
113  *
114  * @param _cpu          CPU whose timebase to query
115  */
116
117 METHOD u_long timebase_freq {
118         platform_t      _plat;
119         struct cpuref  *_cpu;
120 };
121
122 # SMP bits 
123
124 /**
125  * @brief Fill the first CPU's cpuref
126  *
127  * @param _cpuref       CPU
128  */
129 METHOD int smp_first_cpu {
130         platform_t      _plat;
131         struct cpuref  *_cpuref;
132 } DEFAULT platform_null_smp_first_cpu;
133
134 /**
135  * @brief Fill the next CPU's cpuref
136  *
137  * @param _cpuref       CPU
138  */
139 METHOD int smp_next_cpu {
140         platform_t      _plat;
141         struct cpuref  *_cpuref;
142 } DEFAULT platform_null_smp_next_cpu;
143
144 /**
145  * @brief Find the boot processor
146  *
147  * @param _cpuref       CPU
148  */
149 METHOD int smp_get_bsp {
150         platform_t      _plat;
151         struct cpuref  *_cpuref;
152 } DEFAULT platform_null_smp_first_cpu;
153
154 /**
155  * @brief Start a CPU
156  *
157  * @param _cpuref       CPU
158  */
159 METHOD int smp_start_cpu {
160         platform_t      _plat;
161         struct pcpu     *_cpu;
162 };
163