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