debug.asl 2.3 KB

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