* shared/startup/pretaskinghook.c, shared/startup/zerobss.c: New files.
	* Makefile.am, shared/startup/bspstart.c: Split
	pretaskinghook and zerobss into separate, reusable files; Fixed
	#PR837 (set exception in ram flag before initializing exceptions);
	Setup DBATs early, they are needed to access peripherals (Allows
	mvme2100 to use MMU); moved VME initialization into pretasking hook
	so that shared interrupts can be used for VME [shared IRQ facility
	needs functional workspace].
This commit is contained in:
Till Straumann
2005-11-04 00:57:25 +00:00
parent f3173c08dd
commit ab20575a29
4 changed files with 154 additions and 101 deletions

View File

@@ -51,7 +51,8 @@ EXTRA_DIST += shared/start/start.S shared/start/rtems_crti.S
## shared/startup
EXTRA_DIST += shared/startup/bspstart.c shared/startup/pgtbl_setup.c \
shared/startup/pgtbl_activate.c shared/startup/linkcmds
shared/startup/pgtbl_activate.c shared/startup/linkcmds \
shared/startup/zerobss.c shared/startup/pretaskinghook.c
## shared/tod
EXTRA_DIST += shared/tod/todcfg.c

View File

@@ -28,7 +28,6 @@
#include <bsp/pci.h>
#include <bsp/openpic.h>
#include <bsp/irq.h>
#include <bsp/VME.h>
#include <libcpu/bat.h>
#include <libcpu/pte121.h>
#include <libcpu/cpuIdent.h>
@@ -100,6 +99,10 @@ char loaderParam[MAX_LOADER_ADD_PARM];
* Total memory using RESIDUAL DATA
*/
unsigned int BSP_mem_size;
/*
* Where the heap starts; is used by bsp_pretasking_hook;
*/
unsigned int BSP_heap_start;
/*
* PCI Bus Frequency
*/
@@ -148,59 +151,9 @@ char *rtems_progname;
*/
void bsp_postdriver_hook(void);
void bsp_pretasking_hook(void);
void bsp_libc_init( void *, uint32_t, int );
/*
* Function: bsp_pretasking_hook
* Created: 95/03/10
*
* Description:
* BSP pretasking hook. Called just before drivers are initialized.
* Used to setup libc and install any BSP extensions.
*
* NOTES:
* Must not use libc (to do io) from here, since drivers are
* not yet initialized.
*
*/
void bsp_pretasking_hook(void)
{
uint32_t heap_start;
uint32_t heap_size;
uint32_t heap_sbrk_spared;
extern uint32_t _bsp_sbrk_init(uint32_t, uint32_t*);
heap_start = ((uint32_t) __rtems_end) +
INIT_STACK_SIZE + INTR_STACK_SIZE;
if (heap_start & (CPU_ALIGNMENT-1))
heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
heap_size = (BSP_mem_size - heap_start) - BSP_Configuration.work_space_size;
heap_sbrk_spared=_bsp_sbrk_init(heap_start, &heap_size);
#ifdef SHOW_MORE_INIT_SETTINGS
printk( "HEAP start %x size %x (%x bytes spared for sbrk)\n",
heap_start, heap_size, heap_sbrk_spared);
#endif
bsp_libc_init((void *) 0, heap_size, heap_sbrk_spared);
#ifdef RTEMS_DEBUG
rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
#endif
}
void zero_bss()
{
/* prevent these from being accessed in the short data areas */
extern unsigned long __bss_start[], __SBSS_START__[], __SBSS_END__[];
extern unsigned long __SBSS2_START__[], __SBSS2_END__[];
memset(__SBSS_START__, 0, ((unsigned) __SBSS_END__) - ((unsigned)__SBSS_START__));
memset(__SBSS2_START__, 0, ((unsigned) __SBSS2_END__) - ((unsigned)__SBSS2_START__));
memset(__bss_start, 0, ((unsigned) __rtems_end) - ((unsigned)__bss_start));
}
void save_boot_params(RESIDUAL* r3, void *r4, void* r5, char *additional_boot_options)
{
@@ -252,11 +205,33 @@ void bsp_start( void )
myCpu = get_ppc_cpu_type();
myCpuRevision = get_ppc_cpu_revision();
#if defined(mvme2100)
EUMBBAR = get_eumbbar();
/*
* Init MMU block address translation to enable hardware access
*/
Cpu_table.exceptions_in_RAM = TRUE;
{ unsigned v = 0x3000 ; _CPU_MSR_SET(v); }
#if !defined(mvme2100)
/*
* PC legacy IO space used for inb/outb and all PC compatible hardware
*/
setdbat(1, _IO_BASE, _IO_BASE, 0x10000000, IO_PAGE);
#endif
/*
* PCI devices memory area. Needed to access OpenPIC features
* provided by the Raven
*
* T. Straumann: give more PCI address space
*/
setdbat(2, PCI_MEM_BASE+PCI_MEM_WIN0, PCI_MEM_BASE+PCI_MEM_WIN0, 0x10000000, IO_PAGE);
/*
* Must have acces to open pic PCI ACK registers provided by the RAVEN
*/
setdbat(3, 0xf0000000, 0xf0000000, 0x10000000, IO_PAGE);
#if defined(mvme2100)
/* Need 0xfec00000 mapped for this */
EUMBBAR = get_eumbbar();
#endif
#if !defined(mpc8240) && !defined(mpc8245)
@@ -296,8 +271,10 @@ void bsp_start( void )
* This could be done later (e.g in IRQ_INIT) but it helps to understand
* some settings below...
*/
intrStack = ((uint32_t) __rtems_end) +
INIT_STACK_SIZE + INTR_STACK_SIZE - PPC_MINIMUM_STACK_FRAME_SIZE;
BSP_heap_start = ((uint32_t) __rtems_end) + INIT_STACK_SIZE + INTR_STACK_SIZE;
/* reserve space for the marker/tag frame */
intrStack = BSP_heap_start - PPC_MINIMUM_STACK_FRAME_SIZE;
/* make sure it's properly aligned */
intrStack &= ~(CPU_STACK_ALIGNMENT-1);
@@ -311,35 +288,13 @@ void bsp_start( void )
/* signal them that we have fixed PR288 - eventually, this should go away */
_write_SPRG0(PPC_BSP_HAS_FIXED_PR288);
/* initialize_exceptions() evaluates the exceptions_in_RAM flag */
Cpu_table.exceptions_in_RAM = TRUE;
/*
* Initialize default raw exception handlers. See vectors/vectors_init.c
*/
initialize_exceptions();
/*
* Init MMU block address translation to enable hardware access
*/
#if !defined(mvme2100)
/*
* PC legacy IO space used for inb/outb and all PC compatible hardware
*/
setdbat(1, _IO_BASE, _IO_BASE, 0x10000000, IO_PAGE);
#endif
/*
* PCI devices memory area. Needed to access OpenPIC features
* provided by the Raven
*
* T. Straumann: give more PCI address space
*/
setdbat(2, PCI_MEM_BASE+PCI_MEM_WIN0, PCI_MEM_BASE+PCI_MEM_WIN0, 0x10000000, IO_PAGE);
/*
* Must have acces to open pic PCI ACK registers provided by the RAVEN
*/
setdbat(3, 0xf0000000, 0xf0000000, 0x10000000, IO_PAGE);
select_console(CONSOLE_LOG);
/*
@@ -460,8 +415,7 @@ void bsp_start( void )
Cpu_table.postdriver_hook = bsp_postdriver_hook;
Cpu_table.do_zero_of_workspace = TRUE;
Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
Cpu_table.clicks_per_usec = BSP_processor_frequency/(BSP_time_base_divisor * 1000);
Cpu_table.exceptions_in_RAM = TRUE;
Cpu_table.clicks_per_usec = BSP_bus_frequency/(BSP_time_base_divisor * 1000);
#ifdef SHOW_MORE_INIT_SETTINGS
printk("BSP_Configuration.work_space_size = %x\n",
@@ -493,25 +447,10 @@ void bsp_start( void )
printk("Page table setup finished; will activate it NOW...\n");
#endif
BSP_pgtbl_activate(pt);
#if !defined(mvme2100)
/* finally, switch off DBAT3 */
setdbat(3, 0, 0, 0, 0);
#endif
}
/*
* Initialize VME bridge - needs working PCI and IRQ subsystems...
*/
#ifdef SHOW_MORE_INIT_SETTINGS
printk("Going to initialize VME bridge\n");
#endif
/*
* VME initialization is in a separate file so apps which don't use VME or
* want a different configuration may link against a customized routine.
*/
BSP_vme_config();
#if defined(DEBUG_BATS)
ShowBATS();
#endif

