summaryrefslogtreecommitdiff
path: root/util/cbmem
diff options
context:
space:
mode:
authorPratik Prajapati <pratikkumar.v.prajapati@intel.com>2015-09-03 12:58:44 -0700
committerPatrick Georgi <pgeorgi@google.com>2015-11-20 18:21:30 +0100
commitc29e57d88c6c20476354a78a940d85289ee93f36 (patch)
tree4f2e90b77709e506210c55a0e98f9810207824bf /util/cbmem
parentb90b94d3efbbe969c019ab8bb8316e2c08ac4968 (diff)
util/cbmem: Add --rawdump <cbtable ID> and extend -l output
Changed following things, (1) cbmem -l would give both ID and Name for coreboot table along with START and LENGTH of each entry e.g. localhost ~ # cbmem -l CBMEM table of contents: NAME ID START LENGTH <.....> 3. TIME STAMP 54494d45 77ddd000 000002e0 4. MRC DATA 4d524344 77ddb000 00001880 5. ROMSTG STCK 90357ac4 77dd6000 00005000 6. VBOOT WORK 78007343 77dd2000 00004000 7. VBOOT 780074f0 77dd1000 00000c3c 8. RAMSTAGE 9a357a9e 77d13000 000be000 9. REFCODE 04efc0de 77c01000 00112000 10. ACPI GNVS 474e5653 77c00000 00001000 11. SMM BACKUP 07e9acee 77bf0000 00010000 <..etc..> (2) With this patch, new command line arg "rawdump" or "-r" will be added to cbmem user can grab the ID with "cbmem -l" and execute "cbmem -r <ID>" to get raw dump of cbtable for the <ID> in interest. This change is needed to get MMA results data from cbtable. Coreboot stores the MMA results in cbmem. Separate post processing scripts uses cbmem utility to get the these data. This feature in the cbmem tool can also help debugging some issues where some specific ID of cbtable needs examination. BRANCH=none BUG=chrome-os-partner:43731 TEST=Build and Boot kunimitsu (FAB3). Cbmem -r and -l works as described. Not tested on Glados CQ-DEPEND=CL:299476,CL:299475,CL:299473,CL:299509,CL:299508,CL:299507,CL:*230478,CL:*230479 Change-Id: I70ba148113b4e918646b99997a9074300a9c7876 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: f60c79d845d4d4afca480b6884c564a0d5e5caf8 Original-Change-Id: I1dde50856f0aa8d4cdd3ecf013bd58d37d76eb72 Original-Signed-off-by: Pratik Prajapati <pratikkumar.v.prajapati@intel.com> Original-Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com> Original-Reviewed-on: https://chromium-review.googlesource.com/299474 Original-Commit-Ready: Pratikkumar V Prajapati <pratikkumar.v.prajapati@intel.com> Original-Tested-by: Pratikkumar V Prajapati <pratikkumar.v.prajapati@intel.com> Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Original-Reviewed-by: Pratikkumar V Prajapati <pratikkumar.v.prajapati@intel.com> Reviewed-on: http://review.coreboot.org/12482 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'util/cbmem')
-rw-r--r--util/cbmem/cbmem.c75
1 files changed, 72 insertions, 3 deletions
diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c
index d8c6145732..7c210ba0f2 100644
--- a/util/cbmem/cbmem.c
+++ b/util/cbmem/cbmem.c
@@ -757,6 +757,63 @@ static void dump_cbmem_hex(void)
hexdump(unpack_lb64(cbmem.start), unpack_lb64(cbmem.size));
}
+void rawdump(uint64_t base, uint64_t size)
+{
+ int i;
+ uint8_t *m;
+
+ m = map_memory_size((intptr_t)base, size, 1);
+ if (!m) {
+ fprintf(stderr, "Failed to map memory");
+ return;
+ }
+
+ for (i = 0 ; i < size; i++)
+ printf("%c", m[i]);
+ unmap_memory();
+}
+
+static void dump_cbmem_raw(unsigned int id)
+{
+ uint8_t *table;
+ size_t offset;
+ uint64_t base = 0;
+ uint64_t size = 0;
+
+ table = map_lbtable();
+
+ if (table == NULL)
+ return;
+
+ offset = 0;
+
+ while (offset < lbtable_size) {
+ struct lb_record *lbr;
+ struct lb_cbmem_entry *lbe;
+
+ lbr = (void *)(table + offset);
+ offset += lbr->size;
+
+ if (lbr->tag != LB_TAG_CBMEM_ENTRY)
+ continue;
+
+ lbe = (void *)lbr;
+ if (lbe->id == id) {
+ debug("found id for raw dump %0x", lbe->id);
+ base = lbe->address;
+ size = lbe->entry_size;
+ break;
+ }
+ }
+
+ unmap_lbtable();
+
+ if (!base)
+ fprintf(stderr, "id %0x not found in cbtable\n", id);
+ else
+ rawdump(base, size);
+}
+
struct cbmem_id_to_name {
uint32_t id;
const char *name;
@@ -780,7 +837,7 @@ void cbmem_print_entry(int n, uint32_t id, uint64_t base, uint64_t size)
if (name == NULL)
printf("%08x ", id);
else
- printf("%s", name);
+ printf("%s\t%08x", name, id);
printf(" %08" PRIx64 " ", base);
printf(" %08" PRIx64 "\n", size);
}
@@ -797,7 +854,7 @@ static void dump_cbmem_toc(void)
return;
printf("CBMEM table of contents:\n");
- printf(" ID START LENGTH\n");
+ printf(" NAME ID START LENGTH\n");
i = 0;
offset = 0;
@@ -925,6 +982,7 @@ static void print_usage(const char *name)
" -C | --coverage: dump coverage information\n"
" -l | --list: print cbmem table of contents\n"
" -x | --hexdump: print hexdump of cbmem area\n"
+ " -r | --rawdump ID: print rawdump of specific ID (in hex) of cbtable\n"
" -t | --timestamps: print timestamp information\n"
" -T | --parseable-timestamps: print parseable timestamps\n"
" -V | --verbose: verbose (debugging) output\n"
@@ -1056,8 +1114,10 @@ int main(int argc, char** argv)
int print_coverage = 0;
int print_list = 0;
int print_hexdump = 0;
+ int print_rawdump = 0;
int print_timestamps = 0;
int machine_readable_timestamps = 0;
+ unsigned int rawdump_id = 0;
int opt, option_index = 0;
static struct option long_options[] = {
@@ -1067,12 +1127,13 @@ int main(int argc, char** argv)
{"timestamps", 0, 0, 't'},
{"parseable-timestamps", 0, 0, 'T'},
{"hexdump", 0, 0, 'x'},
+ {"rawdump", required_argument, 0, 'r'},
{"verbose", 0, 0, 'V'},
{"version", 0, 0, 'v'},
{"help", 0, 0, 'h'},
{0, 0, 0, 0}
};
- while ((opt = getopt_long(argc, argv, "cCltTxVvh?",
+ while ((opt = getopt_long(argc, argv, "cCltTxVvh?r:",
long_options, &option_index)) != EOF) {
switch (opt) {
case 'c':
@@ -1091,6 +1152,11 @@ int main(int argc, char** argv)
print_hexdump = 1;
print_defaults = 0;
break;
+ case 'r':
+ print_rawdump = 1;
+ print_defaults = 0;
+ rawdump_id = strtoul(optarg, NULL, 16);
+ break;
case 't':
print_timestamps = 1;
print_defaults = 0;
@@ -1198,6 +1264,9 @@ int main(int argc, char** argv)
if (print_hexdump)
dump_cbmem_hex();
+ if (print_rawdump)
+ dump_cbmem_raw(rawdump_id);
+
if (print_defaults || print_timestamps)
dump_timestamps(machine_readable_timestamps);