aml.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma lib "libaml.a"
  2. #pragma src "/sys/src/lib/aml"
  3. /*
  4. * b uint8_t* buffer amllen() returns number of bytes
  5. * s char* string amllen() is strlen()
  6. * n char* undefined name amllen() is strlen()
  7. * i uint64_t* integer
  8. * p void** package amllen() is # of elements
  9. * r void* region
  10. * f void* field
  11. * u void* bufferfield
  12. * N void* name
  13. * R void* reference
  14. */
  15. int amltag(void *);
  16. void* amlval(void *);
  17. uint64_t amlint(void *);
  18. int amllen(void *);
  19. void* amlnew(char tag, int len);
  20. void amlinit(void);
  21. void amlexit(void);
  22. int amlload(uint8_t *data, int len);
  23. void* amlwalk(void *dot, char *name);
  24. int amleval(void *dot, char *fmt, ...);
  25. void amlenum(void *dot, char *seg, int (*proc)(void *, void *), void *arg);
  26. /*
  27. * exclude from garbage collection
  28. */
  29. void amltake(void *);
  30. void amldrop(void *);
  31. void* amlroot;
  32. int amldebug;
  33. uint64_t amlintmask;
  34. #pragma varargck type "V" void*
  35. #pragma varargck type "N" void*
  36. /* to be provided by operating system */
  37. extern void* amlalloc(int);
  38. extern void amlfree(void*);
  39. extern void amldelay(int); /* microseconds */
  40. enum {
  41. MemSpace = 0x00,
  42. IoSpace = 0x01,
  43. PcicfgSpace = 0x02,
  44. EbctlSpace = 0x03,
  45. SmbusSpace = 0x04,
  46. CmosSpace = 0x05,
  47. PcibarSpace = 0x06,
  48. IpmiSpace = 0x07,
  49. };
  50. typedef struct Amlio Amlio;
  51. struct Amlio
  52. {
  53. int space;
  54. uint64_t off;
  55. uint64_t len;
  56. void *name;
  57. uint8_t *va;
  58. void *aux;
  59. int (*read)(Amlio *io, void *data, int len, int off);
  60. int (*write)(Amlio *io, void *data, int len, int off);
  61. };
  62. extern int amlmapio(Amlio *io);
  63. extern void amlunmapio(Amlio *io);