debug.asl 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (C) 2008 Advanced Micro Devices, Inc.
  3. * Copyright (C) 2016 Bin Meng <bmeng.cn@gmail.com>
  4. *
  5. * Modified from coreboot src/arch/x86/acpi/debug.asl
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. /* POST register region */
  10. OperationRegion(X80, SystemIO, 0x80, 1)
  11. Field(X80, ByteAcc, NoLock, Preserve)
  12. {
  13. P80, 8
  14. }
  15. /* Legacy serial port register region */
  16. OperationRegion(CREG, SystemIO, 0x3F8, 8)
  17. Field(CREG, ByteAcc, NoLock, Preserve)
  18. {
  19. CDAT, 8,
  20. CDLM, 8,
  21. , 8,
  22. CLCR, 8,
  23. CMCR, 8,
  24. CLSR, 8
  25. }
  26. /* DINI - Initialize the serial port to 115200 8-N-1 */
  27. Method(DINI)
  28. {
  29. Store(0x83, CLCR)
  30. Store(0x01, CDAT) /* 115200 baud (low) */
  31. Store(0x00, CDLM) /* 115200 baud (high) */
  32. Store(0x03, CLCR) /* word=8 stop=1 parity=none */
  33. Store(0x03, CMCR) /* DTR=1 RTS=1 out1/2=Off loop=Off */
  34. Store(0x00, CDLM) /* turn off interrupts */
  35. }
  36. /* THRE - Wait for serial port transmitter holding register to go empty */
  37. Method(THRE)
  38. {
  39. And(CLSR, 0x20, Local0)
  40. While (LEqual(Local0, Zero)) {
  41. And(CLSR, 0x20, Local0)
  42. }
  43. }
  44. /* OUTX - Send a single raw character */
  45. Method(OUTX, 1)
  46. {
  47. THRE()
  48. Store(Arg0, CDAT)
  49. }
  50. /* OUTC - Send a single character, expanding LF into CR/LF */
  51. Method(OUTC, 1)
  52. {
  53. If (LEqual(Arg0, 0x0a)) {
  54. OUTX(0x0d)
  55. }
  56. OUTX(Arg0)
  57. }
  58. /* DBGN - Send a single hex nibble */
  59. Method(DBGN, 1)
  60. {
  61. And(Arg0, 0x0f, Local0)
  62. If (LLess(Local0, 10)) {
  63. Add(Local0, 0x30, Local0)
  64. } Else {
  65. Add(Local0, 0x37, Local0)
  66. }
  67. OUTC(Local0)
  68. }
  69. /* DBGB - Send a hex byte */
  70. Method(DBGB, 1)
  71. {
  72. ShiftRight(Arg0, 4, Local0)
  73. DBGN(Local0)
  74. DBGN(Arg0)
  75. }
  76. /* DBGW - Send a hex word */
  77. Method(DBGW, 1)
  78. {
  79. ShiftRight(Arg0, 8, Local0)
  80. DBGB(Local0)
  81. DBGB(Arg0)
  82. }
  83. /* DBGD - Send a hex dword */
  84. Method(DBGD, 1)
  85. {
  86. ShiftRight(Arg0, 16, Local0)
  87. DBGW(Local0)
  88. DBGW(Arg0)
  89. }
  90. /* Get a char from a string */
  91. Method(GETC, 2)
  92. {
  93. CreateByteField(Arg0, Arg1, DBGC)
  94. Return (DBGC)
  95. }
  96. /* DBGO - Send either a string or an integer */
  97. Method(DBGO, 1, Serialized)
  98. {
  99. If (LEqual(ObjectType(Arg0), 1)) {
  100. If (LGreater(Arg0, 0xffff)) {
  101. DBGD(Arg0)
  102. } Else {
  103. If (LGreater(Arg0, 0xff)) {
  104. DBGW(Arg0)
  105. } Else {
  106. DBGB(Arg0)
  107. }
  108. }
  109. } Else {
  110. Name(BDBG, Buffer(80) {})
  111. Store(Arg0, BDBG)
  112. Store(0, Local1)
  113. While (One) {
  114. Store(GETC(BDBG, Local1), Local0)
  115. If (LEqual(Local0, 0)) {
  116. Return (Zero)
  117. }
  118. OUTC(Local0)
  119. Increment(Local1)
  120. }
  121. }
  122. Return (Zero)
  123. }