1266301Sandrew#-
2266301Sandrew# Copyright (c) 2009 Nathan Whitehorn
3266301Sandrew# All rights reserved.
4266301Sandrew#
5266301Sandrew# Redistribution and use in source and binary forms, with or without
6266301Sandrew# modification, are permitted provided that the following conditions
7266301Sandrew# are met:
8266301Sandrew# 1. Redistributions of source code must retain the above copyright
9266301Sandrew#    notice, this list of conditions and the following disclaimer.
10266301Sandrew# 2. Redistributions in binary form must reproduce the above copyright
11266301Sandrew#    notice, this list of conditions and the following disclaimer in the
12266301Sandrew#    documentation and/or other materials provided with the distribution.
13266301Sandrew#
14266301Sandrew# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15266301Sandrew# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16266301Sandrew# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17266301Sandrew# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18266301Sandrew# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19266301Sandrew# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20266301Sandrew# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21266301Sandrew# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22266301Sandrew# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23266301Sandrew# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24266301Sandrew# SUCH DAMAGE.
25266301Sandrew#
26266301Sandrew# $FreeBSD: stable/11/sys/arm/arm/platform_if.m 331893 2018-04-02 23:19:07Z gonzo $
27266301Sandrew#
28266301Sandrew
29266301Sandrew#include <sys/param.h>
30266301Sandrew#include <sys/lock.h>
31266301Sandrew#include <sys/mutex.h>
32266301Sandrew#include <sys/systm.h>
33266301Sandrew#include <sys/smp.h>
34266301Sandrew
35266301Sandrew#include <machine/machdep.h>
36266301Sandrew#include <machine/platform.h>
37266301Sandrew#include <machine/platformvar.h>
38266301Sandrew#include <machine/smp.h>
39266301Sandrew#include <machine/vmparam.h>
40266301Sandrew
41266301Sandrew/**
42266301Sandrew * @defgroup PLATFORM platform - KObj methods for ARM platform
43266301Sandrew * implementations
44266301Sandrew * @brief A set of methods required by all platform implementations.
45266301Sandrew * These are used to bring up secondary CPUs, supply the physical memory
46266301Sandrew * map, etc.
47266301Sandrew *@{
48266301Sandrew */
49266301Sandrew
50266301SandrewINTERFACE platform;
51266301Sandrew
52266301Sandrew#
53266301Sandrew# Default implementations
54266301Sandrew#
55266301SandrewCODE {
56266301Sandrew	static void platform_null_attach(platform_t plat)
57266301Sandrew	{
58266301Sandrew		return;
59266301Sandrew	}
60296158Sandrew
61296158Sandrew	static void platform_default_mp_setmaxid(platform_t plat)
62296158Sandrew	{
63296158Sandrew		mp_ncpus = 1;
64296158Sandrew		mp_maxid = 0;
65296158Sandrew	}
66266301Sandrew};
67266301Sandrew
68266301Sandrew/**
69266301Sandrew * @brief Probe for whether we are on this platform, returning the standard
70266301Sandrew * newbus probe codes. If we have Open Firmware or a flattened device tree,
71266301Sandrew * it is guaranteed to be available at this point.
72266301Sandrew */
73266301SandrewMETHOD int probe {
74266301Sandrew	platform_t	_plat;
75266301Sandrew};
76266301Sandrew
77266301Sandrew/**
78266301Sandrew * @brief Attach this platform module. This happens before the MMU is online,
79266301Sandrew * so the platform module can install its own high-priority MMU module at
80266301Sandrew * this point.
81266301Sandrew */
82266301SandrewMETHOD int attach {
83266301Sandrew	platform_t	_plat;
84266301Sandrew} DEFAULT platform_null_attach;
85266301Sandrew
86266301Sandrew/**
87266301Sandrew * @brief Called as one of the last steps of early virtual memory
88266301Sandrew * initialization, shortly before the new page tables are installed.
89266301Sandrew */
90266301SandrewMETHOD int devmap_init {
91266301Sandrew	platform_t	_plat;
92266301Sandrew};
93266301Sandrew
94266301Sandrew/**
95266301Sandrew * @brief Called after devmap_init(), and must return the address of the
96266301Sandrew * first byte of unusable KVA space.  This allows a platform to carve out
97266301Sandrew * of the top of the KVA space whatever reserves it needs for things like
98266301Sandrew * static device mapping, and this is called to get the value before
99266301Sandrew * calling pmap_bootstrap() which uses the value to size the available KVA.
100266301Sandrew */
101266301SandrewMETHOD vm_offset_t lastaddr {
102266301Sandrew	platform_t	_plat;
103266301Sandrew};
104266301Sandrew
105266301Sandrew/**
106266301Sandrew * @brief Called after the static device mappings are established and just
107266301Sandrew * before cninit(). The intention is that the routine can do any hardware
108266301Sandrew * setup (such as gpio or pinmux) necessary to make the console functional.
109266301Sandrew */
110266301SandrewMETHOD void gpio_init {
111266301Sandrew	platform_t	_plat;
112266301Sandrew};
113266301Sandrew
114266301Sandrew/**
115266301Sandrew * @brief Called just after cninit(). This is the first of the init
116266301Sandrew * routines that can use printf() and expect the output to appear on
117266301Sandrew * a standard console.
118266301Sandrew */
119266301SandrewMETHOD void late_init {
120266301Sandrew	platform_t	_plat;
121266301Sandrew};
122266301Sandrew
123296158Sandrew/**
124296158Sandrew * @brief Called by cpu_mp_setmaxid() to set mp_maxid and mp_ncpus.
125296158Sandrew */
126296158SandrewMETHOD void mp_setmaxid {
127296158Sandrew	platform_t	_plat;
128296158Sandrew} DEFAULT platform_default_mp_setmaxid;
129296158Sandrew
130296158Sandrew/**
131296158Sandrew * @brief Called by cpu_mp_start to start the secondary processors.
132296158Sandrew */
133296158SandrewMETHOD void mp_start_ap {
134296158Sandrew	platform_t	_plat;
135296158Sandrew};
136331893Sgonzo
137331893Sgonzo/**
138331893Sgonzo * @brief Called by cpu_reset to reboot.
139331893Sgonzo */
140331893SgonzoMETHOD void cpu_reset {
141331893Sgonzo	platform_t	_plat;
142331893Sgonzo};
143