summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-11-25 08:46:19 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-02-06 08:47:03 +0100
commit7579e255127ee0cf04901bbab6c1538559053508 (patch)
tree197204842c354c82c5fdce975e4dd6051545a41c
parentbsp/leon3: Declare bsp_debug_uart_init() in header (diff)
downloadrtems-7579e255127ee0cf04901bbab6c1538559053508.tar.bz2
bsp/leon3: New BSP variant leon3_qemu
-rw-r--r--c/src/lib/libbsp/sparc/leon3/Makefile.am1
-rw-r--r--c/src/lib/libbsp/sparc/leon3/amba/amba.c4
-rw-r--r--c/src/lib/libbsp/sparc/leon3/clock/ckinit.c25
-rw-r--r--c/src/lib/libbsp/sparc/leon3/configure.ac5
-rw-r--r--c/src/lib/libbsp/sparc/leon3/console/console.c13
-rw-r--r--c/src/lib/libbsp/sparc/leon3/console/printk_support.c26
-rw-r--r--c/src/lib/libbsp/sparc/leon3/make/custom/leon3_qemu.cfg9
-rw-r--r--c/src/lib/libbsp/sparc/leon3/preinstall.am4
-rw-r--r--c/src/lib/libbsp/sparc/leon3/startup/linkcmds.leon3_qemu12
9 files changed, 99 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am b/c/src/lib/libbsp/sparc/leon3/Makefile.am
index 1a24cbfd4b..ac97ecc8fa 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 eb7b0f2a40..c766c762d4 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 e0556ba31a..695e78dfbc 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 dbefd3e8f2..e22f69a00e 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 7e726336b0..4174a71462 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 286e37dca5..4c656785a7 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
@@ -73,6 +74,25 @@ void bsp_debug_uart_init(void)
dbg_uart->status = 0;
}
}
+#else
+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);
+}
+
+void 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;
+}
+#endif
/*
* apbuart_outbyte_polled
@@ -128,12 +148,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);
}
@@ -144,7 +166,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 0000000000..62ffebc2e2
--- /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 0005edda03..c3c81995f2 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 0000000000..1a0e3e5afd
--- /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