qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vincent Sanders <vince@simtec.co.uk>
To: qemu-devel@nongnu.org
Cc: Vincent Sanders <vince@simtec.co.uk>
Subject: [Qemu-devel] [PATCH 15/16] Add SMDK2410 board support
Date: Sat, 23 May 2009 17:35:33 +0100	[thread overview]
Message-ID: <1243096533-22677-16-git-send-email-vince@simtec.co.uk> (raw)
In-Reply-To: <1243096533-22677-1-git-send-email-vince@simtec.co.uk>

Signed-off-by: Vincent Sanders <vince@simtec.co.uk>
---
 Makefile.target |    2 +-
 hw/smdk2410.c   |  125 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 126 insertions(+), 1 deletions(-)
 create mode 100644 hw/smdk2410.c

diff --git a/Makefile.target b/Makefile.target
index 4cb49e1..b30e90a 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -652,7 +652,7 @@ OBJS+= s3c24xx_memc.o s3c24xx_irq.o s3c24xx_clkcon.o s3c24xx_timers.o
 OBJS+= s3c24xx_serial.o s3c24xx_rtc.o s3c24xx_gpio.o s3c24xx_iic.o
 OBJS+= s3c24xx_lcd.o s3c24xx_nand.o
 OBJS+= s3c2410x.o s3c2440.o
-OBJS+= bast.o
+OBJS+= bast.o smdk2410.o
 OBJS+= framebuffer.o
 OBJS+= syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o
 OBJS+= syborg_serial.o syborg_timer.o syborg_pointer.o syborg_rtc.o
