xref: /openbmc/linux/arch/mips/include/asm/fw/cfe/cfe_api.h (revision 3db55767)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (C) 2000, 2001, 2002 Broadcom Corporation
4  */
5 /*
6  * Broadcom Common Firmware Environment (CFE)
7  *
8  * This file contains declarations for doing callbacks to
9  * cfe from an application.  It should be the only header
10  * needed by the application to use this library
11  *
12  * Authors:  Mitch Lichtenberg, Chris Demetriou
13  */
14 #ifndef CFE_API_H
15 #define CFE_API_H
16 
17 #include <linux/types.h>
18 #include <linux/string.h>
19 
20 /*
21  * Constants
22  */
23 
24 /* Seal indicating CFE's presence, passed to user program. */
25 #define CFE_EPTSEAL 0x43464531
26 
27 #define CFE_MI_RESERVED 0	/* memory is reserved, do not use */
28 #define CFE_MI_AVAILABLE 1	/* memory is available */
29 
30 #define CFE_FLG_WARMSTART     0x00000001
31 #define CFE_FLG_FULL_ARENA    0x00000001
32 #define CFE_FLG_ENV_PERMANENT 0x00000001
33 
34 #define CFE_CPU_CMD_START 1
35 #define CFE_CPU_CMD_STOP 0
36 
37 #define CFE_STDHANDLE_CONSOLE	0
38 
39 #define CFE_DEV_NETWORK		1
40 #define CFE_DEV_DISK		2
41 #define CFE_DEV_FLASH		3
42 #define CFE_DEV_SERIAL		4
43 #define CFE_DEV_CPU		5
44 #define CFE_DEV_NVRAM		6
45 #define CFE_DEV_CLOCK		7
46 #define CFE_DEV_OTHER		8
47 #define CFE_DEV_MASK		0x0F
48 
49 #define CFE_CACHE_FLUSH_D	1
50 #define CFE_CACHE_INVAL_I	2
51 #define CFE_CACHE_INVAL_D	4
52 #define CFE_CACHE_INVAL_L2	8
53 
54 #define CFE_FWI_64BIT		0x00000001
55 #define CFE_FWI_32BIT		0x00000002
56 #define CFE_FWI_RELOC		0x00000004
57 #define CFE_FWI_UNCACHED	0x00000008
58 #define CFE_FWI_MULTICPU	0x00000010
59 #define CFE_FWI_FUNCSIM		0x00000020
60 #define CFE_FWI_RTLSIM		0x00000040
61 
62 typedef struct {
63 	int64_t fwi_version;		/* major, minor, eco version */
64 	int64_t fwi_totalmem;		/* total installed mem */
65 	int64_t fwi_flags;		/* various flags */
66 	int64_t fwi_boardid;		/* board ID */
67 	int64_t fwi_bootarea_va;	/* VA of boot area */
68 	int64_t fwi_bootarea_pa;	/* PA of boot area */
69 	int64_t fwi_bootarea_size;	/* size of boot area */
70 } cfe_fwinfo_t;
71 
72 
73 /*
74  * Defines and prototypes for functions which take no arguments.
75  */
76 int64_t cfe_getticks(void);
77 
78 /*
79  * Defines and prototypes for the rest of the functions.
80  */
81 int cfe_close(int handle);
82 int cfe_cpu_start(int cpu, void (*fn) (void), long sp, long gp, long a1);
83 int cfe_cpu_stop(int cpu);
84 int cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen);
85 int cfe_enummem(int idx, int flags, uint64_t * start, uint64_t * length,
86 		uint64_t * type);
87 int cfe_exit(int warm, int status);
88 int cfe_flushcache(int flg);
89 int cfe_getdevinfo(char *name);
90 int cfe_getenv(char *name, char *dest, int destlen);
91 int cfe_getfwinfo(cfe_fwinfo_t * info);
92 int cfe_getstdhandle(int flg);
93 int cfe_init(uint64_t handle, uint64_t ept);
94 int cfe_inpstat(int handle);
95 int cfe_ioctl(int handle, unsigned int ioctlnum, unsigned char *buffer,
96 	      int length, int *retlen, uint64_t offset);
97 int cfe_open(char *name);
98 int cfe_read(int handle, unsigned char *buffer, int length);
99 int cfe_readblk(int handle, int64_t offset, unsigned char *buffer,
100 		int length);
101 int cfe_setenv(char *name, char *val);
102 int cfe_write(int handle, const char *buffer, int length);
103 int cfe_writeblk(int handle, int64_t offset, const char *buffer,
104 		 int length);
105 extern unsigned long cfe_seal;
106 __printf(1, 2) void cfe_die(char *fmt, ...);
107 
108 #endif				/* CFE_API_H */
109