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