/* from: Broadcom Id: cfe_api.h,v 1.31 2006/08/24 02:13:56 binh Exp $ */12/*-3* SPDX-License-Identifier: BSD-3-Clause4*5* Copyright 2000, 2001, 20026* Broadcom Corporation. All rights reserved.7*8* This software is furnished under license and may be used and copied only9* in accordance with the following terms and conditions. Subject to these10* conditions, you may download, copy, install, use, modify and distribute11* modified or unmodified copies of this software in source and/or binary12* form. No title or ownership is transferred hereby.13*14* 1) Any source code used, modified or distributed must reproduce and15* retain this copyright notice and list of conditions as they appear in16* the source file.17*18* 2) No right is granted to use any trade name, trademark, or logo of19* Broadcom Corporation. The "Broadcom Corporation" name may not be20* used to endorse or promote products derived from this software21* without the prior written permission of Broadcom Corporation.22*23* 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED24* WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF25* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR26* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE27* FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE28* LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR29* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF30* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR31* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,32* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE33* OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.34*/3536/* *********************************************************************37*38* Broadcom Common Firmware Environment (CFE)39*40* Device function prototypes File: cfe_api.h41*42* This file contains declarations for doing callbacks to43* cfe from an application. It should be the only header44* needed by the application to use this library45*46* Authors: Mitch Lichtenberg, Chris Demetriou47*48********************************************************************* */4950#ifndef CFE_API_H51#define CFE_API_H5253/*54* Apply customizations here for different OSes. These need to:55* * typedef uint64_t, int64_t, intptr_t, uintptr_t.56* * define cfe_strlen() if use of an existing function is desired.57* * define CFE_API_IMPL_NAMESPACE if API functions are to use58* names in the implementation namespace.59* Also, optionally, if the build environment does not do so automatically,60* CFE_API_* can be defined here as desired.61*/62/* Begin customization. */63#include <sys/types.h>64#include <sys/stdint.h> /* All of the typedefs. */65#include <sys/systm.h> /* strlen() prototype. */6667#define CFE_API_ALL68#define cfe_strlen(x) strlen(x)69/* End customization. */7071/* *********************************************************************72* Constants73********************************************************************* */7475/* Seal indicating CFE's presence, passed to user program. */76#define CFE_EPTSEAL 0x434645317778#define CFE_MI_RESERVED 0 /* memory is reserved, do not use */79#define CFE_MI_AVAILABLE 1 /* memory is available */8081#define CFE_FLG_WARMSTART 0x0000000182#define CFE_FLG_FULL_ARENA 0x0000000183#define CFE_FLG_ENV_PERMANENT 0x000000018485#define CFE_CPU_CMD_START 186#define CFE_CPU_CMD_STOP 08788#define CFE_STDHANDLE_CONSOLE 08990#define CFE_DEV_NETWORK 191#define CFE_DEV_DISK 292#define CFE_DEV_FLASH 393#define CFE_DEV_SERIAL 494#define CFE_DEV_CPU 595#define CFE_DEV_NVRAM 696#define CFE_DEV_CLOCK 797#define CFE_DEV_OTHER 898#define CFE_DEV_MASK 0x0F99100#define CFE_CACHE_FLUSH_D 1101#define CFE_CACHE_INVAL_I 2102#define CFE_CACHE_INVAL_D 4103#define CFE_CACHE_INVAL_L2 8104105#define CFE_FWI_64BIT 0x00000001106#define CFE_FWI_32BIT 0x00000002107#define CFE_FWI_RELOC 0x00000004108#define CFE_FWI_UNCACHED 0x00000008109#define CFE_FWI_MULTICPU 0x00000010110#define CFE_FWI_FUNCSIM 0x00000020111#define CFE_FWI_RTLSIM 0x00000040112113typedef struct {114int64_t fwi_version; /* major, minor, eco version */115int64_t fwi_totalmem; /* total installed mem */116int64_t fwi_flags; /* various flags */117int64_t fwi_boardid; /* board ID */118int64_t fwi_bootarea_va; /* VA of boot area */119int64_t fwi_bootarea_pa; /* PA of boot area */120int64_t fwi_bootarea_size; /* size of boot area */121} cfe_fwinfo_t;122123/*124* cfe_strlen is handled specially: If already defined, it has been125* overridden in this environment with a standard strlen-like function.126*/127#ifdef cfe_strlen128# define CFE_API_STRLEN_CUSTOM129#else130# ifdef CFE_API_IMPL_NAMESPACE131# define cfe_strlen(a) __cfe_strlen(a)132# endif133int cfe_strlen(char *name);134#endif135136/*137* Defines and prototypes for functions which take no arguments.138*/139#ifdef CFE_API_IMPL_NAMESPACE140int64_t __cfe_getticks(void);141#define cfe_getticks() __cfe_getticks()142#else143int64_t cfe_getticks(void);144#endif145146/*147* Defines and prototypes for the rest of the functions.148*/149#ifdef CFE_API_IMPL_NAMESPACE150#define cfe_close(a) __cfe_close(a)151#define cfe_cpu_start(a,b,c,d,e) __cfe_cpu_start(a,b,c,d,e)152#define cfe_cpu_stop(a) __cfe_cpu_stop(a)153#define cfe_enumenv(a,b,d,e,f) __cfe_enumenv(a,b,d,e,f)154#define cfe_enumdev(a,b,c) __cfe_enumdev(a,b,c)155#define cfe_enummem(a,b,c,d,e) __cfe_enummem(a,b,c,d,e)156#define cfe_exit(a,b) __cfe_exit(a,b)157#define cfe_flushcache(a) __cfe_cacheflush(a)158#define cfe_getdevinfo(a) __cfe_getdevinfo(a)159#define cfe_getenv(a,b,c) __cfe_getenv(a,b,c)160#define cfe_getfwinfo(a) __cfe_getfwinfo(a)161#define cfe_getstdhandle(a) __cfe_getstdhandle(a)162#define cfe_init(a,b) __cfe_init(a,b)163#define cfe_inpstat(a) __cfe_inpstat(a)164#define cfe_ioctl(a,b,c,d,e,f) __cfe_ioctl(a,b,c,d,e,f)165#define cfe_open(a) __cfe_open(a)166#define cfe_read(a,b,c) __cfe_read(a,b,c)167#define cfe_readblk(a,b,c,d) __cfe_readblk(a,b,c,d)168#define cfe_setenv(a,b) __cfe_setenv(a,b)169#define cfe_write(a,b,c) __cfe_write(a,b,c)170#define cfe_writeblk(a,b,c,d) __cfe_writeblk(a,b,c,d)171#endif /* CFE_API_IMPL_NAMESPACE */172173int cfe_close(int handle);174int cfe_cpu_start(int cpu, void (*fn)(void), long sp, long gp, long a1);175int cfe_cpu_stop(int cpu);176int cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen);177int cfe_enumdev(int idx, char *name, int namelen);178int cfe_enummem(int idx, int flags, uint64_t *start, uint64_t *length,179uint64_t *type);180int cfe_exit(int warm,int status);181int cfe_flushcache(int flg);182int cfe_getdevinfo(char *name);183int cfe_getenv(char *name, char *dest, int destlen);184int cfe_getfwinfo(cfe_fwinfo_t *info);185int cfe_getstdhandle(int flg);186int cfe_init(uint64_t handle,uint64_t ept);187int cfe_inpstat(int handle);188int cfe_ioctl(int handle, unsigned int ioctlnum, unsigned char *buffer,189int length, int *retlen, uint64_t offset);190int cfe_open(char *name);191int cfe_read(int handle, unsigned char *buffer, int length);192int cfe_readblk(int handle, int64_t offset, unsigned char *buffer, int length);193int cfe_setenv(char *name, char *val);194int cfe_write(int handle, unsigned char *buffer, int length);195int cfe_writeblk(int handle, int64_t offset, unsigned char *buffer,196int length);197198#endif /* CFE_API_H */199200201