summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xEmbeddedPkg/Scripts/LauterbachT32/EFI.CMM40
-rwxr-xr-xEmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm135
-rwxr-xr-xEmbeddedPkg/Scripts/LauterbachT32/EfiLoadFv.cmm131
-rwxr-xr-xEmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm77
-rwxr-xr-xEmbeddedPkg/Scripts/LauterbachT32/EfiProcessTeImage.cmm70
-rwxr-xr-xEmbeddedPkg/Scripts/LauterbachT32/README.txt7
-rwxr-xr-xEmbeddedPkg/Scripts/LauterbachT32/T32.CMM65
7 files changed, 525 insertions, 0 deletions
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EFI.CMM b/EmbeddedPkg/Scripts/LauterbachT32/EFI.CMM
new file mode 100755
index 0000000000..d02b02297c
--- /dev/null
+++ b/EmbeddedPkg/Scripts/LauterbachT32/EFI.CMM
@@ -0,0 +1,40 @@
+;
+; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
+;
+; This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+
+;choose hex mode for input
+ radix hex
+
+ menu.rp
+ (
+ add
+ toolbar
+ (
+ separator
+ toolitem "Reset Target" "RS" "sys.ResetTarget"
+ separator
+ toolitem "Load EFI DXE Symbols" "DX" "do EfiLoadDxe"
+ toolitem "Load EFI Runtime Symbols" "RT" "do EfiLoadRuntimeDxe"
+ )
+ )
+
+ system.config.debugaccessport 0
+ system.config.corebase 0x80001000
+ system.attach
+ break.sel.program onchip
+
+ setup.var %hex.on
+ setup.var %decimal.OFF
+
+
+enddo
+
+
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
new file mode 100755
index 0000000000..8ec1ac4bf3
--- /dev/null
+++ b/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
@@ -0,0 +1,135 @@
+;
+; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
+;
+; This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+
+ LOCAL &maxmem &systbl &memsize
+
+ &memsize=0x20000000 ; default to 512MB
+
+ gosub FindSystemTable &memsize
+ ENTRY &systbl
+
+ if &systbl!=0
+ (
+ print "found system table at &systbl"
+ gosub FindDebugInfo &systbl
+ )
+ else
+ (
+ print "ERROR: system table not found, check memory size"
+ )
+ enddo
+
+FindSystemTable:
+ LOCAL &TopOfRam &offset
+ ENTRY &TopOfRam
+
+ print "FindSystemTable"
+ print "top of mem is &TopOfRam$"
+
+ &offset=&TopOfRam
+
+ ; align to highest 4MB boundary
+ &offset=&offset&0xFFC00000
+
+ ; start at top and look on 4MB boundaries for system table ptr structure
+ while &offset>0
+ (
+ ; low signature match
+ if Data.Long(a:&offset)==0x20494249
+ (
+ ; high signature match
+ if Data.Long(a:&offset+4)==0x54535953
+ (
+ ; less than 4GB?
+ if Data.Long(a:&offset+0x0c)==0
+ (
+ ; less than top of ram?
+ if Data.Long(a:&offset+8)<&TopOfRam
+ (
+ return Data.Long(a:&offset+8)
+ )
+ )
+ )
+ )
+
+ if &offset<0x400000
+ (
+ return 0
+ )
+ &offset=&offset-0x400000
+ )
+
+ return 0
+
+
+FindDebugInfo:
+ LOCAL &SystemTable &CfgTableEntries &ConfigTable &i &offset &dbghdr &dbgentries &dbgptr &dbginfo &loadedimg
+ ENTRY &SystemTable
+
+ print "FindDebugInfo"
+
+ &dbgentries=0
+ &CfgTableEntries=Data.Long(a:&SystemTable+0x40)
+ &ConfigTable=Data.Long(a:&SystemTable+0x44)
+
+ print "config table is at &ConfigTable (&CfgTableEntries entries)"
+
+ ; now search for debug info entry with guid 49152E77-1ADA-4764-B7A2-7AFEFED95E8B
+ ; 0x49152E77 0x47641ADA 0xFE7AA2B7 0x8B5ED9FE
+ &i=0
+ while &i<&CfgTableEntries
+ (
+ &offset=&ConfigTable+(&i*0x14)
+ if Data.Long(a:&offset)==0x49152E77
+ (
+ if Data.Long(a:&offset+4)==0x47641ADA
+ (
+ if Data.Long(a:&offset+8)==0xFE7AA2B7
+ (
+ if Data.Long(a:&offset+0xc)==0x8B5ED9FE
+ (
+ &dbghdr=Data.Long(a:&offset+0x10)
+ &dbgentries=Data.Long(a:&dbghdr+4)
+ &dbgptr=Data.Long(a:&dbghdr+8)
+ )
+ )
+ )
+ )
+
+ &i=&i+1
+ )
+
+ if &dbgentries==0
+ (
+ print "no debug entries found"
+ return
+ )
+
+ print "debug table at &dbgptr (&dbgentries entries)"
+
+ symbol.reset
+
+ &i=0
+ while &i<&dbgentries
+ (
+ &dbginfo=Data.Long(a:&dbgptr+(&i*4))
+ if &dbginfo!=0
+ (
+ if Data.Long(a:&dbginfo)==1 ; normal debug info type
+ (
+ &loadedimg=Data.Long(a:&dbginfo+4)
+ do EfiProcessPeImage Data.Long(a:&loadedimg+0x20)
+ )
+ )
+ &i=&i+1
+ )
+ return
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadFv.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadFv.cmm
new file mode 100755
index 0000000000..e6ccc35b92
--- /dev/null
+++ b/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadFv.cmm
@@ -0,0 +1,131 @@
+;
+; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
+;
+; This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+
+ LOCAL &fvbase &fvsig &fvsig &ffsoffset &ffsfilesize &ffsfileaddr
+ ENTRY &fvbase
+
+ &fvsig=Data.Long(a:&fvbase+0x28)
+ if &fvsig!=0x4856465F
+ (
+ print "FV does not have proper signature, exiting"
+ return
+ )
+
+ print "FV signature found"
+
+ &fvlen=Data.Long(a:&fvbase+0x20)
+
+ ; first ffs file is after fv header, use headerlength field
+ &ffsoffset=(Data.Long(a:&fvbase+0x30)&0xffff)
+
+ ; loop through ffs files
+ &ffsfilesize=1
+ while (&ffsfilesize!=0)&&(&ffsoffset<(&fvlen))
+ (
+ &ffsfileaddr=&fvbase+&ffsoffset
+ ;print "found ffs file at &ffsfileaddr"
+
+ ; process ffs file and increment by ffs file size field
+ gosub ProcessFfsFile &ffsfileaddr
+
+ &ffsfilesize=(Data.Long(a:&ffsfileaddr+0x14)&0x00ffffff)
+ ;print "ffsfilesize is &ffsfilesize"
+
+ &ffsoffset=&ffsoffset+&ffsfilesize
+
+ &ffsfilesize=(Data.Long(a:&fvbase+&ffsoffset+0x14)&0x00ffffff)
+ ;print "ffsfilesize now is &ffsfilesize"
+ if &ffsfilesize==0xffffff
+ (
+ enddo
+ )
+
+ ; align to next 8 byte boundary
+ if (&ffsoffset&0x7)!=0
+ (
+ &ffsoffset=&ffsoffset+(0x8-(&ffsoffset&0x7))
+ )
+
+ ) ; end fv ffs loop
+
+enddo
+
+ProcessFfsFile:
+ LOCAL &ffsfilestart &ffsfilesize &ffsfiletype &secoffset &secsize
+ ENTRY &ffsfilestart
+
+ ;print "processing ffs file at &ffsfilestart"
+ &ffsfilesize=Data.Long(a:&ffsfilestart+0x14)
+ &ffsfiletype=(&ffsfilesize&0xff000000)>>24.
+ &ffsfilesize=&ffsfilesize&0x00ffffff
+
+ if &ffsfiletype==0
+ (
+ return
+ )
+
+ print "ffs file at &ffsfilestart size &ffsfilesize type &ffsfiletype"
+
+ &secoffset=&ffsfilestart+0x18
+
+ ; loop through sections in file
+ while &secoffset<(&ffsfilestart+&ffsfilesize)
+ (
+ print "secoffset at &secoffset"
+
+ ; process fv section and increment section offset by size
+ &secsize=(Data.Long(a:&secoffset)&0x00ffffff)
+
+ gosub ProcessFvSection &secoffset
+
+
+ &secoffset=(&secoffset+&secsize)
+
+ ;print "secsize is &secsize"
+ ;print "secoffset at &secoffset"
+
+ ; align to next 4 byte boundary
+ if (&secoffset&0x3)!=0
+ (
+ &secoffset=&secoffset+(0x4-(&secoffset&0x3))
+ )
+ ) ; end section loop
+ return
+
+
+ProcessFvSection:
+ LOCAL &secstart &sectionsize &sectiontype &secoffset &secsize
+ ENTRY &secstart
+
+ &sectionsize=Data.Long(a:&secstart)
+ &sectiontype=((&sectionsize&0xff000000)>>24.)
+ &sectionsize=&sectionsize&0x00ffffff;
+
+ print "fv section at &secstart size &sectionsize type &sectiontype"
+
+ if &sectiontype==0x10 ; PE32
+ (
+ do EfiProcessPeImage (&secstart+0x4)
+ )
+ else
+ (
+ if &sectiontype==0x12 ; TE
+ (
+ do EfiProcessTeImage (&secstart+0x4)
+ )
+ else
+ (
+ print "unknown section type"
+ )
+ )
+
+ return
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
new file mode 100755
index 0000000000..53d830f7d2
--- /dev/null
+++ b/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
@@ -0,0 +1,77 @@
+;
+; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
+;
+; This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+
+ LOCAL &imgstart &filehdrstart &debugdirentryrva &debugtype &debugrva &dwarfsig &baseofcode &baseofdata &elfbase &elfpath &pathoffset
+ ENTRY &imgstart
+
+ &imgstart=&imgstart
+ print "PE32 image found at &imgstart"
+
+ ; offset from dos hdr to PE file hdr
+ &filehdrstart=&imgstart+Data.Long(c:&imgstart+0x3C)
+
+ ; offset to debug dir in PE hdrs
+ &debugdirentryrva=Data.Long(c:&filehdrstart+0xA8)
+ if &debugdirentryrva==0
+ (
+ print "no debug dir for image at &imgstart"
+ enddo
+ )
+
+ &debugtype=Data.Long(c:&imgstart+&debugdirentryrva+0xc)
+ if (&debugtype!=0xdf)&&(&debugtype!=0x02)
+ (
+ print "debug type is not dwarf for image at &imgstart, it's &debugtype"
+ enddo
+ )
+
+ &debugrva=Data.Long(c:&imgstart+&debugdirentryrva+0x14)
+ &dwarfsig=Data.Long(c:&imgstart+&debugrva)
+
+ if &dwarfsig==0x66727764
+ (
+ &pathoffset=0xc
+ )
+ else
+ (
+ if &dwarfsig==0x3031424E
+ (
+ &pathoffset=0x10
+ )
+ else
+ (
+ print "debug signature not found for image at &imgstart, its &dwarfsig"
+ enddo
+ )
+ )
+
+ &elfpath=Data.String(c:&imgstart+&debugrva+&pathoffset)
+
+ &baseofcode=&imgstart+Data.Long(c:&filehdrstart+0x28)
+ &baseofdata=&imgstart+Data.Long(c:&filehdrstart+0x2c)
+
+ if (&baseofcode<&baseofdata)&&(&baseofcode!=0)
+ (
+ &elfbase=&baseofcode;
+ )
+ else
+ (
+ &elfbase=&baseofdata;
+ )
+
+ print "found path &elfpath"
+ ON ERROR GOSUB
+ return
+ data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR
+ ON error
+
+enddo
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessTeImage.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessTeImage.cmm
new file mode 100755
index 0000000000..9347c9c35b
--- /dev/null
+++ b/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessTeImage.cmm
@@ -0,0 +1,70 @@
+;
+; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
+;
+; This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+
+ LOCAL &imgstart &strippedsize &debugdirentryrva &debugtype &debugrva &dwarfsig &elfbase &elfpath &pathoffset
+ ENTRY &imgstart
+
+ &imgstart=&imgstart
+ print "TE image found at &imgstart"
+
+ ; determine pe header bytes removed to account for in rva references
+ &strippedsize=(Data.Long(a:&imgstart+0x4)&0xffff0000)>>16.
+ &strippedsize=&strippedsize-0x28
+
+ &debugdirentryrva=Data.Long(a:&imgstart+0x20)
+ if &debugdirentryrva==0
+ (
+ print "no debug dir for image at &imgstart"
+ enddo
+ )
+ &debugdirentryrva=&debugdirentryrva-&strippedsize
+
+ &debugtype=Data.Long(a:&imgstart+&debugdirentryrva+0xc)
+ if (&debugtype!=0xdf)&&(&debugtype!=0x02)
+ (
+ print "debug type is not dwarf for image at &imgstart, it's &debugtype"
+ enddo
+ )
+
+ &debugrva=Data.Long(a:&imgstart+&debugdirentryrva+0x14)
+ &debugrva=&debugrva-&strippedsize;
+ &dwarfsig=Data.Long(a:&imgstart+&debugrva);
+ if &dwarfsig==0x66727764
+ (
+ &pathoffset=0xc
+ )
+ else
+ (
+ if &dwarfsig==0x3031424E
+ (
+ &pathoffset=0x10
+ )
+ else
+ (
+ print "debug signature not found for image at &imgstart, its &dwarfsig"
+ enddo
+ )
+ )
+
+ &elfpath=Data.String(c:&imgstart+&debugrva+&pathoffset)
+
+ ; elf base is baseofcode (we hope that for TE images it's not baseofdata)
+ &elfbase=&imgstart+Data.Long(a:&imgstart+0xc)-&strippedsize
+
+ print "found path &elfpath"
+ ; $fprintf 50, "load /ni /np /a %s &0x%x\n",elfpath,elfbase$;
+ ON ERROR GOSUB
+ return
+ data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR
+ ON error
+
+enddo
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/README.txt b/EmbeddedPkg/Scripts/LauterbachT32/README.txt
new file mode 100755
index 0000000000..06602ab876
--- /dev/null
+++ b/EmbeddedPkg/Scripts/LauterbachT32/README.txt
@@ -0,0 +1,7 @@
+DXE Phase Debug
+===============
+Update the memsize variable in EfiLoadDxe.cmm for the actual amount of memory available in your system. Allow your system to boot to the point that the DXE core is initialized (so that the System Table and Debug Information table is present in memory) and execute this script (using the toolbar button or ‘do EfiLoadDxe’ from the command area). It will scan memory for the debug info table and load modules in it.
+
+SEC/PEI Phase Debug
+===================
+There is no way to autodetect where these images reside so you must pass an address for the memory-mapped Firmware Volume containing these images. To do this, enter ‘do EfiLoadFv <addr>’ where <addr> is the base address for the firmware volume containing the SEC or PEI code. To be more efficient you may want to create a script that calls this, like MyBoardLoadSec.cmm which contains the call to EfiLoadFv. You can them map this script to a T32 menu or toolbar button for quick access.
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/T32.CMM b/EmbeddedPkg/Scripts/LauterbachT32/T32.CMM
new file mode 100755
index 0000000000..8a73d5f0c2
--- /dev/null
+++ b/EmbeddedPkg/Scripts/LauterbachT32/T32.CMM
@@ -0,0 +1,65 @@
+;
+; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
+;
+; This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+
+; Copy this to your C:\T32 directory
+;Default startup program for TRACE32
+;
+;This startup program can be modified according to your needs.
+
+; update this path to reflect YOUR current working dir
+GLOBAL &wcdir
+&wcdir="D:\bios"
+
+;choose hex mode for input
+ radix hex
+
+;Add some extra buttons to the toolbar
+
+ menu.rp
+ (
+ add
+ toolbar
+ (
+ separator
+ toolitem "Source/List" ":list" "Data.List"
+ toolitem "Memory Dump" ":dump" "Data.dump"
+ toolitem "Register" ":reg" "Register"
+ separator
+ toolitem "Watch" ":varwatch" "Var.Watch"
+ toolitem "Stack" ":varframe" "Var.Frame /l /c"
+ toolitem "Automatic Watch" ":varref" "Var.Ref"
+ separator
+ toolitem "List Breakpoints" ":break" "Break.List"
+ toolitem "List Symbols" ":symbols" "sYmbol.Browse"
+ toolitem "System Settings" ":config" "SYStem"
+ separator
+ )
+ )
+
+ if language()!=""
+ (
+ local &menuname
+ &menuname="~~/t32"+language()+".men"
+ if os.file(&menuname)
+ menu.rp &menuname
+ )
+
+;Recall and Define History File
+ autostore , history bookmark
+
+; Execute EFI setup script
+ chdir &wcdir\Platform\T32_Scripts
+ do EFI
+
+enddo
+
+