From 07e27ce013ddb28c5c0725d65b1aa28fd95fcd87 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Mar 2014 11:05:11 +0900 Subject: kbuild,mxs: use short logs for MXS images Signed-off-by: Masahiro Yamada Cc: Fabio Estevam Cc: Otavio Salvador Cc: Lauri Hintsala Acked-by: Marek Vasut --- arch/arm/cpu/arm926ejs/mxs/Makefile | 13 +++++++------ arch/arm/cpu/arm926ejs/mxs/mxsimage.mx23.cfg | 4 ++-- arch/arm/cpu/arm926ejs/mxs/mxsimage.mx28.cfg | 4 ++-- arch/arm/cpu/arm926ejs/mxs/u-boot-imx23.bd | 4 ++-- arch/arm/cpu/arm926ejs/mxs/u-boot-imx28.bd | 4 ++-- 5 files changed, 15 insertions(+), 14 deletions(-) (limited to 'arch') diff --git a/arch/arm/cpu/arm926ejs/mxs/Makefile b/arch/arm/cpu/arm926ejs/mxs/Makefile index 152546e..1eee661 100644 --- a/arch/arm/cpu/arm926ejs/mxs/Makefile +++ b/arch/arm/cpu/arm926ejs/mxs/Makefile @@ -14,11 +14,12 @@ obj-y += spl_boot.o spl_lradc_init.o spl_mem_init.o spl_power_init.o endif # Specify the target for use in elftosb call -MKIMAGE_TARGET-$(CONFIG_MX23) = mx23 -MKIMAGE_TARGET-$(CONFIG_MX28) = mx28 +MKIMAGE_TARGET-$(CONFIG_MX23) = mxsimage.mx23.cfg +MKIMAGE_TARGET-$(CONFIG_MX28) = mxsimage.mx28.cfg -$(OBJTREE)/mxsimage.cfg: $(SRCTREE)/$(CPUDIR)/$(SOC)/mxsimage.$(MKIMAGE_TARGET-y).cfg - sed "s@OBJTREE@$(OBJTREE)@g" $^ > $@ +quiet_cmd_mkimage_mxs = UIMAGE $@ +cmd_mkimage_mxs = $(objtree)/tools/mkimage -n $< -T mxsimage $@ \ + $(if $(KBUILD_VERBOSE:1=), >/dev/null) -$(OBJTREE)/u-boot.sb: $(OBJTREE)/u-boot.bin $(OBJTREE)/spl/u-boot-spl.bin $(OBJTREE)/mxsimage.cfg - $(OBJTREE)/tools/mkimage -n $(OBJTREE)/mxsimage.cfg -T mxsimage $@ +u-boot.sb: $(src)/$(MKIMAGE_TARGET-y) u-boot.bin spl/u-boot-spl.bin FORCE + $(call if_changed,mkimage_mxs) diff --git a/arch/arm/cpu/arm926ejs/mxs/mxsimage.mx23.cfg b/arch/arm/cpu/arm926ejs/mxs/mxsimage.mx23.cfg index c9cf4b3..8118767 100644 --- a/arch/arm/cpu/arm926ejs/mxs/mxsimage.mx23.cfg +++ b/arch/arm/cpu/arm926ejs/mxs/mxsimage.mx23.cfg @@ -1,6 +1,6 @@ SECTION 0x0 BOOTABLE TAG LAST - LOAD 0x0 OBJTREE/spl/u-boot-spl.bin + LOAD 0x0 spl/u-boot-spl.bin CALL 0x14 0x0 - LOAD 0x40000100 OBJTREE/u-boot.bin + LOAD 0x40000100 u-boot.bin CALL 0x40000100 0x0 diff --git a/arch/arm/cpu/arm926ejs/mxs/mxsimage.mx28.cfg b/arch/arm/cpu/arm926ejs/mxs/mxsimage.mx28.cfg index 676f5c8..ea772f0 100644 --- a/arch/arm/cpu/arm926ejs/mxs/mxsimage.mx28.cfg +++ b/arch/arm/cpu/arm926ejs/mxs/mxsimage.mx28.cfg @@ -1,8 +1,8 @@ SECTION 0x0 BOOTABLE TAG LAST - LOAD 0x0 OBJTREE/spl/u-boot-spl.bin + LOAD 0x0 spl/u-boot-spl.bin LOAD IVT 0x8000 0x14 CALL HAB 0x8000 0x0 - LOAD 0x40000100 OBJTREE/u-boot.bin + LOAD 0x40000100 u-boot.bin LOAD IVT 0x8000 0x40000100 CALL HAB 0x8000 0x0 diff --git a/arch/arm/cpu/arm926ejs/mxs/u-boot-imx23.bd b/arch/arm/cpu/arm926ejs/mxs/u-boot-imx23.bd index 8b6c30e..3a51879 100644 --- a/arch/arm/cpu/arm926ejs/mxs/u-boot-imx23.bd +++ b/arch/arm/cpu/arm926ejs/mxs/u-boot-imx23.bd @@ -4,8 +4,8 @@ options { } sources { - u_boot_spl="OBJTREE/spl/u-boot-spl.bin"; - u_boot="OBJTREE/u-boot.bin"; + u_boot_spl="spl/u-boot-spl.bin"; + u_boot="u-boot.bin"; } section (0) { diff --git a/arch/arm/cpu/arm926ejs/mxs/u-boot-imx28.bd b/arch/arm/cpu/arm926ejs/mxs/u-boot-imx28.bd index a5fa648..c60615a 100644 --- a/arch/arm/cpu/arm926ejs/mxs/u-boot-imx28.bd +++ b/arch/arm/cpu/arm926ejs/mxs/u-boot-imx28.bd @@ -1,6 +1,6 @@ sources { - u_boot_spl="OBJTREE/spl/u-boot-spl.bin"; - u_boot="OBJTREE/u-boot.bin"; + u_boot_spl="spl/u-boot-spl.bin"; + u_boot="u-boot.bin"; } section (0) { -- cgit v1.1 From b6e53eb320cd3f3685422c1f5274d13a239dc5b0 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Mar 2014 11:05:13 +0900 Subject: kbuild, x86: use a short log for arch/x86/lib/libgcc.a Signed-off-by: Masahiro Yamada Cc: Simon Glass --- arch/x86/lib/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index a35d062..f7303ab 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -23,5 +23,6 @@ obj-$(CONFIG_CMD_ZBOOT) += zimage.o LIBGCC := $(notdir $(NORMAL_LIBGCC)) extra-y := $(LIBGCC) -$(obj)/$(LIBGCC): $(NORMAL_LIBGCC) - $(OBJCOPY) $< $@ --prefix-symbols=__normal_ +OBJCOPYFLAGS := --prefix-symbols=__normal_ +$(obj)/$(LIBGCC): $(NORMAL_LIBGCC) FORCE + $(call if_changed,objcopy) -- cgit v1.1 From c2e5b6a090e1bcc70dcacb4324c8daad0b91fa8a Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Mar 2014 11:05:14 +0900 Subject: x86: specify CONFIG_USE_PRIVATE_LIBGCC more simply Signed-off-by: Masahiro Yamada Cc: Simon Glass --- arch/x86/config.mk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'arch') diff --git a/arch/x86/config.mk b/arch/x86/config.mk index 1e52a5e..38cb7c9 100644 --- a/arch/x86/config.mk +++ b/arch/x86/config.mk @@ -29,6 +29,4 @@ LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3 LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3 export NORMAL_LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) -PREFIXED_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/$(shell basename $(NORMAL_LIBGCC)) - -CONFIG_USE_PRIVATE_LIBGCC=$(shell dirname $(PREFIXED_LIBGCC)) +CONFIG_USE_PRIVATE_LIBGCC := arch/x86/lib -- cgit v1.1 From 323762e54ad3dbd933ecbda20e749487afd2a6fb Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Mar 2014 11:05:15 +0900 Subject: kbuild: delete redundant LDSCRIPT definition $(SRCTREE)/$(CPUDIR)/u-boot.lds is our default location of arch-specific linker script. Remove redundant definitions in arch/{arc,microblaze,openrisc}/config.mk. Signed-off-by: Masahiro Yamada Cc: Alexey Brodkin Cc: Stefan Kristiansson Acked-by: Michal Simek --- arch/arc/config.mk | 2 -- arch/microblaze/config.mk | 2 -- arch/openrisc/config.mk | 2 -- 3 files changed, 6 deletions(-) (limited to 'arch') diff --git a/arch/arc/config.mk b/arch/arc/config.mk index d9f5d9d..a3b8df7 100644 --- a/arch/arc/config.mk +++ b/arch/arc/config.mk @@ -23,8 +23,6 @@ endif PLATFORM_CPPFLAGS += -ffixed-r25 -D__ARC__ -DCONFIG_ARC -gdwarf-2 -LDSCRIPT := $(SRCTREE)/$(CPUDIR)/u-boot.lds - # Needed for relocation LDFLAGS_FINAL += -pie diff --git a/arch/microblaze/config.mk b/arch/microblaze/config.mk index cdb321a..98bbf79 100644 --- a/arch/microblaze/config.mk +++ b/arch/microblaze/config.mk @@ -15,5 +15,3 @@ endif CONFIG_STANDALONE_LOAD_ADDR ?= 0x80F00000 PLATFORM_CPPFLAGS += -ffixed-r31 -D__microblaze__ - -LDSCRIPT ?= $(SRCTREE)/$(CPUDIR)/u-boot.lds diff --git a/arch/openrisc/config.mk b/arch/openrisc/config.mk index 981edff..9902b9a 100644 --- a/arch/openrisc/config.mk +++ b/arch/openrisc/config.mk @@ -14,5 +14,3 @@ endif PLATFORM_CPPFLAGS += -DCONFIG_OPENRISC -D__OR1K__ -ffixed-r10 CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000 - -LDSCRIPT ?= $(SRCTREE)/$(CPUDIR)/u-boot.lds -- cgit v1.1 From 4ab3fc5eba1d24f37ab33f83ea39c1f7082075d3 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Mar 2014 11:05:17 +0900 Subject: kirkwood: kwbimage: refactor CONFIG_SYS_KWD_CONFIG Pull out "$(SRCTREE)/" from CONFIG_SYS_KWD_CONFIG and push it into the top Makefile. Signed-off-by: Masahiro Yamada Cc: Michael Walle Cc: Simon Guinot Cc: Dave Purdy Cc: Stefan Herbrechtsmeier Cc: Luka Perkov Cc: Valentin Longchamp Cc: Jason Cooper Cc: Siddarth Gore Cc: Prafulla Wadaskar Cc: Eric Cooper Cc: Suriyan Ramasami --- arch/arm/include/asm/arch-kirkwood/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/arm/include/asm/arch-kirkwood/config.h b/arch/arm/include/asm/arch-kirkwood/config.h index 197703b..7a688e4 100644 --- a/arch/arm/include/asm/arch-kirkwood/config.h +++ b/arch/arm/include/asm/arch-kirkwood/config.h @@ -38,7 +38,7 @@ * CONFIG_SYS_KWD_CONFIG should be defined in board specific header file */ #ifndef CONFIG_SYS_KWD_CONFIG -#define CONFIG_SYS_KWD_CONFIG $(SRCTREE)/$(CONFIG_BOARDDIR)/kwbimage.cfg +#define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage.cfg #endif /* CONFIG_SYS_KWD_CONFIG */ /* Kirkwood has 2k of Security SRAM, use it for SP */ -- cgit v1.1 From 4379ac614809da2128f8bc1f62e3dde4daaf7deb Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Mar 2014 11:05:19 +0900 Subject: kbuild: rename TOPDIR to stctree Prior to Kbuild, $(TOPDIR) or $(SRCTREE) was used for pointing to the top of source directory. (No difference between the two.) In Kbuild style, $(srctree) is used instead. This commit renames TOPDIR to srctree and delete the defition of TOPDIR. Signed-off-by: Masahiro Yamada --- arch/m68k/cpu/mcf52x2/config.mk | 14 +++++++------- arch/m68k/cpu/mcf532x/config.mk | 4 ++-- arch/m68k/cpu/mcf5445x/config.mk | 2 +- arch/powerpc/cpu/ppc4xx/config.mk | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'arch') diff --git a/arch/m68k/cpu/mcf52x2/config.mk b/arch/m68k/cpu/mcf52x2/config.mk index 25f98de..ebf75e6 100644 --- a/arch/m68k/cpu/mcf52x2/config.mk +++ b/arch/m68k/cpu/mcf52x2/config.mk @@ -8,13 +8,13 @@ # cfg=$(shell grep configs $(OBJTREE)/include/config.h | sed 's/.*<\(configs.*\)>/\1/') -is5208:=$(shell grep CONFIG_M5208 $(TOPDIR)/include/$(cfg)) -is5249:=$(shell grep CONFIG_M5249 $(TOPDIR)/include/$(cfg)) -is5253:=$(shell grep CONFIG_M5253 $(TOPDIR)/include/$(cfg)) -is5271:=$(shell grep CONFIG_M5271 $(TOPDIR)/include/$(cfg)) -is5272:=$(shell grep CONFIG_M5272 $(TOPDIR)/include/$(cfg)) -is5275:=$(shell grep CONFIG_M5275 $(TOPDIR)/include/$(cfg)) -is5282:=$(shell grep CONFIG_M5282 $(TOPDIR)/include/$(cfg)) +is5208:=$(shell grep CONFIG_M5208 $(srctree)/include/$(cfg)) +is5249:=$(shell grep CONFIG_M5249 $(srctree)/include/$(cfg)) +is5253:=$(shell grep CONFIG_M5253 $(srctree)/include/$(cfg)) +is5271:=$(shell grep CONFIG_M5271 $(srctree)/include/$(cfg)) +is5272:=$(shell grep CONFIG_M5272 $(srctree)/include/$(cfg)) +is5275:=$(shell grep CONFIG_M5275 $(srctree)/include/$(cfg)) +is5282:=$(shell grep CONFIG_M5282 $(srctree)/include/$(cfg)) ifneq (,$(findstring CONFIG_M5208,$(is5208))) PLATFORM_CPPFLAGS += -mcpu=5208 diff --git a/arch/m68k/cpu/mcf532x/config.mk b/arch/m68k/cpu/mcf532x/config.mk index 0604ab0..0a248c3 100644 --- a/arch/m68k/cpu/mcf532x/config.mk +++ b/arch/m68k/cpu/mcf532x/config.mk @@ -8,8 +8,8 @@ # cfg=$(shell grep configs $(OBJTREE)/include/config.h | sed 's/.*<\(configs.*\)>/\1/') -is5301x:=$(shell grep CONFIG_MCF5301x $(TOPDIR)/include/$(cfg)) -is532x:=$(shell grep CONFIG_MCF532x $(TOPDIR)/include/$(cfg)) +is5301x:=$(shell grep CONFIG_MCF5301x $(srctree)/include/$(cfg)) +is532x:=$(shell grep CONFIG_MCF532x $(srctree)/include/$(cfg)) ifneq (,$(findstring CONFIG_MCF5301x,$(is5301x))) PLATFORM_CPPFLAGS += -mcpu=53015 -fPIC diff --git a/arch/m68k/cpu/mcf5445x/config.mk b/arch/m68k/cpu/mcf5445x/config.mk index 6da08d5..2f310a5 100644 --- a/arch/m68k/cpu/mcf5445x/config.mk +++ b/arch/m68k/cpu/mcf5445x/config.mk @@ -10,7 +10,7 @@ # cfg=$(shell grep configs $(OBJTREE)/include/config.h | sed 's/.*<\(configs.*\)>/\1/') -is5441x:=$(shell grep CONFIG_MCF5441x $(TOPDIR)/include/$(cfg)) +is5441x:=$(shell grep CONFIG_MCF5441x $(srctree)/include/$(cfg)) ifneq (,$(findstring CONFIG_MCF5441x,$(is5441x))) PLATFORM_CPPFLAGS += -mcpu=54418 -fPIC diff --git a/arch/powerpc/cpu/ppc4xx/config.mk b/arch/powerpc/cpu/ppc4xx/config.mk index 71c2a6c..907a3dd 100644 --- a/arch/powerpc/cpu/ppc4xx/config.mk +++ b/arch/powerpc/cpu/ppc4xx/config.mk @@ -8,7 +8,7 @@ PLATFORM_CPPFLAGS += -DCONFIG_4xx -mstring -msoft-float cfg=$(shell grep configs $(OBJTREE)/include/config.h | sed 's/.*<\(configs.*\)>/\1/') -is440:=$(shell grep CONFIG_440 $(TOPDIR)/include/$(cfg)) +is440:=$(shell grep CONFIG_440 $(srctree)/include/$(cfg)) ifneq (,$(findstring CONFIG_440,$(is440))) PLATFORM_CPPFLAGS += -Wa,-m440 -mcpu=440 -- cgit v1.1 From 5ee828ca95de622cd11d0f3ddcccf97f4935de5b Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Mar 2014 11:05:21 +0900 Subject: kbuild: rename OBJTREE to objtree Prior to Kbuild, $(OBJTREE) was used for pointing to the top of build directory with absolute path. In Kbuild style, $(objtree) is used instead. This commit renames OBJTREE to objtree and delete the defition of OBJTREE. Signed-off-by: Masahiro Yamada --- arch/m68k/cpu/mcf52x2/config.mk | 2 +- arch/m68k/cpu/mcf532x/config.mk | 2 +- arch/m68k/cpu/mcf5445x/config.mk | 2 +- arch/powerpc/cpu/ppc4xx/config.mk | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'arch') diff --git a/arch/m68k/cpu/mcf52x2/config.mk b/arch/m68k/cpu/mcf52x2/config.mk index ebf75e6..34ad99e 100644 --- a/arch/m68k/cpu/mcf52x2/config.mk +++ b/arch/m68k/cpu/mcf52x2/config.mk @@ -7,7 +7,7 @@ # SPDX-License-Identifier: GPL-2.0+ # -cfg=$(shell grep configs $(OBJTREE)/include/config.h | sed 's/.*<\(configs.*\)>/\1/') +cfg=$(shell grep configs $(objtree)/include/config.h | sed 's/.*<\(configs.*\)>/\1/') is5208:=$(shell grep CONFIG_M5208 $(srctree)/include/$(cfg)) is5249:=$(shell grep CONFIG_M5249 $(srctree)/include/$(cfg)) is5253:=$(shell grep CONFIG_M5253 $(srctree)/include/$(cfg)) diff --git a/arch/m68k/cpu/mcf532x/config.mk b/arch/m68k/cpu/mcf532x/config.mk index 0a248c3..af94354 100644 --- a/arch/m68k/cpu/mcf532x/config.mk +++ b/arch/m68k/cpu/mcf532x/config.mk @@ -7,7 +7,7 @@ # SPDX-License-Identifier: GPL-2.0+ # -cfg=$(shell grep configs $(OBJTREE)/include/config.h | sed 's/.*<\(configs.*\)>/\1/') +cfg=$(shell grep configs $(objtree)/include/config.h | sed 's/.*<\(configs.*\)>/\1/') is5301x:=$(shell grep CONFIG_MCF5301x $(srctree)/include/$(cfg)) is532x:=$(shell grep CONFIG_MCF532x $(srctree)/include/$(cfg)) diff --git a/arch/m68k/cpu/mcf5445x/config.mk b/arch/m68k/cpu/mcf5445x/config.mk index 2f310a5..5fd0d4d 100644 --- a/arch/m68k/cpu/mcf5445x/config.mk +++ b/arch/m68k/cpu/mcf5445x/config.mk @@ -9,7 +9,7 @@ # SPDX-License-Identifier: GPL-2.0+ # -cfg=$(shell grep configs $(OBJTREE)/include/config.h | sed 's/.*<\(configs.*\)>/\1/') +cfg=$(shell grep configs $(objtree)/include/config.h | sed 's/.*<\(configs.*\)>/\1/') is5441x:=$(shell grep CONFIG_MCF5441x $(srctree)/include/$(cfg)) ifneq (,$(findstring CONFIG_MCF5441x,$(is5441x))) diff --git a/arch/powerpc/cpu/ppc4xx/config.mk b/arch/powerpc/cpu/ppc4xx/config.mk index 907a3dd..102f069 100644 --- a/arch/powerpc/cpu/ppc4xx/config.mk +++ b/arch/powerpc/cpu/ppc4xx/config.mk @@ -7,7 +7,7 @@ PLATFORM_CPPFLAGS += -DCONFIG_4xx -mstring -msoft-float -cfg=$(shell grep configs $(OBJTREE)/include/config.h | sed 's/.*<\(configs.*\)>/\1/') +cfg=$(shell grep configs $(objtree)/include/config.h | sed 's/.*<\(configs.*\)>/\1/') is440:=$(shell grep CONFIG_440 $(srctree)/include/$(cfg)) ifneq (,$(findstring CONFIG_440,$(is440))) -- cgit v1.1 From 19bb5e4ba0e808dd9234319267f3e551d288331b Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Mon, 10 Mar 2014 15:05:33 +0200 Subject: sh: fix PFC registers definition for SH772{2, 3, 4} Add missing port X data register, and fix the offset of ports Y and Z. Signed-off-by: Baruch Siach Signed-off-by: Nobuhiro Iwamatsu --- arch/sh/include/asm/cpu_sh7722.h | 5 +++-- arch/sh/include/asm/cpu_sh7723.h | 5 +++-- arch/sh/include/asm/cpu_sh7724.h | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'arch') diff --git a/arch/sh/include/asm/cpu_sh7722.h b/arch/sh/include/asm/cpu_sh7722.h index 7be37ae..bf57e18 100644 --- a/arch/sh/include/asm/cpu_sh7722.h +++ b/arch/sh/include/asm/cpu_sh7722.h @@ -1250,8 +1250,9 @@ #define PUDR 0xA4050162 #define PVDR 0xA4050164 #define PWDR 0xA4050166 -#define PYDR 0xA4050168 -#define PZDR 0xA405016A +#define PXDR 0xA4050168 +#define PYDR 0xA405016A +#define PZDR 0xA405016C /* UBC */ #define CBR0 0xFF200000 diff --git a/arch/sh/include/asm/cpu_sh7723.h b/arch/sh/include/asm/cpu_sh7723.h index 3af0b0d..9d8cb8d 100644 --- a/arch/sh/include/asm/cpu_sh7723.h +++ b/arch/sh/include/asm/cpu_sh7723.h @@ -178,8 +178,9 @@ #define PUDR 0xA4050162 #define PVDR 0xA4050164 #define PWDR 0xA4050166 -#define PYDR 0xA4050168 -#define PZDR 0xA405016A +#define PXDR 0xA4050168 +#define PYDR 0xA405016A +#define PZDR 0xA405016C /* UBC */ /* H-UDI */ diff --git a/arch/sh/include/asm/cpu_sh7724.h b/arch/sh/include/asm/cpu_sh7724.h index 2c2a474..88c418a 100644 --- a/arch/sh/include/asm/cpu_sh7724.h +++ b/arch/sh/include/asm/cpu_sh7724.h @@ -200,8 +200,9 @@ #define PUDR 0xA4050162 #define PVDR 0xA4050164 #define PWDR 0xA4050166 -#define PYDR 0xA4050168 -#define PZDR 0xA405016A +#define PXDR 0xA4050168 +#define PYDR 0xA405016A +#define PZDR 0xA405016C /* Ether */ #define EDMR 0xA4600000 -- cgit v1.1 From 66bd1cff901c5b19b351c7b5ad48cee09c15d992 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 27 Feb 2014 13:25:55 -0700 Subject: Use a const pointer for map_to_sysmem() This function does not actually change the pointer contents, so use const so that functions which have a const pointer do not need to cast. Signed-off-by: Simon Glass --- arch/sandbox/cpu/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index 38019e0..3f4005b 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -58,7 +58,7 @@ void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags) return (void *)(gd->arch.ram_buf + paddr); } -phys_addr_t map_to_sysmem(void *ptr) +phys_addr_t map_to_sysmem(const void *ptr) { return (u8 *)ptr - gd->arch.ram_buf; } -- cgit v1.1 From 39741c01e62614309a39a400ef493d62873b69ee Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 27 Feb 2014 13:25:59 -0700 Subject: sandbox: dts: Add display and keyboard to sandbox Add an LCD display and keyboard to the sandbox device tree so that these features can be used. Signed-off-by: Simon Glass --- arch/sandbox/dts/sandbox.dts | 96 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) (limited to 'arch') diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts index 96a4438..62d8037 100644 --- a/arch/sandbox/dts/sandbox.dts +++ b/arch/sandbox/dts/sandbox.dts @@ -17,4 +17,100 @@ colour = "white"; sides = <6>; }; + + host@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "sandbox,host-emulation"; + cros-ec@0 { + reg = <0>; + compatible = "google,cros-ec"; + + /* + * This describes the flash memory within the EC. Note + * that the STM32L flash erases to 0, not 0xff. + */ + #address-cells = <1>; + #size-cells = <1>; + flash@8000000 { + reg = <0x08000000 0x20000>; + erase-value = <0>; + #address-cells = <1>; + #size-cells = <1>; + + /* Information for sandbox */ + ro { + reg = <0 0xf000>; + }; + wp-ro { + reg = <0xf000 0x1000>; + }; + rw { + reg = <0x10000 0x10000>; + }; + }; + }; + }; + + lcd { + compatible = "sandbox,lcd-sdl"; + xres = <800>; + yres = <600>; + }; + + cros-ec-keyb { + compatible = "google,cros-ec-keyb"; + google,key-rows = <8>; + google,key-columns = <13>; + google,repeat-delay-ms = <240>; + google,repeat-rate-ms = <30>; + google,ghost-filter; + /* + * Keymap entries take the form of 0xRRCCKKKK where + * RR=Row CC=Column KKKK=Key Code + * The values below are for a US keyboard layout and + * are taken from the Linux driver. Note that the + * 102ND key is not used for US keyboards. + */ + linux,keymap = < + /* CAPSLCK F1 B F10 */ + 0x0001003a 0x0002003b 0x00030030 0x00040044 + /* N = R_ALT ESC */ + 0x00060031 0x0008000d 0x000a0064 0x01010001 + /* F4 G F7 H */ + 0x0102003e 0x01030022 0x01040041 0x01060023 + /* ' F9 BKSPACE L_CTRL */ + 0x01080028 0x01090043 0x010b000e 0x0200001d + /* TAB F3 T F6 */ + 0x0201000f 0x0202003d 0x02030014 0x02040040 + /* ] Y 102ND [ */ + 0x0205001b 0x02060015 0x02070056 0x0208001a + /* F8 GRAVE F2 5 */ + 0x02090042 0x03010029 0x0302003c 0x03030006 + /* F5 6 - \ */ + 0x0304003f 0x03060007 0x0308000c 0x030b002b + /* R_CTRL A D F */ + 0x04000061 0x0401001e 0x04020020 0x04030021 + /* S K J ; */ + 0x0404001f 0x04050025 0x04060024 0x04080027 + /* L ENTER Z C */ + 0x04090026 0x040b001c 0x0501002c 0x0502002e + /* V X , M */ + 0x0503002f 0x0504002d 0x05050033 0x05060032 + /* L_SHIFT / . SPACE */ + 0x0507002a 0x05080035 0x05090034 0x050B0039 + /* 1 3 4 2 */ + 0x06010002 0x06020004 0x06030005 0x06040003 + /* 8 7 0 9 */ + 0x06050009 0x06060008 0x0608000b 0x0609000a + /* L_ALT DOWN RIGHT Q */ + 0x060a0038 0x060b006c 0x060c006a 0x07010010 + /* E R W I */ + 0x07020012 0x07030013 0x07040011 0x07050017 + /* U R_SHIFT P O */ + 0x07060016 0x07070036 0x07080019 0x07090018 + /* UP LEFT */ + 0x070b0067 0x070c0069>; + }; + }; -- cgit v1.1 From 47f5fcfb4169a8ff6e8c81738b77f8572f972e75 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 27 Feb 2014 13:26:15 -0700 Subject: sandbox: Add os_jump_to_image() to run another executable For some tests it is useful to be able to run U-Boot again but pass on the same memory contents. Add a function to achieve this. Reviewed-by: Simon Glass Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) (limited to 'arch') diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 98f565e..52e1096 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -443,3 +443,92 @@ int os_read_ram_buf(const char *fname) return 0; } + +static int make_exec(char *fname, const void *data, int size) +{ + int fd; + + strcpy(fname, "/tmp/u-boot.jump.XXXXXX"); + fd = mkstemp(fname); + if (fd < 0) + return -ENOENT; + if (write(fd, data, size) < 0) + return -EIO; + close(fd); + if (chmod(fname, 0777)) + return -ENOEXEC; + + return 0; +} + +static int add_args(char ***argvp, const char *add_args[], int count) +{ + char **argv; + int argc; + + for (argv = *argvp, argc = 0; (*argvp)[argc]; argc++) + ; + + argv = malloc((argc + count + 1) * sizeof(char *)); + if (!argv) { + printf("Out of memory for %d argv\n", count); + return -ENOMEM; + } + memcpy(argv, *argvp, argc * sizeof(char *)); + memcpy(argv + argc, add_args, count * sizeof(char *)); + argv[argc + count] = NULL; + + *argvp = argv; + return 0; +} + +int os_jump_to_image(const void *dest, int size) +{ + struct sandbox_state *state = state_get_current(); + char fname[30], mem_fname[30]; + int fd, err; + const char *extra_args[4]; + char **argv = state->argv; +#ifdef DEBUG + int argc, i; +#endif + + err = make_exec(fname, dest, size); + if (err) + return err; + + strcpy(mem_fname, "/tmp/u-boot.mem.XXXXXX"); + fd = mkstemp(mem_fname); + if (fd < 0) + return -ENOENT; + close(fd); + err = os_write_ram_buf(mem_fname); + if (err) + return err; + + os_fd_restore(); + + extra_args[0] = "-j"; + extra_args[1] = fname; + extra_args[2] = "-m"; + extra_args[3] = mem_fname; + err = add_args(&argv, extra_args, + sizeof(extra_args) / sizeof(extra_args[0])); + if (err) + return err; + +#ifdef DEBUG + for (i = 0; argv[i]; i++) + printf("%d %s\n", i, argv[i]); +#endif + + if (state_uninit()) + os_exit(2); + + err = execv(fname, argv); + free(argv); + if (err) + return err; + + return unlink(fname); +} -- cgit v1.1 From bda7773f044a13cf69cbbcb016285dd217b981c3 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 27 Feb 2014 13:26:16 -0700 Subject: sandbox: Add -j option to indicate a jump from a previous U-Boot In order to support the 'go' command we allow the jumping U-Boot to pass its filename to the new U-Boot image. This can then be used to delete that image if required. Reviewed-by: Simon Glass Tested-by: Che-Liang Chiou Signed-off-by: Simon Glass --- arch/sandbox/cpu/start.c | 16 ++++++++++++++++ arch/sandbox/include/asm/state.h | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 1df21d4..2d19fe7 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -107,6 +107,22 @@ static int sandbox_cmdline_cb_interactive(struct sandbox_state *state, SANDBOX_CMDLINE_OPT_SHORT(interactive, 'i', 0, "Enter interactive mode"); +static int sandbox_cmdline_cb_jump(struct sandbox_state *state, + const char *arg) +{ + state->jumped = 1; + + /* + * TODO(sjg@chromium.org): Note this causes problems for gdb which + * wants to read debug data from the image. + * + * os_unlink(arg); + */ + + return 0; +} +SANDBOX_CMDLINE_OPT_SHORT(jump, 'j', 1, "Jumped from previous U-Boot"); + static int sandbox_cmdline_cb_memory(struct sandbox_state *state, const char *arg) { diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index e8e4fea..304104e 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -30,7 +30,8 @@ struct sandbox_state { enum exit_type_id exit_type; /* How we exited U-Boot */ const char *parse_err; /* Error to report from parsing */ int argc; /* Program arguments */ - char **argv; + char **argv; /* Command line arguments */ + bool jumped; /* Jumped from previous U_Boot */ uint8_t *ram_buf; /* Emulated RAM buffer */ unsigned int ram_size; /* Size of RAM buffer */ const char *ram_buf_fname; /* Filename to use for RAM buffer */ -- cgit v1.1 From bbc09bf27e77dc80f74054f7fc8a66111dd113c6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 27 Feb 2014 13:26:17 -0700 Subject: sandbox: Add SDL library for LCD, keyboard, audio SDL (Simple DirectMedia Layer - see www.libsdl.org) is a library which provides simple graphics and sound features. It works under X11 and also with a simple frame buffer interface. It is ideally suited to sandbox U-Boot since it fits nicely with the low-level feature set required by U-Boot. For example, U-Boot has its own font drawing routines, its own keyboard processing and just needs raw sound output. We can use SDL to provide emulation of these basic functions for sandbox. This significantly expands the testing that is possible with sandbox. Add a basic SDL library which we will use in future commits. Tested-by: Che-Liang Chiou Signed-off-by: Simon Glass --- arch/sandbox/config.mk | 5 + arch/sandbox/cpu/Makefile | 3 + arch/sandbox/cpu/sdl.c | 341 +++++++++++++++++++++++++++++++++++++++++ arch/sandbox/include/asm/sdl.h | 118 ++++++++++++++ 4 files changed, 467 insertions(+) create mode 100644 arch/sandbox/cpu/sdl.c create mode 100644 arch/sandbox/include/asm/sdl.h (limited to 'arch') diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 668aa71..e094ae2 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -5,6 +5,11 @@ PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__ -U_FORTIFY_SOURCE PLATFORM_CPPFLAGS += -DCONFIG_ARCH_MAP_SYSMEM -DCONFIG_SYS_GENERIC_BOARD PLATFORM_LIBS += -lrt +ifdef CONFIG_SANDBOX_SDL +PLATFORM_LIBS += $(shell sdl-config --libs) +PLATFORM_CPPFLAGS += $(shell sdl-config --cflags) +endif + # Support generic board on sandbox __HAVE_ARCH_GENERIC_BOARD := y diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile index 63deded..7d4410c 100644 --- a/arch/sandbox/cpu/Makefile +++ b/arch/sandbox/cpu/Makefile @@ -8,6 +8,7 @@ # obj-y := cpu.o os.o start.o state.o +obj-$(CONFIG_SANDBOX_SDL) += sdl.o # os.c is build in the system environment, so needs standard includes # CFLAGS_REMOVE_os.o cannot be used to drop header include path @@ -17,3 +18,5 @@ cmd_cc_os.o = $(CC) $(filter-out -nostdinc, \ $(obj)/os.o: $(src)/os.c FORCE $(call if_changed_dep,cc_os.o) +$(obj)/sdl.o: $(src)/sdl.c FORCE + $(call if_changed_dep,cc_os.o) diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c new file mode 100644 index 0000000..18dc7ed --- /dev/null +++ b/arch/sandbox/cpu/sdl.c @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2013 Google, Inc + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include + +static struct sdl_info { + SDL_Surface *screen; + int width; + int height; + int depth; + int pitch; + uint frequency; + uint audio_pos; + uint audio_size; + uint8_t *audio_data; + bool audio_active; + bool inited; +} sdl; + +static void sandbox_sdl_poll_events(void) +{ + /* + * We don't want to include common.h in this file since it uses + * system headers. So add a declation here. + */ + extern void reset_cpu(unsigned long addr); + SDL_Event event; + + while (SDL_PollEvent(&event)) { + switch (event.type) { + case SDL_QUIT: + puts("LCD window closed - quitting\n"); + reset_cpu(1); + break; + } + } +} + +static int sandbox_sdl_ensure_init(void) +{ + if (!sdl.inited) { + if (SDL_Init(0) < 0) { + printf("Unable to initialize SDL: %s\n", + SDL_GetError()); + return -EIO; + } + + atexit(SDL_Quit); + + sdl.inited = true; + } + return 0; +} + +int sandbox_sdl_init_display(int width, int height, int log2_bpp) +{ + struct sandbox_state *state = state_get_current(); + int err; + + if (!width || !state->show_lcd) + return 0; + err = sandbox_sdl_ensure_init(); + if (err) + return err; + if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { + printf("Unable to initialize SDL LCD: %s\n", SDL_GetError()); + return -EPERM; + } + SDL_WM_SetCaption("U-Boot", "U-Boot"); + + sdl.width = width; + sdl.height = height; + sdl.depth = 1 << log2_bpp; + sdl.pitch = sdl.width * sdl.depth / 8; + sdl.screen = SDL_SetVideoMode(width, height, 0, 0); + sandbox_sdl_poll_events(); + + return 0; +} + +int sandbox_sdl_sync(void *lcd_base) +{ + SDL_Surface *frame; + + frame = SDL_CreateRGBSurfaceFrom(lcd_base, sdl.width, sdl.height, + sdl.depth, sdl.pitch, + 0x1f << 11, 0x3f << 5, 0x1f << 0, 0); + SDL_BlitSurface(frame, NULL, sdl.screen, NULL); + SDL_FreeSurface(frame); + SDL_UpdateRect(sdl.screen, 0, 0, 0, 0); + sandbox_sdl_poll_events(); + + return 0; +} + +#define NONE (-1) +#define NUM_SDL_CODES (SDLK_UNDO + 1) + +static int16_t sdl_to_keycode[NUM_SDL_CODES] = { + /* 0 */ + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, KEY_BACKSPACE, KEY_TAB, + NONE, NONE, NONE, KEY_ENTER, NONE, + NONE, NONE, NONE, NONE, KEY_POWER, /* use PAUSE as POWER */ + + /* 20 */ + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, KEY_ESC, NONE, NONE, + NONE, NONE, KEY_SPACE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + + /* 40 */ + NONE, NONE, NONE, NONE, KEY_COMMA, + KEY_MINUS, KEY_DOT, KEY_SLASH, KEY_0, KEY_1, + KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, + KEY_7, KEY_8, KEY_9, NONE, KEY_SEMICOLON, + + /* 60 */ + NONE, KEY_EQUAL, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + + /* 80 */ + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, KEY_BACKSLASH, NONE, NONE, + NONE, KEY_GRAVE, KEY_A, KEY_B, KEY_C, + + /* 100 */ + KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, + KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, + KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, + KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, + + /* 120 */ + KEY_X, KEY_Y, KEY_Z, NONE, NONE, + NONE, NONE, KEY_DELETE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + + /* 140 */ + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + + /* 160 */ + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + + /* 180 */ + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + + /* 200 */ + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + + /* 220 */ + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + + /* 240 */ + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, NONE, NONE, NONE, NONE, + NONE, KEY_KP0, KEY_KP1, KEY_KP2, KEY_KP3, + + /* 260 */ + KEY_KP4, KEY_KP5, KEY_KP6, KEY_KP7, KEY_KP8, + KEY_KP9, KEY_KPDOT, KEY_KPSLASH, KEY_KPASTERISK, KEY_KPMINUS, + KEY_KPPLUS, KEY_KPENTER, KEY_KPEQUAL, KEY_UP, KEY_DOWN, + KEY_RIGHT, KEY_LEFT, KEY_INSERT, KEY_HOME, KEY_END, + + /* 280 */ + KEY_PAGEUP, KEY_PAGEDOWN, KEY_F1, KEY_F2, KEY_F3, + KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, + KEY_F9, KEY_F10, KEY_F11, KEY_F12, NONE, + NONE, NONE, NONE, NONE, NONE, + + /* 300 */ + KEY_NUMLOCK, KEY_CAPSLOCK, KEY_SCROLLLOCK, KEY_RIGHTSHIFT, + KEY_LEFTSHIFT, + KEY_RIGHTCTRL, KEY_LEFTCTRL, KEY_RIGHTALT, KEY_LEFTALT, KEY_RIGHTMETA, + KEY_LEFTMETA, NONE, KEY_FN, NONE, KEY_COMPOSE, + NONE, KEY_PRINT, KEY_SYSRQ, KEY_PAUSE, NONE, + + /* 320 */ + NONE, NONE, NONE, +}; + +int sandbox_sdl_scan_keys(int key[], int max_keys) +{ + Uint8 *keystate; + int i, count; + + sandbox_sdl_poll_events(); + keystate = SDL_GetKeyState(NULL); + for (i = count = 0; i < NUM_SDL_CODES; i++) { + if (count >= max_keys) + break; + else if (keystate[i]) + key[count++] = sdl_to_keycode[i]; + } + + return count; +} + +int sandbox_sdl_key_pressed(int keycode) +{ + int key[8]; /* allow up to 8 keys to be pressed at once */ + int count; + int i; + + count = sandbox_sdl_scan_keys(key, sizeof(key) / sizeof(key[0])); + for (i = 0; i < count; i++) { + if (key[i] == keycode) + return 0; + } + + return -ENOENT; +} + +void sandbox_sdl_fill_audio(void *udata, Uint8 *stream, int len) +{ + int avail; + + avail = sdl.audio_size - sdl.audio_pos; + if (avail < len) + len = avail; + + SDL_MixAudio(stream, sdl.audio_data + sdl.audio_pos, len, + SDL_MIX_MAXVOLUME); + sdl.audio_pos += len; + + /* Loop if we are at the end */ + if (sdl.audio_pos == sdl.audio_size) + sdl.audio_pos = 0; +} + +int sandbox_sdl_sound_init(void) +{ + SDL_AudioSpec wanted; + + if (sandbox_sdl_ensure_init()) + return -1; + + if (sdl.audio_active) + return 0; + + /* + * At present all sandbox sounds crash. This is probably due to + * symbol name conflicts with U-Boot. We can remove the malloc() + * probles with: + * + * #define USE_DL_PREFIX + * + * and get this: + * + * Assertion 'e->pollfd->fd == e->fd' failed at pulse/mainloop.c:676, + * function dispatch_pollfds(). Aborting. + * + * The right solution is probably to make U-Boot's names private or + * link os.c and sdl.c against their libraries before liking with + * U-Boot. TBD. For now sound is disabled. + */ + printf("(Warning: sandbox sound disabled)\n"); + return 0; + + /* Set the audio format */ + wanted.freq = 22050; + wanted.format = AUDIO_S16; + wanted.channels = 1; /* 1 = mono, 2 = stereo */ + wanted.samples = 1024; /* Good low-latency value for callback */ + wanted.callback = sandbox_sdl_fill_audio; + wanted.userdata = NULL; + + sdl.audio_size = sizeof(uint16_t) * wanted.freq; + sdl.audio_data = malloc(sdl.audio_size); + if (!sdl.audio_data) { + printf("%s: Out of memory\n", __func__); + return -1; + } + sdl.audio_pos = 0; + + if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { + printf("Unable to initialize SDL audio: %s\n", SDL_GetError()); + goto err; + } + + /* Open the audio device, forcing the desired format */ + if (SDL_OpenAudio(&wanted, NULL) < 0) { + printf("Couldn't open audio: %s\n", SDL_GetError()); + goto err; + } + sdl.audio_active = true; + + return 0; + +err: + free(sdl.audio_data); + return -1; +} + +int sandbox_sdl_sound_start(uint frequency) +{ + if (!sdl.audio_active) + return -1; + sdl.frequency = frequency; + sound_create_square_wave((unsigned short *)sdl.audio_data, + sdl.audio_size, frequency); + sdl.audio_pos = 0; + SDL_PauseAudio(0); + + return 0; +} + +int sandbox_sdl_sound_stop(void) +{ + if (!sdl.audio_active) + return -1; + SDL_PauseAudio(1); + + return 0; +} diff --git a/arch/sandbox/include/asm/sdl.h b/arch/sandbox/include/asm/sdl.h new file mode 100644 index 0000000..6edec1a --- /dev/null +++ b/arch/sandbox/include/asm/sdl.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2013 Google, Inc + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __SANDBOX_SDL_H +#define __SANDBOX_SDL_H + +#include + +#ifdef CONFIG_SANDBOX_SDL + +/** + * sandbox_sdl_init_display() - Set up SDL video ready for use + * + * @width: Window width in pixels + * @height Window height in pixels + * @log2_bpp: Log to base 2 of the number of bits per pixel. So a 32bpp + * display will pass 5, since 2*5 = 32 + * @return 0 if OK, -ENODEV if no device, -EIO if SDL failed to initialize + * and -EPERM if the video failed to come up. + */ +int sandbox_sdl_init_display(int width, int height, int log2_bpp); + +/** + * sandbox_sdl_sync() - Sync current U-Boot LCD frame buffer to SDL + * + * This must be called periodically to update the screen for SDL so that the + * user can see it. + * + * @lcd_base: Base of frame buffer + * @return 0 if screen was updated, -ENODEV is there is no screen. + */ +int sandbox_sdl_sync(void *lcd_base); + +/** + * sandbox_sdl_scan_keys() - scan for pressed keys + * + * Works out which keys are pressed and returns a list + * + * @key: Array to receive keycodes + * @max_keys: Size of array + * @return number of keycodes found, 0 if none, -ENODEV if no keyboard + */ +int sandbox_sdl_scan_keys(int key[], int max_keys); + +/** + * sandbox_sdl_key_pressed() - check if a particular key is pressed + * + * @keycode: Keycode to check (KEY_... - see include/linux/input.h + * @return 0 if pressed, -ENOENT if not pressed. -ENODEV if keybord not + * available, + */ +int sandbox_sdl_key_pressed(int keycode); + +/** + * sandbox_sdl_sound_start() - start playing a sound + * + * @frequency: Frequency of sounds in Hertz + * @return 0 if OK, -ENODEV if no sound is available + */ +int sandbox_sdl_sound_start(uint frequency); + +/** + * sandbox_sdl_sound_stop() - stop playing a sound + * + * @return 0 if OK, -ENODEV if no sound is available + */ +int sandbox_sdl_sound_stop(void); + +/** + * sandbox_sdl_sound_init() - set up the sound system + * + * @return 0 if OK, -ENODEV if no sound is available + */ +int sandbox_sdl_sound_init(void); + +#else +static inline int sandbox_sdl_init_display(int width, int height, + int log2_bpp) +{ + return -ENODEV; +} + +static inline int sandbox_sdl_sync(void *lcd_base) +{ + return -ENODEV; +} + +static inline int sandbox_sdl_scan_keys(int key[], int max_keys) +{ + return -ENODEV; +} + +static inline int sandbox_sdl_key_pressed(int keycode) +{ + return -ENODEV; +} + +static inline int sandbox_sdl_sound_start(uint frequency) +{ + return -ENODEV; +} + +static inline int sandbox_sdl_sound_stop(void) +{ + return -ENODEV; +} + +static inline int sandbox_sdl_sound_init(void) +{ + return -ENODEV; +} + +#endif + +#endif -- cgit v1.1 From c34c0246a3600dc4712247b267f71576234e403b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 27 Feb 2014 13:26:18 -0700 Subject: sandbox: Add a simple sound driver Add a sound driver for sandbox, which uses SDL. Tested-by: Che-Liang Chiou Signed-off-by: Simon Glass --- arch/sandbox/include/asm/arch-sandbox/sound.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 arch/sandbox/include/asm/arch-sandbox/sound.h (limited to 'arch') diff --git a/arch/sandbox/include/asm/arch-sandbox/sound.h b/arch/sandbox/include/asm/arch-sandbox/sound.h new file mode 100644 index 0000000..a32e8c8 --- /dev/null +++ b/arch/sandbox/include/asm/arch-sandbox/sound.h @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2013 Google, Inc + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __SANDBOX_SOUND_H +#define __SANDBOX_SOUND_H + +int sound_play(unsigned int msec, unsigned int frequency); + +int sound_init(const void *blob); + +#endif -- cgit v1.1 From 7d95f2a329c964b54cf505503a61e8fd4f12e2a3 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 27 Feb 2014 13:26:19 -0700 Subject: sandbox: Add LCD driver Add a simple LCD driver which uses SDL to display the image. We update the image regularly, while still providing for reasonable performance. Adjust the common lcd code to support sandbox. For command-line runs we do not want the LCD to be displayed, so add a --show_lcd option to enable it. Tested-by: Che-Liang Chiou Signed-off-by: Simon Glass --- arch/sandbox/cpu/start.c | 9 +++++++++ arch/sandbox/include/asm/state.h | 1 + arch/sandbox/include/asm/u-boot-sandbox.h | 3 +++ 3 files changed, 13 insertions(+) (limited to 'arch') diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 2d19fe7..4d5569e 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -175,6 +175,15 @@ static int sandbox_cmdline_cb_ignore_missing(struct sandbox_state *state, SANDBOX_CMDLINE_OPT_SHORT(ignore_missing, 'n', 0, "Ignore missing state on read"); +static int sandbox_cmdline_cb_show_lcd(struct sandbox_state *state, + const char *arg) +{ + state->show_lcd = true; + return 0; +} +SANDBOX_CMDLINE_OPT_SHORT(show_lcd, 'l', 0, + "Show the sandbox LCD display"); + int main(int argc, char *argv[]) { struct sandbox_state *state; diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 304104e..895b3a4 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -41,6 +41,7 @@ struct sandbox_state { bool read_state; /* Read sandbox state on startup */ 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 */ /* Pointer to information for each SPI bus/cs */ struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS] diff --git a/arch/sandbox/include/asm/u-boot-sandbox.h b/arch/sandbox/include/asm/u-boot-sandbox.h index 5707c27..d2f1b65 100644 --- a/arch/sandbox/include/asm/u-boot-sandbox.h +++ b/arch/sandbox/include/asm/u-boot-sandbox.h @@ -25,4 +25,7 @@ int sandbox_main_loop_init(void); int cleanup_before_linux(void); +/* drivers/video/sandbox_sdl.c */ +int sandbox_lcd_sdl_early_init(void); + #endif /* _U_BOOT_SANDBOX_H_ */ -- cgit v1.1 From ffb87905cb3883c84598b87ca05384c17d59dee1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 27 Feb 2014 13:26:22 -0700 Subject: sandbox: Allow Ctrl-C to work in sandbox It is useful for Cltl-C to be handled by U-Boot as it is on other boards. But it is also useful to be able to terminate U-Boot with Ctrl-C. Add an option to enable signals while in raw mode, and make this the default. Add an option to leave the terminal cooked, which is useful for redirecting output. Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c | 13 +++++++------ arch/sandbox/cpu/start.c | 28 ++++++++++++++++++++++++++++ arch/sandbox/include/asm/state.h | 24 ++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 6 deletions(-) (limited to 'arch') diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 52e1096..9de71bb 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -104,21 +104,22 @@ void os_exit(int exit_code) /* Restore tty state when we exit */ static struct termios orig_term; +static bool term_setup; static void os_fd_restore(void) { - tcsetattr(0, TCSANOW, &orig_term); + if (term_setup) + tcsetattr(0, TCSANOW, &orig_term); } /* Put tty into raw mode so and work */ -void os_tty_raw(int fd) +void os_tty_raw(int fd, bool allow_sigs) { - static int setup = 0; struct termios term; - if (setup) + if (term_setup) return; - setup = 1; + term_setup = true; /* If not a tty, don't complain */ if (tcgetattr(fd, &orig_term)) @@ -128,7 +129,7 @@ void os_tty_raw(int fd) term.c_iflag = IGNBRK | IGNPAR; term.c_oflag = OPOST | ONLCR; term.c_cflag = CS8 | CREAD | CLOCAL; - term.c_lflag = 0; + term.c_lflag = allow_sigs ? ISIG : 0; if (tcsetattr(fd, TCSANOW, &term)) return; diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 4d5569e..36dfc0a 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -184,6 +184,34 @@ static int sandbox_cmdline_cb_show_lcd(struct sandbox_state *state, SANDBOX_CMDLINE_OPT_SHORT(show_lcd, 'l', 0, "Show the sandbox LCD display"); +static const char *term_args[STATE_TERM_COUNT] = { + "raw-with-sigs", + "raw", + "cooked", +}; + +static int sandbox_cmdline_cb_terminal(struct sandbox_state *state, + const char *arg) +{ + int i; + + for (i = 0; i < STATE_TERM_COUNT; i++) { + if (!strcmp(arg, term_args[i])) { + state->term_raw = i; + return 0; + } + } + + printf("Unknown terminal setting '%s' (", arg); + for (i = 0; i < STATE_TERM_COUNT; i++) + printf("%s%s", i ? ", " : "", term_args[i]); + puts(")\n"); + + return 1; +} +SANDBOX_CMDLINE_OPT_SHORT(terminal, 't', 1, + "Set terminal to raw/cooked mode"); + int main(int argc, char *argv[]) { struct sandbox_state *state; diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 895b3a4..56bd9a0 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -17,6 +17,29 @@ enum exit_type_id { STATE_EXIT_POWER_OFF, }; +/** + * Selects the behavior of the serial terminal. + * + * If Ctrl-C is processed by U-Boot, then the only way to quit sandbox is with + * the 'reset' command, or equivalent. + * + * If the terminal is cooked, then Ctrl-C will terminate U-Boot, and the + * command line will not be quite such a faithful emulation. + * + * Options are: + * + * raw-with-sigs - Raw, but allow signals (Ctrl-C will quit) + * raw - Terminal is always raw + * cooked - Terminal is always cooked + */ +enum state_terminal_raw { + STATE_TERM_RAW_WITH_SIGS, /* Default */ + STATE_TERM_RAW, + STATE_TERM_COOKED, + + STATE_TERM_COUNT, +}; + struct sandbox_spi_info { const char *spec; const struct sandbox_spi_emu_ops *ops; @@ -42,6 +65,7 @@ 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 state_terminal_raw term_raw; /* Terminal raw/cooked */ /* Pointer to information for each SPI bus/cs */ struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS] -- cgit v1.1 From ab839dc3e6c1d07bc926199f3eebace0804f2ecf Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 27 Feb 2014 13:26:23 -0700 Subject: sandbox: Add options to clean up temporary files When jumping from one sandbox U-Boot to another in sandbox, the RAM buffer is preserved in the jump by using a temporary file. Add an option to tell the receiving U-Boot to remove this file when it is no longer needed. Similarly the old U-Boot image is left behind in this case. We cannot delete it immediately since gdb cannot then find its debug symbols. Delete it just before exiting. Together these changes ensure that temporary files are removed both for memory and U-Boot. Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c | 3 ++- arch/sandbox/cpu/start.c | 23 +++++++++++++++-------- arch/sandbox/cpu/state.c | 6 +++++- arch/sandbox/include/asm/state.h | 3 ++- 4 files changed, 24 insertions(+), 11 deletions(-) (limited to 'arch') diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 9de71bb..57d04a4 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -488,7 +488,7 @@ int os_jump_to_image(const void *dest, int size) struct sandbox_state *state = state_get_current(); char fname[30], mem_fname[30]; int fd, err; - const char *extra_args[4]; + const char *extra_args[5]; char **argv = state->argv; #ifdef DEBUG int argc, i; @@ -513,6 +513,7 @@ int os_jump_to_image(const void *dest, int size) extra_args[1] = fname; extra_args[2] = "-m"; extra_args[3] = mem_fname; + extra_args[4] = "--rm_memory"; err = add_args(&argv, extra_args, sizeof(extra_args) / sizeof(extra_args[0])); if (err) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 36dfc0a..aad3b8b 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -110,14 +110,8 @@ SANDBOX_CMDLINE_OPT_SHORT(interactive, 'i', 0, "Enter interactive mode"); static int sandbox_cmdline_cb_jump(struct sandbox_state *state, const char *arg) { - state->jumped = 1; - - /* - * TODO(sjg@chromium.org): Note this causes problems for gdb which - * wants to read debug data from the image. - * - * os_unlink(arg); - */ + /* Remember to delete this U-Boot image later */ + state->jumped_fname = arg; return 0; } @@ -142,6 +136,15 @@ static int sandbox_cmdline_cb_memory(struct sandbox_state *state, SANDBOX_CMDLINE_OPT_SHORT(memory, 'm', 1, "Read/write ram_buf memory contents from file"); +static int sandbox_cmdline_cb_rm_memory(struct sandbox_state *state, + const char *arg) +{ + state->ram_buf_rm = true; + + return 0; +} +SANDBOX_CMDLINE_OPT(rm_memory, 0, "Remove memory file after reading"); + static int sandbox_cmdline_cb_state(struct sandbox_state *state, const char *arg) { @@ -229,6 +232,10 @@ int main(int argc, char *argv[]) if (ret) goto err; + /* Remove old memory file if required */ + if (state->ram_buf_rm && state->ram_buf_fname) + os_unlink(state->ram_buf_fname); + /* Do pre- and post-relocation init */ board_init_f(0); diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index a145808..59adad6 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -365,7 +365,7 @@ int state_uninit(void) state = &main_state; - if (state->write_ram_buf) { + if (state->write_ram_buf && !state->ram_buf_rm) { err = os_write_ram_buf(state->ram_buf_fname); if (err) { printf("Failed to write RAM buffer\n"); @@ -380,6 +380,10 @@ int state_uninit(void) } } + /* Delete this at the last moment so as not to upset gdb too much */ + if (state->jumped_fname) + os_unlink(state->jumped_fname); + if (state->state_fdt) os_free(state->state_fdt); memset(state, '\0', sizeof(*state)); diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 56bd9a0..d17a82e 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -54,10 +54,11 @@ struct sandbox_state { const char *parse_err; /* Error to report from parsing */ int argc; /* Program arguments */ char **argv; /* Command line arguments */ - bool jumped; /* Jumped from previous U_Boot */ + const char *jumped_fname; /* Jumped from previous U_Boot */ uint8_t *ram_buf; /* Emulated RAM buffer */ unsigned int ram_size; /* Size of RAM buffer */ const char *ram_buf_fname; /* Filename to use for RAM buffer */ + bool ram_buf_rm; /* Remove RAM buffer file after read */ bool write_ram_buf; /* Write RAM buffer on exit */ const char *state_fname; /* File containing sandbox state */ void *state_fdt; /* Holds saved state for sandbox */ -- cgit v1.1