slirp: Avoid redefining MAX_TCPOPTLEN
[qemu-kvm.git] / hw / petalogix_s3adsp1800_mmu.c
blob8b37336001b9c1c655c43813afc3373393946c7e
1 /*
2 * Model of Petalogix linux reference design targeting Xilinx Spartan 3ADSP-1800
3 * boards.
5 * Copyright (c) 2009 Edgar E. Iglesias.
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
26 #include "sysbus.h"
27 #include "hw.h"
28 #include "net.h"
29 #include "flash.h"
30 #include "sysemu.h"
31 #include "devices.h"
32 #include "boards.h"
33 #include "xilinx.h"
34 #include "blockdev.h"
35 #include "exec-memory.h"
37 #include "microblaze_boot.h"
38 #include "microblaze_pic_cpu.h"
40 #define LMB_BRAM_SIZE (128 * 1024)
41 #define FLASH_SIZE (16 * 1024 * 1024)
43 #define BINARY_DEVICE_TREE_FILE "petalogix-s3adsp1800.dtb"
45 #define MEMORY_BASEADDR 0x90000000
46 #define FLASH_BASEADDR 0xa0000000
47 #define INTC_BASEADDR 0x81800000
48 #define TIMER_BASEADDR 0x83c00000
49 #define UARTLITE_BASEADDR 0x84000000
50 #define ETHLITE_BASEADDR 0x81000000
52 static void machine_cpu_reset(CPUMBState *env)
54 env->pvr.regs[10] = 0x0c000000; /* spartan 3a dsp family. */
57 static void
58 petalogix_s3adsp1800_init(ram_addr_t ram_size,
59 const char *boot_device,
60 const char *kernel_filename,
61 const char *kernel_cmdline,
62 const char *initrd_filename, const char *cpu_model)
64 DeviceState *dev;
65 CPUMBState *env;
66 DriveInfo *dinfo;
67 int i;
68 target_phys_addr_t ddr_base = MEMORY_BASEADDR;
69 MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1);
70 MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
71 qemu_irq irq[32], *cpu_irq;
72 MemoryRegion *sysmem = get_system_memory();
74 /* init CPUs */
75 if (cpu_model == NULL) {
76 cpu_model = "microblaze";
78 env = cpu_init(cpu_model);
80 /* Attach emulated BRAM through the LMB. */
81 memory_region_init_ram(phys_lmb_bram,
82 "petalogix_s3adsp1800.lmb_bram", LMB_BRAM_SIZE);
83 vmstate_register_ram_global(phys_lmb_bram);
84 memory_region_add_subregion(sysmem, 0x00000000, phys_lmb_bram);
86 memory_region_init_ram(phys_ram, "petalogix_s3adsp1800.ram", ram_size);
87 vmstate_register_ram_global(phys_ram);
88 memory_region_add_subregion(sysmem, ddr_base, phys_ram);
90 dinfo = drive_get(IF_PFLASH, 0, 0);
91 pflash_cfi01_register(FLASH_BASEADDR,
92 NULL, "petalogix_s3adsp1800.flash", FLASH_SIZE,
93 dinfo ? dinfo->bdrv : NULL, (64 * 1024),
94 FLASH_SIZE >> 16,
95 1, 0x89, 0x18, 0x0000, 0x0, 1);
97 cpu_irq = microblaze_pic_init_cpu(env);
98 dev = xilinx_intc_create(INTC_BASEADDR, cpu_irq[0], 2);
99 for (i = 0; i < 32; i++) {
100 irq[i] = qdev_get_gpio_in(dev, i);
103 sysbus_create_simple("xilinx,uartlite", UARTLITE_BASEADDR, irq[3]);
104 /* 2 timers at irq 2 @ 62 Mhz. */
105 xilinx_timer_create(TIMER_BASEADDR, irq[0], 2, 62 * 1000000);
106 xilinx_ethlite_create(&nd_table[0], ETHLITE_BASEADDR, irq[1], 0, 0);
108 microblaze_load_kernel(env, ddr_base, ram_size,
109 BINARY_DEVICE_TREE_FILE, machine_cpu_reset);
112 static QEMUMachine petalogix_s3adsp1800_machine = {
113 .name = "petalogix-s3adsp1800",
114 .desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800",
115 .init = petalogix_s3adsp1800_init,
116 .is_default = 1
119 static void petalogix_s3adsp1800_machine_init(void)
121 qemu_register_machine(&petalogix_s3adsp1800_machine);
124 machine_init(petalogix_s3adsp1800_machine_init);