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