Joe Bao | 806def8 | 2008-12-02 02:56:38 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008 Advanced Micro Devices, Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
Paul Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Joe Bao | 806def8 | 2008-12-02 02:56:38 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | /* |
| 21 | DefinitionBlock ( |
| 22 | "DSDT.AML", |
| 23 | "DSDT", |
| 24 | 0x01, |
| 25 | "XXXXXX", |
| 26 | "XXXXXXXX", |
| 27 | 0x00010001 |
| 28 | ) |
| 29 | { |
Patrick Georgi | af97d33 | 2010-02-08 15:46:37 +0000 | [diff] [blame] | 30 | #include "debug.asl" |
Joe Bao | 806def8 | 2008-12-02 02:56:38 +0000 | [diff] [blame] | 31 | } |
| 32 | */ |
| 33 | |
| 34 | /* |
| 35 | * 0x80: POST_BASE |
| 36 | * 0x3F8: DEBCOM_BASE |
| 37 | * X80: POST_REGION |
| 38 | * P80: PORT80 |
| 39 | * |
| 40 | * CREG: DEBCOM_REGION |
| 41 | * CUAR: DEBCOM_UART |
| 42 | * CDAT: DEBCOM_DATA |
| 43 | * CDLM: DEBCOM_DLM |
| 44 | * DLCR: DEBCOM_LCR |
| 45 | * CMCR: DEBCOM_MCR |
| 46 | * CLSR: DEBCOM_LSR |
| 47 | * |
| 48 | * DEBUG_INIT DINI |
| 49 | */ |
| 50 | |
| 51 | OperationRegion(X80, SystemIO, 0x80, 1) |
| 52 | Field(X80, ByteAcc, NoLock, Preserve) |
| 53 | { |
| 54 | P80, 8 |
| 55 | } |
| 56 | |
| 57 | OperationRegion(CREG, SystemIO, 0x3F8, 8) |
| 58 | Field(CREG, ByteAcc, NoLock, Preserve) |
| 59 | { |
| 60 | CDAT, 8, |
| 61 | CDLM, 8,, 8, DLCR, 8, CMCR, 8, CLSR, 8 |
| 62 | } |
| 63 | |
| 64 | /* |
| 65 | * DINI |
| 66 | * Initialize the COM port to 115,200 8-N-1 |
| 67 | */ |
| 68 | Method(DINI) |
| 69 | { |
| 70 | store(0x83, DLCR) |
| 71 | store(0x01, CDAT) /* 115200 baud (low) */ |
| 72 | store(0x00, CDLM) /* 115200 baud (high) */ |
| 73 | store(0x03, DLCR) /* word=8 stop=1 parity=none */ |
| 74 | store(0x03, CMCR) /* DTR=1 RTS=1 Out2=Off Loop=Off */ |
| 75 | store(0x00, CDLM) /* turn off interrupts */ |
| 76 | } |
| 77 | |
| 78 | /* |
| 79 | * THRE |
| 80 | * Wait for COM port transmitter holding register to go empty |
| 81 | */ |
| 82 | Method(THRE) |
| 83 | { |
| 84 | and(CLSR, 0x20, local0) |
| 85 | while (Lequal(local0, Zero)) { |
| 86 | and(CLSR, 0x20, local0) |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | /* |
| 91 | * OUTX |
| 92 | * Send a single raw character |
| 93 | */ |
| 94 | Method(OUTX, 1) |
| 95 | { |
| 96 | THRE() |
| 97 | store(Arg0, CDAT) |
| 98 | } |
| 99 | |
| 100 | /* |
| 101 | * OUTC |
| 102 | * Send a single character, expanding LF into CR/LF |
| 103 | */ |
| 104 | Method(OUTC, 1) |
| 105 | { |
| 106 | if (LEqual(Arg0, 0x0a)) { |
| 107 | OUTX(0x0d) |
| 108 | } |
| 109 | OUTX(Arg0) |
| 110 | } |
| 111 | |
| 112 | /* |
| 113 | * DBGN |
| 114 | * Send a single hex nibble |
| 115 | */ |
| 116 | Method(DBGN, 1) |
| 117 | { |
| 118 | and(Arg0, 0x0f, Local0) |
| 119 | if (LLess(Local0, 10)) { |
| 120 | add(Local0, 0x30, Local0) |
| 121 | } else { |
| 122 | add(Local0, 0x37, Local0) |
| 123 | } |
| 124 | OUTC(Local0) |
| 125 | } |
| 126 | |
| 127 | /* |
| 128 | * DBGB |
| 129 | * Send a hex byte |
| 130 | */ |
| 131 | Method(DBGB, 1) |
| 132 | { |
| 133 | ShiftRight(Arg0, 4, Local0) |
| 134 | DBGN(Local0) |
| 135 | DBGN(Arg0) |
| 136 | } |
| 137 | |
| 138 | /* |
| 139 | * DBGW |
| 140 | * Send a hex word |
| 141 | */ |
| 142 | Method(DBGW, 1) |
| 143 | { |
| 144 | ShiftRight(Arg0, 8, Local0) |
| 145 | DBGB(Local0) |
| 146 | DBGB(Arg0) |
| 147 | } |
| 148 | |
| 149 | /* |
| 150 | * DBGD |
| 151 | * Send a hex Dword |
| 152 | */ |
| 153 | Method(DBGD, 1) |
| 154 | { |
| 155 | ShiftRight(Arg0, 16, Local0) |
| 156 | DBGW(Local0) |
| 157 | DBGW(Arg0) |
| 158 | } |
| 159 | |
| 160 | /* |
| 161 | * DBGO |
| 162 | * Send either a string or an integer |
| 163 | */ |
| 164 | Method(DBGO, 1) |
| 165 | { |
| 166 | /* DINI() */ |
| 167 | if (LEqual(ObjectType(Arg0), 1)) { |
| 168 | if (LGreater(Arg0, 0xffff)) { |
| 169 | DBGD(Arg0) |
| 170 | } else { |
| 171 | if (LGreater(Arg0, 0xff)) { |
| 172 | DBGW(Arg0) |
| 173 | } else { |
| 174 | DBGB(Arg0) |
| 175 | } |
| 176 | } |
| 177 | } else { |
| 178 | Name(BDBG, Buffer(80) {}) |
| 179 | store(Arg0, BDBG) |
| 180 | store(0, Local1) |
| 181 | while (One) { |
| 182 | store(GETC(BDBG, Local1), Local0) |
| 183 | if (LEqual(Local0, 0)) { |
| 184 | return (0) |
| 185 | } |
| 186 | OUTC(Local0) |
| 187 | Increment(Local1) |
| 188 | } |
| 189 | } |
| 190 | return (0) |
| 191 | } |
| 192 | |
| 193 | /* Get a char from a string */ |
| 194 | Method(GETC, 2) |
| 195 | { |
| 196 | CreateByteField(Arg0, Arg1, DBGC) |
| 197 | return (DBGC) |
| 198 | } |