summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/Kconfig2
-rw-r--r--arch/arm/cpu/arm926ejs/spear/cpu.c3
-rw-r--r--arch/arm/cpu/armv8/fsl-layerscape/cpu.c2
-rw-r--r--arch/arm/cpu/armv8/fsl-layerscape/fdt.c2
-rw-r--r--arch/arm/dts/stm32mp157-pinctrl.dtsi6
-rw-r--r--arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi5
-rw-r--r--arch/arm/dts/stm32mp157c-ev1.dts15
-rw-r--r--arch/arm/dts/stm32mp157c.dtsi36
-rw-r--r--arch/arm/include/asm/arch-omap3/mmc_host_def.h1
-rw-r--r--arch/arm/include/asm/arch-spear/spr_misc.h4
-rw-r--r--arch/arm/include/asm/atomic.h147
-rw-r--r--arch/arm/mach-tegra/board2.c14
-rw-r--r--arch/mips/include/asm/atomic.h44
-rw-r--r--arch/nds32/config.mk2
-rw-r--r--arch/riscv/config.mk2
-rw-r--r--arch/sandbox/cpu/cpu.c153
-rw-r--r--arch/sandbox/cpu/os.c27
-rw-r--r--arch/sandbox/cpu/state.c8
-rw-r--r--arch/sandbox/include/asm/setjmp.h5
-rw-r--r--arch/sandbox/include/asm/state.h21
-rw-r--r--arch/x86/config.mk1
-rw-r--r--arch/x86/lib/e820.c4
-rw-r--r--arch/xtensa/include/asm/atomic.h44
23 files changed, 266 insertions, 282 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e65c9aef03..ccf2a844be 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -747,6 +747,8 @@ config ARCH_QEMU
select OF_CONTROL
select PL01X_SERIAL
imply CMD_DM
+ imply DM_RTC
+ imply RTC_PL031
config ARCH_RMOBILE
bool "Renesas ARM SoCs"
diff --git a/arch/arm/cpu/arm926ejs/spear/cpu.c b/arch/arm/cpu/arm926ejs/spear/cpu.c
index 88a40c6036..51c4a730f4 100644
--- a/arch/arm/cpu/arm926ejs/spear/cpu.c
+++ b/arch/arm/cpu/arm926ejs/spear/cpu.c
@@ -52,6 +52,9 @@ int arch_cpu_init(void)
#if defined(CONFIG_SPEAR_GPIO)
periph1_clken |= MISC_GPIO3ENB | MISC_GPIO4ENB;
#endif
+#if defined(CONFIG_PL022_SPI)
+ periph1_clken |= MISC_SSP1ENB | MISC_SSP2ENB | MISC_SSP3ENB;
+#endif
writel(periph1_clken, &misc_p->periph1_clken);
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index 052e0708d4..be00bd55ab 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -835,7 +835,7 @@ int dram_init_banksize(void)
return 0;
}
-#if defined(CONFIG_EFI_LOADER) && !defined(CONFIG_SPL_BUILD)
+#if CONFIG_IS_ENABLED(EFI_LOADER)
void efi_add_known_memory(void)
{
int i;
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
index fc9de73bce..c9c2c3f6d3 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
@@ -135,7 +135,7 @@ remove_psci_node:
fdt_add_mem_rsv(blob, (uintptr_t)&secondary_boot_code,
*boot_code_size);
-#if defined(CONFIG_EFI_LOADER) && !defined(CONFIG_SPL_BUILD)
+#if CONFIG_IS_ENABLED(EFI_LOADER)
efi_add_memory_map((uintptr_t)&secondary_boot_code,
ALIGN(*boot_code_size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT,
EFI_RESERVED_MEMORY_TYPE, false);
diff --git a/arch/arm/dts/stm32mp157-pinctrl.dtsi b/arch/arm/dts/stm32mp157-pinctrl.dtsi
index c69c397964..85da592655 100644
--- a/arch/arm/dts/stm32mp157-pinctrl.dtsi
+++ b/arch/arm/dts/stm32mp157-pinctrl.dtsi
@@ -321,6 +321,12 @@
bias-disable;
};
};
+
+ usbotg_hs_pins_a: usbotg_hs-0 {
+ pins {
+ pinmux = <STM32_PINMUX('A', 10, ANALOG)>; /* OTG_ID */
+ };
+ };
};
pinctrl_z: pin-controller-z@54004000 {
diff --git a/arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi b/arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi
index 2f4de3a066..30b173478c 100644
--- a/arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi
+++ b/arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi
@@ -25,6 +25,10 @@
regulator-always-on;
};
+&usbotg_hs {
+ g-tx-fifo-size = <576>;
+};
+
/* SPL part **************************************/
&qspi {
u-boot,dm-spl;
@@ -60,3 +64,4 @@
&flash0 {
u-boot,dm-spl;
};
+
diff --git a/arch/arm/dts/stm32mp157c-ev1.dts b/arch/arm/dts/stm32mp157c-ev1.dts
index d6934f74e0..902a42bee2 100644
--- a/arch/arm/dts/stm32mp157c-ev1.dts
+++ b/arch/arm/dts/stm32mp157c-ev1.dts
@@ -96,6 +96,21 @@
};
};
+&usbh_ehci {
+ phys = <&usbphyc_port0>;
+ phy-names = "usb";
+ vbus-supply = <&vbus_sw>;
+ status = "okay";
+};
+
+&usbotg_hs {
+ pinctrl-names = "default";
+ pinctrl-0 = <&usbotg_hs_pins_a>;
+ phys = <&usbphyc_port1 0>;
+ phy-names = "usb2-phy";
+ status = "okay";
+};
+
&usbphyc {
status = "okay";
};
diff --git a/arch/arm/dts/stm32mp157c.dtsi b/arch/arm/dts/stm32mp157c.dtsi
index cdf2946968..33c5981869 100644
--- a/arch/arm/dts/stm32mp157c.dtsi
+++ b/arch/arm/dts/stm32mp157c.dtsi
@@ -106,6 +106,26 @@
};
};
+ pm_domain {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "st,stm32mp157c-pd";
+
+ pd_core_ret: core-ret-power-domain@1 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <1>;
+ #power-domain-cells = <0>;
+ label = "CORE-RETENTION";
+
+ pd_core: core-power-domain@2 {
+ reg = <2>;
+ #power-domain-cells = <0>;
+ label = "CORE";
+ };
+ };
+ };
+
soc {
compatible = "simple-bus";
#address-cells = <1>;
@@ -654,6 +674,22 @@
status = "disabled";
};
+ usbotg_hs: usb-otg@49000000 {
+ compatible = "st,stm32mp1-hsotg", "snps,dwc2";
+ reg = <0x49000000 0x10000>;
+ clocks = <&rcc USBO_K>;
+ clock-names = "otg";
+ resets = <&rcc USBO_R>;
+ reset-names = "dwc2";
+ interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
+ g-rx-fifo-size = <256>;
+ g-np-tx-fifo-size = <32>;
+ g-tx-fifo-size = <128 128 64 64 64 64 32 32>;
+ dr_mode = "otg";
+ power-domains = <&pd_core>;
+ status = "disabled";
+ };
+
rcc: rcc@50000000 {
compatible = "st,stm32mp1-rcc", "syscon";
reg = <0x50000000 0x1000>;
diff --git a/arch/arm/include/asm/arch-omap3/mmc_host_def.h b/arch/arm/include/asm/arch-omap3/mmc_host_def.h
index 9f2896c4b9..39a7cba0f6 100644
--- a/arch/arm/include/asm/arch-omap3/mmc_host_def.h
+++ b/arch/arm/include/asm/arch-omap3/mmc_host_def.h
@@ -51,6 +51,7 @@ typedef struct t2 {
#define PBIASLITEPWRDNZ0 (1 << 1)
#define PBIASSPEEDCTRL0 (1 << 2)
#define PBIASLITEPWRDNZ1 (1 << 9)
+#define PBIASLITEVMODE1 (1 << 8)
#define PBIASLITEVMODE0 (1 << 0)
#define CTLPROGIO1SPEEDCTRL (1 << 20)
diff --git a/arch/arm/include/asm/arch-spear/spr_misc.h b/arch/arm/include/asm/arch-spear/spr_misc.h
index 65063fca51..0171119351 100644
--- a/arch/arm/include/asm/arch-spear/spr_misc.h
+++ b/arch/arm/include/asm/arch-spear/spr_misc.h
@@ -146,11 +146,13 @@ struct misc_regs {
#define MISC_SMIENB 0x00200000
#define MISC_GPIO3ENB 0x00040000
#define MISC_GPT3ENB 0x00010000
+#define MISC_SSP3ENB 0x00004000
#define MISC_GPIO4ENB 0x00002000
#define MISC_GPT2ENB 0x00000800
#define MISC_FSMCENB 0x00000200
#define MISC_I2CENB 0x00000080
-#define MISC_SSP2ENB 0x00000070
+#define MISC_SSP2ENB 0x00000040
+#define MISC_SSP1ENB 0x00000020
#define MISC_UART0ENB 0x00000008
/* PERIPH_CLK_CFG */
diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
index 171f4d9792..5822b0a52c 100644
--- a/arch/arm/include/asm/atomic.h
+++ b/arch/arm/include/asm/atomic.h
@@ -20,152 +20,8 @@
#error SMP not supported
#endif
-typedef struct { volatile int counter; } atomic_t;
-#if BITS_PER_LONG == 32
-typedef struct { volatile long long counter; } atomic64_t;
-#else /* BIT_PER_LONG == 32 */
-typedef struct { volatile long counter; } atomic64_t;
-#endif
-
-#define ATOMIC_INIT(i) { (i) }
-
-#ifdef __KERNEL__
#include <asm/proc-armv/system.h>
-
-#define atomic_read(v) ((v)->counter)
-#define atomic_set(v, i) (((v)->counter) = (i))
-#define atomic64_read(v) atomic_read(v)
-#define atomic64_set(v, i) atomic_set(v, i)
-
-static inline void atomic_add(int i, volatile atomic_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter += i;
- local_irq_restore(flags);
-}
-
-static inline void atomic_sub(int i, volatile atomic_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter -= i;
- local_irq_restore(flags);
-}
-
-static inline void atomic_inc(volatile atomic_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter += 1;
- local_irq_restore(flags);
-}
-
-static inline void atomic_dec(volatile atomic_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter -= 1;
- local_irq_restore(flags);
-}
-
-static inline int atomic_dec_and_test(volatile atomic_t *v)
-{
- unsigned long flags = 0;
- int val;
-
- local_irq_save(flags);
- val = v->counter;
- v->counter = val -= 1;
- local_irq_restore(flags);
-
- return val == 0;
-}
-
-static inline int atomic_add_negative(int i, volatile atomic_t *v)
-{
- unsigned long flags = 0;
- int val;
-
- local_irq_save(flags);
- val = v->counter;
- v->counter = val += i;
- local_irq_restore(flags);
-
- return val < 0;
-}
-
-static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- *addr &= ~mask;
- local_irq_restore(flags);
-}
-
-#if BITS_PER_LONG == 32
-
-static inline void atomic64_add(long long i, volatile atomic64_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter += i;
- local_irq_restore(flags);
-}
-
-static inline void atomic64_sub(long long i, volatile atomic64_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter -= i;
- local_irq_restore(flags);
-}
-
-#else /* BIT_PER_LONG == 32 */
-
-static inline void atomic64_add(long i, volatile atomic64_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter += i;
- local_irq_restore(flags);
-}
-
-static inline void atomic64_sub(long i, volatile atomic64_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter -= i;
- local_irq_restore(flags);
-}
-#endif
-
-static inline void atomic64_inc(volatile atomic64_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter += 1;
- local_irq_restore(flags);
-}
-
-static inline void atomic64_dec(volatile atomic64_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter -= 1;
- local_irq_restore(flags);
-}
+#include <asm-generic/atomic.h>
/* Atomic operations are already serializing on ARM */
#define smp_mb__before_atomic_dec() barrier()
@@ -174,4 +30,3 @@ static inline void atomic64_dec(volatile atomic64_t *v)
#define smp_mb__after_atomic_inc() barrier()
#endif
-#endif
diff --git a/arch/arm/mach-tegra/board2.c b/arch/arm/mach-tegra/board2.c
index 421a71b301..12257a42b5 100644
--- a/arch/arm/mach-tegra/board2.c
+++ b/arch/arm/mach-tegra/board2.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <dm.h>
+#include <efi_loader.h>
#include <errno.h>
#include <ns16550.h>
#include <usb.h>
@@ -210,6 +211,19 @@ int board_early_init_f(void)
int board_late_init(void)
{
+#if CONFIG_IS_ENABLED(EFI_LOADER)
+ if (gd->bd->bi_dram[1].start) {
+ /*
+ * Only bank 0 is below board_get_usable_ram_top(), so all of
+ * bank 1 is not mapped by the U-Boot MMU configuration, and so
+ * we must prevent EFI from using it.
+ */
+ efi_add_memory_map(gd->bd->bi_dram[1].start,
+ gd->bd->bi_dram[1].size >> EFI_PAGE_SHIFT,
+ EFI_BOOT_SERVICES_DATA, false);
+ }
+#endif
+
#if defined(CONFIG_TEGRA_SUPPORT_NON_SECURE)
if (tegra_cpu_is_non_secure()) {
printf("CPU is in NS mode\n");
diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
index 7551bf6e6c..c4f08b7820 100644
--- a/arch/mips/include/asm/atomic.h
+++ b/arch/mips/include/asm/atomic.h
@@ -7,48 +7,6 @@
#define _MIPS_ATOMIC_H
#include <asm/system.h>
-
-typedef struct { volatile int counter; } atomic_t;
-
-#define ATOMIC_INIT(i) { (i) }
-
-#define atomic_read(v) ((v)->counter)
-#define atomic_set(v, i) ((v)->counter = (i))
-
-static inline void atomic_add(int i, atomic_t *v)
-{
- unsigned long flags;
-
- local_irq_save(flags);
- v->counter += i;
- local_irq_restore(flags);
-}
-
-static inline void atomic_sub(int i, atomic_t *v)
-{
- unsigned long flags;
-
- local_irq_save(flags);
- v->counter -= i;
- local_irq_restore(flags);
-}
-
-static inline void atomic_inc(atomic_t *v)
-{
- unsigned long flags;
-
- local_irq_save(flags);
- ++v->counter;
- local_irq_restore(flags);
-}
-
-static inline void atomic_dec(atomic_t *v)
-{
- unsigned long flags;
-
- local_irq_save(flags);
- --v->counter;
- local_irq_restore(flags);
-}
+#include <asm-generic/atomic.h>
#endif
diff --git a/arch/nds32/config.mk b/arch/nds32/config.mk
index cb3d8b35b5..c5520fd8d8 100644
--- a/arch/nds32/config.mk
+++ b/arch/nds32/config.mk
@@ -15,7 +15,7 @@ endif
CONFIG_STANDALONE_LOAD_ADDR = 0x300000 \
-T $(srctree)/examples/standalone/nds32.lds
-PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -mrelax
+PLATFORM_RELFLAGS += -fno-common -mrelax
PLATFORM_RELFLAGS += -gdwarf-2
PLATFORM_CPPFLAGS += -D__nds32__ -G0 -ffixed-10 -fpie
diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk
index 219e66683d..c0b3858edd 100644
--- a/arch/riscv/config.mk
+++ b/arch/riscv/config.mk
@@ -31,7 +31,7 @@ CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \
-T $(srctree)/examples/standalone/riscv.lds
PLATFORM_CPPFLAGS += -ffixed-gp -fpic
-PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2 -ffunction-sections
+PLATFORM_RELFLAGS += -fno-common -gdwarf-2 -ffunction-sections
LDFLAGS_u-boot += --gc-sections -static -pie
EFI_CRT0 := crt0_riscv_efi.o
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index cde0b055a6..6098945049 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -57,14 +57,104 @@ int cleanup_before_linux_select(int flags)
return 0;
}
+/**
+ * is_in_sandbox_mem() - Checks if a pointer is within sandbox's emulated DRAM
+ *
+ * This provides a way to check if a pointer is owned by sandbox (and is within
+ * its RAM) or not. Sometimes pointers come from a test which conceptually runs
+ * output sandbox, potentially with direct access to the C-library malloc()
+ * function, or the sandbox stack (which is not actually within the emulated
+ * DRAM.
+ *
+ * Such pointers obviously cannot be mapped into sandbox's DRAM, so we must
+ * detect them an process them separately, by recording a mapping to a tag,
+ * which we can use to map back to the pointer later.
+ *
+ * @ptr: Pointer to check
+ * @return true if this is within sandbox emulated DRAM, false if not
+ */
+static bool is_in_sandbox_mem(const void *ptr)
+{
+ return (const uint8_t *)ptr >= gd->arch.ram_buf &&
+ (const uint8_t *)ptr < gd->arch.ram_buf + gd->ram_size;
+}
+
+/**
+ * phys_to_virt() - Converts a sandbox RAM address to a pointer
+ *
+ * Sandbox uses U-Boot addresses from 0 to the size of DRAM. These index into
+ * the emulated DRAM buffer used by sandbox. This function converts such an
+ * address to a pointer into this buffer, which can be used to access the
+ * memory.
+ *
+ * If the address is outside this range, it is assumed to be a tag
+ */
void *phys_to_virt(phys_addr_t paddr)
{
- return (void *)(gd->arch.ram_buf + paddr);
+ struct sandbox_mapmem_entry *mentry;
+ struct sandbox_state *state;
+
+ /* If the address is within emulated DRAM, calculate the value */
+ if (paddr < gd->ram_size)
+ return (void *)(gd->arch.ram_buf + paddr);
+
+ /*
+ * Otherwise search out list of tags for the correct pointer previously
+ * created by map_to_sysmem()
+ */
+ state = state_get_current();
+ list_for_each_entry(mentry, &state->mapmem_head, sibling_node) {
+ if (mentry->tag == paddr) {
+ printf("%s: Used map from %lx to %p\n", __func__,
+ (ulong)paddr, mentry->ptr);
+ return mentry->ptr;
+ }
+ }
+
+ printf("%s: Cannot map sandbox address %lx (SDRAM from 0 to %lx)\n",
+ __func__, (ulong)paddr, (ulong)gd->ram_size);
+ os_abort();
+
+ /* Not reached */
+ return NULL;
+}
+
+struct sandbox_mapmem_entry *find_tag(const void *ptr)
+{
+ struct sandbox_mapmem_entry *mentry;
+ struct sandbox_state *state = state_get_current();
+
+ list_for_each_entry(mentry, &state->mapmem_head, sibling_node) {
+ if (mentry->ptr == ptr) {
+ debug("%s: Used map from %p to %lx\n", __func__, ptr,
+ mentry->tag);
+ return mentry;
+ }
+ }
+ return NULL;
}
-phys_addr_t virt_to_phys(void *vaddr)
+phys_addr_t virt_to_phys(void *ptr)
{
- return (phys_addr_t)((uint8_t *)vaddr - gd->arch.ram_buf);
+ struct sandbox_mapmem_entry *mentry;
+
+ /*
+ * If it is in emulated RAM, don't bother looking for a tag. Just
+ * calculate the pointer using the provides offset into the RAM buffer.
+ */
+ if (is_in_sandbox_mem(ptr))
+ return (phys_addr_t)((uint8_t *)ptr - gd->arch.ram_buf);
+
+ mentry = find_tag(ptr);
+ if (!mentry) {
+ /* Abort so that gdb can be used here */
+ printf("%s: Cannot map sandbox address %p (SDRAM from 0 to %lx)\n",
+ __func__, ptr, (ulong)gd->ram_size);
+ os_abort();
+ }
+ printf("%s: Used map from %p to %lx\n", __func__, ptr, mentry->tag);
+
+ return mentry->tag;
}
void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
@@ -87,24 +177,57 @@ void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
return phys_to_virt(paddr);
}
-void unmap_physmem(const void *vaddr, unsigned long flags)
+void unmap_physmem(const void *ptr, unsigned long flags)
{
#ifdef CONFIG_PCI
if (map_dev) {
- pci_unmap_physmem(vaddr, map_len, map_dev);
+ pci_unmap_physmem(ptr, map_len, map_dev);
map_dev = NULL;
}
#endif
}
-void sandbox_set_enable_pci_map(int enable)
+phys_addr_t map_to_sysmem(const void *ptr)
{
- enable_pci_map = enable;
+ struct sandbox_mapmem_entry *mentry;
+
+ /*
+ * If it is in emulated RAM, don't bother creating a tag. Just return
+ * the offset into the RAM buffer.
+ */
+ if (is_in_sandbox_mem(ptr))
+ return (u8 *)ptr - gd->arch.ram_buf;
+
+ /*
+ * See if there is an existing tag with this pointer. If not, set up a
+ * new one.
+ */
+ mentry = find_tag(ptr);
+ if (!mentry) {
+ struct sandbox_state *state = state_get_current();
+
+ mentry = malloc(sizeof(*mentry));
+ if (!mentry) {
+ printf("%s: Error: Out of memory\n", __func__);
+ os_exit(ENOMEM);
+ }
+ mentry->tag = state->next_tag++;
+ mentry->ptr = (void *)ptr;
+ list_add_tail(&mentry->sibling_node, &state->mapmem_head);
+ debug("%s: Added map from %p to %lx\n", __func__, ptr,
+ (ulong)mentry->tag);
+ }
+
+ /*
+ * Return the tag as the address to use. A later call to map_sysmem()
+ * will return ptr
+ */
+ return mentry->tag;
}
-phys_addr_t map_to_sysmem(const void *ptr)
+void sandbox_set_enable_pci_map(int enable)
{
- return (u8 *)ptr - gd->arch.ram_buf;
+ enable_pci_map = enable;
}
void flush_dcache_range(unsigned long start, unsigned long stop)
@@ -165,15 +288,3 @@ ulong timer_get_boot_us(void)
return (count - base_count) / 1000;
}
-
-int setjmp(jmp_buf jmp)
-{
- return os_setjmp((ulong *)jmp, sizeof(*jmp));
-}
-
-void longjmp(jmp_buf jmp, int ret)
-{
- os_longjmp((ulong *)jmp, ret);
- while (1)
- ;
-}
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 5839932b00..9fbcb9ef92 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -143,14 +143,16 @@ void os_tty_raw(int fd, bool allow_sigs)
void *os_malloc(size_t length)
{
struct os_mem_hdr *hdr;
+ int page_size = getpagesize();
- hdr = mmap(NULL, length + sizeof(*hdr), PROT_READ | PROT_WRITE,
+ hdr = mmap(NULL, length + page_size,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (hdr == MAP_FAILED)
return NULL;
hdr->length = length;
- return hdr + 1;
+ return (void *)hdr + page_size;
}
void os_free(void *ptr)
@@ -630,24 +632,7 @@ void os_localtime(struct rtc_time *rt)
rt->tm_isdst = tm->tm_isdst;
}
-int os_setjmp(ulong *jmp, int size)
+void os_abort(void)
{
- jmp_buf dummy;
-
- /*
- * We cannot rely on the struct name that jmp_buf uses, so use a
- * local variable here
- */
- if (size < sizeof(dummy)) {
- printf("setjmp: jmpbuf is too small (%d bytes, need %d)\n",
- size, sizeof(jmp_buf));
- return -ENOSPC;
- }
-
- return setjmp((struct __jmp_buf_tag *)jmp);
-}
-
-void os_longjmp(ulong *jmp, int ret)
-{
- longjmp((struct __jmp_buf_tag *)jmp, ret);
+ abort();
}
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index cc50819ab9..04a11fed55 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -359,6 +359,14 @@ void state_reset_for_test(struct sandbox_state *state)
memset(&state->wdt, '\0', sizeof(state->wdt));
memset(state->spi, '\0', sizeof(state->spi));
+
+ /*
+ * Set up the memory tag list. Use the top of emulated SDRAM for the
+ * first tag number, since that address offset is outside the legal
+ * range, and can be assumed to be a tag.
+ */
+ INIT_LIST_HEAD(&state->mapmem_head);
+ state->next_tag = state->ram_size;
}
int state_init(void)
diff --git a/arch/sandbox/include/asm/setjmp.h b/arch/sandbox/include/asm/setjmp.h
index 1fe37c91cc..001c7ea322 100644
--- a/arch/sandbox/include/asm/setjmp.h
+++ b/arch/sandbox/include/asm/setjmp.h
@@ -24,6 +24,11 @@ struct jmp_buf_data {
typedef struct jmp_buf_data jmp_buf[1];
+/*
+ * We have to directly link with the system versions of
+ * setjmp/longjmp, because setjmp must not return as otherwise
+ * the stack may become invalid.
+ */
int setjmp(jmp_buf jmp);
__noreturn void longjmp(jmp_buf jmp, int ret);
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index 7ed4b512d2..a612ce8944 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -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*/
diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index 5b04febd68..cc940712a8 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -5,7 +5,6 @@
CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
-PLATFORM_CPPFLAGS += -fno-strict-aliasing
PLATFORM_CPPFLAGS += -fomit-frame-pointer
PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \
$(call cc-option, -fno-unit-at-a-time))
diff --git a/arch/x86/lib/e820.c b/arch/x86/lib/e820.c
index 8b34f677d9..d6ae2c4e9d 100644
--- a/arch/x86/lib/e820.c
+++ b/arch/x86/lib/e820.c
@@ -36,7 +36,7 @@ __weak unsigned int install_e820_map(unsigned int max_entries,
return 4;
}
-#if defined(CONFIG_EFI_LOADER) && !defined(CONFIG_SPL_BUILD)
+#if CONFIG_IS_ENABLED(EFI_LOADER)
void efi_add_known_memory(void)
{
struct e820_entry e820[E820MAX];
@@ -72,4 +72,4 @@ void efi_add_known_memory(void)
efi_add_memory_map(start, pages, type, false);
}
}
-#endif /* defined(EFI_LOADER) && !defined(CONFIG_SPL_BUILD) */
+#endif /* CONFIG_IS_ENABLED(EFI_LOADER) */
diff --git a/arch/xtensa/include/asm/atomic.h b/arch/xtensa/include/asm/atomic.h
index 42b32f5d3d..4e3ad56472 100644
--- a/arch/xtensa/include/asm/atomic.h
+++ b/arch/xtensa/include/asm/atomic.h
@@ -7,48 +7,6 @@
#define _XTENSA_ATOMIC_H
#include <asm/system.h>
-
-typedef struct { volatile int counter; } atomic_t;
-
-#define ATOMIC_INIT(i) { (i) }
-
-#define atomic_read(v) ((v)->counter)
-#define atomic_set(v, i) ((v)->counter = (i))
-
-static inline void atomic_add(int i, atomic_t *v)
-{
- unsigned long flags;
-
- local_irq_save(flags);
- v->counter += i;
- local_irq_restore(flags);
-}
-
-static inline void atomic_sub(int i, atomic_t *v)
-{
- unsigned long flags;
-
- local_irq_save(flags);
- v->counter -= i;
- local_irq_restore(flags);
-}
-
-static inline void atomic_inc(atomic_t *v)
-{
- unsigned long flags;
-
- local_irq_save(flags);
- ++v->counter;
- local_irq_restore(flags);
-}
-
-static inline void atomic_dec(atomic_t *v)
-{
- unsigned long flags;
-
- local_irq_save(flags);
- --v->counter;
- local_irq_restore(flags);
-}
+#include <asm-generic/atomic.h>
#endif