View File

@@ -0,0 +1,85 @@
/*
* bsp_pretasking_hook().
* Initializes the heap, libc and VME.
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* Modified to support the MCP750.
* Modifications Copyright (C) 1999 Eric Valette. valette@crf.canon.fr
*
* $Id$
*/
#include <string.h>
#include <bsp.h>
#include <bsp/consoleIo.h>
#ifndef BSP_HAS_NO_VME
#include <bsp/VME.h>
#endif
void bsp_libc_init( void *, uint32_t, int );
/*
* Function: bsp_pretasking_hook
* Created: 95/03/10
*
* Description:
* BSP pretasking hook. Called just before drivers are initialized.
* Used to setup libc and install any BSP extensions.
*
* NOTES:
* Must not use libc (to do io) from here, since drivers are
* not yet initialized.
*
*/
void bsp_pretasking_hook(void)
{
uint32_t heap_size;
uint32_t heap_sbrk_spared;
extern uint32_t _bsp_sbrk_init(uint32_t, uint32_t*);
extern void BSP_vme_config();
/* make sure it's properly aligned */
BSP_heap_start = (BSP_heap_start + CPU_ALIGNMENT - 1) & ~(CPU_ALIGNMENT-1);
heap_size = (BSP_mem_size - BSP_heap_start) - BSP_Configuration.work_space_size;
heap_sbrk_spared=_bsp_sbrk_init(BSP_heap_start, &heap_size);
#ifdef SHOW_MORE_INIT_SETTINGS
printk( "HEAP start %x size %x (%x bytes spared for sbrk)\n",
BSP_heap_start, heap_size, heap_sbrk_spared);
#endif
bsp_libc_init((void *) 0, heap_size, heap_sbrk_spared);
/* Note that VME support may be omitted also by
* providing a NULL BSP_vme_config routine
* (e.g., linker script)
*/
#ifndef BSP_HAS_NO_VME
/*
* Initialize VME bridge - needs working PCI
* and IRQ subsystems...
*
* NOTE: vmeUniverse driver now uses shared interrupts.
* this requires workspace which is not available
* from bspstart()...
*/
#ifdef SHOW_MORE_INIT_SETTINGS
printk("Going to initialize VME bridge\n");
#endif
if ( BSP_vme_config )
BSP_vme_config();
#endif
#ifdef RTEMS_DEBUG
rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
#endif
}

View File

@@ -0,0 +1,28 @@
/*
* zero the various bss areas.
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* Modified to support the MCP750.
* Modifications Copyright (C) 1999 Eric Valette. valette@crf.canon.fr
*
* $Id$
*/
#include <string.h>
void zero_bss()
{
/* prevent these from being accessed in the short data areas */
extern unsigned long __bss_start[], __SBSS_START__[], __SBSS_END__[];
extern unsigned long __SBSS2_START__[], __SBSS2_END__[];
extern unsigned long __rtems_end[];
memset(__SBSS_START__, 0, ((unsigned) __SBSS_END__) - ((unsigned)__SBSS_START__));
memset(__SBSS2_START__, 0, ((unsigned) __SBSS2_END__) - ((unsigned)__SBSS2_START__));
memset(__bss_start, 0, ((unsigned) __rtems_end) - ((unsigned)__bss_start));
}