1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-11-01 19:05:51 +01:00

sandbox: Enhance map_to_sysmem() to handle foreign pointers

At present map_sysmem() maps an address into the sandbox RAM buffer,
return a pointer, while map_to_sysmem() goes the other way.

The mapping is currently just 1:1 since a case was not found where a more
flexible mapping was needed. PCI does have a separate and more complex
mapping, but uses its own mechanism.

However this arrange cannot handle one important case, which is where a
test declares a stack variable and passes a pointer to it into a U-Boot
function which uses map_to_sysmem() to turn it into a address. Since the
pointer is not inside emulated DRAM, this will fail.

Add a mapping feature which can handle any such pointer, mapping it to a
simple tag value which can be passed around in U-Boot as an address.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
Simon Glass
2018-09-15 00:50:56 -06:00
committed by Alexander Graf
parent fe938fb0df
commit 428aa0ca56
3 changed files with 163 additions and 11 deletions

View File

@@ -9,6 +9,7 @@
#include <config.h>
#include <sysreset.h>
#include <stdbool.h>
#include <linux/list.h>
#include <linux/stringify.h>
/**
@@ -45,6 +46,23 @@ struct sandbox_wdt_info {
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 */
@@ -78,6 +96,9 @@ struct sandbox_state {
/* 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 */
};
/* Minimum space we guarantee in the state FDT when calling read/write*/