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 /*  *********************************************************************
20     *
21     *  Broadcom Common Firmware Environment (CFE)
22     *
23     *  Device function prototypes		File: cfe_api_int.h
24     *
25     *  This header defines all internal types and macros for the
26     *  library.  This is stuff that's not exported to an app
27     *  using the library.
28     *
29     *  Authors:  Mitch Lichtenberg, Chris Demetriou
30     *
31     ********************************************************************* */
32 
33 #ifndef CFE_API_INT_H
34 #define CFE_API_INT_H
35 
36 /*  *********************************************************************
37     *  Constants
38     ********************************************************************* */
39 
40 #define CFE_CMD_FW_GETINFO	0
41 #define CFE_CMD_FW_RESTART	1
42 #define CFE_CMD_FW_BOOT		2
43 #define CFE_CMD_FW_CPUCTL	3
44 #define CFE_CMD_FW_GETTIME      4
45 #define CFE_CMD_FW_MEMENUM	5
46 #define CFE_CMD_FW_FLUSHCACHE	6
47 
48 #define CFE_CMD_DEV_GETHANDLE	9
49 #define CFE_CMD_DEV_ENUM	10
50 #define CFE_CMD_DEV_OPEN	11
51 #define CFE_CMD_DEV_INPSTAT	12
52 #define CFE_CMD_DEV_READ	13
53 #define CFE_CMD_DEV_WRITE	14
54 #define CFE_CMD_DEV_IOCTL	15
55 #define CFE_CMD_DEV_CLOSE	16
56 #define CFE_CMD_DEV_GETINFO	17
57 
58 #define CFE_CMD_ENV_ENUM	20
59 #define CFE_CMD_ENV_GET		22
60 #define CFE_CMD_ENV_SET		23
61 #define CFE_CMD_ENV_DEL		24
62 
63 #define CFE_CMD_MAX		32
64 
65 #define CFE_CMD_VENDOR_USE	0x8000	/* codes above this are for customer use */
66 
67 /*  *********************************************************************
68     *  Structures
69     ********************************************************************* */
70 
71 typedef uint64_t cfe_xuint_t;
72 typedef int64_t cfe_xint_t;
73 typedef int64_t cfe_xptr_t;
74 
75 typedef struct xiocb_buffer_s {
76 	cfe_xuint_t buf_offset;		/* offset on device (bytes) */
77 	cfe_xptr_t  buf_ptr;		/* pointer to a buffer */
78 	cfe_xuint_t buf_length;		/* length of this buffer */
79 	cfe_xuint_t buf_retlen;		/* returned length (for read ops) */
80 	cfe_xuint_t buf_ioctlcmd;	/* IOCTL command (used only for IOCTLs) */
81 } xiocb_buffer_t;
82 
83 #define buf_devflags buf_ioctlcmd	/* returned device info flags */
84 
85 typedef struct xiocb_inpstat_s {
86 	cfe_xuint_t inp_status;		/* 1 means input available */
87 } xiocb_inpstat_t;
88 
89 typedef struct xiocb_envbuf_s {
90 	cfe_xint_t enum_idx;		/* 0-based enumeration index */
91 	cfe_xptr_t name_ptr;		/* name string buffer */
92 	cfe_xint_t name_length;		/* size of name buffer */
93 	cfe_xptr_t val_ptr;		/* value string buffer */
94 	cfe_xint_t val_length;		/* size of value string buffer */
95 } xiocb_envbuf_t;
96 
97 typedef struct xiocb_cpuctl_s {
98 	cfe_xuint_t cpu_number;		/* cpu number to control */
99 	cfe_xuint_t cpu_command;	/* command to issue to CPU */
100 	cfe_xuint_t start_addr;		/* CPU start address */
101 	cfe_xuint_t gp_val;		/* starting GP value */
102 	cfe_xuint_t sp_val;		/* starting SP value */
103 	cfe_xuint_t a1_val;		/* starting A1 value */
104 } xiocb_cpuctl_t;
105 
106 typedef struct xiocb_time_s {
107 	cfe_xint_t ticks;		/* current time in ticks */
108 } xiocb_time_t;
109 
110 typedef struct xiocb_exitstat_s {
111 	cfe_xint_t status;
112 } xiocb_exitstat_t;
113 
114 typedef struct xiocb_meminfo_s {
115 	cfe_xint_t mi_idx;		/* 0-based enumeration index */
116 	cfe_xint_t mi_type;		/* type of memory block */
117 	cfe_xuint_t mi_addr;		/* physical start address */
118 	cfe_xuint_t mi_size;		/* block size */
119 } xiocb_meminfo_t;
120 
121 typedef struct xiocb_fwinfo_s {
122 	cfe_xint_t fwi_version;		/* major, minor, eco version */
123 	cfe_xint_t fwi_totalmem;	/* total installed mem */
124 	cfe_xint_t fwi_flags;		/* various flags */
125 	cfe_xint_t fwi_boardid;		/* board ID */
126 	cfe_xint_t fwi_bootarea_va;	/* VA of boot area */
127 	cfe_xint_t fwi_bootarea_pa;	/* PA of boot area */
128 	cfe_xint_t fwi_bootarea_size;	/* size of boot area */
129 	cfe_xint_t fwi_reserved1;
130 	cfe_xint_t fwi_reserved2;
131 	cfe_xint_t fwi_reserved3;
132 } xiocb_fwinfo_t;
133 
134 typedef struct cfe_xiocb_s {
135 	cfe_xuint_t xiocb_fcode;	/* IOCB function code */
136 	cfe_xint_t xiocb_status;	/* return status */
137 	cfe_xint_t xiocb_handle;	/* file/device handle */
138 	cfe_xuint_t xiocb_flags;	/* flags for this IOCB */
139 	cfe_xuint_t xiocb_psize;	/* size of parameter list */
140 	union {
141 		xiocb_buffer_t xiocb_buffer;	/* buffer parameters */
142 		xiocb_inpstat_t xiocb_inpstat;	/* input status parameters */
143 		xiocb_envbuf_t xiocb_envbuf;	/* environment function parameters */
144 		xiocb_cpuctl_t xiocb_cpuctl;	/* CPU control parameters */
145 		xiocb_time_t xiocb_time;	/* timer parameters */
146 		xiocb_meminfo_t xiocb_meminfo;	/* memory arena info parameters */
147 		xiocb_fwinfo_t xiocb_fwinfo;	/* firmware information */
148 		xiocb_exitstat_t xiocb_exitstat;	/* Exit Status */
149 	} plist;
150 } cfe_xiocb_t;
151 
152 #endif				/* CFE_API_INT_H */
153