api_public.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. #undef CONFIG_SYS_64BIT_LBA
  64. #ifdef CONFIG_SYS_64BIT_LBA
  65. typedef u_int64_t lbasize_t;
  66. #else
  67. typedef unsigned long lbasize_t;
  68. #endif
  69. typedef unsigned long lbastart_t;
  70. #define DEV_TYP_NONE 0x0000
  71. #define DEV_TYP_NET 0x0001
  72. #define DEV_TYP_STOR 0x0002
  73. #define DT_STOR_IDE 0x0010
  74. #define DT_STOR_SCSI 0x0020
  75. #define DT_STOR_USB 0x0040
  76. #define DT_STOR_MMC 0x0080
  77. #define DT_STOR_SATA 0x0100
  78. #define DEV_STA_CLOSED 0x0000 /* invalid, closed */
  79. #define DEV_STA_OPEN 0x0001 /* open i.e. active */
  80. struct device_info {
  81. int type;
  82. void *cookie;
  83. union {
  84. struct {
  85. lbasize_t block_count; /* no of blocks */
  86. unsigned long block_size; /* size of one block */
  87. } storage;
  88. struct {
  89. unsigned char hwaddr[6];
  90. } net;
  91. } info;
  92. #define di_stor info.storage
  93. #define di_net info.net
  94. int state;
  95. };
  96. #define DISPLAY_TYPE_LCD 0x0001
  97. #define DISPLAY_TYPE_VIDEO 0x0002
  98. struct display_info {
  99. int type;
  100. /* screen size in pixels */
  101. int pixel_width;
  102. int pixel_height;
  103. /* screen size in rows and columns of text */
  104. int screen_rows;
  105. int screen_cols;
  106. };
  107. #endif /* _API_PUBLIC_H_ */