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