2 ; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
4 ; SPDX-License-Identifier: BSD-2-Clause-Patent
7 LOCAL &fvbase &fvsig &fvsig &ffsoffset &ffsfilesize &ffsfileaddr
10 &fvsig=Data.Long(a:&fvbase+0x28)
13 print "FV does not have proper signature, exiting"
17 print "FV signature found"
19 &fvlen=Data.Long(a:&fvbase+0x20)
21 ; first ffs file is after fv header, use headerlength field
22 &ffsoffset=(Data.Long(a:&fvbase+0x30)&0xffff)
24 ; loop through ffs files
26 while (&ffsfilesize!=0)&&(&ffsoffset<(&fvlen))
28 &ffsfileaddr=&fvbase+&ffsoffset
29 ;print "found ffs file at &ffsfileaddr"
31 ; process ffs file and increment by ffs file size field
32 gosub ProcessFfsFile &ffsfileaddr
34 &ffsfilesize=(Data.Long(a:&ffsfileaddr+0x14)&0x00ffffff)
35 ;print "ffsfilesize is &ffsfilesize"
37 &ffsoffset=&ffsoffset+&ffsfilesize
39 &ffsfilesize=(Data.Long(a:&fvbase+&ffsoffset+0x14)&0x00ffffff)
40 ;print "ffsfilesize now is &ffsfilesize"
41 if &ffsfilesize==0xffffff
46 ; align to next 8 byte boundary
47 if (&ffsoffset&0x7)!=0
49 &ffsoffset=&ffsoffset+(0x8-(&ffsoffset&0x7))
57 LOCAL &ffsfilestart &ffsfilesize &ffsfiletype &secoffset &secsize
60 ;print "processing ffs file at &ffsfilestart"
61 &ffsfilesize=Data.Long(a:&ffsfilestart+0x14)
62 &ffsfiletype=(&ffsfilesize&0xff000000)>>24.
63 &ffsfilesize=&ffsfilesize&0x00ffffff
70 print "ffs file at &ffsfilestart size &ffsfilesize type &ffsfiletype"
72 &secoffset=&ffsfilestart+0x18
74 ; loop through sections in file
75 while &secoffset<(&ffsfilestart+&ffsfilesize)
77 print "secoffset at &secoffset"
79 ; process fv section and increment section offset by size
80 &secsize=(Data.Long(a:&secoffset)&0x00ffffff)
82 gosub ProcessFvSection &secoffset
85 &secoffset=(&secoffset+&secsize)
87 ;print "secsize is &secsize"
88 ;print "secoffset at &secoffset"
90 ; align to next 4 byte boundary
91 if (&secoffset&0x3)!=0
93 &secoffset=&secoffset+(0x4-(&secoffset&0x3))
100 LOCAL &secstart §ionsize §iontype &secoffset &secsize
103 §ionsize=Data.Long(a:&secstart)
104 §iontype=((§ionsize&0xff000000)>>24.)
105 §ionsize=§ionsize&0x00ffffff;
107 print "fv section at &secstart size §ionsize type §iontype"
109 if §iontype==0x10 ; PE32
111 do EfiProcessPeImage (&secstart+0x4)
115 if §iontype==0x12 ; TE
117 do EfiProcessTeImage (&secstart+0x4)
121 print "unknown section type"