]> git.proxmox.com Git - mirror_edk2.git/blob - EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
EmbeddedPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / EmbeddedPkg / Scripts / LauterbachT32 / EfiLoadDxe.cmm
1 ;
2 ; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
3 ;
4 ; SPDX-License-Identifier: BSD-2-Clause-Patent
5 ;
6
7 LOCAL &maxmem &systbl &memsize
8
9 &memsize=0x20000000 ; default to 512MB
10
11 gosub FindSystemTable &memsize
12 ENTRY &systbl
13
14 if &systbl!=0
15 (
16 print "found system table at &systbl"
17 gosub FindDebugInfo &systbl
18 )
19 else
20 (
21 print "ERROR: system table not found, check memory size"
22 )
23 enddo
24
25 FindSystemTable:
26 LOCAL &TopOfRam &offset
27 ENTRY &TopOfRam
28
29 print "FindSystemTable"
30 print "top of mem is &TopOfRam$"
31
32 &offset=&TopOfRam
33
34 ; align to highest 4MB boundary
35 &offset=&offset&0xFFC00000
36
37 ; start at top and look on 4MB boundaries for system table ptr structure
38 while &offset>0
39 (
40 ; low signature match
41 if Data.Long(a:&offset)==0x20494249
42 (
43 ; high signature match
44 if Data.Long(a:&offset+4)==0x54535953
45 (
46 ; less than 4GB?
47 if Data.Long(a:&offset+0x0c)==0
48 (
49 ; less than top of ram?
50 if Data.Long(a:&offset+8)<&TopOfRam
51 (
52 return Data.Long(a:&offset+8)
53 )
54 )
55 )
56 )
57
58 if &offset<0x400000
59 (
60 return 0
61 )
62 &offset=&offset-0x400000
63 )
64
65 return 0
66
67
68 FindDebugInfo:
69 LOCAL &SystemTable &CfgTableEntries &ConfigTable &i &offset &dbghdr &dbgentries &dbgptr &dbginfo &loadedimg
70 ENTRY &SystemTable
71
72 print "FindDebugInfo"
73
74 &dbgentries=0
75 &CfgTableEntries=Data.Long(a:&SystemTable+0x40)
76 &ConfigTable=Data.Long(a:&SystemTable+0x44)
77
78 print "config table is at &ConfigTable (&CfgTableEntries entries)"
79
80 ; now search for debug info entry with guid 49152E77-1ADA-4764-B7A2-7AFEFED95E8B
81 ; 0x49152E77 0x47641ADA 0xFE7AA2B7 0x8B5ED9FE
82 &i=0
83 while &i<&CfgTableEntries
84 (
85 &offset=&ConfigTable+(&i*0x14)
86 if Data.Long(a:&offset)==0x49152E77
87 (
88 if Data.Long(a:&offset+4)==0x47641ADA
89 (
90 if Data.Long(a:&offset+8)==0xFE7AA2B7
91 (
92 if Data.Long(a:&offset+0xc)==0x8B5ED9FE
93 (
94 &dbghdr=Data.Long(a:&offset+0x10)
95 &dbgentries=Data.Long(a:&dbghdr+4)
96 &dbgptr=Data.Long(a:&dbghdr+8)
97 )
98 )
99 )
100 )
101
102 &i=&i+1
103 )
104
105 if &dbgentries==0
106 (
107 print "no debug entries found"
108 return
109 )
110
111 print "debug table at &dbgptr (&dbgentries entries)"
112
113 symbol.reset
114
115 &i=0
116 while &i<&dbgentries
117 (
118 &dbginfo=Data.Long(a:&dbgptr+(&i*4))
119 if &dbginfo!=0
120 (
121 if Data.Long(a:&dbginfo)==1 ; normal debug info type
122 (
123 &loadedimg=Data.Long(a:&dbginfo+4)
124 do EfiProcessPeImage Data.Long(a:&loadedimg+0x20)
125 )
126 )
127 &i=&i+1
128 )
129 return