summaryrefslogtreecommitdiffstats
path: root/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:17:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:17:27 +0000
commitf215e02bf85f68d3a6106c2a1f4f7f063f819064 (patch)
tree6bb5b92c046312c4e95ac2620b10ddf482d3fa8b /src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts
parentInitial commit. (diff)
downloadvirtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.tar.xz
virtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.zip
Adding upstream version 7.0.14-dfsg.upstream/7.0.14-dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts')
-rw-r--r--src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EFI.CMM34
-rw-r--r--src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm129
-rw-r--r--src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadFv.cmm125
-rw-r--r--src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm71
-rw-r--r--src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessTeImage.cmm64
-rw-r--r--src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/Readme.md16
-rw-r--r--src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/T32.CMM59
7 files changed, 498 insertions, 0 deletions
diff --git a/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EFI.CMM b/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EFI.CMM
new file mode 100644
index 00000000..833d5405
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EFI.CMM
@@ -0,0 +1,34 @@
+;
+; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
+;
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+
+;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/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm b/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
new file mode 100644
index 00000000..2bcf5620
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
@@ -0,0 +1,129 @@
+;
+; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
+;
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+
+ 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/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadFv.cmm b/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadFv.cmm
new file mode 100644
index 00000000..efb59f78
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadFv.cmm
@@ -0,0 +1,125 @@
+;
+; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
+;
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+
+ 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/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm b/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
new file mode 100644
index 00000000..70a3a797
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
@@ -0,0 +1,71 @@
+;
+; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
+;
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+
+ 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/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessTeImage.cmm b/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessTeImage.cmm
new file mode 100644
index 00000000..c23722d8
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessTeImage.cmm
@@ -0,0 +1,64 @@
+;
+; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
+;
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+
+ 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/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/Readme.md b/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/Readme.md
new file mode 100644
index 00000000..845bc469
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/Readme.md
@@ -0,0 +1,16 @@
+# 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/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/T32.CMM b/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/T32.CMM
new file mode 100644
index 00000000..fa7a4ab4
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/EmbeddedPkg/Scripts/LauterbachT32/T32.CMM
@@ -0,0 +1,59 @@
+;
+; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
+;
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+
+; 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
+
+