api_public.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. #ifndef _API_PUBLIC_H_
  9. #define _API_PUBLIC_H_
  10. #define API_EINVAL 1 /* invalid argument(s) */
  11. #define API_ENODEV 2 /* no device */
  12. #define API_ENOMEM 3 /* no memory */
  13. #define API_EBUSY 4 /* busy, occupied etc. */
  14. #define API_EIO 5 /* I/O error */
  15. #define API_ESYSC 6 /* syscall error */
  16. typedef int (*scp_t)(int, int *, ...);
  17. #define API_SIG_VERSION 1
  18. #define API_SIG_MAGIC "UBootAPI"
  19. #define API_SIG_MAGLEN 8
  20. struct api_signature {
  21. char magic[API_SIG_MAGLEN]; /* magic string */
  22. uint16_t version; /* API version */
  23. uint32_t checksum; /* checksum of this sig struct */
  24. scp_t syscall; /* entry point to the API */
  25. };
  26. enum {
  27. API_RSVD = 0,
  28. API_GETC,
  29. API_PUTC,
  30. API_TSTC,
  31. API_PUTS,
  32. API_RESET,
  33. API_GET_SYS_INFO,
  34. API_UDELAY,
  35. API_GET_TIMER,
  36. API_DEV_ENUM,
  37. API_DEV_OPEN,
  38. API_DEV_CLOSE,
  39. API_DEV_READ,
  40. API_DEV_WRITE,
  41. API_ENV_ENUM,
  42. API_ENV_GET,
  43. API_ENV_SET,
  44. API_DISPLAY_GET_INFO,
  45. API_DISPLAY_DRAW_BITMAP,
  46. API_DISPLAY_CLEAR,
  47. API_MAXCALL
  48. };
  49. #define MR_ATTR_FLASH 0x0001
  50. #define MR_ATTR_DRAM 0x0002
  51. #define MR_ATTR_SRAM 0x0003
  52. struct mem_region {
  53. unsigned long start;
  54. unsigned long size;
  55. int flags;
  56. };
  57. struct sys_info {
  58. unsigned long clk_bus;
  59. unsigned long clk_cpu;
  60. unsigned long bar;
  61. struct mem_region *mr;
  62. int mr_no; /* number of memory regions */
  63. };
  64. #undef CONFIG_SYS_64BIT_LBA
  65. #ifdef CONFIG_SYS_64BIT_LBA
  66. typedef u_int64_t lbasize_t;
  67. #else
  68. typedef unsigned long lbasize_t;
  69. #endif
  70. typedef unsigned long lbastart_t;
  71. #define DEV_TYP_NONE 0x0000
  72. #define DEV_TYP_NET 0x0001
  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. #define DT_STOR_SATA 0x0100
  79. #define DEV_STA_CLOSED 0x0000 /* invalid, closed */
  80. #define DEV_STA_OPEN 0x0001 /* open i.e. active */
  81. struct device_info {
  82. int type;
  83. void *cookie;
  84. union {
  85. struct {
  86. lbasize_t block_count; /* no of blocks */
  87. unsigned long block_size; /* size of one block */
  88. } storage;
  89. struct {
  90. unsigned char hwaddr[6];
  91. } net;
  92. } info;
  93. #define di_stor info.storage
  94. #define di_net info.net
  95. int state;
  96. };
  97. #define DISPLAY_TYPE_LCD 0x0001
  98. #define DISPLAY_TYPE_VIDEO 0x0002
  99. struct display_info {
  100. int type;
  101. /* screen size in pixels */
  102. int pixel_width;
  103. int pixel_height;
  104. /* screen size in rows and columns of text */
  105. int screen_rows;
  106. int screen_cols;
  107. };
  108. #endif /* _API_PUBLIC_H_ */