--- c/src/lib/libbsp/sparc/leon3/amba/amba.c | 50 ++++++++++++++++++++ c/src/lib/libbsp/sparc/leon3/clock/ckinit.c | 10 ++++ c/src/lib/libbsp/sparc/leon3/console/console.c | 10 ++++ .../lib/libbsp/sparc/leon3/startup/bsppredriver.c | 32 ++++++++++++- 4 files changed, 101 insertions(+), 1 deletions(-)
diff --git a/c/src/lib/libbsp/sparc/leon3/amba/amba.c b/c/src/lib/libbsp/sparc/leon3/amba/amba.c index 8655ee3..8e6cef5 100644 --- a/c/src/lib/libbsp/sparc/leon3/amba/amba.c +++ b/c/src/lib/libbsp/sparc/leon3/amba/amba.c @@ -26,6 +26,46 @@ int leon3_timer_core_index __attribute__((weak)) = 0; */ struct ambapp_bus ambapp_plb; +/* If RTEMS_DRVMGR_STARTUP is defined extra code is added that + * registers the GRLIB AMBA PnP bus driver as root driver. + */ +#ifdef RTEMS_DRVMGR_STARTUP +#include <drvmgr/drvmgr.h> +#include <drvmgr/ambapp_bus_grlib.h> + +extern void gptimer_register_drv (void); +extern void apbuart_cons_register_drv(void); +/* All drivers included by BSP, this is overridden by the user by including + * the drvmgr_confdefs.h. By default the Timer and UART driver are included. + */ +struct drvmgr_drv_reg_func drvmgr_drivers[] __attribute__((weak)) = +{ + {gptimer_register_drv}, + {apbuart_cons_register_drv}, + {NULL} /* End array with NULL */ +}; + +/* Driver resources configuration for AMBA root bus. It is declared weak + * so that the user may override it, if the defualt settings are not + * enough. + */ +struct drvmgr_bus_res grlib_drv_resources __attribute__((weak)) = +{ + .next = NULL, + .resource = + { + RES_EMPTY, + } +}; + +/* GRLIB AMBA bus configuration (the LEON3 root bus configuration) */ +struct grlib_config grlib_bus_config = +{ + &ambapp_plb, /* AMBAPP bus setup */ + &grlib_drv_resources, /* Driver configuration */ +}; +#endif + rtems_interrupt_lock LEON3_IrqCtrl_Lock = RTEMS_INTERRUPT_LOCK_INITIALIZER("LEON3 IrqCtrl"); @@ -87,6 +127,12 @@ void amba_initialize(void) /* Init Extended IRQ controller if available */ leon3_ext_irq_init(); + /* If we are running without Driver Manager at startup, we must still + * assure that Timer and Console UART is working. So we can not + * depend on the DrvMgr capable Timer and Console UART drivers, + * instead we use the small-footprint drivers. + */ +#ifndef RTEMS_DRVMGR_STARTUP /* find GP Timer */ adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), VENDOR_GAISLER, GAISLER_GPTIMER, @@ -110,4 +156,8 @@ void amba_initialize(void) if (leon3_timer_prescaler) LEON3_Timer_Regs->scaler_reload = leon3_timer_prescaler; } +#else + /* Register Root bus, Use GRLIB AMBA PnP bus as root bus for LEON3 */ + ambapp_grlib_root_register(&grlib_bus_config); +#endif } diff --git a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c index 15050eb..227b7c0 100644 --- a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c +++ b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c @@ -25,6 +25,14 @@ #include <ambapp.h> #include <rtems/score/profiling.h> +/* The LEON3 BSP Timer driver can rely on the Driver Manager if the + * DrvMgr is initialized during startup. Otherwise the classic driver + * must be used. + * + * The DrvMgr Clock driver is located in the shared/timer directory + */ +#ifndef RTEMS_DRVMGR_STARTUP + #if SIMSPARC_FAST_IDLE==1 #define CLOCK_DRIVER_USE_FAST_IDLE 1 #endif @@ -156,3 +164,5 @@ static uint32_t bsp_clock_nanoseconds_since_last_tick(void) bsp_clock_nanoseconds_since_last_tick #include "../../../shared/clockdrv_shell.h" + +#endif diff --git a/c/src/lib/libbsp/sparc/leon3/console/console.c b/c/src/lib/libbsp/sparc/leon3/console/console.c index 35767ce..4140bd6 100644 --- a/c/src/lib/libbsp/sparc/leon3/console/console.c +++ b/c/src/lib/libbsp/sparc/leon3/console/console.c @@ -30,6 +30,14 @@ #include <bsp/fatal.h> #include <apbuart_termios.h> +/* The LEON3 BSP UART driver can rely on the Driver Manager if the + * DrvMgr is initialized during startup. Otherwise the classic driver + * must be used. + * + * The DrvMgr APBUART driver is located in the shared/uart directory + */ +#ifndef RTEMS_DRVMGR_STARTUP + int syscon_uart_index __attribute__((weak)) = 0; /* body is in debugputs.c */ @@ -157,3 +165,5 @@ rtems_device_driver console_initialize( return RTEMS_SUCCESSFUL; } + +#endif diff --git a/c/src/lib/libbsp/sparc/leon3/startup/bsppredriver.c b/c/src/lib/libbsp/sparc/leon3/startup/bsppredriver.c index a45d9d3..bdc1ab8 100644 --- a/c/src/lib/libbsp/sparc/leon3/startup/bsppredriver.c +++ b/c/src/lib/libbsp/sparc/leon3/startup/bsppredriver.c @@ -16,6 +16,14 @@ #include <bsp.h> #include <bsp/bootcard.h> +static void leon3_interrupt_common_init( void ) +{ + /* Initialize shared interrupt handling, must be done after IRQ + * controller has been found and initialized. + */ + BSP_shared_interrupt_init(); +} + /* * bsp_predriver_hook * @@ -24,8 +32,30 @@ */ void bsp_predriver_hook( void ) { +#ifndef RTEMS_DRVMGR_STARTUP + leon3_interrupt_common_init(); +#endif +} + +#ifdef RTEMS_DRVMGR_STARTUP +/* + * bsp_driver_level_hook + * + * BSP driver level hook. Called just after drivers have reached initialization + * level 'level' (1,2,3,4). See exinit.c for meaning of the every level. + * + * Initializes the BSP Interrupt layer + * After Level 1 we can trust that interrupt controller and system + * clock timer drivers now have been initialized. + */ +void bsp_driver_level_hook( int level ) +{ /* Initialize shared interrupt handling, must be done after IRQ * controller has been found and initialized. */ - BSP_shared_interrupt_init(); + if (level != 1) + return; + + leon3_interrupt_common_init(); } +#endif -- 1.7.0.4 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel