Thanks Sebastian. Is there some sim-script support or documentation on using this BSP with Qemu?
On Tue, Feb 4, 2014 at 8:56 AM, Sebastian Huber <sebastian.hu...@embedded-brains.de> wrote: > --- > c/src/lib/libbsp/sparc/leon3/Makefile.am | 1 + > c/src/lib/libbsp/sparc/leon3/amba/amba.c | 4 ++ > c/src/lib/libbsp/sparc/leon3/clock/ckinit.c | 25 ++++++++++++++++ > c/src/lib/libbsp/sparc/leon3/configure.ac | 5 +++ > c/src/lib/libbsp/sparc/leon3/console/console.c | 13 ++++++++ > .../libbsp/sparc/leon3/console/printk_support.c | 30 > ++++++++++++++++++++ > .../libbsp/sparc/leon3/make/custom/leon3_qemu.cfg | 9 ++++++ > c/src/lib/libbsp/sparc/leon3/preinstall.am | 4 ++ > .../libbsp/sparc/leon3/startup/linkcmds.leon3_qemu | 12 ++++++++ > 9 files changed, 103 insertions(+), 0 deletions(-) > create mode 100644 c/src/lib/libbsp/sparc/leon3/make/custom/leon3_qemu.cfg > create mode 100644 c/src/lib/libbsp/sparc/leon3/startup/linkcmds.leon3_qemu > > diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am > b/c/src/lib/libbsp/sparc/leon3/Makefile.am > index 1a24cbf..ac97ecc 100644 > --- a/c/src/lib/libbsp/sparc/leon3/Makefile.am > +++ b/c/src/lib/libbsp/sparc/leon3/Makefile.am > @@ -26,6 +26,7 @@ project_lib_DATA = start.$(OBJEXT) > dist_project_lib_DATA += ../shared/startup/linkcmds.base > dist_project_lib_DATA += startup/linkcmds > dist_project_lib_DATA += startup/linkcmds.leon3 > +dist_project_lib_DATA += startup/linkcmds.leon3_qemu > dist_project_lib_DATA += startup/linkcmds.ngmp > > noinst_LIBRARIES += libbsp.a > diff --git a/c/src/lib/libbsp/sparc/leon3/amba/amba.c > b/c/src/lib/libbsp/sparc/leon3/amba/amba.c > index eb7b0f2..c766c76 100644 > --- a/c/src/lib/libbsp/sparc/leon3/amba/amba.c > +++ b/c/src/lib/libbsp/sparc/leon3/amba/amba.c > @@ -39,6 +39,7 @@ volatile struct irqmp_regs *LEON3_IrqCtrl_Regs; > > void amba_initialize(void) > { > +#ifndef LEON3_QEMU > int icsel; > struct ambapp_dev *adev; > > @@ -90,4 +91,7 @@ void amba_initialize(void) > ambapp_freq_init(&ambapp_plb, adev, > (LEON3_Timer_Regs->scaler_reload + 1) * 1000000); > } > +#else /* LEON3_QEMU */ > + LEON3_IrqCtrl_Regs = (volatile struct irqmp_regs *)0x80000200; > +#endif /* LEON3_QEMU */ > } > diff --git a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c > b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c > index e0556ba..695e78d 100644 > --- a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c > +++ b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c > @@ -55,6 +55,7 @@ static int clkirq; > #define Adjust_clkirq_for_node() do { clkirq += LEON3_CLOCK_INDEX; } > while(0) > #endif > > +#ifndef LEON3_QEMU > #define Clock_driver_support_find_timer() \ > do { \ > struct ambapp_dev *adev; \ > @@ -71,12 +72,21 @@ static int clkirq; > Adjust_clkirq_for_node(); \ > } \ > } while (0) > +#else /* LEON3_QEMU */ > +#define Clock_driver_support_find_timer() \ > + do { \ > + LEON3_Timer_Regs = (volatile struct gptimer_regs *) \ > + 0x80000300; \ > + clkirq = 6; \ > + } while (0) > +#endif /* LEON3_QEMU */ > > #define Clock_driver_support_install_isr( _new, _old ) \ > do { \ > _old = set_vector( _new, CLOCK_VECTOR, 1 ); \ > } while(0) > > +#ifndef LEON3_QEMU > #define Clock_driver_support_initialize_hardware() \ > do { \ > LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].reload = \ > @@ -86,6 +96,17 @@ static int clkirq; > LEON3_GPTIMER_EN | LEON3_GPTIMER_RL | \ > LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN; \ > } while (0) > +#else > +#define Clock_driver_support_initialize_hardware() \ > + do { \ > + LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].reload = \ > + 40 * (rtems_configuration_get_microseconds_per_tick() - 1); \ > + \ > + LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].ctrl = \ > + LEON3_GPTIMER_EN | LEON3_GPTIMER_RL | \ > + LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN; \ > + } while (0) > +#endif > > #define Clock_driver_support_shutdown_hardware() \ > do { \ > @@ -101,7 +122,11 @@ static uint32_t > bsp_clock_nanoseconds_since_last_tick(void) > if ( !LEON3_Timer_Regs ) > return 0; > > +#ifndef LEON3_QEMU > clicks = LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].value; > +#else > + clicks = LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].value / 40; > +#endif > > if ( LEON_Is_interrupt_pending( clkirq ) ) { > clicks = LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].value; > diff --git a/c/src/lib/libbsp/sparc/leon3/configure.ac > b/c/src/lib/libbsp/sparc/leon3/configure.ac > index dbefd3e..e22f69a 100644 > --- a/c/src/lib/libbsp/sparc/leon3/configure.ac > +++ b/c/src/lib/libbsp/sparc/leon3/configure.ac > @@ -26,6 +26,7 @@ RTEMS_BSPOPTS_HELP([CONSOLE_USE_INTERRUPTS], > Under the simulator (especially when FAST_UART is defined), polled seems to > operate > better.]) > > +RTEMS_BSPOPTS_SET([SIMSPARC_FAST_IDLE],[*qemu],[1]) > RTEMS_BSPOPTS_SET([SIMSPARC_FAST_IDLE],[*],[]) > RTEMS_BSPOPTS_HELP([SIMSPARC_FAST_IDLE], > [If defined, speed up the clock ticks while the idle task is running so > @@ -37,6 +38,10 @@ RTEMS_BSPOPTS_HELP([BSP_LEON3_SMP], > [Always defined when on a LEON3 to enable the LEON3 support for > determining the CPU core number in an SMP configuration.]) > > +RTEMS_BSPOPTS_SET([LEON3_QEMU],[*qemu],[1]) > +RTEMS_BSPOPTS_HELP([LEON3_QEMU], > +[If defined, then use settings for QEMU simulator.]) > + > RTEMS_BSP_CLEANUP_OPTIONS(0, 1) > RTEMS_BSP_LINKCMDS > > diff --git a/c/src/lib/libbsp/sparc/leon3/console/console.c > b/c/src/lib/libbsp/sparc/leon3/console/console.c > index 7e72633..4174a71 100644 > --- a/c/src/lib/libbsp/sparc/leon3/console/console.c > +++ b/c/src/lib/libbsp/sparc/leon3/console/console.c > @@ -217,6 +217,7 @@ static int leon3_console_set_attributes(int minor, const > struct termios *t) > return 0; > } > > +#ifndef LEON3_QEMU > /* AMBA PP find routine. Extract AMBA PnP information into data structure. */ > static int find_matching_apbuart(struct ambapp_dev *dev, int index, void > *arg) > { > @@ -248,6 +249,18 @@ static void leon3_console_scan_uarts(void) > ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), > VENDOR_GAISLER, > GAISLER_APBUART, find_matching_apbuart, NULL); > } > +#else /* LEON3_QEMU */ > +static void leon3_console_scan_uarts(void) > +{ > + uarts = 1; > + > + apbuarts[0].regs = (struct apbuart_regs *)0x80000100; > +#if CONSOLE_USE_INTERRUPTS > + apbuarts[0].irq = 3; > +#endif > + apbuarts[0].freq_hz = 40000000; > +} > +#endif /* LEON3_QEMU */ > > /* > * Console Device Driver Entry Points > diff --git a/c/src/lib/libbsp/sparc/leon3/console/printk_support.c > b/c/src/lib/libbsp/sparc/leon3/console/printk_support.c > index ecc44b6..976d5da 100644 > --- a/c/src/lib/libbsp/sparc/leon3/console/printk_support.c > +++ b/c/src/lib/libbsp/sparc/leon3/console/printk_support.c > @@ -25,6 +25,7 @@ > int debug_uart_index __attribute__((weak)) = 0; > static struct apbuart_regs *dbg_uart = NULL; > > +#ifndef LEON3_QEMU > /* Before UART driver has registered (or when no UART is available), calls to > * printk that gets to bsp_out_char() will be filling data into the > * pre_printk_dbgbuf[] buffer, hopefully the buffer can help debugging the > @@ -75,6 +76,29 @@ int bsp_debug_uart_init(void) > } else > return 0; > } > +#else > +int bsp_debug_uart_init(void); > + > +static void bsp_out_char(char c); > + > +static void leon3_qemu_debug_uart_init(char c) > +{ > + bsp_debug_uart_init(); > + > + BSP_output_char = bsp_out_char; > + > + bsp_out_char(c); > +} > + > +int bsp_debug_uart_init(void) > +{ > + dbg_uart = (struct apbuart_regs *)0x80000100; > + dbg_uart->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE; > + dbg_uart->status = 0; > + > + return 1; > +} > +#endif > > /* > * apbuart_outbyte_polled > @@ -130,12 +154,14 @@ int apbuart_inbyte_nonblocking(struct apbuart_regs > *regs) > /* putchar/getchar for printk */ > static void bsp_out_char(char c) > { > +#ifndef LEON3_QEMU > if (dbg_uart == NULL) { > /* Local debug buffer when UART driver has not registered */ > pre_printk_dbgbuf[pre_printk_pos++] = c; > pre_printk_pos = pre_printk_pos & (sizeof(pre_printk_dbgbuf)-1); > return; > } > +#endif > > apbuart_outbyte_polled(dbg_uart, c, 1, 1); > } > @@ -146,7 +172,11 @@ static void bsp_out_char(char c) > > #include <rtems/bspIo.h> > > +#ifndef LEON3_QEMU > BSP_output_char_function_type BSP_output_char = bsp_out_char; > +#else > +BSP_output_char_function_type BSP_output_char = leon3_qemu_debug_uart_init; > +#endif > > static int bsp_in_char(void) > { > diff --git a/c/src/lib/libbsp/sparc/leon3/make/custom/leon3_qemu.cfg > b/c/src/lib/libbsp/sparc/leon3/make/custom/leon3_qemu.cfg > new file mode 100644 > index 0000000..62ffebc > --- /dev/null > +++ b/c/src/lib/libbsp/sparc/leon3/make/custom/leon3_qemu.cfg > @@ -0,0 +1,9 @@ > +include $(RTEMS_ROOT)/make/custom/default.cfg > + > +RTEMS_CPU=sparc > + > +RTEMS_CPU_MODEL=leon3 > + > +CPU_CFLAGS = -mcpu=leon3 -msoft-float > + > +CFLAGS_OPTIMIZE_V = -O0 -g > diff --git a/c/src/lib/libbsp/sparc/leon3/preinstall.am > b/c/src/lib/libbsp/sparc/leon3/preinstall.am > index 0005edd..c3c8199 100644 > --- a/c/src/lib/libbsp/sparc/leon3/preinstall.am > +++ b/c/src/lib/libbsp/sparc/leon3/preinstall.am > @@ -81,6 +81,10 @@ $(PROJECT_LIB)/linkcmds.leon3: startup/linkcmds.leon3 > $(PROJECT_LIB)/$(dirstamp) > $(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds.leon3 > PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds.leon3 > > +$(PROJECT_LIB)/linkcmds.leon3_qemu: startup/linkcmds.leon3_qemu > $(PROJECT_LIB)/$(dirstamp) > + $(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds.leon3_qemu > +PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds.leon3_qemu > + > $(PROJECT_LIB)/linkcmds.ngmp: startup/linkcmds.ngmp > $(PROJECT_LIB)/$(dirstamp) > $(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds.ngmp > PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds.ngmp > diff --git a/c/src/lib/libbsp/sparc/leon3/startup/linkcmds.leon3_qemu > b/c/src/lib/libbsp/sparc/leon3/startup/linkcmds.leon3_qemu > new file mode 100644 > index 0000000..1a0e3e5 > --- /dev/null > +++ b/c/src/lib/libbsp/sparc/leon3/startup/linkcmds.leon3_qemu > @@ -0,0 +1,12 @@ > +MEMORY { > + rom : ORIGIN = 0x00000000, LENGTH = 8M > + ram : ORIGIN = 0x40000000, LENGTH = 64M > +} > + > +_PROM_START = ORIGIN (rom); > +_PROM_SIZE = LENGTH (rom); > + > +_RAM_START = ORIGIN (ram); > +_RAM_SIZE = LENGTH (ram); > + > +INCLUDE linkcmds.base > -- > 1.7.7 > > _______________________________________________ > rtems-devel mailing list > rtems-devel@rtems.org > http://www.rtems.org/mailman/listinfo/rtems-devel _______________________________________________ rtems-devel mailing list rtems-devel@rtems.org http://www.rtems.org/mailman/listinfo/rtems-devel