various minor sandbox improvements
This commit is contained in:
Tom Rini
2021-07-07 13:34:42 -04:00
95 changed files with 348 additions and 24 deletions

View File

@@ -390,6 +390,16 @@ static int sandbox_cmdline_cb_select_unittests(struct sandbox_state *state,
}
SANDBOX_CMDLINE_OPT_SHORT(select_unittests, 'k', 1, "Select unit tests to run");
static int sandbox_cmdline_cb_signals(struct sandbox_state *state,
const char *arg)
{
state->handle_signals = true;
return 0;
}
SANDBOX_CMDLINE_OPT_SHORT(signals, 'S', 0,
"Handle signals (such as SIGSEGV) in sandbox");
static void setup_ram_buf(struct sandbox_state *state)
{
/* Zero the RAM buffer if we didn't read it, to keep valgrind happy */
@@ -426,9 +436,6 @@ void sandbox_reset(void)
if (state_uninit())
os_exit(2);
if (dm_uninit())
os_exit(2);
/* Restart U-Boot */
os_relaunch(os_argv);
}
@@ -443,6 +450,14 @@ int main(int argc, char *argv[])
text_base = os_find_text_base();
/*
* This must be the first invocation of os_malloc() to have
* state->ram_buf in the low 4 GiB.
*/
ret = state_init();
if (ret)
goto err;
/*
* Copy argv[] so that we can pass the arguments in the original
* sequence when resetting the sandbox.
@@ -457,10 +472,6 @@ int main(int argc, char *argv[])
gd = &data;
gd->arch.text_base = text_base;
ret = state_init();
if (ret)
goto err;
state = state_get_current();
if (os_parse_args(state, argc, argv))
return 1;
@@ -476,9 +487,11 @@ int main(int argc, char *argv[])
if (ret)
goto err;
ret = os_setup_signal_handlers();
if (ret)
goto err;
if (state->handle_signals) {
ret = os_setup_signal_handlers();
if (ret)
goto err;
}
#if CONFIG_VAL(SYS_MALLOC_F_LEN)
gd->malloc_base = CONFIG_MALLOC_F_ADDR;

View File

@@ -139,6 +139,12 @@
size = <0x10000>;
};
};
cros_ec_pwm: cros-ec-pwm {
compatible = "google,cros-ec-pwm";
#pwm-cells = <1>;
};
};
dsi_host: dsi_host {

View File

@@ -93,6 +93,7 @@ struct sandbox_state {
bool ram_buf_read; /* true if we read the RAM buffer */
bool run_unittests; /* Run unit tests */
const char *select_unittests; /* Unit test to run */
bool handle_signals; /* Handle signals within sandbox */
/* Pointer to information for each SPI bus/cs */
struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]

View File

@@ -275,4 +275,14 @@ void sandbox_set_enable_memio(bool enable);
*/
void sandbox_cros_ec_set_test_flags(struct udevice *dev, uint flags);
/**
* sandbox_cros_ec_get_pwm_duty() - Get EC PWM config for testing purposes
*
* @dev: Device to check
* @index: PWM channel index
* @duty: Current duty cycle in 0..EC_PWM_MAX_DUTY range.
* @return 0 if OK, -ENOSPC if the PWM number is invalid
*/
int sandbox_cros_ec_get_pwm_duty(struct udevice *dev, uint index, uint *duty);
#endif