Internal (onboard) programming was the only feature which could not be disabled
Make various pieces of code conditional on support for internal
programming. Code shared between PCI device programmers and onboard
programming is now conditional as well.
It is now possible to build only with dummy support:
make CONFIG_INTERNAL=no CONFIG_NIC3COM=no CONFIG_SATASII=no
CONFIG_DRKAISER=no CONFIG_SERPROG=no CONFIG_FT2232SPI=no
This allows building for a specific use case only, and it also
facilitates porting to a new architecture because it is possible to
focus on highlevel code only.
Note: Either internal or dummy programmer needs to be compiled in due to
the current behaviour of always picking a default programmer if -p is
not specified. Picking an arbitrary external programmer as default
wouldn't make sense.
Build and runtime tested in all 1024 possible build combinations. The
only failures are by design as mentioned above.
Corresponding to flashrom svn r797.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Sean Nelson <audiohacked@gmail.com>
diff --git a/flashrom.c b/flashrom.c
index 64a6835..a0dedb5 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -33,10 +33,38 @@
const char *flashrom_version = FLASHROM_VERSION;
char *chip_to_probe = NULL;
int verbose = 0;
+
+#if INTERNAL_SUPPORT == 1
enum programmer programmer = PROGRAMMER_INTERNAL;
+#elif DUMMY_SUPPORT == 1
+enum programmer programmer = PROGRAMMER_DUMMY;
+#else
+/* Activating the #error explodes on make dep. */
+//#error Neither internal nor dummy selected
+#endif
+
char *programmer_param = NULL;
+/**
+ * flashrom defaults to Parallel/LPC/FWH flash devices. If a known host
+ * controller is found, the init routine sets the buses_supported bitfield to
+ * contain the supported buses for that controller.
+ */
+enum chipbustype buses_supported = CHIP_BUSTYPE_NONSPI;
+
+/**
+ * Programmers supporting multiple buses can have differing size limits on
+ * each bus. Store the limits for each bus in a common struct.
+ */
+struct decode_sizes max_rom_decode = {
+ .parallel = 0xffffffff,
+ .lpc = 0xffffffff,
+ .fwh = 0xffffffff,
+ .spi = 0xffffffff
+};
+
const struct programmer_entry programmer_table[] = {
+#if INTERNAL_SUPPORT == 1
{
.name = "internal",
.init = internal_init,
@@ -53,6 +81,7 @@
.chip_writen = fallback_chip_writen,
.delay = internal_delay,
},
+#endif
#if DUMMY_SUPPORT == 1
{
@@ -149,6 +178,7 @@
},
#endif
+#if INTERNAL_SUPPORT == 1
{
.name = "it87spi",
.init = it87spi_init,
@@ -165,6 +195,7 @@
.chip_writen = fallback_chip_writen,
.delay = internal_delay,
},
+#endif
#if FT2232_SPI_SUPPORT == 1
{
@@ -308,6 +339,8 @@
return 0;
}
+unsigned long flashbase = 0;
+
int min(int a, int b)
{
return (a < b) ? a : b;
@@ -866,7 +899,9 @@
" -E | --erase: erase flash device\n"
" -V | --verbose: more verbose output\n"
" -c | --chip <chipname>: probe only for specified flash chip\n"
+#if INTERNAL_SUPPORT == 1
" -m | --mainboard <[vendor:]part>: override mainboard settings\n"
+#endif
" -f | --force: force write without checking image\n"
" -l | --layout <file.layout>: read ROM layout from file\n"
" -i | --image <name>: only flash image name from flash layout\n"
@@ -962,7 +997,7 @@
char *filename = NULL;
- char *tempstr = NULL, *tempstr2 = NULL;
+ char *tempstr = NULL;
print_version();
@@ -1046,18 +1081,12 @@
}
erase_it = 1;
break;
+#if INTERNAL_SUPPORT == 1
case 'm':
tempstr = strdup(optarg);
- strtok(tempstr, ":");
- tempstr2 = strtok(NULL, ":");
- if (tempstr2) {
- lb_vendor = tempstr;
- lb_part = tempstr2;
- } else {
- lb_vendor = NULL;
- lb_part = tempstr;
- }
+ lb_vendor_dev_from_string(tempstr);
break;
+#endif
case 'f':
force = 1;
break;
@@ -1224,7 +1253,8 @@
"this flash part. Please include the flashrom\noutput "
"with the additional -V option for all operations you "
"tested (-V, -rV,\n-wV, -EV), and mention which "
- "mainboard you tested. Thanks for your help!\n===\n");
+ "mainboard or programmer you tested. Thanks for your "
+ "help!\n===\n");
}
size = flash->total_size * 1024;
@@ -1318,7 +1348,9 @@
}
numbytes = fread(buf, 1, size, image);
+#if INTERNAL_SUPPORT == 1
show_id(buf, size, force);
+#endif
fclose(image);
if (numbytes != size) {
fprintf(stderr, "Error: Failed to read file. Got %ld bytes, wanted %ld!\n", numbytes, size);