| OLD | NEW |
| 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 const char* format; /* Format string, if non-NULL and 0==is_string*/ |
| 20 } Param; | 20 } Param; |
| 21 | 21 |
| 22 /* List of parameters, terminated with a param with NULL name */ | 22 /* List of parameters, terminated with a param with NULL name */ |
| 23 const Param sys_param_list[] = { | 23 const Param sys_param_list[] = { |
| 24 /* Read-only integers */ | 24 /* Read-only integers */ |
| 25 {"devsw_cur", 0, 0, "Developer switch current position"}, | 25 {"devsw_cur", 0, 0, "Developer switch current position"}, |
| 26 {"devsw_boot", 0, 0, "Developer switch position at boot"}, | 26 {"devsw_boot", 0, 0, "Developer switch position at boot"}, |
| 27 {"recoverysw_cur", 0, 0, "Recovery switch current position"}, | 27 {"recoverysw_cur", 0, 0, "Recovery switch current position"}, |
| 28 {"recoverysw_boot", 0, 0, "Recovery switch position at boot"}, | 28 {"recoverysw_boot", 0, 0, "Recovery switch position at boot"}, |
| 29 {"recoverysw_ec_boot", 0, 0, "Recovery switch position at EC boot"}, | 29 {"recoverysw_ec_boot", 0, 0, "Recovery switch position at EC boot"}, |
| 30 {"wpsw_cur", 0, 0, "Firmware write protect switch current position"}, | 30 {"wpsw_cur", 0, 0, |
| 31 {"wpsw_boot", 0, 0, "Firmware write protect switch position at boot"}, | 31 "Firmware write protect hardware switch current position"}, |
| 32 {"wpsw_boot", 0, 0, |
| 33 "Firmware write protect hardware switch position at boot"}, |
| 32 {"recovery_reason", 0, 0, "Recovery mode reason for current boot"}, | 34 {"recovery_reason", 0, 0, "Recovery mode reason for current boot"}, |
| 33 {"savedmem_base", 0, 0, "RAM debug data area physical address", "0x%08x"}, | 35 {"savedmem_base", 0, 0, "RAM debug data area physical address", "0x%08x"}, |
| 34 {"savedmem_size", 0, 0, "RAM debug data area size in bytes"}, | 36 {"savedmem_size", 0, 0, "RAM debug data area size in bytes"}, |
| 35 {"fmap_base", 0, 0, "Main firmware flashmap physical address", "0x%08x"}, | 37 {"fmap_base", 0, 0, "Main firmware flashmap physical address", "0x%08x"}, |
| 36 {"tried_fwb", 0, 0, "Tried firmware B before A this boot"}, | 38 {"tried_fwb", 0, 0, "Tried firmware B before A this boot"}, |
| 37 {"cros_debug", 0, 0, "OS should allow debug features"}, | 39 {"cros_debug", 0, 0, "OS should allow debug features"}, |
| 38 /* Read-only strings */ | 40 /* Read-only strings */ |
| 39 {"hwid", 1, 0, "Hardware ID"}, | 41 {"hwid", 1, 0, "Hardware ID"}, |
| 40 {"fwid", 1, 0, "Active firmware ID"}, | 42 {"fwid", 1, 0, "Active firmware ID"}, |
| 41 {"ro_fwid", 1, 0, "Read-only firmware ID"}, | 43 {"ro_fwid", 1, 0, "Read-only firmware ID"}, |
| 42 {"mainfw_act", 1, 0, "Active main firmware"}, | 44 {"mainfw_act", 1, 0, "Active main firmware"}, |
| 43 {"mainfw_type", 1, 0, "Active main firmware type"}, | 45 {"mainfw_type", 1, 0, "Active main firmware type"}, |
| 44 {"ecfw_act", 1, 0, "Active EC firmware"}, | 46 {"ecfw_act", 1, 0, "Active EC firmware"}, |
| 45 {"kernkey_vfy", 1, 0, "Type of verification done on kernel key block"}, | 47 {"kernkey_vfy", 1, 0, "Type of verification done on kernel key block"}, |
| 46 /* Writable integers */ | 48 /* Writable integers */ |
| 47 {"nvram_cleared", 0, 1, "Have NV settings been lost? Write 0 to clear"}, | 49 {"nvram_cleared", 0, 1, "Have NV settings been lost? Write 0 to clear"}, |
| 48 {"kern_nv", 0, 1, "Non-volatile field for kernel use", "0x%08x"}, | 50 {"kern_nv", 0, 1, "Non-volatile field for kernel use", "0x%08x"}, |
| 49 {"recovery_request", 0, 1, "Recovery mode request (writable)"}, | 51 {"recovery_request", 0, 1, "Recovery mode request (writable)"}, |
| 50 {"dbg_reset", 0, 1, "Debug reset mode request (writable)"}, | 52 {"dbg_reset", 0, 1, "Debug reset mode request (writable)"}, |
| 51 {"fwb_tries", 0, 1, "Try firmware B count (writable)"}, | 53 {"fwb_tries", 0, 1, "Try firmware B count (writable)"}, |
| 54 {"vbtest_errfunc", 0, 1, "Verified boot test error function (writable)"}, |
| 55 {"vbtest_errno", 0, 1, "Verified boot test error number (writable)"}, |
| 52 {"vdat", 1, 0, "Raw VDAT contents."}, | 56 {"vdat", 1, 0, "Raw VDAT contents."}, |
| 53 | 57 |
| 54 /* TODO: implement the following: | |
| 55 * nvram_cleared | |
| 56 */ | |
| 57 | |
| 58 /* Terminate with null name */ | 58 /* Terminate with null name */ |
| 59 {NULL, 0, 0, NULL} | 59 {NULL, 0, 0, NULL} |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 | 62 |
| 63 /* Print help */ | 63 /* Print help */ |
| 64 void PrintHelp(const char *progname) { | 64 void PrintHelp(const char *progname) { |
| 65 const Param *p; | 65 const Param *p; |
| 66 | 66 |
| 67 printf("\nUsage:\n" | 67 printf("\nUsage:\n" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 if (has_set) | 226 if (has_set) |
| 227 retval = SetParam(p, value); | 227 retval = SetParam(p, value); |
| 228 else if (has_expect) | 228 else if (has_expect) |
| 229 retval = CheckParam(p, value); | 229 retval = CheckParam(p, value); |
| 230 else | 230 else |
| 231 retval = PrintParam(p); | 231 retval = PrintParam(p); |
| 232 } | 232 } |
| 233 | 233 |
| 234 return retval; | 234 return retval; |
| 235 } | 235 } |
| OLD | NEW |