irq.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. extern void *ACPIRootPointer;
  11. extern int ACPITableSize;
  12. extern UINT32 AcpiDbgLevel;
  13. void hexdump(void *v, int length)
  14. {
  15. int i;
  16. uint8_t *m = v;
  17. uintptr_t memory = (uintptr_t) v;
  18. int all_zero = 0;
  19. print("hexdump: %p, %u\n", v, length);
  20. for (i = 0; i < length; i += 16) {
  21. int j;
  22. all_zero++;
  23. for (j = 0; (j < 16) && (i + j < length); j++) {
  24. if (m[i + j] != 0) {
  25. all_zero = 0;
  26. break;
  27. }
  28. }
  29. if (all_zero < 2) {
  30. print("%p:", (void *)(memory + i));
  31. for (j = 0; j < 16; j++)
  32. print(" %02x", m[i + j]);
  33. print(" ");
  34. for (j = 0; j < 16; j++)
  35. print("%c", isprint(m[i + j]) ? m[i + j] : '.');
  36. print("\n");
  37. } else if (all_zero == 2) {
  38. print("...\n");
  39. }
  40. }
  41. }
  42. /* these go somewhere else, someday. */
  43. ACPI_STATUS FindIOAPICs(int *pic_mode);
  44. void
  45. main(int argc, char *argv[])
  46. {
  47. ACPI_STATUS status;
  48. AcpiDbgLevel = 0; //ACPI_LV_VERBOSITY1;
  49. print("hi\n");
  50. status = AcpiInitializeSubsystem();
  51. if (ACPI_FAILURE(status)) {
  52. sysfatal("Error %d\n", status);
  53. }
  54. status = AcpiInitializeTables(NULL, 0, FALSE);
  55. if (ACPI_FAILURE(status))
  56. sysfatal("can't set up acpi tables: %d", status);
  57. print("initit dables\n");
  58. status = AcpiLoadTables();
  59. if (ACPI_FAILURE(status))
  60. sysfatal("Can't load ACPI tables: %d", status);
  61. /* from acpi: */
  62. /* If the Hardware Reduced flag is set, machine is always in acpi mode */
  63. AcpiGbl_ReducedHardware = 1;
  64. print("LOADED TABLES. Hi the any key to continue\n"); //getchar();
  65. status = AcpiEnableSubsystem(0);
  66. if (ACPI_FAILURE(status))
  67. print("Probably does not matter: Can't enable ACPI subsystem");
  68. print("enabled subsystem. Hi the any key to continue\n"); //getchar();
  69. status = AcpiInitializeObjects(0);
  70. if (ACPI_FAILURE(status))
  71. sysfatal("Can't Initialize ACPI objects");
  72. int picmode;
  73. status = FindIOAPICs(&picmode);
  74. print("FindIOAPICs returns status %d picmode %d\n", status, picmode);
  75. print("inited objects. Hi the any key to continue\n"); //getchar();
  76. AcpiDbgLevel |= ACPI_LV_VERBOSITY1 | ACPI_LV_FUNCTIONS;
  77. AcpiDbgLevel = 0;
  78. status = AcpiInitializeDebugger();
  79. if (ACPI_FAILURE(status)) {
  80. sysfatal("Error %d\n", status);
  81. }
  82. ACPI_STATUS RouteIRQ(ACPI_PCI_ID* device, int pin, int* irq);
  83. AcpiDbgLevel = 0;
  84. ACPI_PCI_ID id = (ACPI_PCI_ID){0, 0, 2, 0};
  85. int irq;
  86. //for(int i = 0; i < 4; i++) {
  87. status = RouteIRQ(&id, 0, &irq);
  88. print("status %d, irq %d\n", status, irq);
  89. //}
  90. // }
  91. AcpiDbgLevel = 0;
  92. //ACPI_STATUS PrintDevices(void);
  93. //status = PrintDevices();
  94. print("OK on init.\n");
  95. exits(0);
  96. }