xref: /openbmc/linux/arch/mips/include/asm/fw/cfe/cfe_api.h (revision 60772e48)
1 /*
2  * Copyright (C) 2000, 2001, 2002 Broadcom Corporation
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18 /*
19  * Broadcom Common Firmware Environment (CFE)
20  *
21  * This file contains declarations for doing callbacks to
22  * cfe from an application.  It should be the only header
23  * needed by the application to use this library
24  *
25  * Authors:  Mitch Lichtenberg, Chris Demetriou
26  */
27 #ifndef CFE_API_H
28 #define CFE_API_H
29 
30 #include <linux/types.h>
31 #include <linux/string.h>
32 
33 typedef long intptr_t;
34 
35 
36 /*
37  * Constants
38  */
39 
40 /* Seal indicating CFE's presence, passed to user program. */
41 #define CFE_EPTSEAL 0x43464531
42 
43 #define CFE_MI_RESERVED 0	/* memory is reserved, do not use */
44 #define CFE_MI_AVAILABLE 1	/* memory is available */
45 
46 #define CFE_FLG_WARMSTART     0x00000001
47 #define CFE_FLG_FULL_ARENA    0x00000001
48 #define CFE_FLG_ENV_PERMANENT 0x00000001
49 
50 #define CFE_CPU_CMD_START 1
51 #define CFE_CPU_CMD_STOP 0
52 
53 #define CFE_STDHANDLE_CONSOLE	0
54 
55 #define CFE_DEV_NETWORK		1
56 #define CFE_DEV_DISK		2
57 #define CFE_DEV_FLASH		3
58 #define CFE_DEV_SERIAL		4
59 #define CFE_DEV_CPU		5
60 #define CFE_DEV_NVRAM		6
61 #define CFE_DEV_CLOCK		7
62 #define CFE_DEV_OTHER		8
63 #define CFE_DEV_MASK		0x0F
64 
65 #define CFE_CACHE_FLUSH_D	1
66 #define CFE_CACHE_INVAL_I	2
67 #define CFE_CACHE_INVAL_D	4
68 #define CFE_CACHE_INVAL_L2	8
69 
70 #define CFE_FWI_64BIT		0x00000001
71 #define CFE_FWI_32BIT		0x00000002
72 #define CFE_FWI_RELOC		0x00000004
73 #define CFE_FWI_UNCACHED	0x00000008
74 #define CFE_FWI_MULTICPU	0x00000010
75 #define CFE_FWI_FUNCSIM		0x00000020
76 #define CFE_FWI_RTLSIM		0x00000040
77 
78 typedef struct {
79 	int64_t fwi_version;		/* major, minor, eco version */
80 	int64_t fwi_totalmem;		/* total installed mem */
81 	int64_t fwi_flags;		/* various flags */
82 	int64_t fwi_boardid;		/* board ID */
83 	int64_t fwi_bootarea_va;	/* VA of boot area */
84 	int64_t fwi_bootarea_pa;	/* PA of boot area */
85 	int64_t fwi_bootarea_size;	/* size of boot area */
86 } cfe_fwinfo_t;
87 
88 
89 /*
90  * Defines and prototypes for functions which take no arguments.
91  */
92 int64_t cfe_getticks(void);
93 
94 /*
95  * Defines and prototypes for the rest of the functions.
96  */
97 int cfe_close(int handle);
98 int cfe_cpu_start(int cpu, void (*fn) (void), long sp, long gp, long a1);
99 int cfe_cpu_stop(int cpu);
100 int cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen);
101 int cfe_enummem(int idx, int flags, uint64_t * start, uint64_t * length,
102 		uint64_t * type);
103 int cfe_exit(int warm, int status);
104 int cfe_flushcache(int flg);
105 int cfe_getdevinfo(char *name);
106 int cfe_getenv(char *name, char *dest, int destlen);
107 int cfe_getfwinfo(cfe_fwinfo_t * info);
108 int cfe_getstdhandle(int flg);
109 int cfe_init(uint64_t handle, uint64_t ept);
110 int cfe_inpstat(int handle);
111 int cfe_ioctl(int handle, unsigned int ioctlnum, unsigned char *buffer,
112 	      int length, int *retlen, uint64_t offset);
113 int cfe_open(char *name);
114 int cfe_read(int handle, unsigned char *buffer, int length);
115 int cfe_readblk(int handle, int64_t offset, unsigned char *buffer,
116 		int length);
117 int cfe_setenv(char *name, char *val);
118 int cfe_write(int handle, const char *buffer, int length);
119 int cfe_writeblk(int handle, int64_t offset, const char *buffer,
120 		 int length);
121 
122 #endif				/* CFE_API_H */
123