xref: /freebsd-src/stand/uboot/api_public.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
1*9dc70af8SWarner Losh /*
2*9dc70af8SWarner Losh  * (C) Copyright 2007-2008 Semihalf
3*9dc70af8SWarner Losh  *
4*9dc70af8SWarner Losh  * Written by: Rafal Jaworowski <raj@semihalf.com>
5*9dc70af8SWarner Losh  *
6*9dc70af8SWarner Losh  * This file is dual licensed; you can use it under the terms of
7*9dc70af8SWarner Losh  * either the GPL, or the BSD license, at your option.
8*9dc70af8SWarner Losh  *
9*9dc70af8SWarner Losh  * I. GPL:
10*9dc70af8SWarner Losh  *
11*9dc70af8SWarner Losh  * This file is free software; you can redistribute it and/or
12*9dc70af8SWarner Losh  * modify it under the terms of the GNU General Public License as
13*9dc70af8SWarner Losh  * published by the Free Software Foundation; either version 2 of
14*9dc70af8SWarner Losh  * the License, or (at your option) any later version.
15*9dc70af8SWarner Losh  *
16*9dc70af8SWarner Losh  * This file is distributed in the hope that it will be useful,
17*9dc70af8SWarner Losh  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18*9dc70af8SWarner Losh  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19*9dc70af8SWarner Losh  * GNU General Public License for more details.
20*9dc70af8SWarner Losh  *
21*9dc70af8SWarner Losh  * You should have received a copy of the GNU General Public License
22*9dc70af8SWarner Losh  * along with this program; if not, write to the Free Software
23*9dc70af8SWarner Losh  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24*9dc70af8SWarner Losh  * MA 02111-1307 USA
25*9dc70af8SWarner Losh  *
26*9dc70af8SWarner Losh  * Alternatively,
27*9dc70af8SWarner Losh  *
28*9dc70af8SWarner Losh  * II. BSD license:
29*9dc70af8SWarner Losh  *
30*9dc70af8SWarner Losh  * Redistribution and use in source and binary forms, with or without
31*9dc70af8SWarner Losh  * modification, are permitted provided that the following conditions
32*9dc70af8SWarner Losh  * are met:
33*9dc70af8SWarner Losh  * 1. Redistributions of source code must retain the above copyright
34*9dc70af8SWarner Losh  *    notice, this list of conditions and the following disclaimer.
35*9dc70af8SWarner Losh  * 2. Redistributions in binary form must reproduce the above copyright
36*9dc70af8SWarner Losh  *    notice, this list of conditions and the following disclaimer in the
37*9dc70af8SWarner Losh  *    documentation and/or other materials provided with the distribution.
38*9dc70af8SWarner Losh  *
39*9dc70af8SWarner Losh  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
40*9dc70af8SWarner Losh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41*9dc70af8SWarner Losh  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
42*9dc70af8SWarner Losh  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
43*9dc70af8SWarner Losh  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
44*9dc70af8SWarner Losh  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
45*9dc70af8SWarner Losh  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46*9dc70af8SWarner Losh  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47*9dc70af8SWarner Losh  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
48*9dc70af8SWarner Losh  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49*9dc70af8SWarner Losh  * SUCH DAMAGE.
50*9dc70af8SWarner Losh  *
51*9dc70af8SWarner Losh  * This file needs to be kept in sync with U-Boot reference:
52*9dc70af8SWarner Losh  * http://www.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=blob;f=include/api_public.h
53*9dc70af8SWarner Losh  */
54*9dc70af8SWarner Losh 
55*9dc70af8SWarner Losh #ifndef _API_PUBLIC_H_
56*9dc70af8SWarner Losh #define	_API_PUBLIC_H_
57*9dc70af8SWarner Losh 
58*9dc70af8SWarner Losh #define	API_EINVAL		1	/* invalid argument(s)	*/
59*9dc70af8SWarner Losh #define	API_ENODEV		2	/* no device		*/
60*9dc70af8SWarner Losh #define	API_ENOMEM		3	/* no memory		*/
61*9dc70af8SWarner Losh #define	API_EBUSY		4	/* busy, occupied etc.	*/
62*9dc70af8SWarner Losh #define	API_EIO			5	/* I/O error		*/
63*9dc70af8SWarner Losh #define	API_ESYSC		6	/* syscall error	*/
64*9dc70af8SWarner Losh 
65*9dc70af8SWarner Losh typedef int (*scp_t)(int, int *, ...);
66*9dc70af8SWarner Losh 
67*9dc70af8SWarner Losh #define	API_SIG_VERSION	1
68*9dc70af8SWarner Losh #define	API_SIG_MAGIC	"UBootAPI"
69*9dc70af8SWarner Losh #define	API_SIG_MAGLEN	8
70*9dc70af8SWarner Losh 
71*9dc70af8SWarner Losh struct api_signature {
72*9dc70af8SWarner Losh 	char		magic[API_SIG_MAGLEN];	/* magic string */
73*9dc70af8SWarner Losh 	uint16_t	version;	/* API version */
74*9dc70af8SWarner Losh 	uint32_t	checksum;	/* checksum of this sig struct */
75*9dc70af8SWarner Losh 	scp_t		syscall;	/* entry point to the API */
76*9dc70af8SWarner Losh };
77*9dc70af8SWarner Losh 
78*9dc70af8SWarner Losh enum {
79*9dc70af8SWarner Losh 	API_RSVD = 0,
80*9dc70af8SWarner Losh 	API_GETC,
81*9dc70af8SWarner Losh 	API_PUTC,
82*9dc70af8SWarner Losh 	API_TSTC,
83*9dc70af8SWarner Losh 	API_PUTS,
84*9dc70af8SWarner Losh 	API_RESET,
85*9dc70af8SWarner Losh 	API_GET_SYS_INFO,
86*9dc70af8SWarner Losh 	API_UDELAY,
87*9dc70af8SWarner Losh 	API_GET_TIMER,
88*9dc70af8SWarner Losh 	API_DEV_ENUM,
89*9dc70af8SWarner Losh 	API_DEV_OPEN,
90*9dc70af8SWarner Losh 	API_DEV_CLOSE,
91*9dc70af8SWarner Losh 	API_DEV_READ,
92*9dc70af8SWarner Losh 	API_DEV_WRITE,
93*9dc70af8SWarner Losh 	API_ENV_ENUM,
94*9dc70af8SWarner Losh 	API_ENV_GET,
95*9dc70af8SWarner Losh 	API_ENV_SET,
96*9dc70af8SWarner Losh 	API_MAXCALL
97*9dc70af8SWarner Losh };
98*9dc70af8SWarner Losh 
99*9dc70af8SWarner Losh #define	MR_ATTR_FLASH	0x0001
100*9dc70af8SWarner Losh #define	MR_ATTR_DRAM	0x0002
101*9dc70af8SWarner Losh #define	MR_ATTR_SRAM	0x0003
102*9dc70af8SWarner Losh 
103*9dc70af8SWarner Losh struct mem_region {
104*9dc70af8SWarner Losh 	unsigned long	start;
105*9dc70af8SWarner Losh 	unsigned long	size;
106*9dc70af8SWarner Losh 	int		flags;
107*9dc70af8SWarner Losh };
108*9dc70af8SWarner Losh 
109*9dc70af8SWarner Losh struct sys_info {
110*9dc70af8SWarner Losh 	unsigned long		clk_bus;
111*9dc70af8SWarner Losh 	unsigned long		clk_cpu;
112*9dc70af8SWarner Losh 	unsigned long		bar;
113*9dc70af8SWarner Losh 	struct mem_region	*mr;
114*9dc70af8SWarner Losh 	int			mr_no;	/* number of memory regions */
115*9dc70af8SWarner Losh };
116*9dc70af8SWarner Losh 
117*9dc70af8SWarner Losh #undef CFG_64BIT_LBA
118*9dc70af8SWarner Losh #ifdef CFG_64BIT_LBA
119*9dc70af8SWarner Losh typedef	uint64_t lbasize_t;
120*9dc70af8SWarner Losh #else
121*9dc70af8SWarner Losh typedef unsigned long lbasize_t;
122*9dc70af8SWarner Losh #endif
123*9dc70af8SWarner Losh typedef unsigned long lbastart_t;
124*9dc70af8SWarner Losh 
125*9dc70af8SWarner Losh #define	DEV_TYP_NONE	0x0000
126*9dc70af8SWarner Losh #define	DEV_TYP_NET	0x0001
127*9dc70af8SWarner Losh 
128*9dc70af8SWarner Losh #define	DEV_TYP_STOR	0x0002
129*9dc70af8SWarner Losh #define	DT_STOR_IDE	0x0010
130*9dc70af8SWarner Losh #define	DT_STOR_SCSI	0x0020
131*9dc70af8SWarner Losh #define	DT_STOR_USB	0x0040
132*9dc70af8SWarner Losh #define	DT_STOR_MMC	0x0080
133*9dc70af8SWarner Losh #define	DT_STOR_SATA	0x0100
134*9dc70af8SWarner Losh 
135*9dc70af8SWarner Losh #define	DEV_STA_CLOSED	0x0000		/* invalid, closed */
136*9dc70af8SWarner Losh #define	DEV_STA_OPEN	0x0001		/* open i.e. active */
137*9dc70af8SWarner Losh 
138*9dc70af8SWarner Losh struct device_info {
139*9dc70af8SWarner Losh 	int	type;
140*9dc70af8SWarner Losh 	void	*cookie;
141*9dc70af8SWarner Losh 
142*9dc70af8SWarner Losh 	union {
143*9dc70af8SWarner Losh 		struct {
144*9dc70af8SWarner Losh 			lbasize_t	block_count;	/* no of blocks */
145*9dc70af8SWarner Losh 			unsigned long	block_size;	/* size of one block */
146*9dc70af8SWarner Losh 		} storage;
147*9dc70af8SWarner Losh 
148*9dc70af8SWarner Losh 		struct {
149*9dc70af8SWarner Losh 			unsigned char	hwaddr[6];
150*9dc70af8SWarner Losh 		} net;
151*9dc70af8SWarner Losh 	} info;
152*9dc70af8SWarner Losh #define	di_stor info.storage
153*9dc70af8SWarner Losh #define	di_net info.net
154*9dc70af8SWarner Losh 
155*9dc70af8SWarner Losh 	int	state;
156*9dc70af8SWarner Losh };
157*9dc70af8SWarner Losh 
158*9dc70af8SWarner Losh #endif /* _API_PUBLIC_H_ */
159