Add a "debug_build" query to crossystem.

Querying "debug_build" allows the caller to determine whether the
image has requested debug, independent of the setting of the
dev_mode switch.

BUG=chromium:308678
BRANCH=none
TEST=use the new command option on both base and dev images

Change-Id: I369f26d75156f2e88d9f6f467efbf8f633e78bda
Reviewed-on: https://chromium-review.googlesource.com/174107
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Will Drewry <wad@chromium.org>
Commit-Queue: Richard Barnette <jrbarnette@chromium.org>
This commit is contained in:
J. Richard Barnette
2013-10-22 16:21:14 -07:00
committed by chrome-internal-fetch
parent d96b25d0c0
commit 92cbd5d214
2 changed files with 40 additions and 8 deletions

View File

@@ -50,6 +50,15 @@ typedef enum VdatIntField {
} VdatIntField;
/* Description of build options that may be specified on the
* kernel command line. */
typedef enum VbBuildOption {
VB_BUILD_OPTION_UNKNOWN,
VB_BUILD_OPTION_DEBUG,
VB_BUILD_OPTION_NODEBUG
} VbBuildOption;
/* Masks for kern_nv usage by kernel. */
#define KERN_NV_FWUPDATE_TRIES_MASK 0x0000000F
/* If you want to use the remaining currently-unused bits in kern_nv
@@ -122,17 +131,14 @@ VbSetNvCleanup:
return retval;
}
/* Determine whether OS-level debugging should be allowed. Passed the
* destination and its size. Returns 1 if yes, 0 if no, -1 if error. */
int VbGetCrosDebug(void) {
/* Find what build/debug status is specified on the kernel command
* line, if any. */
static VbBuildOption VbScanBuildOption(void) {
FILE* f = NULL;
char buf[4096] = "";
char *t, *saveptr;
const char *delimiters = " \r\n";
/* If the currently running system specifies its debug status, use
* that in preference to other indicators. */
f = fopen(KERNEL_CMDLINE_PATH, "r");
if (NULL != f) {
if (NULL == fgets(buf, sizeof(buf), f))
@@ -142,8 +148,31 @@ int VbGetCrosDebug(void) {
for (t = strtok_r(buf, delimiters, &saveptr); t;
t = strtok_r(NULL, delimiters, &saveptr)) {
if (0 == strcmp(t, "cros_debug"))
return 1;
return VB_BUILD_OPTION_DEBUG;
else if (0 == strcmp(t, "cros_nodebug"))
return VB_BUILD_OPTION_NODEBUG;
}
return VB_BUILD_OPTION_UNKNOWN;
}
/* Determine whether the running OS image was built for debugging.
* Returns 1 if yes, 0 if no or indeterminate. */
int VbGetDebugBuild(void) {
return VB_BUILD_OPTION_DEBUG == VbScanBuildOption();
}
/* Determine whether OS-level debugging should be allowed.
* Returns 1 if yes, 0 if no or indeterminate. */
int VbGetCrosDebug(void) {
/* If the currently running system specifies its debug status, use
* that in preference to other indicators. */
VbBuildOption option = VbScanBuildOption();
if (VB_BUILD_OPTION_DEBUG == option) {
return 1;
} else if (VB_BUILD_OPTION_NODEBUG == option) {
return 0;
}
@@ -435,6 +464,8 @@ int VbGetSystemPropertyInt(const char* name) {
/* Other parameters */
else if (!strcasecmp(name,"cros_debug")) {
value = VbGetCrosDebug();
} else if (!strcasecmp(name,"debug_build")) {
value = VbGetDebugBuild();
} else if (!strcasecmp(name,"devsw_boot")) {
value = GetVdatInt(VDAT_INT_DEVSW_BOOT);
} else if (!strcasecmp(name,"devsw_virtual")) {

View File

@@ -40,7 +40,7 @@ const Param sys_param_list[] = {
{"cros_debug", 0, "OS should allow debug features"},
{"dbg_reset", CAN_WRITE, "Debug reset mode request (writable)"},
{"ddr_type", IS_STRING, "Type of DDR RAM"},
{"disable_dev_request", CAN_WRITE, "Disable virtual dev-mode on next boot"},
{"debug_build", 0, "OS image built for debug features"},
{"dev_boot_usb", CAN_WRITE,
"Enable developer mode boot from USB/SD (writable)"},
{"dev_boot_legacy", CAN_WRITE,
@@ -49,6 +49,7 @@ const Param sys_param_list[] = {
"Enable developer mode boot only from official kernels (writable)"},
{"devsw_boot", 0, "Developer switch position at boot"},
{"devsw_cur", 0, "Developer switch current position"},
{"disable_dev_request", CAN_WRITE, "Disable virtual dev-mode on next boot"},
{"ecfw_act", IS_STRING, "Active EC firmware"},
{"fmap_base", 0, "Main firmware flashmap physical address", "0x%08x"},
{"fwb_tries", CAN_WRITE, "Try firmware B count (writable)"},