FixupForRawSection.py revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
## @file
# Apply fixup to VTF binary image for FFS Raw section
#
# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
import sys
# VBox - begin
#filename = sys.argv[1] - VBox changed it to:
raise Exception("Too many arguments");
# VBox - end
#if filename.lower().find('ia32') >= 0: - VBox changed it to:
if OnlyPaddImage:
#d = open(sys.argv[1], 'rb').read() - VBox changed it to:
if c > len(d):
c -= len(d)
#f = open(sys.argv[1], 'wb') - VBox changed it to:
f.write('\x90' * c)
f.write(d)
f.close()
else:
PAGE_PRESENT = 0x01
PAGE_READ_WRITE = 0x02
PAGE_USER_SUPERVISOR = 0x04
PAGE_WRITE_THROUGH = 0x08
PAGE_CACHE_DISABLE = 0x010
PAGE_ACCESSED = 0x020
PAGE_DIRTY = 0x040
PAGE_PAT = 0x080
PAGE_GLOBAL = 0x0100
PAGE_2M_MBO = 0x080
PAGE_2M_PAT = 0x01000
def NopAlign4k(s):
return ('\x90' * c) + s
s = ''
for i in range(0x800):
i = (
)
s += pack('Q', i)
return s
s = ''
for i in range(0x200):
i = (
pdeBase +
)
s += pack('Q', i)
return s
s = ''
for i in range(0x200):
i = (
pdptBase +
)
s += pack('Q', i)
return s
def AlignAndAddPageTables():
#d = open(sys.argv[1], 'rb').read() - VBox changed it to:
code = NopAlign4k(d)
#f = open(sys.argv[1], 'wb') - VBox changed it to:
f.write(d)
f.close()