xref: /f-stack/freebsd/mips/include/hwfunc.h (revision 22ce4aff)
1a9643ea8Slogwang /*-
2*22ce4affSfengbojiang  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*22ce4affSfengbojiang  *
4a9643ea8Slogwang  * Copyright (c) 2003-2004 Juli Mallett.  All rights reserved.
5a9643ea8Slogwang  *
6a9643ea8Slogwang  * Redistribution and use in source and binary forms, with or without
7a9643ea8Slogwang  * modification, are permitted provided that the following conditions
8a9643ea8Slogwang  * are met:
9a9643ea8Slogwang  * 1. Redistributions of source code must retain the above copyright
10a9643ea8Slogwang  *    notice, this list of conditions and the following disclaimer.
11a9643ea8Slogwang  * 2. Redistributions in binary form must reproduce the above copyright
12a9643ea8Slogwang  *    notice, this list of conditions and the following disclaimer in the
13a9643ea8Slogwang  *    documentation and/or other materials provided with the distribution.
14a9643ea8Slogwang  *
15a9643ea8Slogwang  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16a9643ea8Slogwang  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17a9643ea8Slogwang  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18a9643ea8Slogwang  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19a9643ea8Slogwang  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20a9643ea8Slogwang  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21a9643ea8Slogwang  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22a9643ea8Slogwang  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23a9643ea8Slogwang  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24a9643ea8Slogwang  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25a9643ea8Slogwang  * SUCH DAMAGE.
26a9643ea8Slogwang  *
27a9643ea8Slogwang  * $FreeBSD$
28a9643ea8Slogwang  */
29a9643ea8Slogwang 
30a9643ea8Slogwang #ifndef _MACHINE_HWFUNC_H_
31a9643ea8Slogwang #define	_MACHINE_HWFUNC_H_
32a9643ea8Slogwang 
33a9643ea8Slogwang #include <sys/_cpuset.h>
34a9643ea8Slogwang 
35a9643ea8Slogwang struct timecounter;
36a9643ea8Slogwang 
37a9643ea8Slogwang /*
38a9643ea8Slogwang  * Hooks downward into platform functionality.
39a9643ea8Slogwang  */
40a9643ea8Slogwang void platform_reset(void);
41a9643ea8Slogwang void platform_start(__register_t, __register_t,  __register_t, __register_t);
42a9643ea8Slogwang 
43a9643ea8Slogwang /* For clocks and ticks and such */
44a9643ea8Slogwang void platform_initclocks(void);
45a9643ea8Slogwang uint64_t platform_get_frequency(void);
46a9643ea8Slogwang unsigned platform_get_timecount(struct timecounter *);
47a9643ea8Slogwang 
48a9643ea8Slogwang /* For hardware specific CPU initialization */
49a9643ea8Slogwang void platform_cpu_init(void);
50a9643ea8Slogwang 
51a9643ea8Slogwang #ifdef SMP
52a9643ea8Slogwang 
53a9643ea8Slogwang /*
54a9643ea8Slogwang  * Spin up the AP so that it starts executing MP bootstrap entry point: mpentry
55a9643ea8Slogwang  *
56a9643ea8Slogwang  * Returns 0 on sucess and non-zero on failure.
57a9643ea8Slogwang  */
58a9643ea8Slogwang int platform_start_ap(int processor_id);
59a9643ea8Slogwang 
60a9643ea8Slogwang /*
61a9643ea8Slogwang  * Platform-specific initialization that needs to be done when an AP starts
62a9643ea8Slogwang  * running. This function is called from the MP bootstrap code in mpboot.S
63a9643ea8Slogwang  */
64a9643ea8Slogwang void platform_init_ap(int processor_id);
65a9643ea8Slogwang 
66a9643ea8Slogwang /*
67a9643ea8Slogwang  * Return a plaform-specific interrrupt number that is used to deliver IPIs.
68a9643ea8Slogwang  *
69a9643ea8Slogwang  * This hardware interrupt is used to deliver IPIs exclusively and must
70a9643ea8Slogwang  * not be used for any other interrupt source.
71a9643ea8Slogwang  */
72*22ce4affSfengbojiang int platform_ipi_hardintr_num(void);
73*22ce4affSfengbojiang int platform_ipi_softintr_num(void);
74*22ce4affSfengbojiang 
75*22ce4affSfengbojiang #ifdef PLATFORM_INIT_SECONDARY
76*22ce4affSfengbojiang /*
77*22ce4affSfengbojiang  * Set up IPIs for this CPU.
78*22ce4affSfengbojiang  */
79*22ce4affSfengbojiang void platform_init_secondary(int cpuid);
80*22ce4affSfengbojiang #endif
81a9643ea8Slogwang 
82a9643ea8Slogwang /*
83a9643ea8Slogwang  * Trigger a IPI interrupt on 'cpuid'.
84a9643ea8Slogwang  */
85a9643ea8Slogwang void platform_ipi_send(int cpuid);
86a9643ea8Slogwang 
87a9643ea8Slogwang /*
88a9643ea8Slogwang  * Quiesce the IPI interrupt source on the current cpu.
89a9643ea8Slogwang  */
90a9643ea8Slogwang void platform_ipi_clear(void);
91a9643ea8Slogwang 
92a9643ea8Slogwang /*
93a9643ea8Slogwang  * Return the processor id.
94a9643ea8Slogwang  *
95a9643ea8Slogwang  * Note that this function is called in early boot when stack is not available.
96a9643ea8Slogwang  */
97a9643ea8Slogwang extern int platform_processor_id(void);
98a9643ea8Slogwang 
99a9643ea8Slogwang /*
100a9643ea8Slogwang  * Return the cpumask of available processors.
101a9643ea8Slogwang  */
102a9643ea8Slogwang extern void platform_cpu_mask(cpuset_t *mask);
103a9643ea8Slogwang 
104a9643ea8Slogwang /*
105a9643ea8Slogwang  * Return the topology of processors on this platform
106a9643ea8Slogwang  */
107a9643ea8Slogwang struct cpu_group *platform_smp_topo(void);
108a9643ea8Slogwang 
109a9643ea8Slogwang #endif	/* SMP */
110a9643ea8Slogwang 
111a9643ea8Slogwang #endif /* !_MACHINE_HWFUNC_H_ */
112