Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M1ckO-0006ey-LW for qemu-devel@nongnu.org; Wed, 06 May 2009 04:45:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M1ckM-0006eA-Vt for qemu-devel@nongnu.org; Wed, 06 May 2009 04:44:59 -0400 Received: from [199.232.76.173] (port=33352 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M1ckM-0006e7-PZ for qemu-devel@nongnu.org; Wed, 06 May 2009 04:44:58 -0400 Received: from flounder.pepperfish.net ([87.237.62.181]:40256) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M1ckM-00015O-DA for qemu-devel@nongnu.org; Wed, 06 May 2009 04:44:58 -0400 From: Vincent Sanders Date: Wed, 6 May 2009 09:44:42 +0100 Message-Id: <1241599494-28654-4-git-send-email-vince@simtec.co.uk> In-Reply-To: <1241599494-28654-1-git-send-email-vince@simtec.co.uk> References: <1241599494-28654-1-git-send-email-vince@simtec.co.uk> Subject: [Qemu-devel] [PATCH 03/15] Peripheral driver for S3C SOC SDRAM controller. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Vincent Sanders Signed-off-by: Vincent Sanders --- Makefile.target | 1 + hw/s3c24xx_memc.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 0 deletions(-) create mode 100644 hw/s3c24xx_memc.c diff --git a/Makefile.target b/Makefile.target index f735105..c5e6402 100644 --- a/Makefile.target +++ b/Makefile.target @@ -674,6 +674,7 @@ OBJS+= omap_sx1.o palm.o tsc210x.o OBJS+= nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o OBJS+= mst_fpga.o mainstone.o OBJS+= musicpal.o pflash_cfi02.o +OBJS+= s3c24xx_memc.o OBJS+= framebuffer.o CPPFLAGS += -DHAS_AUDIO endif diff --git a/hw/s3c24xx_memc.c b/hw/s3c24xx_memc.c new file mode 100644 index 0000000..07c0f6d --- /dev/null +++ b/hw/s3c24xx_memc.c @@ -0,0 +1,70 @@ +/* hw/s3c24xx_memc.c + * + * Samsung S3C24XX memory controller emulation. + * + * The SDRAM controller on several S3C SOC is generic, the emulation needs to + * be little more than backing the registers. + * + * Copyright 2006, 2007 Daniel Silverstone and Vincent Sanders + * + * This file is under the terms of the GNU General Public + * License Version 2 + */ + +#include "hw.h" + +#include "s3c24xx.h" + +static void +s3c24xx_memc_write_f(void *opaque, target_phys_addr_t addr_, uint32_t value) +{ + S3CState *soc = (S3CState *)opaque; + int addr = (addr_ & 0x3f) >> 2; + + if (addr < 0 || addr > 12) + addr = 12; + + soc->memc_reg[addr] = value; +} + +static uint32_t +s3c24xx_memc_read_f(void *opaque, target_phys_addr_t addr_) +{ + S3CState *soc = (S3CState *)opaque; + int addr = (addr_ & 0x3f) >> 2; + + if (addr < 0 || addr > 12) + addr = 12; + + return soc->memc_reg[addr]; +} + +static CPUReadMemoryFunc *s3c24xx_memc_read[] = { + &s3c24xx_memc_read_f, + &s3c24xx_memc_read_f, + &s3c24xx_memc_read_f, +}; + +static CPUWriteMemoryFunc *s3c24xx_memc_write[] = { + &s3c24xx_memc_write_f, + &s3c24xx_memc_write_f, + &s3c24xx_memc_write_f, +}; + + +void +s3c24xx_memc_init(S3CState *soc, target_phys_addr_t base_addr) +{ + /* Memory controller is simple SDRAM control. As SDRAM is emulated and + * requires no setup the emulation needs to be nothing more than memory + * backing the registers. + * + * There are 13 registers, each 4 bytes. + */ + int tag; + tag = cpu_register_io_memory(0, s3c24xx_memc_read, s3c24xx_memc_write, soc); + cpu_register_physical_memory(base_addr, 13 * 4, tag); + + for (tag = 0; tag < 13; tag++) + soc->memc_reg[tag] = 0; +} -- 1.5.4.3