2010-05-24 Joel Sherrill <joel.sherrill@oarcorp.com>

* Makefile.am, amba/amba.c, console/console.c, console/debugputs.c,
	startup/bspstart.c: Rework initialization order so AMBA bus is
	scanned earlier. This lets us look for UARTs earlier and support
	printk as early as bsp_start() returning.
This commit is contained in:
Joel Sherrill
2010-05-24 15:05:19 +00:00
parent b60473c432
commit d17733ccd8
6 changed files with 54 additions and 33 deletions

View File

@@ -1,3 +1,10 @@
2010-05-24 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, amba/amba.c, console/console.c, console/debugputs.c,
startup/bspstart.c: Rework initialization order so AMBA bus is
scanned earlier. This lets us look for UARTs earlier and support
printk as early as bsp_start() returning.
2010-05-11 Sebastian Huber <sebastian.huber@embedded-brains.de>
* startup/linkcmds: Include basic linker command file and define only

View File

@@ -39,7 +39,7 @@ libbsp_a_SOURCES =
# startup
libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \
../../shared/bsppost.c ../../shared/bootcard.c startup/bspstart.c \
../../sparc/shared/bsppretaskinghook.c \
../../sparc/shared/bsppretaskinghook.c ../../shared/bsppredriverhook.c \
../../sparc/shared/bspgetworkarea.c ../../shared/sbrk.c startup/setvec.c \
startup/spurious.c startup/bspidle.S
# gnatsupp

View File

@@ -24,9 +24,9 @@ volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs;
int LEON3_Cpu_Index = 0;
/*
* bsp_predriver_hook
* amba_initialize
*
* BSP predriver hook. Called just before drivers are initialized.
* Must be called just before drivers are initialized.
* Used to scan system bus. Probes for AHB masters, AHB slaves and
* APB slaves. Addresses to configuration areas of the AHB masters,
* AHB slaves, APB slaves and APB master are storeds in
@@ -43,8 +43,9 @@ asm(" .text \n"
extern rtems_configuration_table Configuration;
extern int scan_uarts(void);
void bsp_predriver_hook(void)
void amba_initialize(void)
{
int i;
amba_apb_device dev;
@@ -71,4 +72,6 @@ void bsp_predriver_hook(void)
LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) dev.start;
}
/* find UARTS */
scan_uarts();
}

View File

@@ -76,27 +76,8 @@ ssize_t console_write_support (int minor, const char *buf, size_t len)
*
*/
int uarts = 0;
static int isinit = 0;
volatile LEON3_UART_Regs_Map *LEON3_Console_Uart[LEON3_APBUARTS];
int scan_uarts(void) {
int i;
amba_apb_device apbuarts[LEON3_APBUARTS];
if (isinit == 0) {
i = 0;
uarts = 0;
uarts = amba_find_apbslvs(
&amba_conf, VENDOR_GAISLER, GAISLER_APBUART, apbuarts, LEON3_APBUARTS);
for(i=0; i<uarts; i++) {
LEON3_Console_Uart[i] = (volatile LEON3_UART_Regs_Map *)apbuarts[i].start;
}
isinit = 1;
}
return uarts;
}
rtems_device_driver console_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
@@ -109,10 +90,7 @@ rtems_device_driver console_initialize(
rtems_termios_initialize();
/* Find UARTs */
scan_uarts();
/* default to zero and override if multiprocessing */
/* default console to zero and override if multiprocessing */
uart0 = 0;
#if defined(RTEMS_MULTIPROCESSING)
if (rtems_configuration_get_user_multiprocessing_table() != NULL)
@@ -120,22 +98,18 @@ rtems_device_driver console_initialize(
#endif
/* Register Device Names */
if (uarts && (uart0 < uarts))
{
if (uarts && (uart0 < uarts)) {
status = rtems_io_register_name( "/dev/console", major, 0 );
if (status != RTEMS_SUCCESSFUL)
rtems_fatal_error_occurred(status);
strcpy(console_name,"/dev/console_a");
for (i = uart0+1; i < uarts; i++)
{
for (i = uart0+1; i < uarts; i++) {
console_name[13]++;
status = rtems_io_register_name( console_name, major, i);
}
}
/*
* Initialize Hardware if ONLY CPU or first CPU in MP system
*/

View File

@@ -27,6 +27,38 @@
*/
extern int uarts;
static int isinit = 0;
/*
* Scan for UARTS in configuration
*/
int scan_uarts(void)
{
int i;
amba_apb_device apbuarts[LEON3_APBUARTS];
if (isinit == 0) {
i = 0;
uarts = 0;
uarts = amba_find_apbslvs(
&amba_conf, VENDOR_GAISLER, GAISLER_APBUART, apbuarts, LEON3_APBUARTS);
for(i=0; i<uarts; i++) {
LEON3_Console_Uart[i] = (volatile LEON3_UART_Regs_Map *)apbuarts[i].start;
}
/* initialize uart 0 if present for printk */
if ( uarts ) {
LEON3_Console_Uart[0]->ctrl |=
LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
LEON3_Console_Uart[0]->status = 0;
}
isinit = 1;
}
return uarts;
}
/*
* console_outbyte_polled
*

View File

@@ -27,6 +27,8 @@
*/
int CPU_SPARC_HAS_SNOOPING;
extern void amba_initialize(void);
/*
* set_snooping
*
@@ -54,4 +56,7 @@ static inline int set_snooping(void)
void bsp_start( void )
{
CPU_SPARC_HAS_SNOOPING = set_snooping();
/* Find UARTs */
amba_initialize();
}