From f43b2df3e068cc7be1aa5656c0c3223e270bba63 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 17 Jan 2023 10:47:27 -0700 Subject: sandbox: Allow ethernet to be disabled at runtime For bootstd tests it is seldom useful to have ethernet enabled. Add a way to disable it, so that ethernet operations like tftpboot do nothing. Signed-off-by: Simon Glass --- arch/sandbox/cpu/state.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'arch/sandbox/cpu/state.c') diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index dd7978cfced..267f280df14 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -12,6 +12,7 @@ #include #include #include +#include /* Main state record for the sandbox */ static struct sandbox_state main_state; @@ -366,6 +367,7 @@ void state_reset_for_test(struct sandbox_state *state) state->sysreset_allowed[SYSRESET_POWER_OFF] = true; state->sysreset_allowed[SYSRESET_COLD] = true; state->allow_memio = false; + sandbox_set_eth_enable(true); memset(&state->wdt, '\0', sizeof(state->wdt)); memset(state->spi, '\0', sizeof(state->spi)); @@ -444,6 +446,20 @@ int state_load_other_fdt(const char **bufp, int *sizep) return 0; } +void sandbox_set_eth_enable(bool enable) +{ + struct sandbox_state *state = state_get_current(); + + state->disable_eth = !enable; +} + +bool sandbox_eth_enabled(void) +{ + struct sandbox_state *state = state_get_current(); + + return !state->disable_eth; +} + int state_init(void) { state = &main_state; -- cgit v1.2.3