api_public.h 1.9 KB

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