harveyacpi.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <acpi.h>
  10. #undef DBG
  11. #define DBG print
  12. #define MiB (1<<20)
  13. //BOOLEAN AcpiGbl_DebugTimeout = FALSE;
  14. static uint32_t rsdp;
  15. static char *name;
  16. /* debug prints for this file. You can set this in gdb or at compile time. */
  17. static int debug;
  18. // From aemain.c
  19. /*
  20. * Init file entry
  21. */
  22. typedef struct init_file_entry INIT_FILE_ENTRY;
  23. INIT_FILE_ENTRY *AcpiGbl_InitEntries = NULL;
  24. UINT32 AcpiGbl_InitFileLineCount = 0;
  25. #if 0
  26. static int
  27. xisprint(int c)
  28. {
  29. return (c >= 32 && c <= 126);
  30. }
  31. static void
  32. hexdump(void *v, int length)
  33. {
  34. int i;
  35. uint8_t *m = v;
  36. uintptr_t memory = (uintptr_t) v;
  37. int all_zero = 0;
  38. if (debug)
  39. fprint(2, "hexdump: %p, %u\n", v, length);
  40. for (i = 0; i < length; i += 16) {
  41. int j;
  42. all_zero++;
  43. for (j = 0; (j < 16) && (i + j < length); j++) {
  44. if (m[i + j] != 0) {
  45. all_zero = 0;
  46. break;
  47. }
  48. }
  49. if (all_zero < 2) {
  50. if (debug)
  51. fprint(2, "%p:", (void *)(memory + i));
  52. for (j = 0; j < 16; j++)
  53. if (debug)
  54. fprint(2, " %02x", m[i + j]);
  55. if (debug)
  56. fprint(2, " ");
  57. for (j = 0; j < 16; j++)
  58. if (debug)
  59. fprint(2, "%c", xisprint(m[i + j]) ? m[i + j] : '.');
  60. if (debug)
  61. fprint(2, "\n");
  62. } else if (all_zero == 2) {
  63. if (debug)
  64. fprint(2, "...\n");
  65. }
  66. }
  67. }
  68. #endif
  69. /* try several variants */
  70. static int
  71. rawfd(void)
  72. {
  73. int fd;
  74. if (name == nil) {
  75. name = "/dev/acpimem";
  76. if (debug)
  77. fprint(2, "Rawfd: open '%s'\n", name);
  78. fd = open(name, OREAD);
  79. if (fd > -1)
  80. return fd;
  81. name = "#P/acpimem";
  82. if (debug)
  83. fprint(2, "Rawfd: open '%s'\n", name);
  84. fd = open(name, OREAD);
  85. if (fd > -1)
  86. return fd;
  87. }
  88. return open(name, OREAD);
  89. }
  90. #if 0
  91. static int
  92. tbdf(ACPI_PCI_ID * p)
  93. {
  94. return (p->Bus << 8) | (p->Device << 3) | (p->Function);
  95. }
  96. #endif
  97. int acpiio = -1;
  98. uint32_t
  99. inl(uint16_t addr)
  100. {
  101. uint64_t off = addr;
  102. uint32_t l;
  103. if (pread(acpiio, &l, 4, off) < 4)
  104. print("inl(0x%x): %r\n", addr);
  105. return l;
  106. }
  107. uint16_t
  108. ins(uint16_t addr)
  109. {
  110. uint64_t off = addr;
  111. uint16_t w;
  112. if (pread(acpiio, &w, 2, off) < 2)
  113. if(debug) DBG("ins(0x%x): %r\n", addr);
  114. return w;
  115. }
  116. uint8_t
  117. inb(uint16_t addr)
  118. {
  119. uint64_t off = addr;
  120. uint16_t b;
  121. if (pread(acpiio, &b, 1, off) < 1)
  122. if(debug) DBG("inb(0x%x): %r\n", addr);
  123. return b;
  124. }
  125. void
  126. outl(uint16_t addr, uint32_t val)
  127. {
  128. uint64_t off = addr;
  129. if (pwrite(acpiio, &val, 4, off) < 4)
  130. if(debug) DBG("outl(0x%x): %r\n", addr);
  131. }
  132. void
  133. outs(uint16_t addr, uint16_t val)
  134. {
  135. uint64_t off = addr;
  136. if (pwrite(acpiio, &val, 2, off) < 2)
  137. if(debug) DBG("outs(0x%x): %r\n", addr);
  138. }
  139. void
  140. outb(uint16_t addr, uint8_t val)
  141. {
  142. uint64_t off = addr;
  143. if (pwrite(acpiio, &val, 1, off) < 1)
  144. if(debug) DBG("outb(0x%x): %r\n", addr);
  145. }
  146. #define MKBUS(t,b,d,f) (((t)<<24)|(((b)&0xFF)<<16)|(((d)&0x1F)<<11)|(((f)&0x07)<<8))
  147. #define BUSFNO(tbdf) (((tbdf)>>8)&0x07)
  148. #define BUSDNO(tbdf) (((tbdf)>>11)&0x1F)
  149. #define BUSBNO(tbdf) (((tbdf)>>16)&0xFF)
  150. #define BUSTYPE(tbdf) ((tbdf)>>24)
  151. #define BUSBDF(tbdf) ((tbdf)&0x00FFFF00)
  152. ACPI_STATUS
  153. AcpiOsReadPciConfiguration(ACPI_PCI_ID * PciId, UINT32 Reg, UINT64 * Value, UINT32 Width)
  154. {
  155. ACPI_STATUS ret = AE_OK;
  156. uint64_t val;
  157. int amt = 0;
  158. static char path[128];
  159. snprint(path, sizeof(path), "/dev/pci/%d.%d.%draw", PciId->Bus,
  160. PciId->Device, PciId->Function);
  161. int fd = open(path, OREAD);
  162. if (fd < 0) {
  163. if (debug)
  164. print("%s: open %s: %r\n", __func__, path);
  165. return AE_IO_ERROR;
  166. }
  167. switch (Width) {
  168. case 32:
  169. case 16:
  170. case 8:
  171. amt = pread(fd, Value, Width / 8, Reg);
  172. if (amt < Width / 8)
  173. ret = AE_IO_ERROR;
  174. break;
  175. default:
  176. sysfatal("Can't read pci: bad width %d\n", Width);
  177. }
  178. close(fd);
  179. if (amt > 0)
  180. memmove(&val, Value, amt);
  181. if (debug)
  182. fprint(2, "pciread 0x%x 0x%x 0x%x 0x%x/%d 0x%x %d\n", PciId->Bus,
  183. PciId->Device, PciId->Function, Reg, Width / 8, *Value, ret);
  184. return ret;
  185. }
  186. ACPI_STATUS
  187. AcpiOsWritePciConfiguration(ACPI_PCI_ID * PciId, UINT32 Reg, UINT64 Value, UINT32 Width)
  188. {
  189. ACPI_STATUS ret = AE_OK;
  190. static char path[128];
  191. snprint(path, sizeof(path), "/dev/pci/%d.%d.%draw", PciId->Bus,
  192. PciId->Device, PciId->Function);
  193. int fd = open(path, ORDWR);
  194. if (fd < 0) {
  195. print("%s: open %s: %r\n", __func__, path);
  196. return AE_IO_ERROR;
  197. }
  198. switch (Width) {
  199. case 32:
  200. case 16:
  201. case 8:
  202. {
  203. int amt = pwrite(fd, &Value, Width / 8, Reg);
  204. if (amt < Width / 8)
  205. ret = AE_IO_ERROR;
  206. break;
  207. }
  208. default:
  209. sysfatal("Can't read pci: bad width %d\n", Width);
  210. }
  211. close(fd);
  212. if (debug)
  213. fprint(2, "pciwrite 0x%x 0x%x 0x%x 0x%x/%d 0x%x %d\n", PciId->Bus,
  214. PciId->Device, PciId->Function, Reg, Width / 8, Value, ret);
  215. return ret;
  216. }
  217. /*
  218. * Miscellaneous
  219. */
  220. BOOLEAN
  221. AcpiOsReadable(void *Pointer, ACPI_SIZE Length)
  222. {
  223. if (debug)
  224. fprint(2, "%s\n", __func__);
  225. sysfatal("%s", __func__);
  226. return AE_OK;
  227. }
  228. BOOLEAN
  229. AcpiOsWritable(void *Pointer, ACPI_SIZE Length)
  230. {
  231. if (debug)
  232. fprint(2, "%s\n", __func__);
  233. sysfatal("%s", __func__);
  234. return AE_OK;
  235. }
  236. UINT64
  237. AcpiOsGetTimer(void)
  238. {
  239. if (debug)
  240. fprint(2, "%s\n", __func__);
  241. // Return value should be in 100ns units
  242. int64_t ns = nsec();
  243. return ns / 100;
  244. }
  245. ACPI_STATUS
  246. AcpiOsSignal(UINT32 Function, void *Info)
  247. {
  248. if (debug)
  249. fprint(2, "%s\n", __func__);
  250. sysfatal("%s", __func__);
  251. return AE_OK;
  252. }
  253. /* N.B. Only works for single thread! */
  254. void ACPI_INTERNAL_VAR_XFACE
  255. AcpiOsPrintf(const char *Format, ...)
  256. {
  257. static char buf[65536];
  258. va_list args;
  259. va_start(args, Format);
  260. vseprint(buf, &buf[65535], (char *)Format, args);
  261. va_end(args);
  262. if (debug)
  263. fprint(2, buf);
  264. }
  265. void
  266. AcpiOsVprintf(const char *Format, va_list Args)
  267. {
  268. /* This is a leaf function, and this function is required to implement
  269. * the va_list argument. I couldn't find any other way to do this. */
  270. static char buf[1024];
  271. vseprint(buf, &buf[1023], (char *)Format, Args);
  272. if (debug)
  273. fprint(2, buf);
  274. }
  275. void
  276. AcpiOsFree(void *Memory)
  277. {
  278. //fprint(2,"%s\n", __func__);
  279. free(Memory);
  280. }
  281. void *
  282. AcpiOsAllocate(ACPI_SIZE Size)
  283. {
  284. //fprint(2,"%s\n", __func__);
  285. return malloc(Size);
  286. }
  287. void hexdump(void *v, int length);
  288. void *
  289. AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS Where, ACPI_SIZE Length)
  290. {
  291. int fd, amt;
  292. fd = rawfd();
  293. if (debug)
  294. fprint(2, "%s %p %d\n", __func__, (void *)Where, Length);
  295. void *v = malloc(Length);
  296. if (!v) {
  297. sysfatal("%s: %r", __func__);
  298. return nil;
  299. }
  300. fd = rawfd();
  301. if (fd < 0) {
  302. if (debug)
  303. fprint(2, "%s: open %s: %r\n", __func__, name);
  304. return nil;
  305. }
  306. amt = pread(fd, v, Length, Where);
  307. close(fd);
  308. /* If we just do the amt < Length test, it will not work when
  309. * amt is -1. Length is uint64_t. */
  310. if ((amt < 0) || (amt < Length)) {
  311. free(v);
  312. if (debug)
  313. fprint(2, "%s: read %s: %r\n", __func__, name);
  314. return nil;
  315. }
  316. //hexdump(v, Length);
  317. //hexdump(v, 36);
  318. return v;
  319. }
  320. void
  321. AcpiOsUnmapMemory(void *LogicalAddress, ACPI_SIZE Size)
  322. {
  323. free(LogicalAddress);
  324. if (debug)
  325. fprint(2, "%s %p %d \n", __func__, LogicalAddress, Size);
  326. }
  327. ACPI_STATUS
  328. AcpiOsGetPhysicalAddress(void *LogicalAddress,
  329. ACPI_PHYSICAL_ADDRESS * PhysicalAddress)
  330. {
  331. ACPI_PHYSICAL_ADDRESS ret = (uintptr_t) LogicalAddress;
  332. if (debug)
  333. fprint(2, "%s %p = %p", __func__, (void *)ret, LogicalAddress);
  334. *PhysicalAddress = ret;
  335. return AE_OK;
  336. }
  337. /* This is the single threaded version of
  338. * these functions. This is now NetBSD does it. */
  339. ACPI_STATUS
  340. AcpiOsCreateSemaphore(UINT32 MaxUnits,
  341. UINT32 InitialUnits, ACPI_SEMAPHORE * OutHandle)
  342. {
  343. //fprint(2,"%s\n", __func__);
  344. *OutHandle = (ACPI_SEMAPHORE) 1;
  345. return AE_OK;
  346. }
  347. ACPI_STATUS
  348. AcpiOsDeleteSemaphore(ACPI_SEMAPHORE Handle)
  349. {
  350. //fprint(2,"%s\n", __func__);
  351. return AE_OK;
  352. }
  353. ACPI_STATUS
  354. AcpiOsWaitSemaphore(ACPI_SEMAPHORE Handle, UINT32 Units, UINT16 Timeout)
  355. {
  356. //fprint(2,"%s\n", __func__);
  357. return AE_OK;
  358. }
  359. ACPI_STATUS
  360. AcpiOsSignalSemaphore(ACPI_SEMAPHORE Handle, UINT32 Units)
  361. {
  362. //fprint(2,"%s\n", __func__);
  363. return AE_OK;
  364. }
  365. /* this is the single threaded case and as minix shows there is nothing to do. */
  366. ACPI_STATUS
  367. AcpiOsCreateLock(ACPI_SPINLOCK * OutHandle)
  368. {
  369. //fprint(2,"%s\n", __func__);
  370. *OutHandle = nil;
  371. return AE_OK;
  372. }
  373. void
  374. AcpiOsDeleteLock(ACPI_SPINLOCK Handle)
  375. {
  376. //fprint(2,"%s\n", __func__);
  377. }
  378. ACPI_CPU_FLAGS
  379. AcpiOsAcquireLock(ACPI_SPINLOCK Handle)
  380. {
  381. //fprint(2,"%s\n", __func__);
  382. return 0;
  383. }
  384. void
  385. AcpiOsReleaseLock(ACPI_SPINLOCK Handle, ACPI_CPU_FLAGS Flags)
  386. {
  387. //fprint(2,"%s\n", __func__);
  388. }
  389. struct handler {
  390. ACPI_OSD_HANDLER ServiceRoutine;
  391. void *Context;
  392. };
  393. static struct handler ihandler;
  394. unsigned int
  395. AcpiIntrWait(int afd, unsigned int *info)
  396. {
  397. int amt;
  398. amt = read(afd, info, sizeof(*info));
  399. if (amt < 1) {
  400. print("ACPI intrwait: eof: %r");
  401. }
  402. if (amt < sizeof(info)) {
  403. print("ACPI intrwait: short read: %r");
  404. }
  405. return amt;
  406. }
  407. ACPI_STATUS AcpiRunInterrupt(void)
  408. {
  409. return ihandler.ServiceRoutine(ihandler.Context);
  410. }
  411. ACPI_STATUS
  412. AcpiOsInstallInterruptHandler(
  413. UINT32 InterruptNumber, ACPI_OSD_HANDLER ServiceRoutine, void *Context)
  414. {
  415. ihandler.ServiceRoutine = ServiceRoutine;
  416. ihandler.Context = Context;
  417. return AE_OK;
  418. }
  419. ACPI_STATUS
  420. AcpiOsRemoveInterruptHandler(UINT32 InterruptNumber, ACPI_OSD_HANDLER ServiceRoutine)
  421. {
  422. if (debug)
  423. fprint(2, "%s\n", __func__);
  424. /* No need to even do this call. Since we're user mode, we exit. */
  425. return AE_OK;
  426. }
  427. void
  428. AcpiOsWaitEventsComplete(void)
  429. {
  430. if (debug)
  431. fprint(2, "%s\n", __func__);
  432. sysfatal("%s", __func__);
  433. }
  434. void
  435. AcpiOsSleep(UINT64 Milliseconds)
  436. {
  437. if (debug)
  438. fprint(2, "%s\n", __func__);
  439. sleep(Milliseconds);
  440. }
  441. void
  442. AcpiOsStall(UINT32 Microseconds)
  443. {
  444. if (debug)
  445. fprint(2, "%s\n", __func__);
  446. sleep(Microseconds / 1000 + 1);
  447. }
  448. ACPI_THREAD_ID
  449. AcpiOsGetThreadId(void)
  450. {
  451. static int pid = 2525;
  452. if (pid < 0)
  453. pid = getpid();
  454. return pid;
  455. }
  456. ACPI_STATUS
  457. AcpiOsExecute(ACPI_EXECUTE_TYPE Type,
  458. ACPI_OSD_EXEC_CALLBACK Function, void *Context)
  459. {
  460. ACPI_STATUS ret = AE_OK;
  461. if (debug)
  462. fprint(2, "%s\n", __func__);
  463. Function(Context);
  464. return ret;
  465. }
  466. ACPI_STATUS
  467. AcpiOsReadPort(ACPI_IO_ADDRESS Address, UINT32 * Value, UINT32 Width)
  468. {
  469. switch (Width) {
  470. case 4 * 8:
  471. *Value = inl(Address);
  472. break;
  473. case 2 * 8:
  474. *Value = ins(Address);
  475. break;
  476. case 1 * 8:
  477. *Value = inb(Address);
  478. break;
  479. default:
  480. sysfatal("%s, bad width %d", __func__, Width);
  481. break;
  482. }
  483. if (debug)
  484. fprint(2, "%s 0x%x 0x%x\n", __func__, Address, *Value);
  485. return AE_OK;
  486. }
  487. ACPI_STATUS
  488. AcpiOsWritePort(ACPI_IO_ADDRESS Address, UINT32 Value, UINT32 Width)
  489. {
  490. switch (Width) {
  491. case 4 * 8:
  492. outl(Address, Value);
  493. break;
  494. case 2 * 8:
  495. outs(Address, Value);
  496. break;
  497. case 1 * 8:
  498. outb(Address, Value);
  499. break;
  500. default:
  501. sysfatal("%s, bad width %d", __func__, Width);
  502. break;
  503. }
  504. if (debug)
  505. fprint(2, "%s 0x%x 0x%x\n", __func__, Address, Value);
  506. return AE_OK;
  507. }
  508. /*
  509. * Platform and hardware-independent physical memory interfaces
  510. */
  511. ACPI_STATUS
  512. AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 * Value, UINT32 Width)
  513. {
  514. if (debug)
  515. fprint(2, "%s\n", __func__);
  516. sysfatal("%s", __func__);
  517. return AE_OK;
  518. }
  519. ACPI_STATUS
  520. AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 Value, UINT32 Width)
  521. {
  522. if (debug)
  523. fprint(2, "%s\n", __func__);
  524. sysfatal("%s", __func__);
  525. return AE_OK;
  526. }
  527. /* Just try to read the rsdp, if that fails, we're screwed anyway. */
  528. ACPI_STATUS
  529. AcpiOsInitialize(void)
  530. {
  531. int fd, amt;
  532. if (debug)
  533. fprint(2, "%s\n", __func__);
  534. fd = rawfd();
  535. if (fd < 0) {
  536. if (debug)
  537. fprint(2, "%s: open %s: %r\n", __func__, name);
  538. return AE_ERROR;
  539. }
  540. amt = read(fd, &rsdp, sizeof(rsdp));
  541. if (amt < sizeof(rsdp)) {
  542. if (debug)
  543. fprint(2, "%s: read %s: %r\n", __func__, name);
  544. return AE_ERROR;
  545. }
  546. close(fd);
  547. acpiio = open("/dev/acpiio", ORDWR);
  548. if (acpiio < 0)
  549. sysfatal("acpiio: %r");
  550. return AE_OK;
  551. }
  552. /*
  553. * ACPI Table interfaces
  554. */
  555. __attribute__ ((weak))ACPI_PHYSICAL_ADDRESS
  556. AcpiOsGetRootPointer(void)
  557. {
  558. if (debug)
  559. fprint(2, "%s returns %p\n", __func__, rsdp);
  560. return (ACPI_PHYSICAL_ADDRESS) rsdp;
  561. }
  562. ACPI_STATUS
  563. AcpiOsPredefinedOverride(const ACPI_PREDEFINED_NAMES * InitVal,
  564. ACPI_STRING * NewVal)
  565. {
  566. if (debug)
  567. fprint(2, "%s\n", __func__);
  568. *NewVal = nil;
  569. return AE_OK;
  570. }
  571. ACPI_STATUS
  572. AcpiOsTableOverride(ACPI_TABLE_HEADER * ExistingTable,
  573. ACPI_TABLE_HEADER ** NewTable)
  574. {
  575. if (debug)
  576. fprint(2, "%s\n", __func__);
  577. *NewTable = nil;
  578. return AE_OK;
  579. }
  580. ACPI_STATUS
  581. AcpiOsPhysicalTableOverride(
  582. ACPI_TABLE_HEADER * ExistingTable,
  583. ACPI_PHYSICAL_ADDRESS * NewAddress,
  584. UINT32 * NewTableLength)
  585. {
  586. if (debug)
  587. fprint(2, "%s\n", __func__);
  588. *NewAddress = (ACPI_PHYSICAL_ADDRESS) nil;
  589. return AE_OK;
  590. }
  591. /*
  592. * Debug input
  593. */
  594. ACPI_STATUS
  595. AcpiOsGetLine(char *Buffer, UINT32 BufferLength, UINT32 * BytesRead)
  596. {
  597. int amt;
  598. if (debug)
  599. fprint(2, "%s\n", __func__);
  600. amt = read(0, Buffer, BufferLength);
  601. if (BytesRead)
  602. *BytesRead = amt;
  603. return AE_OK;
  604. }
  605. ACPI_STATUS
  606. AcpiOsTerminate(void)
  607. {
  608. sysfatal("%s\n", __func__);
  609. return AE_OK;
  610. }
  611. /* Another acpica failure of vision: code in libraries that depends on functions defined only
  612. * in the compiler or other programs. Really! What to do?
  613. * this is how the acpi tools do it. Save we add a print so we know the function is called, duh! */
  614. typedef void *ACPI_PARSE_OBJECT;
  615. typedef void *AML_RESOURCE;
  616. /* this is from acpiexec. */
  617. /* For AcpiExec only */
  618. __attribute__ ((weak))void
  619. AeDoObjectOverrides(void)
  620. {
  621. if (debug)
  622. fprint(2, "%s\n", __func__);
  623. }
  624. /* Stubs for the disassembler */
  625. __attribute__ ((weak))
  626. void
  627. MpSaveGpioInfo(
  628. ACPI_PARSE_OBJECT * Op,
  629. AML_RESOURCE * Resource,
  630. UINT32 PinCount, UINT16 * PinList, char *DeviceName)
  631. {
  632. if (debug)
  633. fprint(2, "%s\n", __func__);
  634. }
  635. __attribute__ ((weak))
  636. void
  637. MpSaveSerialInfo(
  638. ACPI_PARSE_OBJECT * Op,
  639. AML_RESOURCE * Resource, char *DeviceName)
  640. {
  641. if (debug)
  642. fprint(2, "%s\n", __func__);
  643. }
  644. int
  645. AcpiOsWriteFile(ACPI_FILE File, void *Buffer, ACPI_SIZE Size, ACPI_SIZE Count)
  646. {
  647. if (debug)
  648. fprint(2, "%s(%p, %p, %d, %d);\n", File, Buffer, Size, Count);
  649. return write(1, Buffer, Size * Count);
  650. }
  651. __attribute__ ((weak))
  652. void hexdump(void *v, int length)
  653. {
  654. int i;
  655. uint8_t *m = v;
  656. uintptr_t memory = (uintptr_t) v;
  657. int all_zero = 0;
  658. print("hexdump: %p, %u\n", v, length);
  659. for (i = 0; i < length; i += 16) {
  660. int j;
  661. all_zero++;
  662. for (j = 0; (j < 16) && (i + j < length); j++) {
  663. if (m[i + j] != 0) {
  664. all_zero = 0;
  665. break;
  666. }
  667. }
  668. if (all_zero < 2) {
  669. print("%p:", (void *)(memory + i));
  670. for (j = 0; j < 16; j++)
  671. print(" %02x", m[i + j]);
  672. print(" ");
  673. for (j = 0; j < 16; j++)
  674. print("%c", isprint(m[i + j]) ? m[i + j] : '.');
  675. print("\n");
  676. } else if (all_zero == 2) {
  677. print("...\n");
  678. }
  679. }
  680. }
  681. ACPI_STATUS AcpiOsEnterSleep(UINT8 SleepState, UINT32 RegA, UINT32 RegB)
  682. {
  683. return AE_OK;
  684. }
  685. ACPI_STATUS AcpiOsWaitCommandReady()
  686. {
  687. return AE_CTRL_TERMINATE;
  688. }
  689. ACPI_STATUS AcpiOsNotifyCommandComplete()
  690. {
  691. return AE_CTRL_TERMINATE;
  692. }