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 2bd28f6b1c1739b5857407d1e055676698330435..ad3e94beb9a77e79e6167cf2852b2eb7614ecf52 100644 (file)
@@ -1,14 +1,15 @@
+/* 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 <reset.h>
+#include <sysreset.h>
 #include <stdbool.h>
+#include <linux/list.h>
 #include <linux/stringify.h>
 
 /**
@@ -35,10 +36,32 @@ enum state_terminal_raw {
 };
 
 struct sandbox_spi_info {
-       const char *spec;
        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 */
@@ -60,13 +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 reset_t last_reset;        /* Last reset type */
-       bool reset_allowed[RESET_COUNT];        /* Allowed reset types */
+       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*/
@@ -184,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
  */