[PATCH v2 00/32] sandbox: Move to SDL2

2020-02-03 Thread Simon Glass
This series handles moving sandbox to the latest version of SDL, SDL2. It
provides a few more features, better performance and has been around for
long enough that it is present in distributions in the last several years.

Unfortunately it requires considerable rework of how memory allocation is
handled in sandbox.

At present sandbox is built such that it uses U-Boot's malloc() instead
of the C library's malloc. This mostly works but it is fragile, since any
use of libraries can cause strange behaviour. For example SDL ends up
calling U-Boot's malloc/free and this can confuse valgrind and even cause
a crash in some cases.

The simplest solution seems to be to set a prefix for the allocation
functions so that U-Boot's functions can co-exist with the C library's.
This requires a little bit of fiddling but it guarantees that things work
correctly in all circumstances.

We have got away with this for a long time partly due to the way that
SDL1.2 operates on init. But with SDL2 this does not seem to be possible.

As a result of this series, malloc() is #defined to dlmalloc() within
U-Boot (for sandbox only). The use of 'free' as a function in U-Boot is
thus best avoided, since it is #defined to dlfree. The series updates some
APIs to deal with this.

Changes in v2:
- Update the name of the implementing callback function too
- Drop the patch with the Roboto font
- Fix 'adress' typo

Simon Glass (32):
  sandbox: Sort the help options
  video: Support truetype fonts on a 32-bit display
  video: sandbox: Enable all colour depths
  mailbox: Rename free() to rfree()
  power-domain: Rename free() to rfree()
  reset: Rename free() to rfree()
  gpio: Rename free() to rfree()
  clk: Rename free() to rfree()
  dma: Rename free() to rfree()
  mtd: Rename free() to rfree()
  sandbox: Rename 'free' variable
  sandbox: Use a prefix for all allocation functions
  exports: Add the malloc.h header
  string: Allow arch override of strndup() also
  sandbox: Rename strdup() functions
  sandbox: Drop use of special os_malloc() where possible
  sandbox: Drop os_realloc()
  sandbox: Ensure that long-options array is terminated
  sandbox: Add a new header for the system malloc()
  sound: Add a new stop_play() method
  sandbox: sound: Handle errors better in sound_beep()
  sandbox: Add comments to the sdl struct
  sandbox: sdl: Improve error handling
  sandbox: sdl: Support waiting for audio to complete
  gitlab: Disable SDL when building sandbox
  sandbox: sdl: Move to use SDL2
  sandbox: sdl: Add an option to double the screen size
  sandbox: Support changing the LCD colour depth
  dm: core: Require users of devres to include the header
  dm: core: Create a new header file for 'compat' features
  dm: core: Drop the inclusion of linux/compat.h in dm.h
  sandbox: Complete migration away from os_malloc()

 .gitlab-ci.yml|   5 +-
 .travis.yml   |   2 +-
 arch/arm/mach-aspeed/ast2500/clk_ast2500.c|   1 +
 arch/arm/mach-imx/cmd_nandbcb.c   |   2 +
 arch/arm/mach-imx/imx8/image.c|   1 +
 arch/arm/mach-meson/board-info.c  |   1 +
 arch/arm/mach-meson/sm.c  |   1 +
 arch/arm/mach-mvebu/mbus.c|   1 +
 arch/arm/mach-rockchip/px30/clk_px30.c|   1 +
 arch/arm/mach-rockchip/rk3036/clk_rk3036.c|   1 +
 arch/arm/mach-rockchip/rk3128/clk_rk3128.c|   1 +
 arch/arm/mach-rockchip/rk3188/clk_rk3188.c|   1 +
 arch/arm/mach-rockchip/rk3188/rk3188.c|   1 +
 arch/arm/mach-rockchip/rk322x/clk_rk322x.c|   1 +
 arch/arm/mach-rockchip/rk3288/clk_rk3288.c|   1 +
 arch/arm/mach-rockchip/rk3288/rk3288.c|   2 +
 arch/arm/mach-rockchip/rk3308/clk_rk3308.c|   1 +
 arch/arm/mach-rockchip/rk3308/rk3308.c|   1 +
 arch/arm/mach-rockchip/rk3328/clk_rk3328.c|   1 +
 arch/arm/mach-rockchip/rk3368/clk_rk3368.c|   1 +
 arch/arm/mach-rockchip/rk3399/clk_rk3399.c|   1 +
 arch/arm/mach-rockchip/rv1108/clk_rv1108.c|   1 +
 arch/arm/mach-socfpga/clock_manager_agilex.c  |   1 +
 arch/arm/mach-socfpga/clock_manager_arria10.c |   1 +
 arch/arm/mach-stm32mp/pwr_regulator.c |   2 +
 arch/arm/mach-tegra/cboot.c   |   1 +
 arch/arm/mach-zynq/clk.c  |   1 +
 arch/arm/mach-zynq/timer.c|   1 +
 arch/mips/mach-mtmips/cpu.c   |   1 +
 arch/mips/mach-pic32/cpu.c|   1 +
 arch/riscv/lib/andes_plic.c   |   1 +
 arch/riscv/lib/andes_plmt.c   |   1 +
 arch/riscv/lib/sifive_clint.c |   1 +
 arch/sandbox/config.mk|   2 +-
 arch/sandbox/cpu/cpu.c|   1 +
 arch/sandbox/cpu/eth-raw-os.c |   6 +-
 arch/sandbox/cpu/os.c |  48 +--
 arch/sandbox/cpu/sdl.c| 338 +++---
 arch/sandbox/cpu/start.c  |  62 +++-
 

