xref: /netbsd-src/sys/arch/mips/cfe/cfe_api.h (revision 8a6b8c3b72150fdb12c10e7534080664c135f24b)
1*8a6b8c3bScgd /* $NetBSD: cfe_api.h,v 1.3 2003/02/07 17:38:48 cgd Exp $ */
249c87f08Scgd /* from: SiByte Id: cfe_api.h,v 1.29 2002/07/09 23:29:11 cgd Exp $ */
31b5ddfe4Ssimonb 
41b5ddfe4Ssimonb /*
549c87f08Scgd  * Copyright 2000, 2001, 2002
61b5ddfe4Ssimonb  * Broadcom Corporation. All rights reserved.
71b5ddfe4Ssimonb  *
81b5ddfe4Ssimonb  * This software is furnished under license and may be used and copied only
91b5ddfe4Ssimonb  * in accordance with the following terms and conditions.  Subject to these
101b5ddfe4Ssimonb  * conditions, you may download, copy, install, use, modify and distribute
111b5ddfe4Ssimonb  * modified or unmodified copies of this software in source and/or binary
121b5ddfe4Ssimonb  * form. No title or ownership is transferred hereby.
131b5ddfe4Ssimonb  *
141b5ddfe4Ssimonb  * 1) Any source code used, modified or distributed must reproduce and
151b5ddfe4Ssimonb  *    retain this copyright notice and list of conditions as they appear in
161b5ddfe4Ssimonb  *    the source file.
171b5ddfe4Ssimonb  *
181b5ddfe4Ssimonb  * 2) No right is granted to use any trade name, trademark, or logo of
1949c87f08Scgd  *    Broadcom Corporation.  The "Broadcom Corporation" name may not be
2049c87f08Scgd  *    used to endorse or promote products derived from this software
2149c87f08Scgd  *    without the prior written permission of Broadcom Corporation.
221b5ddfe4Ssimonb  *
231b5ddfe4Ssimonb  * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
241b5ddfe4Ssimonb  *    WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
251b5ddfe4Ssimonb  *    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
261b5ddfe4Ssimonb  *    NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
271b5ddfe4Ssimonb  *    FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
281b5ddfe4Ssimonb  *    LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
291b5ddfe4Ssimonb  *    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
301b5ddfe4Ssimonb  *    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
311b5ddfe4Ssimonb  *    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
321b5ddfe4Ssimonb  *    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
331b5ddfe4Ssimonb  *    OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
341b5ddfe4Ssimonb  */
351b5ddfe4Ssimonb 
361b5ddfe4Ssimonb /*  *********************************************************************
3749c87f08Scgd     *
381b5ddfe4Ssimonb     *  Broadcom Common Firmware Environment (CFE)
391b5ddfe4Ssimonb     *
401b5ddfe4Ssimonb     *  Device function prototypes		File: cfe_api.h
411b5ddfe4Ssimonb     *
4249c87f08Scgd     *  This file contains declarations for doing callbacks to
4349c87f08Scgd     *  cfe from an application.  It should be the only header
4449c87f08Scgd     *  needed by the application to use this library
451b5ddfe4Ssimonb     *
4649c87f08Scgd     *  Authors:  Mitch Lichtenberg, Chris Demetriou
471b5ddfe4Ssimonb     *
481b5ddfe4Ssimonb     ********************************************************************* */
491b5ddfe4Ssimonb 
5049c87f08Scgd #ifndef CFE_API_H
5149c87f08Scgd #define CFE_API_H
521b5ddfe4Ssimonb 
5349c87f08Scgd /*
5449c87f08Scgd  * Apply customizations here for different OSes.  These need to:
5549c87f08Scgd  *	* typedef uint64_t, int64_t, intptr_t, uintptr_t.
5649c87f08Scgd  *	* define cfe_strlen() if use of an existing function is desired.
5749c87f08Scgd  *	* define CFE_API_IMPL_NAMESPACE if API functions are to use
5849c87f08Scgd  *	  names in the implementation namespace.
5949c87f08Scgd  * Also, optionally, if the build environment does not do so automatically,
6049c87f08Scgd  * CFE_API_* can be defined here as desired.
6149c87f08Scgd  */
6249c87f08Scgd /* Begin customization. */
6349c87f08Scgd #include <sys/stdint.h>		/* All of the typedefs.  */
6449c87f08Scgd #include <sys/systm.h>		/* strlen() prototype.  */
6549c87f08Scgd 
6649c87f08Scgd #define	CFE_API_ALL
6749c87f08Scgd #define	cfe_strlen(x)	strlen(x)
6849c87f08Scgd /* End customization. */
6949c87f08Scgd 
7049c87f08Scgd 
7149c87f08Scgd /*  *********************************************************************
7249c87f08Scgd     *  Constants
7349c87f08Scgd     ********************************************************************* */
7449c87f08Scgd 
7549c87f08Scgd /* Seal indicating CFE's presence, passed to user program. */
761b5ddfe4Ssimonb #define CFE_EPTSEAL 0x43464531
771b5ddfe4Ssimonb 
7849c87f08Scgd #define CFE_MI_RESERVED	0		/* memory is reserved, do not use */
7949c87f08Scgd #define CFE_MI_AVAILABLE 1		/* memory is available */
8049c87f08Scgd 
8149c87f08Scgd #define CFE_FLG_WARMSTART     0x00000001
8249c87f08Scgd #define CFE_FLG_FULL_ARENA    0x00000001
8349c87f08Scgd #define CFE_FLG_ENV_PERMANENT 0x00000001
8449c87f08Scgd 
8549c87f08Scgd #define CFE_CPU_CMD_START 1
8649c87f08Scgd #define CFE_CPU_CMD_STOP 0
8749c87f08Scgd 
8849c87f08Scgd #define CFE_STDHANDLE_CONSOLE	0
8949c87f08Scgd 
9049c87f08Scgd #define CFE_DEV_NETWORK 	1
9149c87f08Scgd #define CFE_DEV_DISK		2
9249c87f08Scgd #define CFE_DEV_FLASH		3
9349c87f08Scgd #define CFE_DEV_SERIAL		4
9449c87f08Scgd #define CFE_DEV_CPU		5
9549c87f08Scgd #define CFE_DEV_NVRAM		6
9649c87f08Scgd #define CFE_DEV_CLOCK           7
9749c87f08Scgd #define CFE_DEV_OTHER		8
9849c87f08Scgd #define CFE_DEV_MASK		0x0F
9949c87f08Scgd 
10049c87f08Scgd #define CFE_CACHE_FLUSH_D	1
10149c87f08Scgd #define CFE_CACHE_INVAL_I	2
10249c87f08Scgd #define CFE_CACHE_INVAL_D	4
10349c87f08Scgd #define CFE_CACHE_INVAL_L2	8
10449c87f08Scgd 
10549c87f08Scgd #define CFE_FWI_64BIT		0x00000001
10649c87f08Scgd #define CFE_FWI_32BIT		0x00000002
10749c87f08Scgd #define CFE_FWI_RELOC		0x00000004
10849c87f08Scgd #define CFE_FWI_UNCACHED	0x00000008
10949c87f08Scgd #define CFE_FWI_MULTICPU	0x00000010
11049c87f08Scgd #define CFE_FWI_FUNCSIM		0x00000020
11149c87f08Scgd #define CFE_FWI_RTLSIM		0x00000040
11249c87f08Scgd 
11349c87f08Scgd typedef struct {
11449c87f08Scgd     int64_t fwi_version;		/* major, minor, eco version */
11549c87f08Scgd     int64_t fwi_totalmem;		/* total installed mem */
11649c87f08Scgd     int64_t fwi_flags;		        /* various flags */
11749c87f08Scgd     int64_t fwi_boardid;		/* board ID */
11849c87f08Scgd     int64_t fwi_bootarea_va;		/* VA of boot area */
11949c87f08Scgd     int64_t fwi_bootarea_pa;		/* PA of boot area */
12049c87f08Scgd     int64_t fwi_bootarea_size;	        /* size of boot area */
12149c87f08Scgd } cfe_fwinfo_t;
12249c87f08Scgd 
12349c87f08Scgd 
12449c87f08Scgd /*
12549c87f08Scgd  * cfe_strlen is handled specially: If already defined, it has been
12649c87f08Scgd  * overridden in this environment with a standard strlen-like function.
12749c87f08Scgd  */
12849c87f08Scgd #ifdef cfe_strlen
12949c87f08Scgd # define CFE_API_STRLEN_CUSTOM
13049c87f08Scgd #else
13149c87f08Scgd # ifdef CFE_API_IMPL_NAMESPACE
13249c87f08Scgd #  define cfe_strlen(a)			__cfe_strlen(a)
13349c87f08Scgd # endif
13449c87f08Scgd int cfe_strlen(char *name);
13549c87f08Scgd #endif
13649c87f08Scgd 
13749c87f08Scgd /*
13849c87f08Scgd  * Defines and prototypes for functions which take no arguments.
13949c87f08Scgd  */
14049c87f08Scgd #ifdef CFE_API_IMPL_NAMESPACE
14149c87f08Scgd int64_t __cfe_getticks(void);
14249c87f08Scgd #define cfe_getticks()			__cfe_getticks()
14349c87f08Scgd #else
14449c87f08Scgd int64_t cfe_getticks(void);
14549c87f08Scgd #endif
14649c87f08Scgd 
14749c87f08Scgd /*
14849c87f08Scgd  * Defines and prototypes for the rest of the functions.
14949c87f08Scgd  */
15049c87f08Scgd #ifdef CFE_API_IMPL_NAMESPACE
15149c87f08Scgd #define cfe_close(a)			__cfe_close(a)
15249c87f08Scgd #define cfe_cpu_start(a,b,c,d,e)	__cfe_cpu_start(a,b,c,d,e)
15349c87f08Scgd #define cfe_cpu_stop(a)			__cfe_cpu_stop(a)
15449c87f08Scgd #define cfe_enumenv(a,b,d,e,f)		__cfe_enumenv(a,b,d,e,f)
15549c87f08Scgd #define cfe_enummem(a,b,c,d,e)		__cfe_enummem(a,b,c,d,e)
15649c87f08Scgd #define cfe_exit(a,b)			__cfe_exit(a,b)
15749c87f08Scgd #define cfe_flushcache(a)		__cfe_cacheflush(a)
15849c87f08Scgd #define cfe_getdevinfo(a)		__cfe_getdevinfo(a)
15949c87f08Scgd #define cfe_getenv(a,b,c)		__cfe_getenv(a,b,c)
16049c87f08Scgd #define cfe_getfwinfo(a)		__cfe_getfwinfo(a)
16149c87f08Scgd #define cfe_getstdhandle(a)		__cfe_getstdhandle(a)
16249c87f08Scgd #define cfe_init(a,b)			__cfe_init(a,b)
16349c87f08Scgd #define cfe_inpstat(a)			__cfe_inpstat(a)
16449c87f08Scgd #define cfe_ioctl(a,b,c,d,e,f)		__cfe_ioctl(a,b,c,d,e,f)
16549c87f08Scgd #define cfe_open(a)			__cfe_open(a)
16649c87f08Scgd #define cfe_read(a,b,c)			__cfe_read(a,b,c)
16749c87f08Scgd #define cfe_readblk(a,b,c,d)		__cfe_readblk(a,b,c,d)
16849c87f08Scgd #define cfe_setenv(a,b)			__cfe_setenv(a,b)
16949c87f08Scgd #define cfe_write(a,b,c)		__cfe_write(a,b,c)
17049c87f08Scgd #define cfe_writeblk(a,b,c,d)		__cfe_writeblk(a,b,c,d)
17149c87f08Scgd #endif /* CFE_API_IMPL_NAMESPACE */
17249c87f08Scgd 
1731b5ddfe4Ssimonb int cfe_close(int handle);
17449c87f08Scgd int cfe_cpu_start(int cpu, void (*fn)(void), long sp, long gp, long a1);
17549c87f08Scgd int cfe_cpu_stop(int cpu);
1761b5ddfe4Ssimonb int cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen);
17749c87f08Scgd int cfe_enummem(int idx, int flags, uint64_t *start, uint64_t *length,
17849c87f08Scgd 		uint64_t *type);
1791b5ddfe4Ssimonb int cfe_exit(int warm,int status);
1801b5ddfe4Ssimonb int cfe_flushcache(int flg);
1811b5ddfe4Ssimonb int cfe_getdevinfo(char *name);
18249c87f08Scgd int cfe_getenv(char *name, char *dest, int destlen);
1831b5ddfe4Ssimonb int cfe_getfwinfo(cfe_fwinfo_t *info);
18449c87f08Scgd int cfe_getstdhandle(int flg);
18549c87f08Scgd int cfe_init(uint64_t handle,uint64_t ept);
18649c87f08Scgd int cfe_inpstat(int handle);
18749c87f08Scgd int cfe_ioctl(int handle, unsigned int ioctlnum, unsigned char *buffer,
18849c87f08Scgd 	      int length, int *retlen, uint64_t offset);
18949c87f08Scgd int cfe_open(char *name);
19049c87f08Scgd int cfe_read(int handle, unsigned char *buffer, int length);
19149c87f08Scgd int cfe_readblk(int handle, int64_t offset, unsigned char *buffer, int length);
19249c87f08Scgd int cfe_setenv(char *name, char *val);
19349c87f08Scgd int cfe_write(int handle, unsigned char *buffer, int length);
19449c87f08Scgd int cfe_writeblk(int handle, int64_t offset, unsigned char *buffer,
19549c87f08Scgd 		 int length);
19649c87f08Scgd 
19749c87f08Scgd #endif /* CFE_API_H */
198