| Line 2... |
Line 2... |
| 2 |
#
|
2 |
#
|
| 3 |
#
|
3 |
#
|
| 4 |
# Copyright 2010 TheSeven
|
4 |
# Copyright 2010 TheSeven
|
| 5 |
#
|
5 |
#
|
| 6 |
#
|
6 |
#
|
| 7 |
# This file is part of emBIOS.
|
7 |
# This file is part of emCORE.
|
| 8 |
#
|
8 |
#
|
| 9 |
# emBIOS is free software: you can redistribute it and/or
|
9 |
# emCORE is free software: you can redistribute it and/or
|
| 10 |
# modify it under the terms of the GNU General Public License as
|
10 |
# modify it under the terms of the GNU General Public License as
|
| 11 |
# published by the Free Software Foundation, either version 2 of the
|
11 |
# published by the Free Software Foundation, either version 2 of the
|
| 12 |
# License, or (at your option) any later version.
|
12 |
# License, or (at your option) any later version.
|
| 13 |
#
|
13 |
#
|
| 14 |
# emBIOS is distributed in the hope that it will be useful,
|
14 |
# emCORE is distributed in the hope that it will be useful,
|
| 15 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
| 17 |
# See the GNU General Public License for more details.
|
17 |
# See the GNU General Public License for more details.
|
| 18 |
#
|
18 |
#
|
| 19 |
# You should have received a copy of the GNU General Public License
|
19 |
# You should have received a copy of the GNU General Public License
|
| 20 |
# along with emBIOS. If not, see <http://www.gnu.org/licenses/>.
|
20 |
# along with emCORE. If not, see <http://www.gnu.org/licenses/>.
|
| 21 |
#
|
21 |
#
|
| 22 |
#
|
22 |
#
|
| 23 |
|
23 |
|
| 24 |
import sys
|
24 |
import sys
|
| 25 |
import libembiosbootcfg
|
25 |
import libemcorebootcfg
|
| 26 |
from optparse import *
|
26 |
from optparse import *
|
| 27 |
|
27 |
|
| 28 |
parser = OptionParser("usage: %prog [options] <infile> <outfile>")
|
28 |
parser = OptionParser("usage: %prog [options] <infile> <outfile>")
|
| 29 |
filegroup = OptionGroup(parser, "Booting from a file",
|
29 |
filegroup = OptionGroup(parser, "Booting from a file",
|
| 30 |
"Use these options to configure emBIOS to try "
|
30 |
"Use these options to configure emCORE to try "
|
| 31 |
"booting from a file on a FAT32 partition")
|
31 |
"booting from a file on a FAT32 partition")
|
| 32 |
filegroup.add_option("--file", help = "Boot from FILE")
|
32 |
filegroup.add_option("--file", help = "Boot from FILE")
|
| 33 |
filegroup.add_option("--file-compressed", action = "store_true", default = False,
|
33 |
filegroup.add_option("--file-compressed", action = "store_true", default = False,
|
| 34 |
help = "Specify this if FILE is compressed")
|
34 |
help = "Specify this if FILE is compressed")
|
| 35 |
filegroup.add_option("--file-run-from", type = "int", metavar = "ADDR",
|
35 |
filegroup.add_option("--file-run-from", type = "int", metavar = "ADDR",
|
| 36 |
help = "Make sure FILE is executed from memory address ADDR")
|
36 |
help = "Make sure FILE is executed from memory address ADDR")
|
| 37 |
parser.add_option_group(filegroup)
|
37 |
parser.add_option_group(filegroup)
|
| 38 |
flashgroup = OptionGroup(parser, "Booting from a boot flash image",
|
38 |
flashgroup = OptionGroup(parser, "Booting from a boot flash image",
|
| 39 |
"Use these options to configure emBIOS to try "
|
39 |
"Use these options to configure emCORE to try "
|
| 40 |
"booting from an image located in the boot flash")
|
40 |
"booting from an image located in the boot flash")
|
| 41 |
flashgroup.add_option("--flash", metavar = "NAME", help = "Boot from flash image NAME")
|
41 |
flashgroup.add_option("--flash", metavar = "NAME", help = "Boot from flash image NAME")
|
| 42 |
flashgroup.add_option("--flash-compressed", action = "store_true", default = False,
|
42 |
flashgroup.add_option("--flash-compressed", action = "store_true", default = False,
|
| 43 |
help = "Specify this if the image is compressed")
|
43 |
help = "Specify this if the image is compressed")
|
| 44 |
flashgroup.add_option("--flash-run-from", type = "int", metavar = "ADDR",
|
44 |
flashgroup.add_option("--flash-run-from", type = "int", metavar = "ADDR",
|
| 45 |
help = "Make sure the image is executed from memory address ADDR")
|
45 |
help = "Make sure the image is executed from memory address ADDR")
|
| 46 |
parser.add_option_group(flashgroup)
|
46 |
parser.add_option_group(flashgroup)
|
| 47 |
mmapgroup = OptionGroup(parser, "Booting from a memory region",
|
47 |
mmapgroup = OptionGroup(parser, "Booting from a memory region",
|
| 48 |
"Use these options to configure emBIOS to try "
|
48 |
"Use these options to configure emCORE to try "
|
| 49 |
"booting from a memory location, such as an embedded "
|
49 |
"booting from a memory location, such as an embedded "
|
| 50 |
"app or an app located on a memory-mapped flash")
|
50 |
"app or an app located on a memory-mapped flash")
|
| 51 |
mmapgroup.add_option("--mmap-addr", metavar = "ADDR", help = "Boot from memory location ADDR")
|
51 |
mmapgroup.add_option("--mmap-addr", metavar = "ADDR", help = "Boot from memory location ADDR")
|
| 52 |
mmapgroup.add_option("--mmap-size", metavar = "SIZE",
|
52 |
mmapgroup.add_option("--mmap-size", metavar = "SIZE",
|
| 53 |
help = "Specifies the size of the executable at ADDR in bytes")
|
53 |
help = "Specifies the size of the executable at ADDR in bytes")
|
| Line 89... |
Line 89... |
| 89 |
if options.mmap_compressed: config["mmapcomp"] = True
|
89 |
if options.mmap_compressed: config["mmapcomp"] = True
|
| 90 |
if options.mmap_run_from:
|
90 |
if options.mmap_run_from:
|
| 91 |
config["mmapcopy"] = True
|
91 |
config["mmapcopy"] = True
|
| 92 |
config["mmapdest"] = options.mmap_run_from
|
92 |
config["mmapdest"] = options.mmap_run_from
|
| 93 |
|
93 |
|
| 94 |
data = libembiosbootcfg.configure(data, **config)
|
94 |
data = libemcorebootcfg.configure(data, **config)
|
| 95 |
|
95 |
|
| 96 |
file = open(args[1], "wb")
|
96 |
file = open(args[1], "wb")
|
| 97 |
file.write(data)
|
97 |
file.write(data)
|
| 98 |
file.close()
|
98 |
file.close()
|