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

Side by Side Diff: utility/crossystem_main.c

Issue 6582004: Print addresses as hex (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 * 4 *
5 * Chrome OS firmware/system interface utility 5 * Chrome OS firmware/system interface utility
6 */ 6 */
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
11 11
12 #include "crossystem.h" 12 #include "crossystem.h"
13 13
14 typedef struct Param { 14 typedef struct Param {
15 const char* name; /* Parameter name */ 15 const char* name; /* Parameter name */
16 int is_string; /* 0 if integer, 1 if string */ 16 int is_string; /* 0 if integer, 1 if string */
17 int can_write; /* 0 if read-only, 1 if writable */ 17 int can_write; /* 0 if read-only, 1 if writable */
18 const char* desc; /* Human-readable description */ 18 const char* desc; /* Human-readable description */
19 const char* format; /* Format string, if non-NULL and 0==is_string*/
19 } Param; 20 } Param;
20 21
21 /* List of parameters, terminated with a param with NULL name */ 22 /* List of parameters, terminated with a param with NULL name */
22 const Param sys_param_list[] = { 23 const Param sys_param_list[] = {
23 /* Read-only integers */ 24 /* Read-only integers */
24 {"devsw_cur", 0, 0, "Developer switch current position"}, 25 {"devsw_cur", 0, 0, "Developer switch current position"},
25 {"devsw_boot", 0, 0, "Developer switch position at boot"}, 26 {"devsw_boot", 0, 0, "Developer switch position at boot"},
26 {"recoverysw_cur", 0, 0, "Recovery switch current position"}, 27 {"recoverysw_cur", 0, 0, "Recovery switch current position"},
27 {"recoverysw_boot", 0, 0, "Recovery switch position at boot"}, 28 {"recoverysw_boot", 0, 0, "Recovery switch position at boot"},
28 {"recoverysw_ec_boot", 0, 0, "Recovery switch position at EC boot"}, 29 {"recoverysw_ec_boot", 0, 0, "Recovery switch position at EC boot"},
29 {"wpsw_cur", 0, 0, "Firmware write protect switch current position"}, 30 {"wpsw_cur", 0, 0, "Firmware write protect switch current position"},
30 {"wpsw_boot", 0, 0, "Firmware write protect switch position at boot"}, 31 {"wpsw_boot", 0, 0, "Firmware write protect switch position at boot"},
31 {"recovery_reason", 0, 0, "Recovery mode reason for current boot"}, 32 {"recovery_reason", 0, 0, "Recovery mode reason for current boot"},
32 {"savedmem_base", 0, 0, "RAM debug data area physical address"}, 33 {"savedmem_base", 0, 0, "RAM debug data area physical address", "0x%08x"},
33 {"savedmem_size", 0, 0, "RAM debug data area size in bytes"}, 34 {"savedmem_size", 0, 0, "RAM debug data area size in bytes"},
34 {"fmap_base", 0, 0, "Main firmware flashmap physical address"}, 35 {"fmap_base", 0, 0, "Main firmware flashmap physical address", "0x%08x"},
35 /* Read-only strings */ 36 /* Read-only strings */
36 {"hwid", 1, 0, "Hardware ID"}, 37 {"hwid", 1, 0, "Hardware ID"},
37 {"fwid", 1, 0, "Active firmware ID"}, 38 {"fwid", 1, 0, "Active firmware ID"},
38 {"ro_fwid", 1, 0, "Read-only firmware ID"}, 39 {"ro_fwid", 1, 0, "Read-only firmware ID"},
39 {"mainfw_act", 1, 0, "Active main firmware"}, 40 {"mainfw_act", 1, 0, "Active main firmware"},
40 {"mainfw_type", 1, 0, "Active main firmware type"}, 41 {"mainfw_type", 1, 0, "Active main firmware type"},
41 {"ecfw_act", 1, 0, "Active EC firmware"}, 42 {"ecfw_act", 1, 0, "Active EC firmware"},
42 /* Writable integers */ 43 /* Writable integers */
43 {"recovery_request", 0, 1, "Recovery mode request (writable)"}, 44 {"recovery_request", 0, 1, "Recovery mode request (writable)"},
44 {"dbg_reset", 0, 1, "Debug reset mode request (writable)"}, 45 {"dbg_reset", 0, 1, "Debug reset mode request (writable)"},
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if (p->is_string) { 111 if (p->is_string) {
111 char buf[256]; 112 char buf[256];
112 const char* v = VbGetSystemPropertyString(p->name, buf, sizeof(buf)); 113 const char* v = VbGetSystemPropertyString(p->name, buf, sizeof(buf));
113 if (!v) 114 if (!v)
114 return 1; 115 return 1;
115 printf("%s", v); 116 printf("%s", v);
116 } else { 117 } else {
117 int v = VbGetSystemPropertyInt(p->name); 118 int v = VbGetSystemPropertyInt(p->name);
118 if (v == -1) 119 if (v == -1)
119 return 1; 120 return 1;
120 printf("%d", v); 121 printf(p->format ? p->format : "%d", v);
121 } 122 }
122 return 0; 123 return 0;
123 } 124 }
124 125
125 126
126 /* Print all parameters with descriptions, 127 /* Print all parameters with descriptions,
127 * 128 *
128 * Returns 0 if success, non-zero if error. */ 129 * Returns 0 if success, non-zero if error. */
129 int PrintAllParams(void) { 130 int PrintAllParams(void) {
130 const Param* p; 131 const Param* p;
131 int retval = 0; 132 int retval = 0;
132 char buf[256]; 133 char buf[256];
133 const char* value; 134 const char* value;
134 135
135 for (p = sys_param_list; p->name; p++) { 136 for (p = sys_param_list; p->name; p++) {
136 if (p->is_string) { 137 if (p->is_string) {
137 value = VbGetSystemPropertyString(p->name, buf, sizeof(buf)); 138 value = VbGetSystemPropertyString(p->name, buf, sizeof(buf));
138 } else { 139 } else {
139 int v = VbGetSystemPropertyInt(p->name); 140 int v = VbGetSystemPropertyInt(p->name);
140 if (v == -1) 141 if (v == -1)
141 value = NULL; 142 value = NULL;
142 else { 143 else {
143 snprintf(buf, sizeof(buf), "%d", v); 144 snprintf(buf, sizeof(buf), p->format ? p->format : "%d", v);
144 value = buf; 145 value = buf;
145 } 146 }
146 } 147 }
147 printf("%-22s = %-20s # %s\n", 148 printf("%-22s = %-20s # %s\n",
148 p->name, (value ? value : "(error)"), p->desc); 149 p->name, (value ? value : "(error)"), p->desc);
149 } 150 }
150 return retval; 151 return retval;
151 } 152 }
152 153
153 154
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if (i > 1) 186 if (i > 1)
186 printf(" "); /* Output params space-delimited */ 187 printf(" "); /* Output params space-delimited */
187 if (value) 188 if (value)
188 retval = SetParam(p, value); 189 retval = SetParam(p, value);
189 else 190 else
190 retval = PrintParam(p); 191 retval = PrintParam(p);
191 } 192 }
192 193
193 return retval; 194 return retval;
194 } 195 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698