xref: /openbmc/u-boot/include/api_public.h (revision d622ac39)
1 /*
2  * (C) Copyright 2007-2008 Semihalf
3  *
4  * Written by: Rafal Jaworowski <raj@semihalf.com>
5  *
6  * SPDX-License-Identifier:	GPL-2.0+	BSD-2-Clause
7  */
8 
9 #ifndef _API_PUBLIC_H_
10 #define _API_PUBLIC_H_
11 
12 #define API_EINVAL		1	/* invalid argument(s)	*/
13 #define API_ENODEV		2	/* no device		*/
14 #define API_ENOMEM		3	/* no memory		*/
15 #define API_EBUSY		4	/* busy, occupied etc.	*/
16 #define API_EIO			5	/* I/O error		*/
17 #define API_ESYSC		6	/* syscall error	*/
18 
19 typedef	int (*scp_t)(int, int *, ...);
20 
21 #define API_SIG_VERSION	1
22 #define API_SIG_MAGIC	"UBootAPI"
23 #define API_SIG_MAGLEN	8
24 
25 struct api_signature {
26 	char		magic[API_SIG_MAGLEN];	/* magic string */
27 	uint16_t	version;		/* API version */
28 	uint32_t	checksum;		/* checksum of this sig struct */
29 	scp_t		syscall;		/* entry point to the API */
30 };
31 
32 enum {
33 	API_RSVD = 0,
34 	API_GETC,
35 	API_PUTC,
36 	API_TSTC,
37 	API_PUTS,
38 	API_RESET,
39 	API_GET_SYS_INFO,
40 	API_UDELAY,
41 	API_GET_TIMER,
42 	API_DEV_ENUM,
43 	API_DEV_OPEN,
44 	API_DEV_CLOSE,
45 	API_DEV_READ,
46 	API_DEV_WRITE,
47 	API_ENV_ENUM,
48 	API_ENV_GET,
49 	API_ENV_SET,
50 	API_DISPLAY_GET_INFO,
51 	API_DISPLAY_DRAW_BITMAP,
52 	API_DISPLAY_CLEAR,
53 	API_MAXCALL
54 };
55 
56 #define MR_ATTR_FLASH	0x0001
57 #define MR_ATTR_DRAM	0x0002
58 #define MR_ATTR_SRAM	0x0003
59 
60 struct mem_region {
61 	unsigned long	start;
62 	unsigned long	size;
63 	int		flags;
64 };
65 
66 struct sys_info {
67 	unsigned long		clk_bus;
68 	unsigned long		clk_cpu;
69 	unsigned long		bar;
70 	struct mem_region	*mr;
71 	int			mr_no;	/* number of memory regions */
72 };
73 
74 #undef CONFIG_SYS_64BIT_LBA
75 #ifdef CONFIG_SYS_64BIT_LBA
76 typedef	u_int64_t lbasize_t;
77 #else
78 typedef unsigned long lbasize_t;
79 #endif
80 typedef unsigned long lbastart_t;
81 
82 #define DEV_TYP_NONE	0x0000
83 #define DEV_TYP_NET	0x0001
84 
85 #define DEV_TYP_STOR	0x0002
86 #define DT_STOR_IDE	0x0010
87 #define DT_STOR_SCSI	0x0020
88 #define DT_STOR_USB	0x0040
89 #define DT_STOR_MMC	0x0080
90 #define DT_STOR_SATA	0x0100
91 
92 #define DEV_STA_CLOSED	0x0000		/* invalid, closed */
93 #define DEV_STA_OPEN	0x0001		/* open i.e. active */
94 
95 struct device_info {
96 	int	type;
97 	void	*cookie;
98 
99 	union {
100 		struct {
101 			lbasize_t	block_count;	/* no of blocks */
102 			unsigned long	block_size;	/* size of one block */
103 		} storage;
104 
105 		struct {
106 			unsigned char	hwaddr[6];
107 		} net;
108 	} info;
109 #define di_stor info.storage
110 #define di_net info.net
111 
112 	int	state;
113 };
114 
115 #define DISPLAY_TYPE_LCD	0x0001
116 #define DISPLAY_TYPE_VIDEO	0x0002
117 
118 struct display_info {
119 	int type;
120 	/* screen size in pixels */
121 	int pixel_width;
122 	int pixel_height;
123 	/* screen size in rows and columns of text */
124 	int screen_rows;
125 	int screen_cols;
126 };
127 
128 #endif /* _API_PUBLIC_H_ */
129