Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 1 | #ifndef _API_PUBLIC_H_ |
| 2 | #define _API_PUBLIC_H_ |
| 3 | |
| 4 | #define API_EINVAL 1 /* invalid argument(s) */ |
| 5 | #define API_ENODEV 2 /* no device */ |
| 6 | #define API_ENOMEM 3 /* no memory */ |
| 7 | #define API_EBUSY 4 /* busy, occupied etc. */ |
| 8 | #define API_EIO 5 /* I/O error */ |
| 9 | |
| 10 | typedef int (*scp_t)(int, int *, ...); |
| 11 | |
| 12 | #define API_SIG_VERSION 1 |
| 13 | #define API_SIG_MAGIC "UBootAPI" |
| 14 | #define API_SIG_MAGLEN 8 |
| 15 | |
| 16 | struct api_signature { |
| 17 | char magic[API_SIG_MAGLEN]; /* magic string */ |
| 18 | uint16_t version; /* API version */ |
| 19 | uint32_t checksum; /* checksum of this sig struct */ |
| 20 | scp_t syscall; /* entry point to the API */ |
| 21 | }; |
| 22 | |
| 23 | enum { |
| 24 | API_RSVD = 0, |
| 25 | API_GETC, |
| 26 | API_PUTC, |
| 27 | API_TSTC, |
| 28 | API_PUTS, |
| 29 | API_RESET, |
| 30 | API_GET_SYS_INFO, |
| 31 | API_UDELAY, |
| 32 | API_GET_TIMER, |
| 33 | API_DEV_ENUM, |
| 34 | API_DEV_OPEN, |
| 35 | API_DEV_CLOSE, |
| 36 | API_DEV_READ, |
| 37 | API_DEV_WRITE, |
| 38 | API_ENV_ENUM, |
| 39 | API_ENV_GET, |
| 40 | API_ENV_SET, |
| 41 | API_MAXCALL |
| 42 | }; |
| 43 | |
| 44 | #define MR_ATTR_FLASH 0x0001 |
| 45 | #define MR_ATTR_DRAM 0x0002 |
| 46 | #define MR_ATTR_SRAM 0x0003 |
| 47 | |
| 48 | struct mem_region { |
| 49 | unsigned long start; |
| 50 | unsigned long size; |
| 51 | int flags; |
| 52 | }; |
| 53 | |
| 54 | struct sys_info { |
| 55 | unsigned long clk_bus; |
| 56 | unsigned long clk_cpu; |
| 57 | unsigned long bar; |
| 58 | struct mem_region *mr; |
| 59 | int mr_no; /* number of memory regions */ |
| 60 | }; |
| 61 | |
| 62 | #undef CFG_64BIT_LBA |
| 63 | #ifdef CFG_64BIT_LBA |
| 64 | typedef u_int64_t lbasize_t; |
| 65 | #else |
| 66 | typedef unsigned long lbasize_t; |
| 67 | #endif |
| 68 | typedef unsigned long lbastart_t; |
| 69 | |
| 70 | #define DEV_TYP_NONE 0x0000 |
| 71 | #define DEV_TYP_NET 0x0001 |
| 72 | |
| 73 | #define DEV_TYP_STOR 0x0002 |
| 74 | #define DT_STOR_IDE 0x0010 |
| 75 | #define DT_STOR_SCSI 0x0020 |
| 76 | #define DT_STOR_USB 0x0040 |
| 77 | #define DT_STOR_MMC 0x0080 |
| 78 | |
| 79 | #define DEV_STA_CLOSED 0x0000 /* invalid, closed */ |
| 80 | #define DEV_STA_OPEN 0x0001 /* open i.e. active */ |
| 81 | |
| 82 | struct device_info { |
| 83 | int type; |
| 84 | void *cookie; |
| 85 | |
| 86 | union { |
| 87 | struct { |
| 88 | lbasize_t block_count; /* no of blocks */ |
| 89 | unsigned long block_size; /* size of one block */ |
| 90 | } storage; |
| 91 | |
| 92 | struct { |
| 93 | unsigned char hwaddr[6]; |
| 94 | } net; |
| 95 | } info; |
| 96 | #define di_stor info.storage |
| 97 | #define di_net info.net |
| 98 | |
| 99 | int state; |
| 100 | }; |
| 101 | |
| 102 | #endif /* _API_PUBLIC_H_ */ |