[coreboot-gerrit] Patch set updated for coreboot: 09474d5 ifdtool: Apply coding style
Aaron Jin (jin.aaron@gmail.com)
gerrit at coreboot.org
Wed Jan 28 08:10:46 CET 2015
Aaron Jin (jin.aaron at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8275
-gerrit
commit 09474d5c40f538dac7830d4553ae9e6b88afc628
Author: Aaron Jin <jin.aaron at gmail.com>
Date: Fri Jan 23 23:35:22 2015 -0800
ifdtool: Apply coding style
- Run "indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs *.[ch]"
- Fix coding style violations documented in:
http://www.coreboot.org/Coding_Style
Change-Id: Ibdf51c03cbd17b4a0e1cb526c6de8178920b5db7
Signed-off-by: Aaron Jin <jin.aaron at gmail.com>
---
util/ifdtool/ifdtool.c | 289 +++++++++++++++++++++++++------------------------
1 file changed, 150 insertions(+), 139 deletions(-)
diff --git a/util/ifdtool/ifdtool.c b/util/ifdtool/ifdtool.c
old mode 100644
new mode 100755
index 9569dfa..a31bda5
--- a/util/ifdtool/ifdtool.c
+++ b/util/ifdtool/ifdtool.c
@@ -34,20 +34,21 @@
#define NUM_REGIONS 5
static const struct region_name region_names[NUM_REGIONS] = {
- { "Flash Descriptor", "fd" },
- { "BIOS", "bios" },
- { "Intel ME", "me" },
- { "GbE", "gbe" },
- { "Platform Data", "pd" }
+ {"Flash Descriptor", "fd"},
+ {"BIOS", "bios"},
+ {"Intel ME", "me"},
+ {"GbE", "gbe"},
+ {"Platform Data", "pd"}
};
static fdbar_t *find_fd(char *image, int size)
{
- int i, found = 0;
+ int i;
+ int found = 0;
/* Scan for FD signature */
for (i = 0; i < (size - 4); i += 4) {
- if (*(uint32_t *) (image + i) == 0x0FF0A55A) {
+ if (*(uint32_t *)(image + i) == 0x0FF0A55A) {
found = 1;
break; // signature found.
}
@@ -60,13 +61,16 @@ static fdbar_t *find_fd(char *image, int size)
printf("Found Flash Descriptor signature at 0x%08x\n", i);
- return (fdbar_t *) (image + i);
+ return (fdbar_t *)(image + i);
}
-static region_t get_region(frba_t *frba, int region_type)
+static region_t get_region(frba_t * frba, int region_type)
{
region_t region;
- region.base = 0, region.limit = 0, region.size = 0;
+
+ region.base = 0;
+ region.limit = 0;
+ region.size = 0;
switch (region_type) {
case 0:
@@ -91,7 +95,7 @@ static region_t get_region(frba_t *frba, int region_type)
break;
default:
fprintf(stderr, "Invalid region type.\n");
- exit (EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
region.size = region.limit - region.base + 1;
@@ -106,27 +110,27 @@ static void set_region(frba_t *frba, int region_type, region_t region)
switch (region_type) {
case 0:
frba->flreg0 = (((region.limit >> 12) & 0x7fff) << 16)
- | ((region.base >> 12) & 0x7fff);
+ | ((region.base >> 12) & 0x7fff);
break;
case 1:
frba->flreg1 = (((region.limit >> 12) & 0x7fff) << 16)
- | ((region.base >> 12) & 0x7fff);
+ | ((region.base >> 12) & 0x7fff);
break;
case 2:
frba->flreg2 = (((region.limit >> 12) & 0x7fff) << 16)
- | ((region.base >> 12) & 0x7fff);
+ | ((region.base >> 12) & 0x7fff);
break;
case 3:
frba->flreg3 = (((region.limit >> 12) & 0x7fff) << 16)
- | ((region.base >> 12) & 0x7fff);
+ | ((region.base >> 12) & 0x7fff);
break;
case 4:
frba->flreg4 = (((region.limit >> 12) & 0x7fff) << 16)
- | ((region.base >> 12) & 0x7fff);
+ | ((region.base >> 12) & 0x7fff);
break;
default:
fprintf(stderr, "Invalid region type.\n");
- exit (EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
}
@@ -134,7 +138,7 @@ static const char *region_name(int region_type)
{
if (region_type < 0 || region_type >= NUM_REGIONS) {
fprintf(stderr, "Invalid region type.\n");
- exit (EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
return region_names[region_type].pretty;
@@ -144,7 +148,7 @@ static const char *region_name_short(int region_type)
{
if (region_type < 0 || region_type >= NUM_REGIONS) {
fprintf(stderr, "Invalid region type.\n");
- exit (EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
return region_names[region_type].terse;
@@ -176,7 +180,7 @@ static const char *region_filename(int region_type)
if (region_type < 0 || region_type >= NUM_REGIONS) {
fprintf(stderr, "Invalid region type.\n");
- exit (EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
return region_filenames[region_type];
@@ -186,18 +190,19 @@ static void dump_region(int num, frba_t *frba)
{
region_t region = get_region(frba, num);
printf(" Flash Region %d (%s): %08x - %08x %s\n",
- num, region_name(num), region.base, region.limit,
- region.size < 1 ? "(unused)" : "");
+ num, region_name(num), region.base, region.limit,
+ region.size < 1 ? "(unused)" : "");
}
-static void dump_region_layout(char *buf, size_t bufsize, int num, frba_t *frba)
+static void dump_region_layout(char *buf, size_t bufsize, int num,
+ frba_t *frba)
{
region_t region = get_region(frba, num);
snprintf(buf, bufsize, "%08x:%08x %s\n",
- region.base, region.limit, region_name_short(num));
+ region.base, region.limit, region_name_short(num));
}
-static void dump_frba(frba_t * frba)
+static void dump_frba(frba_t *frba)
{
printf("Found Region Section\n");
printf("FLREG0: 0x%08x\n", frba->flreg0);
@@ -212,14 +217,14 @@ static void dump_frba(frba_t * frba)
dump_region(4, frba);
}
-static void dump_frba_layout(frba_t * frba, char *layout_fname)
+static void dump_frba_layout(frba_t *frba, char *layout_fname)
{
char buf[LAYOUT_LINELEN];
size_t bufsize = LAYOUT_LINELEN;
int i;
int layout_fd = open(layout_fname, O_WRONLY | O_CREAT | O_TRUNC,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (layout_fd == -1) {
perror("Could not open file");
exit(EXIT_FAILURE);
@@ -279,12 +284,12 @@ static void decode_component_density(unsigned int density)
}
}
-static void dump_fcba(fcba_t * fcba)
+static void dump_fcba(fcba_t *fcba)
{
printf("\nFound Component Section\n");
printf("FLCOMP 0x%08x\n", fcba->flcomp);
printf(" Dual Output Fast Read Support: %ssupported\n",
- (fcba->flcomp & (1 << 30))?"":"not ");
+ (fcba->flcomp & (1 << 30)) ? "" : "not ");
printf(" Read ID/Read Status Clock Frequency: ");
decode_spi_frequency((fcba->flcomp >> 27) & 7);
printf("\n Write/Erase Clock Frequency: ");
@@ -292,7 +297,7 @@ static void dump_fcba(fcba_t * fcba)
printf("\n Fast Read Clock Frequency: ");
decode_spi_frequency((fcba->flcomp >> 21) & 7);
printf("\n Fast Read Support: %ssupported",
- (fcba->flcomp & (1 << 20))?"":"not ");
+ (fcba->flcomp & (1 << 20)) ? "" : "not ");
printf("\n Read Clock Frequency: ");
decode_spi_frequency((fcba->flcomp >> 17) & 7);
printf("\n Component 2 Density: ");
@@ -301,20 +306,16 @@ static void dump_fcba(fcba_t * fcba)
decode_component_density(fcba->flcomp & 7);
printf("\n");
printf("FLILL 0x%08x\n", fcba->flill);
- printf(" Invalid Instruction 3: 0x%02x\n",
- (fcba->flill >> 24) & 0xff);
- printf(" Invalid Instruction 2: 0x%02x\n",
- (fcba->flill >> 16) & 0xff);
- printf(" Invalid Instruction 1: 0x%02x\n",
- (fcba->flill >> 8) & 0xff);
- printf(" Invalid Instruction 0: 0x%02x\n",
- fcba->flill & 0xff);
+ printf(" Invalid Instruction 3: 0x%02x\n", (fcba->flill >> 24) & 0xff);
+ printf(" Invalid Instruction 2: 0x%02x\n", (fcba->flill >> 16) & 0xff);
+ printf(" Invalid Instruction 1: 0x%02x\n", (fcba->flill >> 8) & 0xff);
+ printf(" Invalid Instruction 0: 0x%02x\n", fcba->flill & 0xff);
printf("FLPB 0x%08x\n", fcba->flpb);
printf(" Flash Partition Boundary Address: 0x%06x\n\n",
- (fcba->flpb & 0xfff) << 12);
+ (fcba->flpb & 0xfff) << 12);
}
-static void dump_fpsba(fpsba_t * fpsba)
+static void dump_fpsba(fpsba_t *fpsba)
{
printf("Found PCH Strap Section\n");
printf("PCHSTRP0: 0x%08x\n", fpsba->pchstrp0);
@@ -340,32 +341,32 @@ static void dump_fpsba(fpsba_t * fpsba)
static void decode_flmstr(uint32_t flmstr)
{
printf(" Platform Data Region Write Access: %s\n",
- (flmstr & (1 << 28)) ? "enabled" : "disabled");
+ (flmstr & (1 << 28)) ? "enabled" : "disabled");
printf(" GbE Region Write Access: %s\n",
- (flmstr & (1 << 27)) ? "enabled" : "disabled");
+ (flmstr & (1 << 27)) ? "enabled" : "disabled");
printf(" Intel ME Region Write Access: %s\n",
- (flmstr & (1 << 26)) ? "enabled" : "disabled");
+ (flmstr & (1 << 26)) ? "enabled" : "disabled");
printf(" Host CPU/BIOS Region Write Access: %s\n",
- (flmstr & (1 << 25)) ? "enabled" : "disabled");
+ (flmstr & (1 << 25)) ? "enabled" : "disabled");
printf(" Flash Descriptor Write Access: %s\n",
- (flmstr & (1 << 24)) ? "enabled" : "disabled");
+ (flmstr & (1 << 24)) ? "enabled" : "disabled");
printf(" Platform Data Region Read Access: %s\n",
- (flmstr & (1 << 20)) ? "enabled" : "disabled");
+ (flmstr & (1 << 20)) ? "enabled" : "disabled");
printf(" GbE Region Read Access: %s\n",
- (flmstr & (1 << 19)) ? "enabled" : "disabled");
+ (flmstr & (1 << 19)) ? "enabled" : "disabled");
printf(" Intel ME Region Read Access: %s\n",
- (flmstr & (1 << 18)) ? "enabled" : "disabled");
+ (flmstr & (1 << 18)) ? "enabled" : "disabled");
printf(" Host CPU/BIOS Region Read Access: %s\n",
- (flmstr & (1 << 17)) ? "enabled" : "disabled");
+ (flmstr & (1 << 17)) ? "enabled" : "disabled");
printf(" Flash Descriptor Read Access: %s\n",
- (flmstr & (1 << 16)) ? "enabled" : "disabled");
+ (flmstr & (1 << 16)) ? "enabled" : "disabled");
printf(" Requester ID: 0x%04x\n\n",
- flmstr & 0xffff);
+ flmstr & 0xffff);
}
-static void dump_fmba(fmba_t * fmba)
+static void dump_fmba(fmba_t *fmba)
{
printf("Found Master Section\n");
printf("FLMSTR1: 0x%08x (Host CPU/BIOS)\n", fmba->flmstr1);
@@ -376,7 +377,7 @@ static void dump_fmba(fmba_t * fmba)
decode_flmstr(fmba->flmstr3);
}
-static void dump_fmsba(fmsba_t * fmsba)
+static void dump_fmsba(fmsba_t *fmsba)
{
printf("Found Processor Strap Section\n");
printf("????: 0x%08x\n", fmsba->data[0]);
@@ -388,23 +389,21 @@ static void dump_fmsba(fmsba_t * fmsba)
static void dump_jid(uint32_t jid)
{
printf(" SPI Componend Device ID 1: 0x%02x\n",
- (jid >> 16) & 0xff);
+ (jid >> 16) & 0xff);
printf(" SPI Componend Device ID 0: 0x%02x\n",
- (jid >> 8) & 0xff);
- printf(" SPI Componend Vendor ID: 0x%02x\n",
- jid & 0xff);
+ (jid >> 8) & 0xff);
+ printf(" SPI Componend Vendor ID: 0x%02x\n", jid & 0xff);
}
static void dump_vscc(uint32_t vscc)
{
- printf(" Lower Erase Opcode: 0x%02x\n",
- vscc >> 24);
+ printf(" Lower Erase Opcode: 0x%02x\n", vscc >> 24);
printf(" Lower Write Enable on Write Status: 0x%02x\n",
- vscc & (1 << 20) ? 0x06 : 0x50);
+ vscc & (1 << 20) ? 0x06 : 0x50);
printf(" Lower Write Status Required: %s\n",
- vscc & (1 << 19) ? "Yes" : "No");
+ vscc & (1 << 19) ? "Yes" : "No");
printf(" Lower Write Granularity: %d bytes\n",
- vscc & (1 << 18) ? 64 : 1);
+ vscc & (1 << 18) ? 64 : 1);
printf(" Lower Block / Sector Erase Size: ");
switch ((vscc >> 16) & 0x3) {
case 0:
@@ -422,13 +421,13 @@ static void dump_vscc(uint32_t vscc)
}
printf(" Upper Erase Opcode: 0x%02x\n",
- (vscc >> 8) & 0xff);
+ (vscc >> 8) & 0xff);
printf(" Upper Write Enable on Write Status: 0x%02x\n",
- vscc & (1 << 4) ? 0x06 : 0x50);
+ vscc & (1 << 4) ? 0x06 : 0x50);
printf(" Upper Write Status Required: %s\n",
- vscc & (1 << 3) ? "Yes" : "No");
+ vscc & (1 << 3) ? "Yes" : "No");
printf(" Upper Write Granularity: %d bytes\n",
- vscc & (1 << 2) ? 64 : 1);
+ vscc & (1 << 2) ? 64 : 1);
printf(" Upper Block / Sector Erase Size: ");
switch (vscc & 0x3) {
case 0:
@@ -463,15 +462,17 @@ static void dump_vtba(vtba_t *vtba, int vtl)
static void dump_oem(uint8_t *oem)
{
- int i, j;
+ int i;
+ int j;
+
printf("OEM Section:\n");
for (i = 0; i < 4; i++) {
printf("%02x:", i << 4);
for (j = 0; j < 16; j++)
- printf(" %02x", oem[(i<<4)+j]);
- printf ("\n");
+ printf(" %02x", oem[(i << 4) + j]);
+ printf("\n");
}
- printf ("\n");
+ printf("\n");
}
static void dump_fd(char *image, int size)
@@ -498,20 +499,20 @@ static void dump_fd(char *image, int size)
printf("FLUMAP1: 0x%08x\n", fdb->flumap1);
printf(" Intel ME VSCC Table Length (VTL): %d\n",
- (fdb->flumap1 >> 8) & 0xff);
+ (fdb->flumap1 >> 8) & 0xff);
printf(" Intel ME VSCC Table Base Address (VTBA): 0x%06x\n\n",
- (fdb->flumap1 & 0xff) << 4);
+ (fdb->flumap1 & 0xff) << 4);
dump_vtba((vtba_t *)
- (image + ((fdb->flumap1 & 0xff) << 4)),
- (fdb->flumap1 >> 8) & 0xff);
- dump_oem((uint8_t *)image + 0xf00);
+ (image + ((fdb->flumap1 & 0xff) << 4)),
+ (fdb->flumap1 >> 8) & 0xff);
+ dump_oem((uint8_t *) image + 0xf00);
dump_frba((frba_t *)
- (image + (((fdb->flmap0 >> 16) & 0xff) << 4)));
- dump_fcba((fcba_t *) (image + (((fdb->flmap0) & 0xff) << 4)));
+ (image + (((fdb->flmap0 >> 16) & 0xff) << 4)));
+ dump_fcba((fcba_t *)(image + (((fdb->flmap0) & 0xff) << 4)));
dump_fpsba((fpsba_t *)
- (image + (((fdb->flmap1 >> 16) & 0xff) << 4)));
- dump_fmba((fmba_t *) (image + (((fdb->flmap1) & 0xff) << 4)));
- dump_fmsba((fmsba_t *) (image + (((fdb->flmap2) & 0xff) << 4)));
+ (image + (((fdb->flmap1 >> 16) & 0xff) << 4)));
+ dump_fmba((fmba_t *)(image + (((fdb->flmap1) & 0xff) << 4)));
+ dump_fmsba((fmsba_t *)(image + (((fdb->flmap2) & 0xff) << 4)));
}
static void dump_layout(char *image, int size, char *layout_fname)
@@ -521,8 +522,8 @@ static void dump_layout(char *image, int size, char *layout_fname)
exit(EXIT_FAILURE);
dump_frba_layout((frba_t *)
- (image + (((fdb->flmap0 >> 16) & 0xff) << 4)),
- layout_fname);
+ (image + (((fdb->flmap0 >> 16) & 0xff) << 4)),
+ layout_fname);
}
static void write_regions(char *image, int size)
@@ -533,8 +534,7 @@ static void write_regions(char *image, int size)
if (!fdb)
exit(EXIT_FAILURE);
- frba_t *frba =
- (frba_t *) (image + (((fdb->flmap0 >> 16) & 0xff) << 4));
+ frba_t *frba = (frba_t *)(image + (((fdb->flmap0 >> 16) & 0xff) << 4));
for (i = 0; i < NUM_REGIONS; i++) {
region_t region = get_region(frba, i);
@@ -542,13 +542,15 @@ static void write_regions(char *image, int size)
if (region.size > 0) {
int region_fd;
region_fd = open(region_filename(i),
- O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
+ O_WRONLY | O_CREAT | O_TRUNC |
+ O_BINARY,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (region_fd < 0) {
perror("Error while trying to open file");
exit(EXIT_FAILURE);
}
- if (write(region_fd, image + region.base, region.size) != region.size)
+ if (write(region_fd, image + region.base, region.size)
+ != region.size)
perror("Error while writing");
close(region_fd);
}
@@ -557,7 +559,7 @@ static void write_regions(char *image, int size)
static void write_image(char *filename, char *image, int size)
{
- char new_filename[FILENAME_MAX]; // allow long file names
+ char new_filename[FILENAME_MAX]; // allow long file names
int new_fd;
// - 5: leave room for ".new\0"
@@ -568,8 +570,8 @@ static void write_image(char *filename, char *image, int size)
// Now write out new image
new_fd = open(new_filename,
- O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (new_fd < 0) {
perror("Error while trying to open file");
exit(EXIT_FAILURE);
@@ -583,7 +585,7 @@ static void set_spi_frequency(char *filename, char *image, int size,
enum spi_frequency freq)
{
fdbar_t *fdb = find_fd(image, size);
- fcba_t *fcba = (fcba_t *) (image + (((fdb->flmap0) & 0xff) << 4));
+ fcba_t *fcba = (fcba_t *)(image + (((fdb->flmap0) & 0xff) << 4));
/* clear bits 21-29 */
fcba->flcomp &= ~0x3fe00000;
@@ -600,7 +602,7 @@ static void set_spi_frequency(char *filename, char *image, int size,
static void set_em100_mode(char *filename, char *image, int size)
{
fdbar_t *fdb = find_fd(image, size);
- fcba_t *fcba = (fcba_t *) (image + (((fdb->flmap0) & 0xff) << 4));
+ fcba_t *fcba = (fcba_t *)(image + (((fdb->flmap0) & 0xff) << 4));
fcba->flcomp &= ~(1 << 30);
set_spi_frequency(filename, image, size, SPI_FREQUENCY_20MHZ);
@@ -609,7 +611,7 @@ static void set_em100_mode(char *filename, char *image, int size)
static void lock_descriptor(char *filename, char *image, int size)
{
fdbar_t *fdb = find_fd(image, size);
- fmba_t *fmba = (fmba_t *) (image + (((fdb->flmap1) & 0xff) << 4));
+ fmba_t *fmba = (fmba_t *)(image + (((fdb->flmap1) & 0xff) << 4));
/* TODO: Dynamically take Platform Data Region and GbE Region
* into regard.
*/
@@ -623,7 +625,7 @@ static void lock_descriptor(char *filename, char *image, int size)
static void unlock_descriptor(char *filename, char *image, int size)
{
fdbar_t *fdb = find_fd(image, size);
- fmba_t *fmba = (fmba_t *) (image + (((fdb->flmap1) & 0xff) << 4));
+ fmba_t *fmba = (fmba_t *)(image + (((fdb->flmap1) & 0xff) << 4));
fmba->flmstr1 = 0xffff0000;
fmba->flmstr2 = 0xffff0000;
fmba->flmstr3 = 0x08080118;
@@ -637,13 +639,13 @@ void inject_region(char *filename, char *image, int size, int region_type,
fdbar_t *fdb = find_fd(image, size);
if (!fdb)
exit(EXIT_FAILURE);
- frba_t *frba =
- (frba_t *) (image + (((fdb->flmap0 >> 16) & 0xff) << 4));
+ frba_t *frba = (frba_t *)(image + (((fdb->flmap0 >> 16) & 0xff) << 4));
region_t region = get_region(frba, region_type);
if (region.size <= 0xfff) {
- fprintf(stderr, "Region %s is disabled in target. Not injecting.\n",
- region_name(region_type));
+ fprintf(stderr,
+ "Region %s is disabled in target. Not injecting.\n",
+ region_name(region_type));
exit(EXIT_FAILURE);
}
@@ -661,21 +663,21 @@ void inject_region(char *filename, char *image, int size, int region_type,
printf("File %s is %d bytes\n", region_fname, region_size);
- if ( (region_size > region.size) || ((region_type != 1) &&
- (region_size > region.size))) {
+ if ((region_size > region.size) || ((region_type != 1) &&
+ (region_size > region.size))) {
fprintf(stderr, "Region %s is %d(0x%x) bytes. File is %d(0x%x)"
- " bytes. Not injecting.\n",
- region_name(region_type), region.size,
- region.size, region_size, region_size);
+ " bytes. Not injecting.\n",
+ region_name(region_type), region.size,
+ region.size, region_size, region_size);
exit(EXIT_FAILURE);
}
int offset = 0;
if ((region_type == 1) && (region_size < region.size)) {
fprintf(stderr, "Region %s is %d(0x%x) bytes. File is %d(0x%x)"
- " bytes. Padding before injecting.\n",
- region_name(region_type), region.size,
- region.size, region_size, region_size);
+ " bytes. Padding before injecting.\n",
+ region_name(region_type), region.size,
+ region.size, region_size, region_size);
offset = region.size - region_size;
memset(image + region.base, 0xff, offset);
}
@@ -687,7 +689,7 @@ void inject_region(char *filename, char *image, int size, int region_type,
}
if (read(region_fd, image + region.base + offset, region_size)
- != region_size) {
+ != region_size) {
perror("Could not read file");
exit(EXIT_FAILURE);
}
@@ -722,8 +724,8 @@ static int regions_collide(region_t r1, region_t r2)
if ((r1.size == 0) || (r2.size == 0))
return 0;
- if ( ((r1.base >= r2.base) && (r1.base <= r2.limit)) ||
- ((r1.limit >= r2.base) && (r1.limit <= r2.limit)) )
+ if (((r1.base >= r2.base) && (r1.base <= r2.limit)) ||
+ ((r1.limit >= r2.base) && (r1.limit <= r2.limit)))
return 1;
return 0;
@@ -734,7 +736,8 @@ void new_layout(char *filename, char *image, int size, char *layout_fname)
FILE *romlayout;
char tempstr[256];
char layout_region_name[256];
- int i, j;
+ int i;
+ int j;
int region_number;
region_t current_regions[NUM_REGIONS];
region_t new_regions[NUM_REGIONS];
@@ -746,8 +749,7 @@ void new_layout(char *filename, char *image, int size, char *layout_fname)
if (!fdb)
exit(EXIT_FAILURE);
- frba_t *frba =
- (frba_t *) (image + (((fdb->flmap0 >> 16) & 0xff) << 4));
+ frba_t *frba = (frba_t *)(image + (((fdb->flmap0 >> 16) & 0xff) << 4));
for (i = 0; i < NUM_REGIONS; i++) {
current_regions[i] = get_region(frba, i);
@@ -766,7 +768,7 @@ void new_layout(char *filename, char *image, int size, char *layout_fname)
char *tstr1, *tstr2;
if (2 != fscanf(romlayout, "%255s %255s\n", tempstr,
- layout_region_name))
+ layout_region_name))
continue;
region_number = region_num(layout_region_name);
@@ -780,12 +782,12 @@ void new_layout(char *filename, char *image, int size, char *layout_fname)
exit(EXIT_FAILURE);
}
new_regions[region_number].base = strtol(tstr1,
- (char **)NULL, 16);
+ (char **)NULL, 16);
new_regions[region_number].limit = strtol(tstr2,
- (char **)NULL, 16);
+ (char **)NULL, 16);
new_regions[region_number].size =
- new_regions[region_number].limit -
- new_regions[region_number].base + 1;
+ new_regions[region_number].limit -
+ new_regions[region_number].base + 1;
if (new_regions[region_number].size < 0)
new_regions[region_number].size = 0;
@@ -799,7 +801,7 @@ void new_layout(char *filename, char *image, int size, char *layout_fname)
if (new_regions[i].size < current_regions[i].size) {
printf("DANGER: Region %s is shrinking.\n",
- region_name(i));
+ region_name(i));
printf(" The region will be truncated to fit.\n");
printf(" This may result in an unusable image.\n");
}
@@ -828,7 +830,8 @@ void new_layout(char *filename, char *image, int size, char *layout_fname)
memset(new_image, 0xff, new_extent);
for (i = 0; i < NUM_REGIONS; i++) {
int copy_size = new_regions[i].size;
- int offset_current = 0, offset_new = 0;
+ int offset_current = 0;
+ int offset_new = 0;
region_t current = current_regions[i];
region_t new = new_regions[i];
@@ -846,16 +849,15 @@ void new_layout(char *filename, char *image, int size, char *layout_fname)
offset_current = current.size - new.size;
}
- printf("Copy Descriptor %d (%s) (%d bytes)\n", i,
- region_name(i), copy_size);
+ printf("Copy Descriptor %d (%s)(%d bytes)\n", i,
+ region_name(i), copy_size);
printf(" from %08x+%08x:%08x (%10d)\n", current.base,
- offset_current, current.limit, current.size);
+ offset_current, current.limit, current.size);
printf(" to %08x+%08x:%08x (%10d)\n", new.base,
- offset_new, new.limit, new.size);
+ offset_new, new.limit, new.size);
memcpy(new_image + new.base + offset_new,
- image + current.base + offset_current,
- copy_size);
+ image + current.base + offset_current, copy_size);
}
/* update new descriptor regions */
@@ -863,7 +865,7 @@ void new_layout(char *filename, char *image, int size, char *layout_fname)
if (!fdb)
exit(EXIT_FAILURE);
- frba = (frba_t *) (new_image + (((fdb->flmap0 >> 16) & 0xff) << 4));
+ frba = (frba_t *)(new_image + (((fdb->flmap0 >> 16) & 0xff) << 4));
for (i = 1; i < NUM_REGIONS; i++) {
set_region(frba, i, new_regions[i]);
}
@@ -904,18 +906,26 @@ static void print_usage(const char *name)
" -u | --unlock Unlock firmware descriptor and ME region\n"
" -v | --version: print the version\n"
" -h | --help: print this help\n\n"
- "<region> is one of Descriptor, BIOS, ME, GbE, Platform\n"
- "\n");
+ "<region> is one of Descriptor, BIOS, ME, GbE, Platform\n" "\n");
}
int main(int argc, char *argv[])
{
int opt, option_index = 0;
- int mode_dump = 0, mode_extract = 0, mode_inject = 0, mode_spifreq = 0;
- int mode_em100 = 0, mode_locked = 0, mode_unlocked = 0;
- int mode_layout = 0, mode_newlayout = 0;
- char *region_type_string = NULL, *region_fname = NULL, *layout_fname = NULL;
- int region_type = -1, inputfreq = 0;
+ int mode_dump = 0;
+ int mode_extract = 0;
+ int mode_inject = 0;
+ int mode_spifreq = 0;
+ int mode_em100 = 0;
+ int mode_locked = 0;
+ int mode_unlocked = 0;
+ int mode_layout = 0;
+ int mode_newlayout = 0;
+ char *region_type_string = NULL;
+ char *region_fname = NULL;
+ char *layout_fname = NULL;
+ int region_type = -1;
+ int inputfreq = 0;
enum spi_frequency spifreq = SPI_FREQUENCY_20MHZ;
static struct option long_options[] = {
@@ -1017,14 +1027,16 @@ int main(int argc, char *argv[])
case 'l':
mode_locked = 1;
if (mode_unlocked == 1) {
- fprintf(stderr, "Locking/Unlocking FD and ME are mutually exclusive\n");
+ fprintf(stderr,
+ "Locking/Unlocking FD and ME are mutually exclusive\n");
exit(EXIT_FAILURE);
}
break;
case 'u':
mode_unlocked = 1;
if (mode_locked == 1) {
- fprintf(stderr, "Locking/Unlocking FD and ME are mutually exclusive\n");
+ fprintf(stderr,
+ "Locking/Unlocking FD and ME are mutually exclusive\n");
exit(EXIT_FAILURE);
}
break;
@@ -1042,8 +1054,8 @@ int main(int argc, char *argv[])
}
if ((mode_dump + mode_layout + mode_extract + mode_inject +
- mode_newlayout + (mode_spifreq | mode_em100 | mode_unlocked |
- mode_locked)) > 1) {
+ mode_newlayout + (mode_spifreq | mode_em100 | mode_unlocked |
+ mode_locked)) > 1) {
fprintf(stderr, "You may not specify more than one mode.\n\n");
print_usage(argv[0]);
exit(EXIT_FAILURE);
@@ -1101,8 +1113,7 @@ int main(int argc, char *argv[])
write_regions(image, size);
if (mode_inject)
- inject_region(filename, image, size, region_type,
- region_fname);
+ inject_region(filename, image, size, region_type, region_fname);
if (mode_newlayout)
new_layout(filename, image, size, layout_fname);
@@ -1113,7 +1124,7 @@ int main(int argc, char *argv[])
if (mode_em100)
set_em100_mode(filename, image, size);
- if(mode_locked)
+ if (mode_locked)
lock_descriptor(filename, image, size);
if (mode_unlocked)
More information about the coreboot-gerrit
mailing list