* [edk2-devel] [PATCH 0/1] EmbeddedPkg/Scripts/LauterbachT32: Fix EfiLoadDxe.cmm
@ 2024-01-29 19:01 Rebecca Cran via groups.io
2024-01-29 19:01 ` [edk2-devel] [PATCH 1/1] " Rebecca Cran via groups.io
0 siblings, 1 reply; 5+ messages in thread
From: Rebecca Cran via groups.io @ 2024-01-29 19:01 UTC (permalink / raw)
To: Leif Lindholm, Ard Biesheuvel, Abner Chang, devel; +Cc: Rebecca Cran
There have been many changes since EfiLoadDxe.cmm was last updated in
2011. The EFI_SYSTEM_TABLE can no longer be found by scanning memory
on 4KB boundaries, so require users pass in its address instead.
Update various offsets so that the debug information can be found and
loaded with a recent version of TRACE32.
PR: https://github.com/tianocore/edk2/pull/5318
Rebecca Cran (1):
EmbeddedPkg/Scripts/LauterbachT32: Fix EfiLoadDxe.cmm
EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm | 77 +++-----------------
EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm | 7 +-
EmbeddedPkg/Scripts/LauterbachT32/Readme.md | 8 +-
3 files changed, 19 insertions(+), 73 deletions(-)
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114735): https://edk2.groups.io/g/devel/message/114735
Mute This Topic: https://groups.io/mt/104038272/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 5+ messages in thread
* [edk2-devel] [PATCH 1/1] EmbeddedPkg/Scripts/LauterbachT32: Fix EfiLoadDxe.cmm
2024-01-29 19:01 [edk2-devel] [PATCH 0/1] EmbeddedPkg/Scripts/LauterbachT32: Fix EfiLoadDxe.cmm Rebecca Cran via groups.io
@ 2024-01-29 19:01 ` Rebecca Cran via groups.io
2024-02-11 23:10 ` Rebecca Cran
0 siblings, 1 reply; 5+ messages in thread
From: Rebecca Cran via groups.io @ 2024-01-29 19:01 UTC (permalink / raw)
To: Leif Lindholm, Ard Biesheuvel, Abner Chang, devel; +Cc: Rebecca Cran
There have been many changes since EfiLoadDxe.cmm was last updated in
2011. The EFI_SYSTEM_TABLE can no longer be found by scanning memory on
4KB boundaries, so require users pass in its address instead. Update
various offsets so that the debug information can be found and loaded
with a recent version of TRACE32.
Signed-off-by: Rebecca Cran <rebecca@os.amperecomputing.com>
---
EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm | 77 +++-----------------
EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm | 7 +-
EmbeddedPkg/Scripts/LauterbachT32/Readme.md | 8 +-
3 files changed, 19 insertions(+), 73 deletions(-)
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
index 1605a9b478df..06d307e12d8c 100644
--- a/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
+++ b/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
@@ -1,79 +1,22 @@
;
+; Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR>
; 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"
- )
+ PARAMETERS &systbl
+
+ gosub FindDebugInfo &systbl
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)
+ &CfgTableEntries=Data.Long(a:&SystemTable+0x68)
+ &ConfigTable=Data.Long(a:&SystemTable+0x70)
print "config table is at &ConfigTable (&CfgTableEntries entries)"
@@ -82,7 +25,7 @@ FindDebugInfo:
&i=0
while &i<&CfgTableEntries
(
- &offset=&ConfigTable+(&i*0x14)
+ &offset=&ConfigTable+(&i*0x18)
if Data.Long(a:&offset)==0x49152E77
(
if Data.Long(a:&offset+4)==0x47641ADA
@@ -120,8 +63,10 @@ FindDebugInfo:
(
if Data.Long(a:&dbginfo)==1 ; normal debug info type
(
- &loadedimg=Data.Long(a:&dbginfo+4)
- do EfiProcessPeImage Data.Long(a:&loadedimg+0x20)
+ &loadedimg=Data.Long(a:&dbginfo+8)
+ &imagebaseptr=&loadedimg+0x40
+ &imagebase=Data.Long(a:&imagebaseptr)
+ do ~~~~/EfiProcessPeImage.cmm "&imagebase"
)
)
&i=&i+1
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
index c3aab9d06a47..b0d97eec71b0 100644
--- a/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
+++ b/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
@@ -1,4 +1,5 @@
;
+; Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR>
; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
;
; SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -10,11 +11,11 @@
&imgstart=&imgstart
print "PE32 image found at &imgstart"
- ; offset from dos hdr to PE file hdr
+ ; offset from dos hdr to PE file hdr (i.e. 'PE\0\0' signature)
&filehdrstart=&imgstart+Data.Long(c:&imgstart+0x3C)
; offset to debug dir in PE hdrs
- &debugdirentryrva=Data.Long(c:&filehdrstart+0xA8)
+ &debugdirentryrva=Data.Long(c:&imgstart+0xf10)
if &debugdirentryrva==0
(
print "no debug dir for image at &imgstart"
@@ -62,7 +63,7 @@
&elfbase=&baseofdata;
)
- print "found path &elfpath"
+ print "found path &elfpath with address &elfbase"
ON ERROR GOSUB
return
data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/Readme.md b/EmbeddedPkg/Scripts/LauterbachT32/Readme.md
index 51d2c8da5405..c30ec20a3d96 100644
--- a/EmbeddedPkg/Scripts/LauterbachT32/Readme.md
+++ b/EmbeddedPkg/Scripts/LauterbachT32/Readme.md
@@ -1,10 +1,10 @@
# 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
+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.
+'do EfiLoadDxe "0xGST_ADDRESS"' from the command area). 'GST_ADDRESS' is the
+address of the EFI_SYSTEM_TABLE, and can be found by the global `gST`.
+The script 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
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114736): https://edk2.groups.io/g/devel/message/114736
Mute This Topic: https://groups.io/mt/104038273/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] EmbeddedPkg/Scripts/LauterbachT32: Fix EfiLoadDxe.cmm
2024-01-29 19:01 ` [edk2-devel] [PATCH 1/1] " Rebecca Cran via groups.io
@ 2024-02-11 23:10 ` Rebecca Cran
2024-02-12 17:41 ` Leif Lindholm
0 siblings, 1 reply; 5+ messages in thread
From: Rebecca Cran @ 2024-02-11 23:10 UTC (permalink / raw)
To: devel, rebecca, Leif Lindholm, Ard Biesheuvel, Abner Chang,
Michael D Kinney
I'm guessing there haven't been any reviews because so few people are
familiar with the PRACTICE scripting language.
If there's nobody who can review it, could I get approval to commit it
anyway?
--
Rebecca Cran
On 1/29/24 12:01, Rebecca Cran via groups.io wrote:
> There have been many changes since EfiLoadDxe.cmm was last updated in
> 2011. The EFI_SYSTEM_TABLE can no longer be found by scanning memory on
> 4KB boundaries, so require users pass in its address instead. Update
> various offsets so that the debug information can be found and loaded
> with a recent version of TRACE32.
>
> Signed-off-by: Rebecca Cran <rebecca@os.amperecomputing.com>
> ---
> EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm | 77 +++-----------------
> EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm | 7 +-
> EmbeddedPkg/Scripts/LauterbachT32/Readme.md | 8 +-
> 3 files changed, 19 insertions(+), 73 deletions(-)
>
> diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
> index 1605a9b478df..06d307e12d8c 100644
> --- a/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
> +++ b/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
> @@ -1,79 +1,22 @@
> ;
> +; Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR>
> ; 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"
> - )
> + PARAMETERS &systbl
> +
> + gosub FindDebugInfo &systbl
> 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)
> + &CfgTableEntries=Data.Long(a:&SystemTable+0x68)
> + &ConfigTable=Data.Long(a:&SystemTable+0x70)
>
> print "config table is at &ConfigTable (&CfgTableEntries entries)"
>
> @@ -82,7 +25,7 @@ FindDebugInfo:
> &i=0
> while &i<&CfgTableEntries
> (
> - &offset=&ConfigTable+(&i*0x14)
> + &offset=&ConfigTable+(&i*0x18)
> if Data.Long(a:&offset)==0x49152E77
> (
> if Data.Long(a:&offset+4)==0x47641ADA
> @@ -120,8 +63,10 @@ FindDebugInfo:
> (
> if Data.Long(a:&dbginfo)==1 ; normal debug info type
> (
> - &loadedimg=Data.Long(a:&dbginfo+4)
> - do EfiProcessPeImage Data.Long(a:&loadedimg+0x20)
> + &loadedimg=Data.Long(a:&dbginfo+8)
> + &imagebaseptr=&loadedimg+0x40
> + &imagebase=Data.Long(a:&imagebaseptr)
> + do ~~~~/EfiProcessPeImage.cmm "&imagebase"
> )
> )
> &i=&i+1
> diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
> index c3aab9d06a47..b0d97eec71b0 100644
> --- a/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
> +++ b/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
> @@ -1,4 +1,5 @@
> ;
> +; Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR>
> ; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
> ;
> ; SPDX-License-Identifier: BSD-2-Clause-Patent
> @@ -10,11 +11,11 @@
> &imgstart=&imgstart
> print "PE32 image found at &imgstart"
>
> - ; offset from dos hdr to PE file hdr
> + ; offset from dos hdr to PE file hdr (i.e. 'PE\0\0' signature)
> &filehdrstart=&imgstart+Data.Long(c:&imgstart+0x3C)
>
> ; offset to debug dir in PE hdrs
> - &debugdirentryrva=Data.Long(c:&filehdrstart+0xA8)
> + &debugdirentryrva=Data.Long(c:&imgstart+0xf10)
> if &debugdirentryrva==0
> (
> print "no debug dir for image at &imgstart"
> @@ -62,7 +63,7 @@
> &elfbase=&baseofdata;
> )
>
> - print "found path &elfpath"
> + print "found path &elfpath with address &elfbase"
> ON ERROR GOSUB
> return
> data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR
> diff --git a/EmbeddedPkg/Scripts/LauterbachT32/Readme.md b/EmbeddedPkg/Scripts/LauterbachT32/Readme.md
> index 51d2c8da5405..c30ec20a3d96 100644
> --- a/EmbeddedPkg/Scripts/LauterbachT32/Readme.md
> +++ b/EmbeddedPkg/Scripts/LauterbachT32/Readme.md
> @@ -1,10 +1,10 @@
> # 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
> +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.
> +'do EfiLoadDxe "0xGST_ADDRESS"' from the command area). 'GST_ADDRESS' is the
> +address of the EFI_SYSTEM_TABLE, and can be found by the global `gST`.
> +The script 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
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115345): https://edk2.groups.io/g/devel/message/115345
Mute This Topic: https://groups.io/mt/104038273/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] EmbeddedPkg/Scripts/LauterbachT32: Fix EfiLoadDxe.cmm
2024-02-11 23:10 ` Rebecca Cran
@ 2024-02-12 17:41 ` Leif Lindholm
2024-02-27 17:24 ` Rebecca Cran
0 siblings, 1 reply; 5+ messages in thread
From: Leif Lindholm @ 2024-02-12 17:41 UTC (permalink / raw)
To: Rebecca Cran
Cc: devel, rebecca, Ard Biesheuvel, Abner Chang, Michael D Kinney
On Sun, Feb 11, 2024 at 16:10:32 -0700, Rebecca Cran wrote:
> I'm guessing there haven't been any reviews because so few people are
> familiar with the PRACTICE scripting language.
>
> If there's nobody who can review it, could I get approval to commit it
> anyway?
I'm good with that (after stable tag, of course):
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
It would make sense to also add you as a maintainer for
EmbeddedPkg/Scripts/LauterbachT32/
Regards,
Leif
> --
>
> Rebecca Cran
>
>
> On 1/29/24 12:01, Rebecca Cran via groups.io wrote:
> > There have been many changes since EfiLoadDxe.cmm was last updated in
> > 2011. The EFI_SYSTEM_TABLE can no longer be found by scanning memory on
> > 4KB boundaries, so require users pass in its address instead. Update
> > various offsets so that the debug information can be found and loaded
> > with a recent version of TRACE32.
> >
> > Signed-off-by: Rebecca Cran <rebecca@os.amperecomputing.com>
> > ---
> > EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm | 77 +++-----------------
> > EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm | 7 +-
> > EmbeddedPkg/Scripts/LauterbachT32/Readme.md | 8 +-
> > 3 files changed, 19 insertions(+), 73 deletions(-)
> >
> > diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
> > index 1605a9b478df..06d307e12d8c 100644
> > --- a/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
> > +++ b/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
> > @@ -1,79 +1,22 @@
> > ;
> > +; Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR>
> > ; 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"
> > - )
> > + PARAMETERS &systbl
> > +
> > + gosub FindDebugInfo &systbl
> > 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)
> > + &CfgTableEntries=Data.Long(a:&SystemTable+0x68)
> > + &ConfigTable=Data.Long(a:&SystemTable+0x70)
> > print "config table is at &ConfigTable (&CfgTableEntries entries)"
> > @@ -82,7 +25,7 @@ FindDebugInfo:
> > &i=0
> > while &i<&CfgTableEntries
> > (
> > - &offset=&ConfigTable+(&i*0x14)
> > + &offset=&ConfigTable+(&i*0x18)
> > if Data.Long(a:&offset)==0x49152E77
> > (
> > if Data.Long(a:&offset+4)==0x47641ADA
> > @@ -120,8 +63,10 @@ FindDebugInfo:
> > (
> > if Data.Long(a:&dbginfo)==1 ; normal debug info type
> > (
> > - &loadedimg=Data.Long(a:&dbginfo+4)
> > - do EfiProcessPeImage Data.Long(a:&loadedimg+0x20)
> > + &loadedimg=Data.Long(a:&dbginfo+8)
> > + &imagebaseptr=&loadedimg+0x40
> > + &imagebase=Data.Long(a:&imagebaseptr)
> > + do ~~~~/EfiProcessPeImage.cmm "&imagebase"
> > )
> > )
> > &i=&i+1
> > diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
> > index c3aab9d06a47..b0d97eec71b0 100644
> > --- a/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
> > +++ b/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
> > @@ -1,4 +1,5 @@
> > ;
> > +; Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR>
> > ; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
> > ;
> > ; SPDX-License-Identifier: BSD-2-Clause-Patent
> > @@ -10,11 +11,11 @@
> > &imgstart=&imgstart
> > print "PE32 image found at &imgstart"
> > - ; offset from dos hdr to PE file hdr
> > + ; offset from dos hdr to PE file hdr (i.e. 'PE\0\0' signature)
> > &filehdrstart=&imgstart+Data.Long(c:&imgstart+0x3C)
> > ; offset to debug dir in PE hdrs
> > - &debugdirentryrva=Data.Long(c:&filehdrstart+0xA8)
> > + &debugdirentryrva=Data.Long(c:&imgstart+0xf10)
> > if &debugdirentryrva==0
> > (
> > print "no debug dir for image at &imgstart"
> > @@ -62,7 +63,7 @@
> > &elfbase=&baseofdata;
> > )
> > - print "found path &elfpath"
> > + print "found path &elfpath with address &elfbase"
> > ON ERROR GOSUB
> > return
> > data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR
> > diff --git a/EmbeddedPkg/Scripts/LauterbachT32/Readme.md b/EmbeddedPkg/Scripts/LauterbachT32/Readme.md
> > index 51d2c8da5405..c30ec20a3d96 100644
> > --- a/EmbeddedPkg/Scripts/LauterbachT32/Readme.md
> > +++ b/EmbeddedPkg/Scripts/LauterbachT32/Readme.md
> > @@ -1,10 +1,10 @@
> > # 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
> > +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.
> > +'do EfiLoadDxe "0xGST_ADDRESS"' from the command area). 'GST_ADDRESS' is the
> > +address of the EFI_SYSTEM_TABLE, and can be found by the global `gST`.
> > +The script 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
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115369): https://edk2.groups.io/g/devel/message/115369
Mute This Topic: https://groups.io/mt/104038273/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] EmbeddedPkg/Scripts/LauterbachT32: Fix EfiLoadDxe.cmm
2024-02-12 17:41 ` Leif Lindholm
@ 2024-02-27 17:24 ` Rebecca Cran
0 siblings, 0 replies; 5+ messages in thread
From: Rebecca Cran @ 2024-02-27 17:24 UTC (permalink / raw)
To: devel, quic_llindhol, Rebecca Cran
Cc: Ard Biesheuvel, Abner Chang, Michael D Kinney
Merged as e59a40b92ce92f17e3d8d99917868c5678d408b7.
--
Rebecca Cran
On 2/12/2024 10:41 AM, Leif Lindholm via groups.io wrote:
> On Sun, Feb 11, 2024 at 16:10:32 -0700, Rebecca Cran wrote:
>> I'm guessing there haven't been any reviews because so few people are
>> familiar with the PRACTICE scripting language.
>>
>> If there's nobody who can review it, could I get approval to commit it
>> anyway?
> I'm good with that (after stable tag, of course):
> Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
>
> It would make sense to also add you as a maintainer for
> EmbeddedPkg/Scripts/LauterbachT32/
>
> Regards,
>
> Leif
>
>
>> --
>>
>> Rebecca Cran
>>
>>
>> On 1/29/24 12:01, Rebecca Cran via groups.io wrote:
>>> There have been many changes since EfiLoadDxe.cmm was last updated in
>>> 2011. The EFI_SYSTEM_TABLE can no longer be found by scanning memory on
>>> 4KB boundaries, so require users pass in its address instead. Update
>>> various offsets so that the debug information can be found and loaded
>>> with a recent version of TRACE32.
>>>
>>> Signed-off-by: Rebecca Cran <rebecca@os.amperecomputing.com>
>>> ---
>>> EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm | 77 +++-----------------
>>> EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm | 7 +-
>>> EmbeddedPkg/Scripts/LauterbachT32/Readme.md | 8 +-
>>> 3 files changed, 19 insertions(+), 73 deletions(-)
>>>
>>> diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
>>> index 1605a9b478df..06d307e12d8c 100644
>>> --- a/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
>>> +++ b/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
>>> @@ -1,79 +1,22 @@
>>> ;
>>> +; Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR>
>>> ; 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"
>>> - )
>>> + PARAMETERS &systbl
>>> +
>>> + gosub FindDebugInfo &systbl
>>> 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)
>>> + &CfgTableEntries=Data.Long(a:&SystemTable+0x68)
>>> + &ConfigTable=Data.Long(a:&SystemTable+0x70)
>>> print "config table is at &ConfigTable (&CfgTableEntries entries)"
>>> @@ -82,7 +25,7 @@ FindDebugInfo:
>>> &i=0
>>> while &i<&CfgTableEntries
>>> (
>>> - &offset=&ConfigTable+(&i*0x14)
>>> + &offset=&ConfigTable+(&i*0x18)
>>> if Data.Long(a:&offset)==0x49152E77
>>> (
>>> if Data.Long(a:&offset+4)==0x47641ADA
>>> @@ -120,8 +63,10 @@ FindDebugInfo:
>>> (
>>> if Data.Long(a:&dbginfo)==1 ; normal debug info type
>>> (
>>> - &loadedimg=Data.Long(a:&dbginfo+4)
>>> - do EfiProcessPeImage Data.Long(a:&loadedimg+0x20)
>>> + &loadedimg=Data.Long(a:&dbginfo+8)
>>> + &imagebaseptr=&loadedimg+0x40
>>> + &imagebase=Data.Long(a:&imagebaseptr)
>>> + do ~~~~/EfiProcessPeImage.cmm "&imagebase"
>>> )
>>> )
>>> &i=&i+1
>>> diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
>>> index c3aab9d06a47..b0d97eec71b0 100644
>>> --- a/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
>>> +++ b/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
>>> @@ -1,4 +1,5 @@
>>> ;
>>> +; Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR>
>>> ; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
>>> ;
>>> ; SPDX-License-Identifier: BSD-2-Clause-Patent
>>> @@ -10,11 +11,11 @@
>>> &imgstart=&imgstart
>>> print "PE32 image found at &imgstart"
>>> - ; offset from dos hdr to PE file hdr
>>> + ; offset from dos hdr to PE file hdr (i.e. 'PE\0\0' signature)
>>> &filehdrstart=&imgstart+Data.Long(c:&imgstart+0x3C)
>>> ; offset to debug dir in PE hdrs
>>> - &debugdirentryrva=Data.Long(c:&filehdrstart+0xA8)
>>> + &debugdirentryrva=Data.Long(c:&imgstart+0xf10)
>>> if &debugdirentryrva==0
>>> (
>>> print "no debug dir for image at &imgstart"
>>> @@ -62,7 +63,7 @@
>>> &elfbase=&baseofdata;
>>> )
>>> - print "found path &elfpath"
>>> + print "found path &elfpath with address &elfbase"
>>> ON ERROR GOSUB
>>> return
>>> data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR
>>> diff --git a/EmbeddedPkg/Scripts/LauterbachT32/Readme.md b/EmbeddedPkg/Scripts/LauterbachT32/Readme.md
>>> index 51d2c8da5405..c30ec20a3d96 100644
>>> --- a/EmbeddedPkg/Scripts/LauterbachT32/Readme.md
>>> +++ b/EmbeddedPkg/Scripts/LauterbachT32/Readme.md
>>> @@ -1,10 +1,10 @@
>>> # 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
>>> +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.
>>> +'do EfiLoadDxe "0xGST_ADDRESS"' from the command area). 'GST_ADDRESS' is the
>>> +address of the EFI_SYSTEM_TABLE, and can be found by the global `gST`.
>>> +The script 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
>>>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116056): https://edk2.groups.io/g/devel/message/116056
Mute This Topic: https://groups.io/mt/104038273/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-27 17:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-29 19:01 [edk2-devel] [PATCH 0/1] EmbeddedPkg/Scripts/LauterbachT32: Fix EfiLoadDxe.cmm Rebecca Cran via groups.io
2024-01-29 19:01 ` [edk2-devel] [PATCH 1/1] " Rebecca Cran via groups.io
2024-02-11 23:10 ` Rebecca Cran
2024-02-12 17:41 ` Leif Lindholm
2024-02-27 17:24 ` Rebecca Cran
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox