xref: /freebsd/sys/dev/cfe/cfe_api.h (revision 95ee2897)
13cbea0b1SLandon J. Fuller /* from: Broadcom Id: cfe_api.h,v 1.31 2006/08/24 02:13:56 binh Exp $ */
2ae36cccdSWarner Losh 
3ae36cccdSWarner Losh /*-
4718cf2ccSPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
5718cf2ccSPedro F. Giffuni  *
6ae36cccdSWarner Losh  * Copyright 2000, 2001, 2002
7ae36cccdSWarner Losh  * Broadcom Corporation. All rights reserved.
8ae36cccdSWarner Losh  *
9ae36cccdSWarner Losh  * This software is furnished under license and may be used and copied only
10ae36cccdSWarner Losh  * in accordance with the following terms and conditions.  Subject to these
11ae36cccdSWarner Losh  * conditions, you may download, copy, install, use, modify and distribute
12ae36cccdSWarner Losh  * modified or unmodified copies of this software in source and/or binary
13ae36cccdSWarner Losh  * form. No title or ownership is transferred hereby.
14ae36cccdSWarner Losh  *
15ae36cccdSWarner Losh  * 1) Any source code used, modified or distributed must reproduce and
16ae36cccdSWarner Losh  *    retain this copyright notice and list of conditions as they appear in
17ae36cccdSWarner Losh  *    the source file.
18ae36cccdSWarner Losh  *
19ae36cccdSWarner Losh  * 2) No right is granted to use any trade name, trademark, or logo of
20ae36cccdSWarner Losh  *    Broadcom Corporation.  The "Broadcom Corporation" name may not be
21ae36cccdSWarner Losh  *    used to endorse or promote products derived from this software
22ae36cccdSWarner Losh  *    without the prior written permission of Broadcom Corporation.
23ae36cccdSWarner Losh  *
24ae36cccdSWarner Losh  * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
25ae36cccdSWarner Losh  *    WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
26ae36cccdSWarner Losh  *    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
27ae36cccdSWarner Losh  *    NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
28ae36cccdSWarner Losh  *    FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
29ae36cccdSWarner Losh  *    LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30ae36cccdSWarner Losh  *    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31ae36cccdSWarner Losh  *    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32ae36cccdSWarner Losh  *    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33ae36cccdSWarner Losh  *    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
34ae36cccdSWarner Losh  *    OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35ae36cccdSWarner Losh  */
36ae36cccdSWarner Losh 
37ae36cccdSWarner Losh /*  *********************************************************************
38ae36cccdSWarner Losh     *
39ae36cccdSWarner Losh     *  Broadcom Common Firmware Environment (CFE)
40ae36cccdSWarner Losh     *
41ae36cccdSWarner Losh     *  Device function prototypes		File: cfe_api.h
42ae36cccdSWarner Losh     *
43ae36cccdSWarner Losh     *  This file contains declarations for doing callbacks to
44ae36cccdSWarner Losh     *  cfe from an application.  It should be the only header
45ae36cccdSWarner Losh     *  needed by the application to use this library
46ae36cccdSWarner Losh     *
47ae36cccdSWarner Losh     *  Authors:  Mitch Lichtenberg, Chris Demetriou
48ae36cccdSWarner Losh     *
49ae36cccdSWarner Losh     ********************************************************************* */
50ae36cccdSWarner Losh 
51ae36cccdSWarner Losh #ifndef CFE_API_H
52ae36cccdSWarner Losh #define CFE_API_H
53ae36cccdSWarner Losh 
54ae36cccdSWarner Losh /*
55ae36cccdSWarner Losh  * Apply customizations here for different OSes.  These need to:
56ae36cccdSWarner Losh  *	* typedef uint64_t, int64_t, intptr_t, uintptr_t.
57ae36cccdSWarner Losh  *	* define cfe_strlen() if use of an existing function is desired.
58ae36cccdSWarner Losh  *	* define CFE_API_IMPL_NAMESPACE if API functions are to use
59ae36cccdSWarner Losh  *	  names in the implementation namespace.
60ae36cccdSWarner Losh  * Also, optionally, if the build environment does not do so automatically,
61ae36cccdSWarner Losh  * CFE_API_* can be defined here as desired.
62ae36cccdSWarner Losh  */
63ae36cccdSWarner Losh /* Begin customization. */
6485ccd84cSKyle Evans #include <sys/types.h>
65ae36cccdSWarner Losh #include <sys/stdint.h>		/* All of the typedefs.  */
66ae36cccdSWarner Losh #include <sys/systm.h>		/* strlen() prototype.  */
67ae36cccdSWarner Losh 
68ae36cccdSWarner Losh #define	CFE_API_ALL
69ae36cccdSWarner Losh #define	cfe_strlen(x)	strlen(x)
70ae36cccdSWarner Losh /* End customization. */
71ae36cccdSWarner Losh 
72ae36cccdSWarner Losh /*  *********************************************************************
73ae36cccdSWarner Losh     *  Constants
74ae36cccdSWarner Losh     ********************************************************************* */
75ae36cccdSWarner Losh 
76ae36cccdSWarner Losh /* Seal indicating CFE's presence, passed to user program. */
77ae36cccdSWarner Losh #define CFE_EPTSEAL 0x43464531
78ae36cccdSWarner Losh 
79ae36cccdSWarner Losh #define CFE_MI_RESERVED	0		/* memory is reserved, do not use */
80ae36cccdSWarner Losh #define CFE_MI_AVAILABLE 1		/* memory is available */
81ae36cccdSWarner Losh 
82ae36cccdSWarner Losh #define CFE_FLG_WARMSTART     0x00000001
83ae36cccdSWarner Losh #define CFE_FLG_FULL_ARENA    0x00000001
84ae36cccdSWarner Losh #define CFE_FLG_ENV_PERMANENT 0x00000001
85ae36cccdSWarner Losh 
86ae36cccdSWarner Losh #define CFE_CPU_CMD_START 1
87ae36cccdSWarner Losh #define CFE_CPU_CMD_STOP 0
88ae36cccdSWarner Losh 
89ae36cccdSWarner Losh #define CFE_STDHANDLE_CONSOLE	0
90ae36cccdSWarner Losh 
91ae36cccdSWarner Losh #define CFE_DEV_NETWORK 	1
92ae36cccdSWarner Losh #define CFE_DEV_DISK		2
93ae36cccdSWarner Losh #define CFE_DEV_FLASH		3
94ae36cccdSWarner Losh #define CFE_DEV_SERIAL		4
95ae36cccdSWarner Losh #define CFE_DEV_CPU		5
96ae36cccdSWarner Losh #define CFE_DEV_NVRAM		6
97ae36cccdSWarner Losh #define CFE_DEV_CLOCK           7
98ae36cccdSWarner Losh #define CFE_DEV_OTHER		8
99ae36cccdSWarner Losh #define CFE_DEV_MASK		0x0F
100ae36cccdSWarner Losh 
101ae36cccdSWarner Losh #define CFE_CACHE_FLUSH_D	1
102ae36cccdSWarner Losh #define CFE_CACHE_INVAL_I	2
103ae36cccdSWarner Losh #define CFE_CACHE_INVAL_D	4
104ae36cccdSWarner Losh #define CFE_CACHE_INVAL_L2	8
105ae36cccdSWarner Losh 
106ae36cccdSWarner Losh #define CFE_FWI_64BIT		0x00000001
107ae36cccdSWarner Losh #define CFE_FWI_32BIT		0x00000002
108ae36cccdSWarner Losh #define CFE_FWI_RELOC		0x00000004
109ae36cccdSWarner Losh #define CFE_FWI_UNCACHED	0x00000008
110ae36cccdSWarner Losh #define CFE_FWI_MULTICPU	0x00000010
111ae36cccdSWarner Losh #define CFE_FWI_FUNCSIM		0x00000020
112ae36cccdSWarner Losh #define CFE_FWI_RTLSIM		0x00000040
113ae36cccdSWarner Losh 
114ae36cccdSWarner Losh typedef struct {
115ae36cccdSWarner Losh     int64_t fwi_version;		/* major, minor, eco version */
116ae36cccdSWarner Losh     int64_t fwi_totalmem;		/* total installed mem */
117ae36cccdSWarner Losh     int64_t fwi_flags;		        /* various flags */
118ae36cccdSWarner Losh     int64_t fwi_boardid;		/* board ID */
119ae36cccdSWarner Losh     int64_t fwi_bootarea_va;		/* VA of boot area */
120ae36cccdSWarner Losh     int64_t fwi_bootarea_pa;		/* PA of boot area */
121ae36cccdSWarner Losh     int64_t fwi_bootarea_size;	        /* size of boot area */
122ae36cccdSWarner Losh } cfe_fwinfo_t;
123ae36cccdSWarner Losh 
124ae36cccdSWarner Losh /*
125ae36cccdSWarner Losh  * cfe_strlen is handled specially: If already defined, it has been
126ae36cccdSWarner Losh  * overridden in this environment with a standard strlen-like function.
127ae36cccdSWarner Losh  */
128ae36cccdSWarner Losh #ifdef cfe_strlen
129ae36cccdSWarner Losh # define CFE_API_STRLEN_CUSTOM
130ae36cccdSWarner Losh #else
131ae36cccdSWarner Losh # ifdef CFE_API_IMPL_NAMESPACE
132ae36cccdSWarner Losh #  define cfe_strlen(a)			__cfe_strlen(a)
133ae36cccdSWarner Losh # endif
134ae36cccdSWarner Losh int cfe_strlen(char *name);
135ae36cccdSWarner Losh #endif
136ae36cccdSWarner Losh 
137ae36cccdSWarner Losh /*
138ae36cccdSWarner Losh  * Defines and prototypes for functions which take no arguments.
139ae36cccdSWarner Losh  */
140ae36cccdSWarner Losh #ifdef CFE_API_IMPL_NAMESPACE
141ae36cccdSWarner Losh int64_t __cfe_getticks(void);
142ae36cccdSWarner Losh #define cfe_getticks()			__cfe_getticks()
143ae36cccdSWarner Losh #else
144ae36cccdSWarner Losh int64_t cfe_getticks(void);
145ae36cccdSWarner Losh #endif
146ae36cccdSWarner Losh 
147ae36cccdSWarner Losh /*
148ae36cccdSWarner Losh  * Defines and prototypes for the rest of the functions.
149ae36cccdSWarner Losh  */
150ae36cccdSWarner Losh #ifdef CFE_API_IMPL_NAMESPACE
151ae36cccdSWarner Losh #define cfe_close(a)			__cfe_close(a)
152ae36cccdSWarner Losh #define cfe_cpu_start(a,b,c,d,e)	__cfe_cpu_start(a,b,c,d,e)
153ae36cccdSWarner Losh #define cfe_cpu_stop(a)			__cfe_cpu_stop(a)
154ae36cccdSWarner Losh #define cfe_enumenv(a,b,d,e,f)		__cfe_enumenv(a,b,d,e,f)
1553cbea0b1SLandon J. Fuller #define cfe_enumdev(a,b,c)		__cfe_enumdev(a,b,c)
156ae36cccdSWarner Losh #define cfe_enummem(a,b,c,d,e)		__cfe_enummem(a,b,c,d,e)
157ae36cccdSWarner Losh #define cfe_exit(a,b)			__cfe_exit(a,b)
158ae36cccdSWarner Losh #define cfe_flushcache(a)		__cfe_cacheflush(a)
159ae36cccdSWarner Losh #define cfe_getdevinfo(a)		__cfe_getdevinfo(a)
160ae36cccdSWarner Losh #define cfe_getenv(a,b,c)		__cfe_getenv(a,b,c)
161ae36cccdSWarner Losh #define cfe_getfwinfo(a)		__cfe_getfwinfo(a)
162ae36cccdSWarner Losh #define cfe_getstdhandle(a)		__cfe_getstdhandle(a)
163ae36cccdSWarner Losh #define cfe_init(a,b)			__cfe_init(a,b)
164ae36cccdSWarner Losh #define cfe_inpstat(a)			__cfe_inpstat(a)
165ae36cccdSWarner Losh #define cfe_ioctl(a,b,c,d,e,f)		__cfe_ioctl(a,b,c,d,e,f)
166ae36cccdSWarner Losh #define cfe_open(a)			__cfe_open(a)
167ae36cccdSWarner Losh #define cfe_read(a,b,c)			__cfe_read(a,b,c)
168ae36cccdSWarner Losh #define cfe_readblk(a,b,c,d)		__cfe_readblk(a,b,c,d)
169ae36cccdSWarner Losh #define cfe_setenv(a,b)			__cfe_setenv(a,b)
170ae36cccdSWarner Losh #define cfe_write(a,b,c)		__cfe_write(a,b,c)
171ae36cccdSWarner Losh #define cfe_writeblk(a,b,c,d)		__cfe_writeblk(a,b,c,d)
172ae36cccdSWarner Losh #endif /* CFE_API_IMPL_NAMESPACE */
173ae36cccdSWarner Losh 
174ae36cccdSWarner Losh int cfe_close(int handle);
175ae36cccdSWarner Losh int cfe_cpu_start(int cpu, void (*fn)(void), long sp, long gp, long a1);
176ae36cccdSWarner Losh int cfe_cpu_stop(int cpu);
177ae36cccdSWarner Losh int cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen);
1783cbea0b1SLandon J. Fuller int cfe_enumdev(int idx, char *name, int namelen);
179ae36cccdSWarner Losh int cfe_enummem(int idx, int flags, uint64_t *start, uint64_t *length,
180ae36cccdSWarner Losh 		uint64_t *type);
181ae36cccdSWarner Losh int cfe_exit(int warm,int status);
182ae36cccdSWarner Losh int cfe_flushcache(int flg);
183ae36cccdSWarner Losh int cfe_getdevinfo(char *name);
184ae36cccdSWarner Losh int cfe_getenv(char *name, char *dest, int destlen);
185ae36cccdSWarner Losh int cfe_getfwinfo(cfe_fwinfo_t *info);
186ae36cccdSWarner Losh int cfe_getstdhandle(int flg);
187ae36cccdSWarner Losh int cfe_init(uint64_t handle,uint64_t ept);
188ae36cccdSWarner Losh int cfe_inpstat(int handle);
189ae36cccdSWarner Losh int cfe_ioctl(int handle, unsigned int ioctlnum, unsigned char *buffer,
190ae36cccdSWarner Losh 	      int length, int *retlen, uint64_t offset);
191ae36cccdSWarner Losh int cfe_open(char *name);
192ae36cccdSWarner Losh int cfe_read(int handle, unsigned char *buffer, int length);
193ae36cccdSWarner Losh int cfe_readblk(int handle, int64_t offset, unsigned char *buffer, int length);
194ae36cccdSWarner Losh int cfe_setenv(char *name, char *val);
195ae36cccdSWarner Losh int cfe_write(int handle, unsigned char *buffer, int length);
196ae36cccdSWarner Losh int cfe_writeblk(int handle, int64_t offset, unsigned char *buffer,
197ae36cccdSWarner Losh 		 int length);
198ae36cccdSWarner Losh 
199ae36cccdSWarner Losh #endif /* CFE_API_H */
200