Merge tag 'u-boot-imx-20191009' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
[oweals/u-boot.git] / arch / sandbox / include / asm / state.h
index 4e0981a672556035a13b3d02575e257e9130c5af..ad3e94beb9a77e79e6167cf2852b2eb7614ecf52 100644 (file)
@@ -1,22 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 2011-2012 The Chromium OS Authors.
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #ifndef __SANDBOX_STATE_H
 #define __SANDBOX_STATE_H
 
 #include <config.h>
+#include <sysreset.h>
 #include <stdbool.h>
+#include <linux/list.h>
 #include <linux/stringify.h>
 
-/* How we exited U-Boot */
-enum exit_type_id {
-       STATE_EXIT_NORMAL,
-       STATE_EXIT_COLD_REBOOT,
-       STATE_EXIT_POWER_OFF,
-};
-
 /**
  * Selects the behavior of the serial terminal.
  *
@@ -41,17 +36,38 @@ enum state_terminal_raw {
 };
 
 struct sandbox_spi_info {
-       const char *spec;
-       const struct sandbox_spi_emu_ops *ops;
        struct udevice *emul;
 };
 
+struct sandbox_wdt_info {
+       unsigned long long counter;
+       uint reset_count;
+       bool running;
+};
+
+/**
+ * struct sandbox_mapmem_entry - maps pointers to/from U-Boot addresses
+ *
+ * When map_to_sysmem() is called with an address outside sandbox's emulated
+ * RAM, a record is created with a tag that can be used to reference that
+ * pointer. When map_sysmem() is called later with that tag, the pointer will
+ * be returned, just as it would for a normal sandbox address.
+ *
+ * @tag: Address tag (a value which U-Boot uses to refer to the address)
+ * @ptr: Associated pointer for that tag
+ */
+struct sandbox_mapmem_entry {
+       ulong tag;
+       void *ptr;
+       struct list_head sibling_node;
+};
+
 /* The complete state of the test system */
 struct sandbox_state {
        const char *cmd;                /* Command to execute */
        bool interactive;               /* Enable cmdline after execute */
+       bool run_distro_boot;           /* Automatically run distro bootcommands */
        const char *fdt_fname;          /* Filename of FDT binary */
-       enum exit_type_id exit_type;    /* How we exited U-Boot */
        const char *parse_err;          /* Error to report from parsing */
        int argc;                       /* Program arguments */
        char **argv;                    /* Command line arguments */
@@ -67,11 +83,35 @@ struct sandbox_state {
        bool write_state;               /* Write sandbox state on exit */
        bool ignore_missing_state_on_read;      /* No error if state missing */
        bool show_lcd;                  /* Show LCD on start-up */
+       enum sysreset_t last_sysreset;  /* Last system reset type */
+       bool sysreset_allowed[SYSRESET_COUNT];  /* Allowed system reset types */
        enum state_terminal_raw term_raw;       /* Terminal raw/cooked */
+       bool skip_delays;               /* Ignore any time delays (for test) */
+       bool show_test_output;          /* Don't suppress stdout in tests */
+       int default_log_level;          /* Default log level for sandbox */
+       bool show_of_platdata;          /* Show of-platdata in SPL */
+       bool ram_buf_read;              /* true if we read the RAM buffer */
 
        /* Pointer to information for each SPI bus/cs */
        struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]
                                        [CONFIG_SANDBOX_SPI_MAX_CS];
+
+       /* Information about Watchdog */
+       struct sandbox_wdt_info wdt;
+
+       ulong next_tag;                 /* Next address tag to allocate */
+       struct list_head mapmem_head;   /* struct sandbox_mapmem_entry */
+       bool hwspinlock;                /* Hardware Spinlock status */
+       bool allow_memio;               /* Allow readl() etc. to work */
+
+       /*
+        * This struct is getting large.
+        *
+        * Consider putting test data in driver-private structs, like
+        * sandbox_pch.c.
+        *
+        * If you add new members, please put them above this comment.
+        */
 };
 
 /* Minimum space we guarantee in the state FDT when calling read/write*/
@@ -139,13 +179,6 @@ struct sandbox_state_io {
                .compat = _compat, \
        }
 
-/**
- * Record the exit type to be reported by the test program.
- *
- * @param exit_type    Exit type to record
- */
-void state_record_exit(enum exit_type_id exit_type);
-
 /**
  * Gets a pointer to the current state.
  *
@@ -196,6 +229,38 @@ int sandbox_write_state(struct sandbox_state *state, const char *fname);
  */
 int state_setprop(int node, const char *prop_name, const void *data, int size);
 
+/**
+ * Control skipping of time delays
+ *
+ * Some tests have unnecessay time delays (e.g. USB). Allow these to be
+ * skipped to speed up testing
+ *
+ * @param skip_delays  true to skip delays from now on, false to honour delay
+ *                     requests
+ */
+void state_set_skip_delays(bool skip_delays);
+
+/**
+ * See if delays should be skipped
+ *
+ * @return true if delays should be skipped, false if they should be honoured
+ */
+bool state_get_skip_delays(void);
+
+/**
+ * state_reset_for_test() - Reset ready to re-run tests
+ *
+ * This clears out any test state ready for another test run.
+ */
+void state_reset_for_test(struct sandbox_state *state);
+
+/**
+ * state_show() - Show information about the sandbox state
+ *
+ * @param state                Sandbox state to show
+ */
+void state_show(struct sandbox_state *state);
+
 /**
  * Initialize the test system state
  */