dsdt.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /* $OpenBSD: dsdt.h,v 1.64 2015/06/13 21:41:42 guenther Exp $ */
  2. /*
  3. * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
  4. *
  5. * Permission to use, copy, modify, and distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #ifndef __DEV_ACPI_DSDT_H__
  18. #define __DEV_ACPI_DSDT_H__
  19. struct aml_scope {
  20. struct acpi_softc *sc;
  21. uint8_t *pos;
  22. uint8_t *start;
  23. uint8_t *end;
  24. struct aml_node *node;
  25. struct aml_scope *parent;
  26. struct aml_value *locals;
  27. struct aml_value *args;
  28. struct aml_value *retv;
  29. int type;
  30. int depth;
  31. };
  32. struct aml_opcode {
  33. u_int32_t opcode;
  34. const char *mnem;
  35. const char *args;
  36. };
  37. const char *aml_eisaid(u_int32_t);
  38. const char *aml_mnem(int, uint8_t *);
  39. int64_t aml_val2int(struct aml_value *);
  40. struct aml_node *aml_searchname(struct aml_node *, const void *);
  41. struct aml_node *aml_searchrel(struct aml_node *, const void *);
  42. struct aml_value *aml_getstack(struct aml_scope *, int);
  43. struct aml_value *aml_allocvalue(int, int64_t, const void *);
  44. void aml_freevalue(struct aml_value *);
  45. void aml_notify(struct aml_node *, int);
  46. void aml_showvalue(struct aml_value *, int);
  47. void aml_walkroot(void);
  48. void aml_walktree(struct aml_node *);
  49. int aml_find_node(struct aml_node *, const char *,
  50. int (*)(struct aml_node *, void *), void *);
  51. int acpi_parse_aml(struct acpi_softc *, u_int8_t *,
  52. u_int32_t);
  53. void aml_register_notify(struct aml_node *, const char *,
  54. int (*)(struct aml_node *, int, void *), void *,
  55. int);
  56. int aml_evalnode(struct acpi_softc *, struct aml_node *,
  57. int, struct aml_value *, struct aml_value *);
  58. int aml_node_setval(struct acpi_softc *, struct aml_node *,
  59. int64_t);
  60. int aml_evalname(struct acpi_softc *, struct aml_node *,
  61. const char *, int, struct aml_value *,
  62. struct aml_value *);
  63. int aml_evalinteger(struct acpi_softc *, struct aml_node *,
  64. const char *, int, struct aml_value *, int64_t *);
  65. void aml_create_defaultobjects(void);
  66. const char *aml_nodename(struct aml_node *);
  67. #define SRT_IRQ2 0x22
  68. #define SRT_IRQ3 0x23
  69. #define SRT_DMA 0x2A
  70. #define SRT_STARTDEP0 0x30
  71. #define SRT_STARTDEP1 0x31
  72. #define SRT_ENDDEP 0x38
  73. #define SRT_IOPORT 0x47
  74. #define SRT_FIXEDPORT 0x4B
  75. #define SRT_ENDTAG 0x78
  76. #define SR_IRQ 0x04
  77. #define SR_DMA 0x05
  78. #define SR_STARTDEP 0x06
  79. #define SR_ENDDEP 0x07
  80. #define SR_IOPORT 0x08
  81. #define SR_FIXEDPORT 0x09
  82. #define SR_ENDTAG 0x0F
  83. /* byte zero of small resources combines the tag above a length [1..7] */
  84. #define SR_TAG(tag,len) ((tag << 3) + (len))
  85. #define LR_24BIT 0x81
  86. #define LR_GENREGISTER 0x82
  87. #define LR_32BIT 0x85
  88. #define LR_32BITFIXED 0x86
  89. #define LR_DWORD 0x87
  90. #define LR_WORD 0x88
  91. #define LR_EXTIRQ 0x89
  92. #define LR_QWORD 0x8A
  93. #define __amlflagbit(v,s,l)
  94. union acpi_resource {
  95. struct {
  96. uint8_t typecode;
  97. uint16_t length;
  98. } __packed hdr;
  99. /* Small resource structures
  100. * format of typecode is: tttttlll, t = type, l = length
  101. */
  102. struct {
  103. uint8_t typecode;
  104. uint16_t irq_mask;
  105. uint8_t irq_flags;
  106. #define SR_IRQ_SHR (1L << 4)
  107. #define SR_IRQ_POLARITY (1L << 3)
  108. #define SR_IRQ_MODE (1L << 0)
  109. } __packed sr_irq;
  110. struct {
  111. uint8_t typecode;
  112. uint8_t channel;
  113. uint8_t flags;
  114. #define SR_DMA_TYP_MASK 0x3
  115. #define SR_DMA_TYP_SHIFT 5
  116. #define SR_DMA_BM (1L << 2)
  117. #define SR_DMA_SIZE_MASK 0x3
  118. #define SR_DMA_SIZE_SHIFT 0
  119. } __packed sr_dma;
  120. struct {
  121. uint8_t typecode;
  122. uint8_t flags;
  123. #define SR_IOPORT_DEC (1L << 0)
  124. uint16_t _min;
  125. uint16_t _max;
  126. uint8_t _aln;
  127. uint8_t _len;
  128. } __packed sr_ioport;
  129. struct {
  130. uint8_t typecode;
  131. uint16_t _bas;
  132. uint8_t _len;
  133. } __packed sr_fioport;
  134. /* Large resource structures */
  135. struct {
  136. uint8_t typecode;
  137. uint16_t length;
  138. uint8_t _info;
  139. uint16_t _min;
  140. uint16_t _max;
  141. uint16_t _aln;
  142. uint16_t _len;
  143. } __packed lr_m24;
  144. struct {
  145. uint8_t typecode;
  146. uint16_t length;
  147. uint8_t _info;
  148. uint32_t _min;
  149. uint32_t _max;
  150. uint32_t _aln;
  151. uint32_t _len;
  152. } __packed lr_m32;
  153. struct {
  154. uint8_t typecode;
  155. uint16_t length;
  156. uint8_t flags;
  157. #define LR_EXTIRQ_SHR (1L << 3)
  158. #define LR_EXTIRQ_POLARITY (1L << 2)
  159. #define LR_EXTIRQ_MODE (1L << 1)
  160. uint8_t irq_count;
  161. uint32_t irq[1];
  162. } __packed lr_extirq;
  163. struct {
  164. uint8_t typecode;
  165. uint16_t length;
  166. uint8_t type;
  167. uint8_t flags;
  168. uint8_t tflags;
  169. uint16_t _gra;
  170. uint16_t _min;
  171. uint16_t _max;
  172. uint16_t _tra;
  173. uint16_t _len;
  174. uint8_t src_index;
  175. char src[1];
  176. } __packed lr_word;
  177. struct {
  178. uint8_t typecode;
  179. uint16_t length;
  180. uint8_t type;
  181. uint8_t flags;
  182. uint8_t tflags;
  183. uint32_t _gra;
  184. uint32_t _min;
  185. uint32_t _max;
  186. uint32_t _tra;
  187. uint32_t _len;
  188. uint8_t src_index;
  189. char src[1];
  190. } __packed lr_dword;
  191. struct {
  192. uint8_t typecode;
  193. uint16_t length;
  194. uint8_t type;
  195. uint8_t flags;
  196. uint8_t tflags;
  197. uint64_t _gra;
  198. uint64_t _min;
  199. uint64_t _max;
  200. uint64_t _tra;
  201. uint64_t _len;
  202. uint8_t src_index;
  203. char src[1];
  204. } __packed lr_qword;
  205. uint8_t pad[64];
  206. } __packed;
  207. #define AML_CRSTYPE(x) ((x)->hdr.typecode & 0x80 ? \
  208. (x)->hdr.typecode : (x)->hdr.typecode >> 3)
  209. #define AML_CRSLEN(x) ((x)->hdr.typecode & 0x80 ? \
  210. 3+(x)->hdr.length : 1+((x)->hdr.typecode & 0x7))
  211. int aml_print_resource(union acpi_resource *, void *);
  212. int aml_parse_resource(struct aml_value *,
  213. int (*)(union acpi_resource *, void *), void *);
  214. #define ACPI_E_NOERROR 0x00
  215. #define ACPI_E_BADVALUE 0x01
  216. #define AML_MAX_ARG 7
  217. #define AML_MAX_LOCAL 8
  218. #define AML_WALK_PRE 0x00
  219. #define AML_WALK_POST 0x01
  220. void aml_walknodes(struct aml_node *, int,
  221. int (*)(struct aml_node *, void *), void *);
  222. void aml_postparse(void);
  223. void aml_hashopcodes(void);
  224. void aml_foreachpkg(struct aml_value *, int,
  225. void (*fn)(struct aml_value *, void *), void *);
  226. const char *aml_val_to_string(const struct aml_value *);
  227. void aml_disasm(struct aml_scope *scope, int lvl,
  228. void (*dbprintf)(void *, const char *, ...),
  229. void *arg);
  230. int aml_getpci(struct aml_node *, int64_t *);
  231. int aml_evalhid(struct aml_node *, struct aml_value *);
  232. int acpi_walkmem(int, const char *);
  233. #define aml_get8(p) *(uint8_t *)(p)
  234. #define aml_get16(p) *(uint16_t *)(p)
  235. #define aml_get32(p) *(uint32_t *)(p)
  236. #define aml_get64(p) *(uint64_t *)(p)
  237. union amlpci_t {
  238. uint64_t addr;
  239. struct {
  240. uint16_t reg;
  241. uint16_t fun;
  242. uint16_t dev;
  243. uint16_t bus;
  244. };
  245. };
  246. int aml_rdpciaddr(struct aml_node *pcidev,
  247. union amlpci_t *);
  248. #ifndef SMALL_KERNEL
  249. void acpi_getdevlist(struct acpi_devlist_head *,
  250. struct aml_node *, struct aml_value *, int);
  251. #endif
  252. void aml_notify_dev(const char *, int);
  253. void acpi_freedevlist(struct acpi_devlist_head *);
  254. void acpi_glk_enter(void);
  255. void acpi_glk_leave(void);
  256. #endif /* __DEV_ACPI_DSDT_H__ */