xref: /openbmc/linux/arch/mips/include/asm/fw/cfe/cfe_api.h (revision 4419617e)
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 typedef long intptr_t;
21 
22 
23 /*
24  * Constants
25  */
26 
27 /* Seal indicating CFE's presence, passed to user program. */
28 #define CFE_EPTSEAL 0x43464531
29 
30 #define CFE_MI_RESERVED 0	/* memory is reserved, do not use */
31 #define CFE_MI_AVAILABLE 1	/* memory is available */
32 
33 #define CFE_FLG_WARMSTART     0x00000001
34 #define CFE_FLG_FULL_ARENA    0x00000001
35 #define CFE_FLG_ENV_PERMANENT 0x00000001
36 
37 #define CFE_CPU_CMD_START 1
38 #define CFE_CPU_CMD_STOP 0
39 
40 #define CFE_STDHANDLE_CONSOLE	0
41 
42 #define CFE_DEV_NETWORK		1
43 #define CFE_DEV_DISK		2
44 #define CFE_DEV_FLASH		3
45 #define CFE_DEV_SERIAL		4
46 #define CFE_DEV_CPU		5
47 #define CFE_DEV_NVRAM		6
48 #define CFE_DEV_CLOCK		7
49 #define CFE_DEV_OTHER		8
50 #define CFE_DEV_MASK		0x0F
51 
52 #define CFE_CACHE_FLUSH_D	1
53 #define CFE_CACHE_INVAL_I	2
54 #define CFE_CACHE_INVAL_D	4
55 #define CFE_CACHE_INVAL_L2	8
56 
57 #define CFE_FWI_64BIT		0x00000001
58 #define CFE_FWI_32BIT		0x00000002
59 #define CFE_FWI_RELOC		0x00000004
60 #define CFE_FWI_UNCACHED	0x00000008
61 #define CFE_FWI_MULTICPU	0x00000010
62 #define CFE_FWI_FUNCSIM		0x00000020
63 #define CFE_FWI_RTLSIM		0x00000040
64 
65 typedef struct {
66 	int64_t fwi_version;		/* major, minor, eco version */
67 	int64_t fwi_totalmem;		/* total installed mem */
68 	int64_t fwi_flags;		/* various flags */
69 	int64_t fwi_boardid;		/* board ID */
70 	int64_t fwi_bootarea_va;	/* VA of boot area */
71 	int64_t fwi_bootarea_pa;	/* PA of boot area */
72 	int64_t fwi_bootarea_size;	/* size of boot area */
73 } cfe_fwinfo_t;
74 
75 
76 /*
77  * Defines and prototypes for functions which take no arguments.
78  */
79 int64_t cfe_getticks(void);
80 
81 /*
82  * Defines and prototypes for the rest of the functions.
83  */
84 int cfe_close(int handle);
85 int cfe_cpu_start(int cpu, void (*fn) (void), long sp, long gp, long a1);
86 int cfe_cpu_stop(int cpu);
87 int cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen);
88 int cfe_enummem(int idx, int flags, uint64_t * start, uint64_t * length,
89 		uint64_t * type);
90 int cfe_exit(int warm, int status);
91 int cfe_flushcache(int flg);
92 int cfe_getdevinfo(char *name);
93 int cfe_getenv(char *name, char *dest, int destlen);
94 int cfe_getfwinfo(cfe_fwinfo_t * info);
95 int cfe_getstdhandle(int flg);
96 int cfe_init(uint64_t handle, uint64_t ept);
97 int cfe_inpstat(int handle);
98 int cfe_ioctl(int handle, unsigned int ioctlnum, unsigned char *buffer,
99 	      int length, int *retlen, uint64_t offset);
100 int cfe_open(char *name);
101 int cfe_read(int handle, unsigned char *buffer, int length);
102 int cfe_readblk(int handle, int64_t offset, unsigned char *buffer,
103 		int length);
104 int cfe_setenv(char *name, char *val);
105 int cfe_write(int handle, const char *buffer, int length);
106 int cfe_writeblk(int handle, int64_t offset, const char *buffer,
107 		 int length);
108 
109 #endif				/* CFE_API_H */
110