[PATCH v2 00/32] sandbox: Move to SDL2

2020-02-03 Thread Simon Glass
This series handles moving sandbox to the latest version of SDL, SDL2. It
provides a few more features, better performance and has been around for
long enough that it is present in distributions in the last several years.

Unfortunately it requires considerable rework of how memory allocation is
handled in sandbox.

At present sandbox is built such that it uses U-Boot's malloc() instead
of the C library's malloc. This mostly works but it is fragile, since any
use of libraries can cause strange behaviour. For example SDL ends up
calling U-Boot's malloc/free and this can confuse valgrind and even cause
a crash in some cases.

The simplest solution seems to be to set a prefix for the allocation
functions so that U-Boot's functions can co-exist with the C library's.
This requires a little bit of fiddling but it guarantees that things work
correctly in all circumstances.

We have got away with this for a long time partly due to the way that
SDL1.2 operates on init. But with SDL2 this does not seem to be possible.

As a result of this series, malloc() is #defined to dlmalloc() within
U-Boot (for sandbox only). The use of 'free' as a function in U-Boot is
thus best avoided, since it is #defined to dlfree. The series updates some
APIs to deal with this.

Changes in v2:
- Update the name of the implementing callback function too
- Drop the patch with the Roboto font
- Fix 'adress' typo

Simon Glass (32):
  sandbox: Sort the help options
  video: Support truetype fonts on a 32-bit display
  video: sandbox: Enable all colour depths
  mailbox: Rename free() to rfree()
  power-domain: Rename free() to rfree()
  reset: Rename free() to rfree()
  gpio: Rename free() to rfree()
  clk: Rename free() to rfree()
  dma: Rename free() to rfree()
  mtd: Rename free() to rfree()
  sandbox: Rename 'free' variable
  sandbox: Use a prefix for all allocation functions
  exports: Add the malloc.h header
  string: Allow arch override of strndup() also
  sandbox: Rename strdup() functions
  sandbox: Drop use of special os_malloc() where possible
  sandbox: Drop os_realloc()
  sandbox: Ensure that long-options array is terminated
  sandbox: Add a new header for the system malloc()
  sound: Add a new stop_play() method
  sandbox: sound: Handle errors better in sound_beep()
  sandbox: Add comments to the sdl struct
  sandbox: sdl: Improve error handling
  sandbox: sdl: Support waiting for audio to complete
  gitlab: Disable SDL when building sandbox
  sandbox: sdl: Move to use SDL2
  sandbox: sdl: Add an option to double the screen size
  sandbox: Support changing the LCD colour depth
  dm: core: Require users of devres to include the header
  dm: core: Create a new header file for 'compat' features
  dm: core: Drop the inclusion of linux/compat.h in dm.h
  sandbox: Complete migration away from os_malloc()

 .gitlab-ci.yml|   5 +-
 .travis.yml   |   2 +-
 arch/arm/mach-aspeed/ast2500/clk_ast2500.c|   1 +
 arch/arm/mach-imx/cmd_nandbcb.c   |   2 +
 arch/arm/mach-imx/imx8/image.c|   1 +
 arch/arm/mach-meson/board-info.c  |   1 +
 arch/arm/mach-meson/sm.c  |   1 +
 arch/arm/mach-mvebu/mbus.c|   1 +
 arch/arm/mach-rockchip/px30/clk_px30.c|   1 +
 arch/arm/mach-rockchip/rk3036/clk_rk3036.c|   1 +
 arch/arm/mach-rockchip/rk3128/clk_rk3128.c|   1 +
 arch/arm/mach-rockchip/rk3188/clk_rk3188.c|   1 +
 arch/arm/mach-rockchip/rk3188/rk3188.c|   1 +
 arch/arm/mach-rockchip/rk322x/clk_rk322x.c|   1 +
 arch/arm/mach-rockchip/rk3288/clk_rk3288.c|   1 +
 arch/arm/mach-rockchip/rk3288/rk3288.c|   2 +
 arch/arm/mach-rockchip/rk3308/clk_rk3308.c|   1 +
 arch/arm/mach-rockchip/rk3308/rk3308.c|   1 +
 arch/arm/mach-rockchip/rk3328/clk_rk3328.c|   1 +
 arch/arm/mach-rockchip/rk3368/clk_rk3368.c|   1 +
 arch/arm/mach-rockchip/rk3399/clk_rk3399.c|   1 +
 arch/arm/mach-rockchip/rv1108/clk_rv1108.c|   1 +
 arch/arm/mach-socfpga/clock_manager_agilex.c  |   1 +
 arch/arm/mach-socfpga/clock_manager_arria10.c |   1 +
 arch/arm/mach-stm32mp/pwr_regulator.c |   2 +
 arch/arm/mach-tegra/cboot.c   |   1 +
 arch/arm/mach-zynq/clk.c  |   1 +
 arch/arm/mach-zynq/timer.c|   1 +
 arch/mips/mach-mtmips/cpu.c   |   1 +
 arch/mips/mach-pic32/cpu.c|   1 +
 arch/riscv/lib/andes_plic.c   |   1 +
 arch/riscv/lib/andes_plmt.c   |   1 +
 arch/riscv/lib/sifive_clint.c |   1 +
 arch/sandbox/config.mk|   2 +-
 arch/sandbox/cpu/cpu.c|   1 +
 arch/sandbox/cpu/eth-raw-os.c |   6 +-
 arch/sandbox/cpu/os.c |  48 +--
 arch/sandbox/cpu/sdl.c| 338 +++---
 arch/sandbox/cpu/start.c  |  62 +++-