cfe_api.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * Copyright (C) 2000, 2001, 2002 Broadcom Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. /* *********************************************************************
  19. *
  20. * Broadcom Common Firmware Environment (CFE)
  21. *
  22. * Device function prototypes File: cfe_api.h
  23. *
  24. * This file contains declarations for doing callbacks to
  25. * cfe from an application. It should be the only header
  26. * needed by the application to use this library
  27. *
  28. * Authors: Mitch Lichtenberg, Chris Demetriou
  29. *
  30. ********************************************************************* */
  31. #ifndef CFE_API_H
  32. #define CFE_API_H
  33. /*
  34. * Apply customizations here for different OSes. These need to:
  35. * * typedef uint64_t, int64_t, intptr_t, uintptr_t.
  36. * * define cfe_strlen() if use of an existing function is desired.
  37. * * define CFE_API_IMPL_NAMESPACE if API functions are to use
  38. * names in the implementation namespace.
  39. * Also, optionally, if the build environment does not do so automatically,
  40. * CFE_API_* can be defined here as desired.
  41. */
  42. /* Begin customization. */
  43. #include <linux/types.h>
  44. #include <linux/string.h>
  45. typedef long intptr_t;
  46. #define cfe_strlen strlen
  47. #define CFE_API_ALL
  48. #define CFE_API_STRLEN_CUSTOM
  49. /* End customization. */
  50. /* *********************************************************************
  51. * Constants
  52. ********************************************************************* */
  53. /* Seal indicating CFE's presence, passed to user program. */
  54. #define CFE_EPTSEAL 0x43464531
  55. #define CFE_MI_RESERVED 0 /* memory is reserved, do not use */
  56. #define CFE_MI_AVAILABLE 1 /* memory is available */
  57. #define CFE_FLG_WARMSTART 0x00000001
  58. #define CFE_FLG_FULL_ARENA 0x00000001
  59. #define CFE_FLG_ENV_PERMANENT 0x00000001
  60. #define CFE_CPU_CMD_START 1
  61. #define CFE_CPU_CMD_STOP 0
  62. #define CFE_STDHANDLE_CONSOLE 0
  63. #define CFE_DEV_NETWORK 1
  64. #define CFE_DEV_DISK 2
  65. #define CFE_DEV_FLASH 3
  66. #define CFE_DEV_SERIAL 4
  67. #define CFE_DEV_CPU 5
  68. #define CFE_DEV_NVRAM 6
  69. #define CFE_DEV_CLOCK 7
  70. #define CFE_DEV_OTHER 8
  71. #define CFE_DEV_MASK 0x0F
  72. #define CFE_CACHE_FLUSH_D 1
  73. #define CFE_CACHE_INVAL_I 2
  74. #define CFE_CACHE_INVAL_D 4
  75. #define CFE_CACHE_INVAL_L2 8
  76. #define CFE_FWI_64BIT 0x00000001
  77. #define CFE_FWI_32BIT 0x00000002
  78. #define CFE_FWI_RELOC 0x00000004
  79. #define CFE_FWI_UNCACHED 0x00000008
  80. #define CFE_FWI_MULTICPU 0x00000010
  81. #define CFE_FWI_FUNCSIM 0x00000020
  82. #define CFE_FWI_RTLSIM 0x00000040
  83. typedef struct {
  84. int64_t fwi_version; /* major, minor, eco version */
  85. int64_t fwi_totalmem; /* total installed mem */
  86. int64_t fwi_flags; /* various flags */
  87. int64_t fwi_boardid; /* board ID */
  88. int64_t fwi_bootarea_va; /* VA of boot area */
  89. int64_t fwi_bootarea_pa; /* PA of boot area */
  90. int64_t fwi_bootarea_size; /* size of boot area */
  91. } cfe_fwinfo_t;
  92. /*
  93. * cfe_strlen is handled specially: If already defined, it has been
  94. * overridden in this environment with a standard strlen-like function.
  95. */
  96. #ifdef cfe_strlen
  97. # define CFE_API_STRLEN_CUSTOM
  98. #else
  99. # ifdef CFE_API_IMPL_NAMESPACE
  100. # define cfe_strlen(a) __cfe_strlen(a)
  101. # endif
  102. int cfe_strlen(char *name);
  103. #endif
  104. /*
  105. * Defines and prototypes for functions which take no arguments.
  106. */
  107. #ifdef CFE_API_IMPL_NAMESPACE
  108. int64_t __cfe_getticks(void);
  109. #define cfe_getticks() __cfe_getticks()
  110. #else
  111. int64_t cfe_getticks(void);
  112. #endif
  113. /*
  114. * Defines and prototypes for the rest of the functions.
  115. */
  116. #ifdef CFE_API_IMPL_NAMESPACE
  117. #define cfe_close(a) __cfe_close(a)
  118. #define cfe_cpu_start(a, b, c, d, e) __cfe_cpu_start(a, b, c, d, e)
  119. #define cfe_cpu_stop(a) __cfe_cpu_stop(a)
  120. #define cfe_enumenv(a, b, d, e, f) __cfe_enumenv(a, b, d, e, f)
  121. #define cfe_enummem(a, b, c, d, e) __cfe_enummem(a, b, c, d, e)
  122. #define cfe_exit(a, b) __cfe_exit(a, b)
  123. #define cfe_flushcache(a) __cfe_cacheflush(a)
  124. #define cfe_getdevinfo(a) __cfe_getdevinfo(a)
  125. #define cfe_getenv(a, b, c) __cfe_getenv(a, b, c)
  126. #define cfe_getfwinfo(a) __cfe_getfwinfo(a)
  127. #define cfe_getstdhandle(a) __cfe_getstdhandle(a)
  128. #define cfe_init(a, b) __cfe_init(a, b)
  129. #define cfe_inpstat(a) __cfe_inpstat(a)
  130. #define cfe_ioctl(a, b, c, d, e, f) __cfe_ioctl(a, b, c, d, e, f)
  131. #define cfe_open(a) __cfe_open(a)
  132. #define cfe_read(a, b, c) __cfe_read(a, b, c)
  133. #define cfe_readblk(a, b, c, d) __cfe_readblk(a, b, c, d)
  134. #define cfe_setenv(a, b) __cfe_setenv(a, b)
  135. #define cfe_write(a, b, c) __cfe_write(a, b, c)
  136. #define cfe_writeblk(a, b, c, d) __cfe_writeblk(a, b, c, d)
  137. #endif /* CFE_API_IMPL_NAMESPACE */
  138. int cfe_close(int handle);
  139. int cfe_cpu_start(int cpu, void (*fn) (void), long sp, long gp, long a1);
  140. int cfe_cpu_stop(int cpu);
  141. int cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen);
  142. int cfe_enummem(int idx, int flags, uint64_t * start, uint64_t * length,
  143. uint64_t * type);
  144. int cfe_exit(int warm, int status);
  145. int cfe_flushcache(int flg);
  146. int cfe_getdevinfo(char *name);
  147. int cfe_getenv(char *name, char *dest, int destlen);
  148. int cfe_getfwinfo(cfe_fwinfo_t * info);
  149. int cfe_getstdhandle(int flg);
  150. int cfe_init(uint64_t handle, uint64_t ept);
  151. int cfe_inpstat(int handle);
  152. int cfe_ioctl(int handle, unsigned int ioctlnum, unsigned char *buffer,
  153. int length, int *retlen, uint64_t offset);
  154. int cfe_open(char *name);
  155. int cfe_read(int handle, unsigned char *buffer, int length);
  156. int cfe_readblk(int handle, int64_t offset, unsigned char *buffer,
  157. int length);
  158. int cfe_setenv(char *name, char *val);
  159. int cfe_write(int handle, unsigned char *buffer, int length);
  160. int cfe_writeblk(int handle, int64_t offset, unsigned char *buffer,
  161. int length);
  162. #endif /* CFE_API_H */