api_public.h 3.0 KB

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