blob: bdb0097cd3b7b27c2676f8aef7e82ff0428457cf [file] [log] [blame]
T Michael Turney5c49d182018-04-24 11:02:23 -07001;============================================================================
2;##
3;## This file is part of the coreboot project.
4;##
5;## Copyright (C) 2018, The Linux Foundation. All rights reserved.
6;##
7;## This program is free software; you can redistribute it and/or modify
8;## it under the terms of the GNU General Public License version 2 and
9;## only version 2 as published by the Free Software Foundation.
10;##
11;## This program is distributed in the hope that it will be useful,
12;## but WITHOUT ANY WARRANTY; without even the implied warranty of
13;## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;## GNU General Public License for more details.
15;##
16;============================================================================
17; Name:
18; debug_cb_common.cmm
19;
20; Description:
21; Debug coreboot Environment
22;============================================================================
23
24;============================================================================
25; CMM script variables
26;============================================================================
27
28LOCAL &BBStage // Bootblock Stage stop?
29LOCAL &VERStage // Verify Stage stop?
30LOCAL &ROMStage // Rom Stage stop?
31LOCAL &QCLStage // QCL Stage stop?
32LOCAL &RAMStage // Ram Stage stop?
33LOCAL &BL31Stage // BL31 Stage stop?
34LOCAL &DCStage // Depthcharge Stage stop?
35
36LOCAL &KernelSyms // Load Kernel Symbols?
37
38LOCAL &RAMLoad // T32 Load Code?
39
40;============================================================================
41
42;---------------------------------------------------
43; Entry point
44;---------------------------------------------------
45ENTRY &TargetPkg &srcpath &xblsrcpath &ImageName
46
47 // Parse for RAMLoad first
48 if (STR.CP("&ImageName","RAM,*"))
49 (
50 &RAMLoad=TRUE()
51 &ImageName=STR.CUT("&ImageName",4)
52 )
53 else
54 &RAMLoad=FALSE()
55
56 // Parse &ImageName the easy way
57 if (STR.CP("&ImageName","*ALL*"))
58 (
59 &BBStage=TRUE()
60 &VERStage=TRUE()
61 &ROMStage=TRUE()
62 &QCLStage=TRUE()
63 &RAMStage=TRUE()
64 ;&BL31Stage=TRUE()
65 &DCStage=TRUE()
66 &KernelSyms=STRING.CP("&ImageName", "*KERNEL*")
67 )
68 else
69 (
70 &BBStage=STRING.CP("&ImageName","*BB*")
71 &VERStage=STRING.CP("&ImageName","*VER*")
72 &ROMStage=STRING.CP("&ImageName","*ROM*")
73 &QCLStage=STRING.CP("&ImageName","*QCL*")
74 &RAMStage=STRING.CP("&ImageName","*RAM*")
75 &BL31Stage=STRING.CP("&ImageName","*BL31*")
76 &DCStage=STRING.CP("&ImageName","*DC*")
77 &KernelSyms=STRING.CP("&ImageName", "*KERNEL*")
78 )
79
80 PRINT %String "Debug Script: debug_cb_common.cmm"
81 PRINT %String "Images to debug: &ImageName"
82 PRINT %String "Loading Kernel Symbols: &KernelSyms"
83 PRINT %String "RAMLoad Requested: &RAMLoad"
84 PRINT %String "BootBlock Entry Addr: &BBEntryAddr"
85 PRINT %String "VerStage Entry Addr: &VEREntryAddr"
86 PRINT %String "RomStage Entry Addr: &ROMEntryAddr"
87 PRINT %String "QCLStage Entry Addr: &QCLEntryAddr"
88 PRINT %String "RamStage Entry Addr: &RAMEntryAddr"
89 PRINT %String "BL31 Entry Addr: &BL31EntryAddr"
90 PRINT %String "DepthCharge Entry Addr: &DCEntryAddr"
91 PRINT %String "Kernel Entry Addr: &KernelEntryAddr"
92 PRINT %String "PreRamCbfsCache: &PreRamCbfsCache"
93 PRINT %String "PreRamConsoleAddr: &PreRamConsoleAddr"
94 PRINT %String "VBoot2Work: &VBoot2Work"
95 PRINT %String "Stack: &Stack"
96 PRINT %String "Ttb: &Ttb"
97 PRINT %String "Timestamp &Timestamp"
98 PRINT %String "RamConsoleAddr &RamConsoleAddr"
99 PRINT %String "CbmemTop &CbmemTop"
100 PRINT %String "PostRamCbfsCache &PostRamCbfsCache"
101
102 // HW at BB entry, first stop: bootblock
103 ////////////////////////////////////////
104
105 if &BBStage
106 (
107 &imgpath="build\cbfs\fallback\bootblock.elf"
108 if (&RAMLoad)
109 d.load.elf &imgpath /strippart "coreboot" /sourcepath &srcpath
110 else
111 d.load.elf &imgpath /strippart "coreboot" /sourcepath &srcpath /nocode
112
113 ;uncomment b.s if not simulating (CONFIG_SOC_SIMULATE)
114 ;b.s run_romstage /o
115 ;d.set &PreRamConsoleAddr++0x8000 0
116 d.dump &PreRamConsoleAddr /spotlight
117 print %String "Now the control is in BootBlock, press enter after debugging to go to next stage"
118 print %String "Press enter to go to next stage"
119 enter
120 )
121
122 go &VEREntryAddr
123 wait !run()
124
125 if &VERStage
126 (
127 &imgpath="build\cbfs\fallback\verstage.elf"
128 if (&RAMLoad)
129 d.load.elf &imgpath /strippart "coreboot" /sourcepath &srcpath /noclear
130 else
131 d.load.elf &imgpath /strippart "coreboot" /sourcepath &srcpath /nocode /noclear
132
133 print %String "Now the control is in VERStage, press enter after debugging to go to next stage"
134 print %String "Press enter to go to next stage"
135 enter
136 )
137
138 go &ROMEntryAddr
139 wait !run()
140
141 if &ROMStage
142 (
143 &imgpath="build\cbfs\fallback\romstage.elf"
144 if (&RAMLoad)
145 d.load.elf &imgpath /strippart "coreboot" /sourcepath &srcpath
146 else
147 d.load.elf &imgpath /strippart "coreboot" /sourcepath &srcpath /nocode
148
149 print %String "Now the control is in ROMStage, press enter after debugging to go to next stage"
150 print %String "Press enter to go to next stage"
151 enter
152 )
153
154; go &QCLEntryAddr
155; wait !run()
156;
157; if &QCLStage
158; (
159; &imgpath="3rdparty\blobs\soc\qualcomm\sdm845\QcLib.elf"
160; if (&RAMLoad)
161; d.load.elf &imgpath /strippart "coreboot" /sourcepath &srcpath /noclear
162; else
163; d.load.elf &imgpath /strippart "coreboot" /sourcepath &srcpath /nocode /noclear
164;
165; print %String "Now the control is in QCLStage, press enter after debugging to go to next stage"
166; print %String "Press enter to go to next stage"
167; enter
168; )
169
170 go &RAMEntryAddr
171 wait !run()
172
173 if &RAMStage
174 (
175 &imgpath="build\cbfs\fallback\ramstage.elf"
176 if (&RAMLoad)
177 d.load.elf &imgpath /strippart "coreboot" /sourcepath &srcpath
178 else
179 d.load.elf &imgpath /strippart "coreboot" /sourcepath &srcpath /nocode
180 print %String "Now the control is in RAMStage, press enter after debugging to go to next stage"
181 print %String "Press enter to go to next stage"
182 enter
183 )
184
185; BL31 disabled for now
186; Next block of code commented out
187; go &BL31EntryAddr
188; wait !run()
189;
190; if &BL31Stage
191; (
192; &imgpath="build\bl31.elf"
193; if (&RAMLoad)
194; d.load.elf &imgpath /strippart "coreboot" /sourcepath &srcpath
195; else
196; d.load.elf &imgpath /strippart "coreboot" /sourcepath &srcpath /nocode
197; y.spath.srd 3rdparty/arm-trusted-firmware
198; print %String "Now the control is in BL31, press enter after debugging to go to next stage"
199; print %String "Press enter to go to next stage"
200; enter
201; )
202; End of commented out code block: bl31
203
204 go &DCEntryAddr
205 wait !run()
206
207 if &DCStage
208 (
209 &imgpath="payloads\external\depthcharge\depthcharge\build\depthcharge.elf"
210 symbol.sourcepath.setbasedir &srcpath\payloads
211 if (&RAMLoad)
212 d.load.elf &imgpath /strippart "payloads" /sourcepath &srcpath
213 else
214 d.load.elf &imgpath /strippart "payloads" /sourcepath &srcpath /nocode
215 b.d /all
216 b.set main
217 b.set halt
218 b.set &KernelEntryAddr ; kernel entry point
219 y.spath.srd + payloads/external/depthcharge/depthcharge
220 y.spath.srd + 3rdparty\vboot_reference
221 d.dump &RamConsoleAddr /spotlight
222 &CBTablePtr=Register(X0)
223 Data.SAVE.Binary CBTablePtr.bin &CBTablePtr++0x400
224 print %String "Now the control is in Depthcharge, press enter after debugging to run free"
225 ;print %String "Use this command to load kernel symbols: d.load.elf vmlinux /nocode /strippart kernel"
226 print %String "Press enter when done debugging Depthcharge"
227 enter
228 )
229
230; go &KernelEntryAddr
231; wait !run()
232;
233; if &KernelSyms
234; (
235; print %String "Kernel Symbols are being loaded, this requires two files in coreboot root tree:"
236; print %String "vmlinux needs to be copied from ChromiumOS build tree"
237; print %String "msm-4.4 needs to be symbolic link to kernel source tree"
238; d.load.elf vmlinux /strippart "msm-4.4" /nocode
239; y.spath.srd msm-4.4
240; print %String "This script now concludes at kernel entry point"
241; )
242
243 enddo