diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2007-05-09 10:17:44 +0000 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2007-05-09 10:17:44 +0000 |
commit | c7dc7cc196a4bd5ba1cfafc87b193b89ae01a470 (patch) | |
tree | 06360b19621400a94e7ea8fa8c4a33e33392197b /util/flashrom/lbtable.c | |
parent | 33d1af37ae58c34288ae5fad9879a2ea2b752620 (diff) | |
download | coreboot-c7dc7cc196a4bd5ba1cfafc87b193b89ae01a470.tar.xz |
Fix coding style of flashrom by running indent on all files:
indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs *.[ch]
Some minor fixups were required, and maybe a few more cosmetic
changeѕ are needed.
Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2643 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/flashrom/lbtable.c')
-rw-r--r-- | util/flashrom/lbtable.c | 88 |
1 files changed, 45 insertions, 43 deletions
diff --git a/util/flashrom/lbtable.c b/util/flashrom/lbtable.c index 4409e51d8f..d65d1a0c4d 100644 --- a/util/flashrom/lbtable.c +++ b/util/flashrom/lbtable.c @@ -11,13 +11,13 @@ #include "linuxbios_tables.h" #include "debug.h" -char *lb_part=NULL, *lb_vendor=NULL; +char *lb_part = NULL, *lb_vendor = NULL; static unsigned long compute_checksum(void *addr, unsigned long length) { uint8_t *ptr; volatile union { - uint8_t byte[2]; + uint8_t byte[2]; uint16_t word; } value; unsigned long sum; @@ -27,7 +27,7 @@ static unsigned long compute_checksum(void *addr, unsigned long length) */ sum = 0; ptr = addr; - for(i = 0; i < length; i++) { + for (i = 0; i < length; i++) { unsigned long value; value = ptr[i]; if (i & 1) { @@ -50,10 +50,9 @@ static unsigned long compute_checksum(void *addr, unsigned long length) (((char *)rec) < (((char *)head) + sizeof(*head) + head->table_bytes)) && \ (rec->size >= 1) && \ ((((char *)rec) + rec->size) <= (((char *)head) + sizeof(*head) + head->table_bytes)); \ - rec = (struct lb_record *)(((char *)rec) + rec->size)) - + rec = (struct lb_record *)(((char *)rec) + rec->size)) -static int count_lb_records(struct lb_header *head) +static int count_lb_records(struct lb_header *head) { struct lb_record *rec; int count; @@ -64,18 +63,20 @@ static int count_lb_records(struct lb_header *head) return count; } - -static struct lb_header *find_lb_table(void *base, unsigned long start, unsigned long end) +static struct lb_header *find_lb_table(void *base, unsigned long start, + unsigned long end) { unsigned long addr; /* For now be stupid.... */ - for(addr = start; addr < end; addr += 16) { - struct lb_header *head = (struct lb_header *)(((char*)base) + addr); - struct lb_record *recs = (struct lb_record *)(((char*)base) + addr + sizeof(*head)); + for (addr = start; addr < end; addr += 16) { + struct lb_header *head = + (struct lb_header *)(((char *)base) + addr); + struct lb_record *recs = + (struct lb_record *)(((char *)base) + addr + sizeof(*head)); if (memcmp(head->signature, "LBIO", 4) != 0) continue; - printf_debug( "Found canidate at: %08lx-%08lx\n", - addr, addr + head->table_bytes); + printf_debug("Found canidate at: %08lx-%08lx\n", + addr, addr + head->table_bytes); if (head->header_bytes != sizeof(*head)) { fprintf(stderr, "Header bytes of %d are incorrect\n", head->header_bytes); @@ -86,12 +87,12 @@ static struct lb_header *find_lb_table(void *base, unsigned long start, unsigned head->table_entries); continue; } - if (compute_checksum((uint8_t *)head, sizeof(*head)) != 0) { + if (compute_checksum((uint8_t *) head, sizeof(*head)) != 0) { fprintf(stderr, "bad header checksum\n"); continue; } if (compute_checksum(recs, head->table_bytes) - != head->table_checksum) { + != head->table_checksum) { fprintf(stderr, "bad table checksum: %04x\n", head->table_checksum); continue; @@ -111,21 +112,20 @@ static void find_mainboard(struct lb_record *ptr, unsigned long addr) rec = (struct lb_mainboard *)ptr; max_size = rec->size - sizeof(*rec); printf("vendor id: %.*s part id: %.*s\n", - max_size - rec->vendor_idx, - rec->strings + rec->vendor_idx, - max_size - rec->part_number_idx, - rec->strings + rec->part_number_idx); - snprintf(vendor, 255, "%.*s", max_size - rec->vendor_idx, - rec->strings + rec->vendor_idx); + max_size - rec->vendor_idx, + rec->strings + rec->vendor_idx, + max_size - rec->part_number_idx, + rec->strings + rec->part_number_idx); + snprintf(vendor, 255, "%.*s", max_size - rec->vendor_idx, + rec->strings + rec->vendor_idx); snprintf(part, 255, "%.*s", max_size - rec->part_number_idx, - rec->strings + rec->part_number_idx); + rec->strings + rec->part_number_idx); - if(lb_part) { - printf("overwritten by command line, vendor id: %s part id: %s\n", - lb_vendor, lb_part); + if (lb_part) { + printf("overwritten by command line, vendor id: %s part id: %s\n", lb_vendor, lb_part); } else { - lb_part=strdup(part); - lb_vendor=strdup(vendor); + lb_part = strdup(part); + lb_vendor = strdup(vendor); } } @@ -134,33 +134,35 @@ static struct lb_record *next_record(struct lb_record *rec) return (struct lb_record *)(((char *)rec) + rec->size); } -static void search_lb_records(struct lb_record *rec, struct lb_record *last, - unsigned long addr) +static void search_lb_records(struct lb_record *rec, struct lb_record *last, + unsigned long addr) { struct lb_record *next; int count; count = 0; - for(next = next_record(rec); (rec < last) && (next <= last); - rec = next, addr += rec->size) { + for (next = next_record(rec); (rec < last) && (next <= last); + rec = next, addr += rec->size) { next = next_record(rec); count++; - if(rec->tag == LB_TAG_MAINBOARD) { - find_mainboard(rec,addr); + if (rec->tag == LB_TAG_MAINBOARD) { + find_mainboard(rec, addr); break; } } } -int linuxbios_init(void) +int linuxbios_init(void) { uint8_t *low_1MB; struct lb_header *lb_table; struct lb_record *rec, *last; - - low_1MB = mmap(0, 1024*1024, PROT_READ, MAP_SHARED, fd_mem, 0x00000000); + + low_1MB = mmap(0, 1024 * 1024, PROT_READ, MAP_SHARED, fd_mem, + 0x00000000); if (low_1MB == MAP_FAILED) { - fprintf(stderr, "Can not mmap " MEM_DEV " at %08lx errno(%d):%s\n", + fprintf(stderr, + "Can not mmap " MEM_DEV " at %08lx errno(%d):%s\n", 0x00000000UL, errno, strerror(errno)); exit(-2); } @@ -168,19 +170,19 @@ int linuxbios_init(void) if (!lb_table) lb_table = find_lb_table(low_1MB, 0x00000, 0x1000); if (!lb_table) - lb_table = find_lb_table(low_1MB, 0xf0000, 1024*1024); + lb_table = find_lb_table(low_1MB, 0xf0000, 1024 * 1024); if (lb_table) { unsigned long addr; addr = ((char *)lb_table) - ((char *)low_1MB); printf_debug("lb_table found at address %p\n", lb_table); - rec = (struct lb_record *)(((char *)lb_table) + lb_table->header_bytes); + rec = (struct lb_record *)(((char *)lb_table) + lb_table->header_bytes); last = (struct lb_record *)(((char *)rec) + lb_table->table_bytes); printf_debug("LinuxBIOS header(%d) checksum: %04x table(%d) checksum: %04x entries: %d\n", - lb_table->header_bytes, lb_table->header_checksum, - lb_table->table_bytes, lb_table->table_checksum, lb_table->table_entries); + lb_table->header_bytes, lb_table->header_checksum, + lb_table->table_bytes, lb_table->table_checksum, + lb_table->table_entries); search_lb_records(rec, last, addr + lb_table->header_bytes); - } - else { + } else { printf("No LinuxBIOS table found.\n"); return -1; } |