/* bspstart.c
|
/* bspstart.c
|
*
|
*
|
* This set of routines starts the application. It includes application,
|
* This set of routines starts the application. It includes application,
|
* board, and monitor specific initialization and configuration.
|
* board, and monitor specific initialization and configuration.
|
* The generic CPU dependent initialization has been performed
|
* The generic CPU dependent initialization has been performed
|
* before any of these are invoked.
|
* before any of these are invoked.
|
*
|
*
|
* COPYRIGHT (c) 1989-1997.
|
* COPYRIGHT (c) 1989-1997.
|
* On-Line Applications Research Corporation (OAR).
|
* On-Line Applications Research Corporation (OAR).
|
* Copyright assigned to U.S. Government, 1994.
|
* Copyright assigned to U.S. Government, 1994.
|
*
|
*
|
* The license and distribution terms for this file may in
|
* The license and distribution terms for this file may in
|
* the file LICENSE in this distribution or at
|
* the file LICENSE in this distribution or at
|
* http://www.OARcorp.com/rtems/license.html.
|
* http://www.OARcorp.com/rtems/license.html.
|
*
|
*
|
* $Id:
|
* $Id:
|
*/
|
*/
|
|
|
#include <bsp.h>
|
#include <bsp.h>
|
#include <rtems/libio.h>
|
#include <rtems/libio.h>
|
|
|
#include <libcsupport.h>
|
#include <libcsupport.h>
|
|
|
#include <string.h>
|
#include <string.h>
|
|
|
/*
|
/*
|
* The original table from the application and our copy of it with
|
* The original table from the application and our copy of it with
|
* some changes.
|
* some changes.
|
*/
|
*/
|
|
|
extern rtems_configuration_table Configuration;
|
extern rtems_configuration_table Configuration;
|
rtems_configuration_table BSP_Configuration;
|
rtems_configuration_table BSP_Configuration;
|
rtems_cpu_table Cpu_table;
|
rtems_cpu_table Cpu_table;
|
rtems_unsigned32 bsp_isr_level;
|
rtems_unsigned32 bsp_isr_level;
|
|
|
/*
|
/*
|
* Use the shared implementations of the following routines
|
* Use the shared implementations of the following routines
|
*/
|
*/
|
|
|
void bsp_postdriver_hook(void);
|
void bsp_postdriver_hook(void);
|
void bsp_libc_init( void *, unsigned32, int );
|
void bsp_libc_init( void *, unsigned32, int );
|
|
|
/*PAGE
|
/*PAGE
|
*
|
*
|
* bsp_pretasking_hook
|
* bsp_pretasking_hook
|
*
|
*
|
* BSP pretasking hook. Called just before drivers are initialized.
|
* BSP pretasking hook. Called just before drivers are initialized.
|
* Used to setup libc and install any BSP extensions.
|
* Used to setup libc and install any BSP extensions.
|
*/
|
*/
|
|
|
void bsp_pretasking_hook(void)
|
void bsp_pretasking_hook(void)
|
{
|
{
|
extern int end;
|
extern int end;
|
rtems_unsigned32 heap_start;
|
rtems_unsigned32 heap_start;
|
rtems_unsigned32 heap_size;
|
rtems_unsigned32 heap_size;
|
|
|
heap_start = (rtems_unsigned32) &end;
|
heap_start = (rtems_unsigned32) &end;
|
if (heap_start & (CPU_ALIGNMENT-1))
|
if (heap_start & (CPU_ALIGNMENT-1))
|
heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
|
heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
|
|
|
heap_size = BSP_Configuration.work_space_start - (void *)&end;
|
heap_size = BSP_Configuration.work_space_start - (void *)&end;
|
heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */
|
heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */
|
|
|
bsp_libc_init((void *) heap_start, heap_size, 0);
|
bsp_libc_init((void *) heap_start, heap_size, 0);
|
|
|
#ifdef RTEMS_DEBUG
|
#ifdef RTEMS_DEBUG
|
rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
|
rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
|
#endif
|
#endif
|
}
|
}
|
|
|
/*PAGE
|
/*PAGE
|
*
|
*
|
* bsp_predriver_hook
|
* bsp_predriver_hook
|
*
|
*
|
* Before drivers are setup initialize interupt vectors.
|
* Before drivers are setup initialize interupt vectors.
|
*/
|
*/
|
|
|
void init_RTC();
|
void init_RTC();
|
void initialize_PMC();
|
void initialize_PMC();
|
|
|
void bsp_predriver_hook(void)
|
void bsp_predriver_hook(void)
|
{
|
{
|
init_RTC();
|
init_RTC();
|
|
|
init_PCI();
|
init_PCI();
|
initialize_universe();
|
initialize_universe();
|
initialize_PCI_bridge ();
|
initialize_PCI_bridge ();
|
|
|
#if (HAS_PMC_PSC8)
|
#if (HAS_PMC_PSC8)
|
initialize_PMC();
|
initialize_PMC();
|
#endif
|
#endif
|
|
|
/*
|
/*
|
* Initialize Bsp General purpose vector table.
|
* Initialize Bsp General purpose vector table.
|
*/
|
*/
|
initialize_external_exception_vector();
|
initialize_external_exception_vector();
|
|
|
#if (0)
|
#if (0)
|
/*
|
/*
|
* XXX - Modify this to write a 48000000 (loop to self) command
|
* XXX - Modify this to write a 48000000 (loop to self) command
|
* to each interrupt location. This is better for debug.
|
* to each interrupt location. This is better for debug.
|
*/
|
*/
|
bsp_spurious_initialize();
|
bsp_spurious_initialize();
|
#endif
|
#endif
|
|
|
}
|
}
|
|
|
/*PAGE
|
/*PAGE
|
*
|
*
|
* initialize_PMC
|
* initialize_PMC
|
*/
|
*/
|
|
|
void initialize_PMC() {
|
void initialize_PMC() {
|
volatile rtems_unsigned32 *PMC_addr;
|
volatile rtems_unsigned32 *PMC_addr;
|
rtems_unsigned8 data;
|
rtems_unsigned8 data;
|
|
|
#if (0) /* First Values sent */
|
#if (0) /* First Values sent */
|
/*
|
/*
|
* set PMC base address.
|
* set PMC base address.
|
*/
|
*/
|
PMC_addr = SCORE603E_PCI_DEVICE_ADDRESS( 0x14 );
|
PMC_addr = SCORE603E_PCI_DEVICE_ADDRESS( 0x14 );
|
*PMC_addr = (SCORE603E_PCI_REGISTER_BASE >> 24) & 0x3f;
|
*PMC_addr = (SCORE603E_PCI_REGISTER_BASE >> 24) & 0x3f;
|
|
|
/*
|
/*
|
* Clear status, enable SERR and memory space only.
|
* Clear status, enable SERR and memory space only.
|
*/
|
*/
|
PMC_addr = SCORE603E_PCI_DEVICE_ADDRESS( 0x4 );
|
PMC_addr = SCORE603E_PCI_DEVICE_ADDRESS( 0x4 );
|
*PMC_addr = 0x0201ff37;
|
*PMC_addr = 0x0201ff37;
|
|
|
/*
|
/*
|
* Bit 0 and 1 HI cause Medium Loopback to occur.
|
* Bit 0 and 1 HI cause Medium Loopback to occur.
|
*/
|
*/
|
PMC_addr = (volatile rtems_unsigned32 *)
|
PMC_addr = (volatile rtems_unsigned32 *)
|
SCORE603E_PMC_SERIAL_ADDRESS( 0x100000 );
|
SCORE603E_PMC_SERIAL_ADDRESS( 0x100000 );
|
data = *PMC_addr;
|
data = *PMC_addr;
|
/* *PMC_addr = data | 0x3; */
|
/* *PMC_addr = data | 0x3; */
|
*PMC_addr = data & 0xfc;
|
*PMC_addr = data & 0xfc;
|
|
|
#endif
|
#endif
|
|
|
|
|
#if (1)
|
#if (1)
|
|
|
/*
|
/*
|
* Clear status, enable SERR and memory space only.
|
* Clear status, enable SERR and memory space only.
|
*/
|
*/
|
PMC_addr = SCORE603E_PCI_DEVICE_ADDRESS( 0x4 );
|
PMC_addr = SCORE603E_PCI_DEVICE_ADDRESS( 0x4 );
|
*PMC_addr = 0x020080cc;
|
*PMC_addr = 0x020080cc;
|
|
|
/*
|
/*
|
* set PMC base address.
|
* set PMC base address.
|
*/
|
*/
|
PMC_addr = SCORE603E_PCI_DEVICE_ADDRESS( 0x14 );
|
PMC_addr = SCORE603E_PCI_DEVICE_ADDRESS( 0x14 );
|
*PMC_addr = (SCORE603E_PCI_REGISTER_BASE >> 24) & 0x3f;
|
*PMC_addr = (SCORE603E_PCI_REGISTER_BASE >> 24) & 0x3f;
|
|
|
PMC_addr = (volatile rtems_unsigned32 *)
|
PMC_addr = (volatile rtems_unsigned32 *)
|
SCORE603E_PMC_SERIAL_ADDRESS( 0x100000 );
|
SCORE603E_PMC_SERIAL_ADDRESS( 0x100000 );
|
data = *PMC_addr;
|
data = *PMC_addr;
|
*PMC_addr = data & 0xfc;
|
*PMC_addr = data & 0xfc;
|
|
|
#endif
|
#endif
|
}
|
}
|
|
|
|
|
|
|
/*PAGE
|
/*PAGE
|
*
|
*
|
* SCORE603e_bsp_postdriver_hook
|
* SCORE603e_bsp_postdriver_hook
|
*
|
*
|
* Standard post driver hook plus some BSP specific stuff.
|
* Standard post driver hook plus some BSP specific stuff.
|
*/
|
*/
|
|
|
void SCORE603e_bsp_postdriver_hook(void)
|
void SCORE603e_bsp_postdriver_hook(void)
|
{
|
{
|
extern void Init_EE_mask_init(void);
|
extern void Init_EE_mask_init(void);
|
|
|
bsp_postdriver_hook();
|
bsp_postdriver_hook();
|
|
|
Init_EE_mask_init();
|
Init_EE_mask_init();
|
}
|
}
|
|
|
void bsp_set_trap_vectors( void );
|
void bsp_set_trap_vectors( void );
|
|
|
/*PAGE
|
/*PAGE
|
*
|
*
|
* bsp_start
|
* bsp_start
|
*
|
*
|
* This routine does the bulk of the system initialization.
|
* This routine does the bulk of the system initialization.
|
*/
|
*/
|
|
|
void bsp_start( void )
|
void bsp_start( void )
|
{
|
{
|
unsigned char *work_space_start;
|
unsigned char *work_space_start;
|
unsigned int msr_value = 0x0000;
|
unsigned int msr_value = 0x0000;
|
volatile rtems_unsigned32 *ptr;
|
volatile rtems_unsigned32 *ptr;
|
|
|
delay( 1000 );
|
delay( 1000 );
|
|
|
/*
|
/*
|
* Zero out lots of memory
|
* Zero out lots of memory
|
*/
|
*/
|
|
|
memset(
|
memset(
|
&end,
|
&end,
|
0,
|
0,
|
(unsigned char *)&RAM_END - (unsigned char *) &end
|
(unsigned char *)&RAM_END - (unsigned char *) &end
|
);
|
);
|
|
|
/*
|
/*
|
* There are multiple ROM monitors available for this board.
|
* There are multiple ROM monitors available for this board.
|
*/
|
*/
|
#if (SCORE603E_USE_SDS)
|
#if (SCORE603E_USE_SDS)
|
|
|
/*
|
/*
|
* Write instruction for Unconditional Branch to ROM vector.
|
* Write instruction for Unconditional Branch to ROM vector.
|
*/
|
*/
|
|
|
Code = 0x4bf00002;
|
Code = 0x4bf00002;
|
for (Address = 0x100; Address <= 0xe00; Address += 0x100) {
|
for (Address = 0x100; Address <= 0xe00; Address += 0x100) {
|
A_Vector = (unsigned32 *)Address;
|
A_Vector = (unsigned32 *)Address;
|
Code = 0x4bf00002 + Address;
|
Code = 0x4bf00002 + Address;
|
*A_Vector = Code;
|
*A_Vector = Code;
|
}
|
}
|
|
|
for (Address = 0x1000; Address <= 0x1400; Address += 0x100) {
|
for (Address = 0x1000; Address <= 0x1400; Address += 0x100) {
|
A_Vector = (unsigned32 *)Address;
|
A_Vector = (unsigned32 *)Address;
|
Code = 0x4bf00002 + Address;
|
Code = 0x4bf00002 + Address;
|
*A_Vector = Code;
|
*A_Vector = Code;
|
}
|
}
|
|
|
Cpu_table.exceptions_in_RAM = TRUE;
|
Cpu_table.exceptions_in_RAM = TRUE;
|
msr_value = 0x2030;
|
msr_value = 0x2030;
|
|
|
#elif (SCORE603E_USE_OPEN_FIRMWARE)
|
#elif (SCORE603E_USE_OPEN_FIRMWARE)
|
Cpu_table.exceptions_in_RAM = TRUE;
|
Cpu_table.exceptions_in_RAM = TRUE;
|
msr_value = 0x2030;
|
msr_value = 0x2030;
|
|
|
#elif (SCORE603E_USE_NONE)
|
#elif (SCORE603E_USE_NONE)
|
Cpu_table.exceptions_in_RAM = TRUE;
|
Cpu_table.exceptions_in_RAM = TRUE;
|
msr_value = 0x2030;
|
msr_value = 0x2030;
|
_CPU_MSR_SET( msr_value );
|
_CPU_MSR_SET( msr_value );
|
bsp_set_trap_vectors();
|
bsp_set_trap_vectors();
|
|
|
#elif (SCORE603E_USE_DINK)
|
#elif (SCORE603E_USE_DINK)
|
Cpu_table.exceptions_in_RAM = TRUE;
|
Cpu_table.exceptions_in_RAM = TRUE;
|
msr_value = 0x2030;
|
msr_value = 0x2030;
|
_CPU_MSR_SET( msr_value );
|
_CPU_MSR_SET( msr_value );
|
|
|
/*
|
/*
|
* Override the DINK error on a Decrementor interrupt.
|
* Override the DINK error on a Decrementor interrupt.
|
*/
|
*/
|
/* org dec_vector - rfi */
|
/* org dec_vector - rfi */
|
ptr = (rtems_unsigned32 *)0x900;
|
ptr = (rtems_unsigned32 *)0x900;
|
*ptr = 0x4c000064;
|
*ptr = 0x4c000064;
|
|
|
#else
|
#else
|
#error "SCORE603E BSPSTART.C -- what ROM monitor are you using"
|
#error "SCORE603E BSPSTART.C -- what ROM monitor are you using"
|
#endif
|
#endif
|
|
|
_CPU_MSR_SET( msr_value );
|
_CPU_MSR_SET( msr_value );
|
|
|
/*
|
/*
|
* Need to "allocate" the memory for the RTEMS Workspace and
|
* Need to "allocate" the memory for the RTEMS Workspace and
|
* tell the RTEMS configuration where it is. This memory is
|
* tell the RTEMS configuration where it is. This memory is
|
* not malloc'ed. It is just "pulled from the air".
|
* not malloc'ed. It is just "pulled from the air".
|
*/
|
*/
|
|
|
work_space_start =
|
work_space_start =
|
(unsigned char *)&RAM_END - BSP_Configuration.work_space_size;
|
(unsigned char *)&RAM_END - BSP_Configuration.work_space_size;
|
|
|
if ( work_space_start <= (unsigned char *)&end ) {
|
if ( work_space_start <= (unsigned char *)&end ) {
|
DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
|
DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
|
bsp_cleanup();
|
bsp_cleanup();
|
}
|
}
|
|
|
BSP_Configuration.work_space_start = work_space_start;
|
BSP_Configuration.work_space_start = work_space_start;
|
|
|
/*
|
/*
|
* initialize the CPU table for this BSP
|
* initialize the CPU table for this BSP
|
*/
|
*/
|
|
|
/* Cpu_table.exceptions_in_RAM was set above */
|
/* Cpu_table.exceptions_in_RAM was set above */
|
Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */
|
Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */
|
Cpu_table.predriver_hook = bsp_predriver_hook; /* Init vectors */
|
Cpu_table.predriver_hook = bsp_predriver_hook; /* Init vectors */
|
Cpu_table.postdriver_hook = SCORE603e_bsp_postdriver_hook;
|
Cpu_table.postdriver_hook = SCORE603e_bsp_postdriver_hook;
|
Cpu_table.clicks_per_usec = 66 / 4; /* XXX get from linkcmds */
|
Cpu_table.clicks_per_usec = 66 / 4; /* XXX get from linkcmds */
|
Cpu_table.do_zero_of_workspace = TRUE;
|
Cpu_table.do_zero_of_workspace = TRUE;
|
Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
|
Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
|
Cpu_table.idle_task_stack_size = (3 * STACK_MINIMUM_SIZE);
|
Cpu_table.idle_task_stack_size = (3 * STACK_MINIMUM_SIZE);
|
|
|
#if ( PPC_USE_DATA_CACHE )
|
#if ( PPC_USE_DATA_CACHE )
|
instruction_cache_enable ();
|
instruction_cache_enable ();
|
data_cache_enable ();
|
data_cache_enable ();
|
#endif
|
#endif
|
}
|
}
|
|
|
|
|