xref: /freebsd/sys/arm/arm/platform_if.m (revision 0957b409)
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/systm.h>
31#include <sys/devmap.h>
32#include <sys/lock.h>
33#include <sys/mutex.h>
34#include <sys/smp.h>
35
36#include <machine/machdep.h>
37#include <machine/platform.h>
38#include <machine/platformvar.h>
39#include <machine/smp.h>
40#include <machine/vmparam.h>
41
42/**
43 * @defgroup PLATFORM platform - KObj methods for ARM platform
44 * implementations
45 * @brief A set of methods required by all platform implementations.
46 * These are used to bring up secondary CPUs, supply the physical memory
47 * map, etc.
48 *@{
49 */
50
51INTERFACE platform;
52
53#
54# Default implementations
55#
56CODE {
57	static void platform_null_attach(platform_t plat)
58	{
59		return;
60	}
61
62	static vm_offset_t platform_default_lastaddr(platform_t plat)
63	{
64		return (devmap_lastaddr());
65	}
66
67	static void platform_default_mp_setmaxid(platform_t plat)
68	{
69		mp_ncpus = 1;
70		mp_maxid = 0;
71	}
72};
73
74/**
75 * @brief Probe for whether we are on this platform, returning the standard
76 * newbus probe codes. If we have Open Firmware or a flattened device tree,
77 * it is guaranteed to be available at this point.
78 */
79METHOD int probe {
80	platform_t	_plat;
81};
82
83/**
84 * @brief Attach this platform module. This happens before the MMU is online,
85 * so the platform module can install its own high-priority MMU module at
86 * this point.
87 */
88METHOD int attach {
89	platform_t	_plat;
90} DEFAULT platform_null_attach;
91
92/**
93 * @brief Called as one of the last steps of early virtual memory
94 * initialization, shortly before the new page tables are installed.
95 */
96METHOD int devmap_init {
97	platform_t	_plat;
98};
99
100/**
101 * @brief Called after devmap_init(), and must return the address of the
102 * first byte of unusable KVA space.  This allows a platform to carve out
103 * of the top of the KVA space whatever reserves it needs for things like
104 * static device mapping, and this is called to get the value before
105 * calling pmap_bootstrap() which uses the value to size the available KVA.
106 */
107METHOD vm_offset_t lastaddr {
108	platform_t	_plat;
109} DEFAULT platform_default_lastaddr;
110
111/**
112 * @brief Called after the static device mappings are established and just
113 * before cninit(). The intention is that the routine can do any hardware
114 * setup (such as gpio or pinmux) necessary to make the console functional.
115 */
116METHOD void gpio_init {
117	platform_t	_plat;
118};
119
120/**
121 * @brief Called just after cninit(). This is the first of the init
122 * routines that can use printf() and expect the output to appear on
123 * a standard console.
124 */
125METHOD void late_init {
126	platform_t	_plat;
127};
128
129/**
130 * @brief Called by cpu_mp_setmaxid() to set mp_maxid and mp_ncpus.
131 */
132METHOD void mp_setmaxid {
133	platform_t	_plat;
134} DEFAULT platform_default_mp_setmaxid;
135
136/**
137 * @brief Called by cpu_mp_start to start the secondary processors.
138 */
139METHOD void mp_start_ap {
140	platform_t	_plat;
141};
142
143/**
144 * @brief Called by cpu_reset to reboot.
145 */
146METHOD void cpu_reset {
147	platform_t	_plat;
148};
149