On Fri, Jan 21, 2011 at 7:02 PM, Blue Swirl <blauwir...@gmail.com> wrote: > On Fri, Jan 21, 2011 at 5:00 PM, Fabien Chouteau <chout...@adacore.com> wrote: >> Leon3 is an open-source VHDL System-On-Chip, well known in space industry >> (more >> information on http://www.gaisler.com). >> >> Leon3 is made of multiple components available in the GrLib VHDL library. >> Three devices are implemented: uart, timers and IRQ manager. >> You can find code for these peripherals in the grlib_* files. >> >> Signed-off-by: Fabien Chouteau <chout...@adacore.com> >> --- >> Makefile.target | 5 +- >> hw/leon3.c | 231 >> ++++++++++++++++++++++++++++++++++++++++++++++ >> target-sparc/cpu.h | 37 +++++--- >> target-sparc/helper.c | 7 +- >> target-sparc/helper.h | 1 + >> target-sparc/op_helper.c | 154 ++++++++++++++++++++++++++++++- >> target-sparc/translate.c | 13 ++- >> 7 files changed, 426 insertions(+), 22 deletions(-) >> >> diff --git a/Makefile.target b/Makefile.target >> index e15b1c4..efd8406 100644 >> --- a/Makefile.target >> +++ b/Makefile.target >> @@ -286,7 +286,10 @@ obj-sparc-y += cirrus_vga.o >> else >> obj-sparc-y = sun4m.o lance.o tcx.o sun4m_iommu.o slavio_intctl.o >> obj-sparc-y += slavio_timer.o slavio_misc.o sparc32_dma.o >> -obj-sparc-y += cs4231.o eccmemctl.o sbi.o sun4c_intctl.o >> +obj-sparc-y += cs4231.o eccmemctl.o sbi.o sun4c_intctl.o leon3.o >> + >> +# GRLIB >> +obj-sparc-y += grlib_gptimer.o grlib_irqmp.o grlib_apbuart.o >> endif >> >> obj-arm-y = integratorcp.o versatilepb.o arm_pic.o arm_timer.o >> diff --git a/hw/leon3.c b/hw/leon3.c >> new file mode 100644 >> index 0000000..f8f994a >> --- /dev/null >> +++ b/hw/leon3.c >> @@ -0,0 +1,231 @@ >> +/* >> + * QEMU Leon3 System Emulator >> + * >> + * Copyright (c) 2010-2011 AdaCore >> + * >> + * Permission is hereby granted, free of charge, to any person obtaining a >> copy >> + * of this software and associated documentation files (the "Software"), to >> deal >> + * in the Software without restriction, including without limitation the >> rights >> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell >> + * copies of the Software, and to permit persons to whom the Software is >> + * furnished to do so, subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice shall be included >> in >> + * all copies or substantial portions of the Software. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS >> OR >> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL >> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR >> OTHER >> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING >> FROM, >> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN >> + * THE SOFTWARE. >> + */ >> +#include "hw.h" >> +#include "qemu-timer.h" >> +#include "qemu-char.h" >> +#include "sysemu.h" >> +#include "boards.h" >> +#include "loader.h" >> +#include "elf.h" >> + >> +#include "grlib.h" >> + >> +//#define DEBUG_LEON3 >> + >> +#ifdef DEBUG_LEON3 >> +#define DPRINTF(fmt, ...) \ >> + do { printf("Leon3: " fmt , ## __VA_ARGS__); } while (0) >> +#else >> +#define DPRINTF(fmt, ...) >> +#endif >> + >> +/* Default system clock. */ >> +#define CPU_CLK (40 * 1000 * 1000) >> + >> +#define PROM_FILENAME "u-boot.bin" >> + >> +#define MAX_PILS 16 >> + >> +typedef struct ResetData { >> + CPUState *env; >> + uint32_t entry; /* save kernel entry in case of reset */ >> +} ResetData; >> + >> +static void main_cpu_reset(void *opaque) >> +{ >> + ResetData *s = (ResetData *)opaque; >> + CPUState *env = s->env; >> + >> + cpu_reset(env); >> + >> + env->halted = 0; >> + env->pc = s->entry; >> + env->npc = s->entry + 4; >> +} >> + >> +static void leon3_irq_ack(void *irq_manager, int intno) >> +{ >> + grlib_irqmp_ack((DeviceState *)irq_manager, intno); >> + leon3_cache_control_int(); >> +} >> + >> +static void leon3_set_pil_in(void *opaque, uint32_t pil_in) >> +{ >> + CPUState *env = (CPUState *)opaque; >> + >> + assert(env != NULL); >> + >> + env->pil_in = pil_in; >> + >> + if (env->pil_in && (env->interrupt_index == 0 || >> + (env->interrupt_index & ~15) == TT_EXTINT)) { >> + unsigned int i; >> + >> + for (i = 15; i > 0; i--) { >> + if (env->pil_in & (1 << i)) { >> + int old_interrupt = env->interrupt_index; >> + >> + env->interrupt_index = TT_EXTINT | i; >> + if (old_interrupt != env->interrupt_index) { >> + DPRINTF("Set CPU IRQ %d\n", i); >> + cpu_interrupt(env, CPU_INTERRUPT_HARD); >> + } >> + break; >> + } >> + } >> + } else if (!env->pil_in && (env->interrupt_index & ~15) == TT_EXTINT) { >> + DPRINTF("Reset CPU IRQ %d\n", env->interrupt_index & 15); >> + env->interrupt_index = 0; >> + cpu_reset_interrupt(env, CPU_INTERRUPT_HARD); >> + } >> +} >> + >> +static void leon3_generic_hw_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) >> +{ >> + CPUState *env; >> + ram_addr_t ram_offset, prom_offset; >> + int ret; >> + char *filename; >> + qemu_irq *cpu_irqs = NULL; >> + int bios_size; >> + int prom_size; >> + int aligned_bios_size;
GCC 4.6.0 spotted this one: /src/qemu/hw/leon3.c: In function 'leon3_generic_hw_init': /src/qemu/hw/leon3.c:118:17: error: variable 'aligned_bios_size' set but not used [-Werror=unused-but-set-variable]