#include <string.h>
#include <errno.h>
#include <sys/mman.h>
-#include "../../src/include/boot/linuxbios_tables.h"
+#include "../../src/include/boot/coreboot_tables.h"
void print_lb_records(struct lb_record *rec, struct lb_record *last, unsigned long addr);
(((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)
{
struct lb_record *recs = (struct lb_record *)(((char*)base) + addr + sizeof(*head));
if (memcmp(head->signature, "LBIO", 4) != 0)
continue;
- fprintf(stdout, "Found canidate at: %08lx-%08lx\n",
+ fprintf(stdout, "Found candidate 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->table_checksum);
continue;
}
- fprintf(stdout, "Found LinuxBIOS table at: %08lx\n", addr);
+ fprintf(stdout, "Found coreboot table at: %08lx\n", addr);
return head;
};
return;
}
-void pretty_print_number(FILE *stream, uint64_t value)
+void pretty_print_number(FILE *stream, uint64_t num)
{
+ unsigned long long value = (unsigned long long) num;
+
if (value > 1024ULL*1024*1024*1024*1024*1024) {
value /= 1024ULL*1024*1024*1024*1024*1024;
- fprintf(stream, "%ldEB", value);
+ fprintf(stream, "%lldEB", value);
}
else if (value > 1024ULL*1024*1024*1024*1024) {
value /= 1024ULL*1024*1024*1024*1024;
- fprintf(stream, "%ldPB", value);
+ fprintf(stream, "%lldPB", value);
}
else if (value > 1024ULL*1024*1024*1024) {
value /= 1024ULL*1024*1024*1024;
- fprintf(stream, "%ldTB", value);
+ fprintf(stream, "%lldTB", value);
}
else if (value > 1024ULL*1024*1024) {
value /= 1024ULL*1024*1024;
- fprintf(stream, "%ldGB", value);
+ fprintf(stream, "%lldGB", value);
}
else if (value > 1024ULL*1024) {
value /= 1024ULL*1024;
- fprintf(stream, "%ldMB", value);
+ fprintf(stream, "%lldMB", value);
}
else if (value > 1024ULL) {
value /= 1024ULL;
- fprintf(stream, "%ldKB", value);
+ fprintf(stream, "%lldKB", value);
}
else {
- fprintf(stream, "%ldB", value);
+ fprintf(stream, "%lldB", value);
}
}
default:
case 2: mem_type = "reserved"; break;
}
- printf("0x%08lx - 0x%08lx %s (",
- start, end, mem_type);
+ printf("0x%08llx - 0x%08llx %s (",
+ (unsigned long long)start, (unsigned long long)end, mem_type);
pretty_print_number(stdout, start);
printf(" - ");
- pretty_print_number(stdout, end);
+ pretty_print_number(stdout, end);
printf(")\n");
}
}
rec = (struct lb_mainboard *)ptr;
max_size = rec->size - sizeof(*rec);
printf("vendor: %.*s part number: %.*s\n",
- 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);
}
struct cmos_checksum *rec;
rec = (struct cmos_checksum *)ptr;
printf("checksum %d, rec len %d, range %d-%d location %d type %d\n",
- rec->tag, rec->size,
+ rec->tag, rec->size,
rec->range_start, rec->range_end, rec->location, rec->type);
}
return (struct lb_record *)(((char *)rec) + rec->size);
}
-void print_lb_records(struct lb_record *rec, struct lb_record *last,
+void print_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++;
for(i = 0; lb_types[i].print != 0; i++) {
rec = (struct lb_record *)(((char *)head) + head->header_bytes);
last = (struct lb_record *)(((char *)rec) + head->table_bytes);
- printf("LinuxBIOS header(%d) checksum: %04x table(%d) checksum: %04x entries: %d\n",
+ printf("Coreboot header(%d) checksum: %04x table(%d) checksum: %04x entries: %d\n",
head->header_bytes, head->header_checksum,
head->table_bytes, head->table_checksum, head->table_entries);
print_lb_records(rec, last, addr + head->header_bytes);
}
-int main(int argc, char **argv)
+int main(int argc, char **argv)
{
unsigned char *low_1MB;
struct lb_header *lb_table;