]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/sandbox/cpu/cpu.c
2 * Copyright (c) 2011 The Chromium OS Authors.
3 * SPDX-License-Identifier: GPL-2.0+
12 #include <asm/state.h>
15 DECLARE_GLOBAL_DATA_PTR
;
17 /* Enable access to PCI memory with map_sysmem() */
18 static bool enable_pci_map
;
21 /* Last device that was mapped into memory, and length of mapping */
22 static struct udevice
*map_dev
;
23 unsigned long map_len
;
26 void sandbox_exit(void)
28 /* Do this here while it still has an effect */
36 /* This is considered normal termination for now */
40 /* delay x useconds */
41 void __udelay(unsigned long usec
)
43 struct sandbox_state
*state
= state_get_current();
45 if (!state
->skip_delays
)
49 int cleanup_before_linux(void)
54 int cleanup_before_linux_select(int flags
)
59 void *map_physmem(phys_addr_t paddr
, unsigned long len
, unsigned long flags
)
61 #if defined(CONFIG_PCI) && !defined(CONFIG_SPL_BUILD)
62 unsigned long plen
= len
;
66 if (enable_pci_map
&& !pci_map_physmem(paddr
, &len
, &map_dev
, &ptr
)) {
68 printf("%s: Warning: partial map at %x, wanted %lx, got %lx\n",
69 __func__
, paddr
, len
, plen
);
76 return (void *)(gd
->arch
.ram_buf
+ paddr
);
79 void unmap_physmem(const void *vaddr
, unsigned long flags
)
83 pci_unmap_physmem(vaddr
, map_len
, map_dev
);
89 void sandbox_set_enable_pci_map(int enable
)
91 enable_pci_map
= enable
;
94 phys_addr_t
map_to_sysmem(const void *ptr
)
96 return (u8
*)ptr
- gd
->arch
.ram_buf
;
99 void flush_dcache_range(unsigned long start
, unsigned long stop
)
103 void invalidate_dcache_range(unsigned long start
, unsigned long stop
)
107 int sandbox_read_fdt_from_file(void)
109 struct sandbox_state
*state
= state_get_current();
110 const char *fname
= state
->fdt_fname
;
116 blob
= map_sysmem(CONFIG_SYS_FDT_LOAD_ADDR
, 0);
117 if (!state
->fdt_fname
) {
118 err
= fdt_create_empty_tree(blob
, 256);
121 printf("Unable to create empty FDT: %s\n", fdt_strerror(err
));
125 err
= os_get_filesize(fname
, &size
);
127 printf("Failed to file FDT file '%s'\n", fname
);
130 fd
= os_open(fname
, OS_O_RDONLY
);
132 printf("Failed to open FDT file '%s'\n", fname
);
135 if (os_read(fd
, blob
, size
) != size
) {
147 ulong
timer_get_boot_us(void)
149 static uint64_t base_count
;
150 uint64_t count
= os_get_nsec();
155 return (count
- base_count
) / 1000;