blob: 44c37bb9a0c70b8719b5a6c46371d5e4d1de973d [file] [log] [blame]
Joe Bao806def82008-12-02 02:56:38 +00001/*
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.
Joe Bao806def82008-12-02 02:56:38 +000014 */
15
16/*
17 DefinitionBlock (
18 "DSDT.AML",
19 "DSDT",
20 0x01,
21 "XXXXXX",
22 "XXXXXXXX",
23 0x00010001
24 )
25 {
Patrick Georgiaf97d332010-02-08 15:46:37 +000026 #include "debug.asl"
Joe Bao806def82008-12-02 02:56:38 +000027 }
28*/
29
30/*
31* 0x80: POST_BASE
32* 0x3F8: DEBCOM_BASE
33* X80: POST_REGION
34* P80: PORT80
35*
36* CREG: DEBCOM_REGION
37* CUAR: DEBCOM_UART
38* CDAT: DEBCOM_DATA
39* CDLM: DEBCOM_DLM
40* DLCR: DEBCOM_LCR
41* CMCR: DEBCOM_MCR
42* CLSR: DEBCOM_LSR
43*
44* DEBUG_INIT DINI
45*/
46
47OperationRegion(X80, SystemIO, 0x80, 1)
48 Field(X80, ByteAcc, NoLock, Preserve)
49{
50 P80, 8
51}
52
53OperationRegion(CREG, SystemIO, 0x3F8, 8)
54 Field(CREG, ByteAcc, NoLock, Preserve)
55{
56 CDAT, 8,
57 CDLM, 8,, 8, DLCR, 8, CMCR, 8, CLSR, 8
58}
59
60/*
61* DINI
62* Initialize the COM port to 115,200 8-N-1
63*/
64Method(DINI)
65{
66 store(0x83, DLCR)
67 store(0x01, CDAT) /* 115200 baud (low) */
68 store(0x00, CDLM) /* 115200 baud (high) */
69 store(0x03, DLCR) /* word=8 stop=1 parity=none */
70 store(0x03, CMCR) /* DTR=1 RTS=1 Out2=Off Loop=Off */
71 store(0x00, CDLM) /* turn off interrupts */
72}
73
74/*
75* THRE
76* Wait for COM port transmitter holding register to go empty
77*/
78Method(THRE)
79{
80 and(CLSR, 0x20, local0)
81 while (Lequal(local0, Zero)) {
82 and(CLSR, 0x20, local0)
83 }
84}
85
86/*
87* OUTX
88* Send a single raw character
89*/
90Method(OUTX, 1)
91{
92 THRE()
93 store(Arg0, CDAT)
94}
95
96/*
97* OUTC
98* Send a single character, expanding LF into CR/LF
99*/
100Method(OUTC, 1)
101{
102 if (LEqual(Arg0, 0x0a)) {
103 OUTX(0x0d)
104 }
105 OUTX(Arg0)
106}
107
108/*
109* DBGN
110* Send a single hex nibble
111*/
112Method(DBGN, 1)
113{
114 and(Arg0, 0x0f, Local0)
115 if (LLess(Local0, 10)) {
116 add(Local0, 0x30, Local0)
117 } else {
118 add(Local0, 0x37, Local0)
119 }
120 OUTC(Local0)
121}
122
123/*
124* DBGB
125* Send a hex byte
126*/
127Method(DBGB, 1)
128{
129 ShiftRight(Arg0, 4, Local0)
130 DBGN(Local0)
131 DBGN(Arg0)
132}
133
134/*
135* DBGW
136* Send a hex word
137*/
138Method(DBGW, 1)
139{
140 ShiftRight(Arg0, 8, Local0)
141 DBGB(Local0)
142 DBGB(Arg0)
143}
144
145/*
146* DBGD
147* Send a hex Dword
148*/
149Method(DBGD, 1)
150{
151 ShiftRight(Arg0, 16, Local0)
152 DBGW(Local0)
153 DBGW(Arg0)
154}
155
156/*
157* DBGO
158* Send either a string or an integer
159*/
160Method(DBGO, 1)
161{
162 /* DINI() */
163 if (LEqual(ObjectType(Arg0), 1)) {
164 if (LGreater(Arg0, 0xffff)) {
165 DBGD(Arg0)
166 } else {
167 if (LGreater(Arg0, 0xff)) {
168 DBGW(Arg0)
169 } else {
170 DBGB(Arg0)
171 }
172 }
173 } else {
174 Name(BDBG, Buffer(80) {})
175 store(Arg0, BDBG)
176 store(0, Local1)
177 while (One) {
178 store(GETC(BDBG, Local1), Local0)
179 if (LEqual(Local0, 0)) {
180 return (0)
181 }
182 OUTC(Local0)
183 Increment(Local1)
184 }
185 }
186 return (0)
187}
188
189/* Get a char from a string */
190Method(GETC, 2)
191{
192 CreateByteField(Arg0, Arg1, DBGC)
193 return (DBGC)
194}