Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: bct_dump.c

Issue 6524004: Add bct_dump tool. (Closed)
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« GNUmakefile ('K') | « GNUmakefile ('k') | nvboot_bct.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /**
2 * Copyright (c) 2011 NVIDIA Corporation. All rights reserved.
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23 #include "cbootimage.h"
24 #include "nvbctlib.h"
25 #include "context.h"
26
27 #include <string.h>
28
29 int enable_debug = 0;
30
31 typedef struct {
32 nvbct_lib_id id;
33 char const * message;
34 } value_data;
35
36 static value_data const values[] = {
37 {nvbct_lib_id_boot_data_version, "Version................: 0x%08x\n"},
38 {nvbct_lib_id_block_size_log2, "Block size (log2)......: %d\n"},
39 {nvbct_lib_id_page_size_log2, "Page size (log2).......: %d\n"},
40 {nvbct_lib_id_partition_size, "Parition size..........: 0x%08x\n"},
41 {nvbct_lib_id_bootloader_used, "Bootloader used........: %d\n"},
42 {nvbct_lib_id_bootloaders_max, "Bootloaders max........: %d\n"},
43 {nvbct_lib_id_bct_size, "BCT size...............: %d\n"},
44 {nvbct_lib_id_hash_size, "Hash size..............: %d\n"},
45 {nvbct_lib_id_crypto_offset, "Crypto offset..........: %d\n"},
46 {nvbct_lib_id_crypto_length, "Crypto length..........: %d\n"},
47 {nvbct_lib_id_max_bct_search_blks, "Max BCT search blocks..: %d\n"},
48 };
49
50 static value_data const bl_values[] = {
51 {nvbct_lib_id_bl_version, " Version.......: 0x%08x\n"},
52 {nvbct_lib_id_bl_start_blk, " Start block...: %d\n"},
53 {nvbct_lib_id_bl_start_page, " Start page....: %d\n"},
54 {nvbct_lib_id_bl_length, " Length........: %d\n"},
55 {nvbct_lib_id_bl_load_addr, " Load address..: 0x%08x\n"},
56 {nvbct_lib_id_bl_entry_point, " Entry point...: 0x%08x\n"},
57 {nvbct_lib_id_bl_attribute, " Attributes....: 0x%08x\n"},
58 };
59
60 static void
61 usage(void)
62 {
63 printf("Usage: bct_dump bctfile\n");
64 printf(" bctfile BCT filename to read and display\n");
65 }
66
67 int
68 main(int argc, char *argv[])
69 {
70 int e;
71 build_image_context context;
72 u_int32_t bootloaders_used;
73 u_int32_t data;
74 int i;
75 int j;
76
77 if (argc != 2)
78 usage();
79
80 memset(&context, 0, sizeof(build_image_context));
81
82 context.bct_filename = argv[1];
83
84 /* Set up the Nvbctlib function pointers. */
85 nvbct_lib_get_fns(&(context.bctlib));
86
87 e = init_context(&context);
88 if (e != 0) {
89 printf("context initialization failed. Aborting.\n");
90 return e;
91 }
92
93 read_bct_file(&context);
94
95 for (i = 0; i < sizeof(values) / sizeof(values[0]); ++i) {
96 e = context.bctlib.get_value(values[i].id, &data, context.bct);
97 printf(values[i].message, e == 0 ? data : -1);
98 }
99
100 e = context.bctlib.get_value(nvbct_lib_id_bootloader_used,
101 &bootloaders_us ed,
vb 2011/02/23 22:34:02 please wrap long lines
robotboy 2011/02/23 22:45:52 This is an artifact of the code review server. Th
102 context.bct);
103
104 for (i = 0; (e == 0) && (i < bootloaders_used); ++i) {
105 printf("Bootloader[%d]\n", i);
106
107 for (j = 0; j < sizeof(bl_values) / sizeof(bl_values[0]); ++j) {
108 e = context.bctlib.getbl_param(i,
109 bl_values[j].id,
110 &data,
111 context.bct);
112 printf(bl_values[j].message, e == 0 ? data : -1);
113 }
114 }
115
116 /* Clean up memory. */
117 cleanup_context(&context);
118
119 return e;
120 }
OLDNEW
« GNUmakefile ('K') | « GNUmakefile ('k') | nvboot_bct.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698