2 ; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
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
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.
13 LOCAL &fvbase &fvsig &fvsig &ffsoffset &ffsfilesize &ffsfileaddr
16 &fvsig=Data.Long(a:&fvbase+0x28)
19 print "FV does not have proper signature, exiting"
23 print "FV signature found"
25 &fvlen=Data.Long(a:&fvbase+0x20)
27 ; first ffs file is after fv header, use headerlength field
28 &ffsoffset=(Data.Long(a:&fvbase+0x30)&0xffff)
30 ; loop through ffs files
32 while (&ffsfilesize!=0)&&(&ffsoffset<(&fvlen))
34 &ffsfileaddr=&fvbase+&ffsoffset
35 ;print "found ffs file at &ffsfileaddr"
37 ; process ffs file and increment by ffs file size field
38 gosub ProcessFfsFile &ffsfileaddr
40 &ffsfilesize=(Data.Long(a:&ffsfileaddr+0x14)&0x00ffffff)
41 ;print "ffsfilesize is &ffsfilesize"
43 &ffsoffset=&ffsoffset+&ffsfilesize
45 &ffsfilesize=(Data.Long(a:&fvbase+&ffsoffset+0x14)&0x00ffffff)
46 ;print "ffsfilesize now is &ffsfilesize"
47 if &ffsfilesize==0xffffff
52 ; align to next 8 byte boundary
53 if (&ffsoffset&0x7)!=0
55 &ffsoffset=&ffsoffset+(0x8-(&ffsoffset&0x7))
63 LOCAL &ffsfilestart &ffsfilesize &ffsfiletype &secoffset &secsize
66 ;print "processing ffs file at &ffsfilestart"
67 &ffsfilesize=Data.Long(a:&ffsfilestart+0x14)
68 &ffsfiletype=(&ffsfilesize&0xff000000)>>24.
69 &ffsfilesize=&ffsfilesize&0x00ffffff
76 print "ffs file at &ffsfilestart size &ffsfilesize type &ffsfiletype"
78 &secoffset=&ffsfilestart+0x18
80 ; loop through sections in file
81 while &secoffset<(&ffsfilestart+&ffsfilesize)
83 print "secoffset at &secoffset"
85 ; process fv section and increment section offset by size
86 &secsize=(Data.Long(a:&secoffset)&0x00ffffff)
88 gosub ProcessFvSection &secoffset
91 &secoffset=(&secoffset+&secsize)
93 ;print "secsize is &secsize"
94 ;print "secoffset at &secoffset"
96 ; align to next 4 byte boundary
97 if (&secoffset&0x3)!=0
99 &secoffset=&secoffset+(0x4-(&secoffset&0x3))
106 LOCAL &secstart §ionsize §iontype &secoffset &secsize
109 §ionsize=Data.Long(a:&secstart)
110 §iontype=((§ionsize&0xff000000)>>24.)
111 §ionsize=§ionsize&0x00ffffff;
113 print "fv section at &secstart size §ionsize type §iontype"
115 if §iontype==0x10 ; PE32
117 do EfiProcessPeImage (&secstart+0x4)
121 if §iontype==0x12 ; TE
123 do EfiProcessTeImage (&secstart+0x4)
127 print "unknown section type"