diff --git a/hw/smdk2410.c b/hw/smdk2410.c
new file mode 100644
index 0000000..2c13faf
--- /dev/null
+++ b/hw/smdk2410.c
@@ -0,0 +1,125 @@
+/* hw/smdk2410.c
+ *
+ * System emulation for the Samsung SMDK2410
+ *
+ * Copyright 2006, 2008 Daniel Silverstone and Vincent Sanders
+ *
+ * This file is under the terms of the GNU General Public
+ * License Version 2.
+ */
+
+#include "hw.h"
+#include "sysemu.h"
+#include "arm-misc.h"
+#include "net.h"
+#include "smbus.h"
+#include "devices.h"
+#include "boards.h"
+
+#include "s3c2410x.h"
+
+#define BIOS_FILENAME "smdk2410.bin"
+
+typedef struct {
+    S3CState *soc;
+    unsigned char cpld_ctrl2;
+    NANDFlashState *nand[4];
+} SMDK2410State;
+
+/* Bytes in a Kilobyte */
+#define KILO 1024
+/* Bytes in a megabyte */
+#define MEGA 1024 * KILO
+/* Bytes */
+#define BYTE 1
+/* Bits in a byte */
+#define BIT 8
+
+/* Useful defines */
+#define SMDK2410_NOR_BASE CPU_S3C2410X_CS0
+#define SMDK2410_NOR_SIZE 16 * MEGA / BIT
+#define SMDK2410_BOARD_ID 193
+
+static struct arm_boot_info smdk2410_binfo = {
+    .board_id = SMDK2410_BOARD_ID,
+    .ram_size = 0x10000000, /* 256MB */
+};
+
+static void smdk2410_init(ram_addr_t _ram_size,
+                      const char *boot_device,
+                      const char *kernel_filename, const char *kernel_cmdline,
+                      const char *initrd_filename, const char *cpu_model)
+{
+    SMDK2410State *stcb;
+    int ret, index;
+
+    /* ensure memory is limited to 256MB */
+    if (_ram_size > (256 * MEGA * BYTE))
+        _ram_size = 256 * MEGA * BYTE;
+    ram_size = _ram_size;
+
+    /* allocate storage for board state */
+    stcb = malloc(sizeof(SMDK2410State));
+
+    /* initialise CPU and memory */
+    stcb->soc = s3c2410x_init(ram_size);
+
+    /* Register the NOR flash ROM */
+    cpu_register_physical_memory(SMDK2410_NOR_BASE,
+                                 SMDK2410_NOR_SIZE,
+                                 qemu_ram_alloc(SMDK2410_NOR_SIZE) | IO_MEM_ROM);
+
+    /* initialise board informations */
+    smdk2410_binfo.ram_size = ram_size;
+    smdk2410_binfo.kernel_filename = kernel_filename;
+    smdk2410_binfo.kernel_cmdline = kernel_cmdline;
+    smdk2410_binfo.initrd_filename = initrd_filename;
+    smdk2410_binfo.nb_cpus = 1;
+    smdk2410_binfo.loader_start = SMDK2410_NOR_BASE;
+
+    if (kernel_filename == NULL) {
+        /* No kernel given so try and aquire a bootloader */
+        char buf[PATH_MAX];
+
+        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
+        ret = load_image_targphys(buf, smdk2410_binfo.loader_start, SMDK2410_NOR_SIZE);
+        if (ret <= 0) {
+            perror("qemu");
+            fprintf(stderr, "qemu: warning, could not load SMDK2410 BIOS from %s\n", buf);
+            exit (1);
+        } else {
+            fprintf(stdout, "qemu: info, loaded SMDK2410 BIOS %d bytes from %s\n", ret, buf);
+        }
+    } else {
+        smdk2410_binfo.loader_start = CPU_S3C2410X_DRAM;
+        arm_load_kernel(stcb->soc->cpu_env, &smdk2410_binfo);
+    }
+
+    /* Setup initial (reset) program counter */
+    stcb->soc->cpu_env->regs[15] = smdk2410_binfo.loader_start;
+
+    /* Attach some NAND devices */
+    stcb->nand[0] = NULL;
+    stcb->nand[1] = NULL;
+    index = drive_get_index(IF_MTD, 0, 0);
+    if (index == -1)
+        stcb->nand[2] = NULL;
+    else
+        stcb->nand[2] = nand_init(0xEC, 0x79); /* 128MiB small-page */
+
+}
+
+
+static QEMUMachine smdk2410_machine = {
+  .name = "smdk2410",
+  .desc = "Samsung SMDK2410 (S3C2410A, ARM920T)",
+  .init = smdk2410_init,
+  .max_cpus = 1,
+};
+
+static void smdk2410_machine_init(void)
+{
+    qemu_register_machine(&smdk2410_machine);
+}
+
+machine_init(smdk2410_machine_init);
-- 
1.6.0.4

      parent reply	other threads:[~2009-05-23 16:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-23 16:35 [Qemu-devel] Add ARM S3C SOC core, drivers and boards - v3 Vincent Sanders
2009-05-23 16:35 ` [Qemu-devel] [PATCH 01/16] Add ARM 920T CPU identifier Vincent Sanders
2009-05-23 16:35 ` [Qemu-devel] [PATCH 02/16] S3C2410 and S3C2440 core SOC implementation Vincent Sanders
2009-05-23 16:35 ` [Qemu-devel] [PATCH 03/16] Peripheral driver for S3C SOC SDRAM controller Vincent Sanders
2009-05-23 16:35 ` [Qemu-devel] [PATCH 04/16] Peripheral driver for S3C SOC IRQ controller Vincent Sanders
2009-05-23 16:35 ` [Qemu-devel] [PATCH 05/16] Peripheral driver for S3C SOC clock control Vincent Sanders
2009-05-23 16:35 ` [Qemu-devel] [PATCH 06/16] Peripheral driver for S3C SOC timers Vincent Sanders
2009-05-23 16:35 ` [Qemu-devel] [PATCH 07/16] Peripheral driver for S3C SOC Serial ports Vincent Sanders
2009-05-23 16:35 ` [Qemu-devel] [PATCH 08/16] Peripheral driver for S3C SOC real time clock Vincent Sanders
2009-05-23 16:35 ` [Qemu-devel] [PATCH 09/16] Peripheral driver for S3C SOC general purpose I/O Vincent Sanders
2009-05-23 16:35 ` [Qemu-devel] [PATCH 10/16] Peripheral driver for S3C SOC I2C controller Vincent Sanders
2009-05-23 16:35 ` [Qemu-devel] [PATCH 11/16] Peripheral driver for S3C SOC LCD controller Vincent Sanders
2009-05-23 16:35 ` [Qemu-devel] [PATCH 12/16] Peripheral driver for S3C SOC NAND controller Vincent Sanders
2009-05-23 16:35 ` [Qemu-devel] [PATCH 13/16] Peripheral driver for S3C OHCI controller Vincent Sanders
2009-05-23 16:35 ` [Qemu-devel] [PATCH 14/16] Add bast board support Vincent Sanders
2009-05-23 16:35 ` Vincent Sanders [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1243096533-22677-16-git-send-email-vince@simtec.co.uk \
    --to=vince@simtec.co.uk \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).