2 * Copyright (c) 2011 The Chromium OS Authors.
3 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/state.h>
12 DECLARE_GLOBAL_DATA_PTR;
14 /* Enable access to PCI memory with map_sysmem() */
15 static bool enable_pci_map;
18 /* Last device that was mapped into memory, and length of mapping */
19 static struct udevice *map_dev;
20 unsigned long map_len;
23 void reset_cpu(ulong ignored)
31 /* This is considered normal termination for now */
35 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
42 /* delay x useconds */
43 void __udelay(unsigned long usec)
48 int cleanup_before_linux(void)
53 void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
56 unsigned long plen = len;
60 if (enable_pci_map && !pci_map_physmem(paddr, &len, &map_dev, &ptr)) {
62 printf("%s: Warning: partial map at %x, wanted %lx, got %lx\n",
63 __func__, paddr, len, plen);
70 return (void *)(gd->arch.ram_buf + paddr);
73 void unmap_physmem(const void *vaddr, unsigned long flags)
77 pci_unmap_physmem(vaddr, map_len, map_dev);
83 void sandbox_set_enable_pci_map(int enable)
85 enable_pci_map = enable;
88 phys_addr_t map_to_sysmem(const void *ptr)
90 return (u8 *)ptr - gd->arch.ram_buf;
93 void flush_dcache_range(unsigned long start, unsigned long stop)
97 int sandbox_read_fdt_from_file(void)
99 struct sandbox_state *state = state_get_current();
100 const char *fname = state->fdt_fname;
106 blob = map_sysmem(CONFIG_SYS_FDT_LOAD_ADDR, 0);
107 if (!state->fdt_fname) {
108 err = fdt_create_empty_tree(blob, 256);
111 printf("Unable to create empty FDT: %s\n", fdt_strerror(err));
115 err = os_get_filesize(fname, &size);
117 printf("Failed to file FDT file '%s'\n", fname);
120 fd = os_open(fname, OS_O_RDONLY);
122 printf("Failed to open FDT file '%s'\n", fname);
125 if (os_read(fd, blob, size) != size) {