forked from Imagelibrary/rtems
2006-07-12 Joel Sherrill <joel@OARcorp.com>
* Makefile.am: Merge SHM support from 4.6 branch. * shmsupp/README, shmsupp/addrconv.c, shmsupp/getcfg.c, shmsupp/lock.c, shmsupp/mpisr.c: New files.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2006-07-12 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* Makefile.am: Merge SHM support from 4.6 branch.
|
||||
* shmsupp/README, shmsupp/addrconv.c, shmsupp/getcfg.c, shmsupp/lock.c,
|
||||
shmsupp/mpisr.c: New files.
|
||||
|
||||
2006-07-11 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* clock/ckinit.c: Actually call the routine to find the LEON3 time.
|
||||
|
||||
@@ -105,10 +105,24 @@ if HAS_NETWORKING
|
||||
libbsp_a_LIBADD += leon_greth.rel
|
||||
endif
|
||||
|
||||
if HAS_MP
|
||||
EXTRA_DIST += shmsupp/README
|
||||
|
||||
noinst_PROGRAMS += shmsupp.rel
|
||||
shmsupp_rel_SOURCES = shmsupp/addrconv.c shmsupp/getcfg.c shmsupp/lock.c \
|
||||
shmsupp/mpisr.c
|
||||
shmsupp_rel_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
shmsupp_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
|
||||
endif
|
||||
|
||||
libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/cache.rel \
|
||||
../../../libcpu/@RTEMS_CPU@/reg_win.rel \
|
||||
../../../libcpu/@RTEMS_CPU@/syscall.rel
|
||||
|
||||
if HAS_MP
|
||||
libbsp_a_LIBADD += shmsupp.rel
|
||||
endif
|
||||
|
||||
EXTRA_DIST += times
|
||||
|
||||
include $(srcdir)/preinstall.am
|
||||
|
||||
8
c/src/lib/libbsp/sparc/leon3/shmsupp/README
Normal file
8
c/src/lib/libbsp/sparc/leon3/shmsupp/README
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
This should describe how to use SHM in a multiprocessor LEON3
|
||||
configuration.
|
||||
|
||||
Especially useful would be how to test this on tsim-leon3.
|
||||
30
c/src/lib/libbsp/sparc/leon3/shmsupp/addrconv.c
Normal file
30
c/src/lib/libbsp/sparc/leon3/shmsupp/addrconv.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/* Shm_Convert_address
|
||||
*
|
||||
* No address range conversion is required.
|
||||
*
|
||||
* Input parameters:
|
||||
* address - address to convert
|
||||
*
|
||||
* Output parameters:
|
||||
* returns - converted address
|
||||
*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* 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.
|
||||
*
|
||||
* addrconv.c,v 1.7.8.1 2003/09/04 18:44:55 joel Exp
|
||||
*/
|
||||
|
||||
#include <rtems.h>
|
||||
#include <bsp.h>
|
||||
#include <shm_driver.h>
|
||||
|
||||
void *Shm_Convert_address(
|
||||
void *address
|
||||
)
|
||||
{
|
||||
return ( address );
|
||||
}
|
||||
134
c/src/lib/libbsp/sparc/leon3/shmsupp/getcfg.c
Normal file
134
c/src/lib/libbsp/sparc/leon3/shmsupp/getcfg.c
Normal file
@@ -0,0 +1,134 @@
|
||||
/* void Shm_Get_configuration( localnode, &shmcfg )
|
||||
*
|
||||
* This routine initializes, if necessary, and returns a pointer
|
||||
* to the Shared Memory Configuration Table for the XXX target.
|
||||
*
|
||||
* INPUT PARAMETERS:
|
||||
* localnode - local node number
|
||||
* shmcfg - address of pointer to SHM Config Table
|
||||
*
|
||||
* OUTPUT PARAMETERS:
|
||||
* *shmcfg - pointer to SHM Config Table
|
||||
*
|
||||
XXX: FIX THE COMMENTS BELOW WHEN THE CPU IS KNOWN
|
||||
* NOTES: The XYZ does not have an interprocessor interrupt.
|
||||
*
|
||||
* The following table illustrates the configuration limitations:
|
||||
*
|
||||
* BUS MAX
|
||||
* MODE ENDIAN NODES
|
||||
* ========= ====== =======
|
||||
* POLLED BIG 2+
|
||||
* INTERRUPT **** NOT SUPPORTED ****
|
||||
*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* 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.
|
||||
*
|
||||
* getcfg.c,v 1.7.8.1 2003/09/04 18:44:56 joel Exp
|
||||
*/
|
||||
|
||||
#include <rtems.h>
|
||||
#include <bsp.h>
|
||||
#include <shm_driver.h>
|
||||
|
||||
/* multiprocessor communications interface (MPCI) table */
|
||||
|
||||
|
||||
extern rtems_mpci_entry Shm_Get_packet(
|
||||
rtems_packet_prefix **
|
||||
);
|
||||
|
||||
rtems_mpci_entry Shm_Initialization( void );
|
||||
|
||||
extern rtems_mpci_entry Shm_Receive_packet(
|
||||
rtems_packet_prefix **
|
||||
);
|
||||
|
||||
extern rtems_mpci_entry Shm_Return_packet(
|
||||
rtems_packet_prefix *
|
||||
);
|
||||
|
||||
extern rtems_mpci_entry Shm_Send_packet(
|
||||
rtems_unsigned32,
|
||||
rtems_packet_prefix *
|
||||
);
|
||||
|
||||
|
||||
/* rtems_mpci_table MPCI_table = { */
|
||||
/* 100000, /\* default timeout value in ticks *\/ */
|
||||
/* MAX_PACKET_SIZE, /\* maximum packet size *\/ */
|
||||
/* Shm_Initialization, /\* initialization procedure *\/ */
|
||||
/* Shm_Get_packet, /\* get packet procedure *\/ */
|
||||
/* Shm_Return_packet, /\* return packet procedure *\/ */
|
||||
/* Shm_Send_packet, /\* packet send procedure *\/ */
|
||||
/* Shm_Receive_packet /\* packet receive procedure *\/ */
|
||||
/* }; */
|
||||
|
||||
|
||||
/*
|
||||
* configured if currently polling of interrupt driven
|
||||
*/
|
||||
|
||||
#define INTERRUPT 0 /* XXX: */
|
||||
#define POLLING 1 /* XXX: fix me -- is polling ONLY!!! */
|
||||
|
||||
|
||||
shm_config_table BSP_shm_cfgtbl;
|
||||
|
||||
void Shm_Get_configuration(
|
||||
rtems_unsigned32 localnode,
|
||||
shm_config_table **shmcfg
|
||||
)
|
||||
{
|
||||
extern rtems_configuration_table Configuration;
|
||||
int i;
|
||||
unsigned int tmp, ncpu;
|
||||
|
||||
BSP_shm_cfgtbl.base = 0x40000000;
|
||||
BSP_shm_cfgtbl.length = 0x00001000;
|
||||
BSP_shm_cfgtbl.format = SHM_BIG;
|
||||
|
||||
/*
|
||||
* Override cause_intr or shm_isr if your target has
|
||||
* special requirements.
|
||||
*/
|
||||
|
||||
BSP_shm_cfgtbl.cause_intr = Shm_Cause_interrupt;
|
||||
|
||||
#ifdef NEUTRAL_BIG
|
||||
BSP_shm_cfgtbl.convert = NULL_CONVERT;
|
||||
#else
|
||||
BSP_shm_cfgtbl.convert = CPU_swap_u32;
|
||||
#endif
|
||||
|
||||
BSP_shm_cfgtbl.poll_intr = INTR_MODE;
|
||||
BSP_shm_cfgtbl.Intr.address = (vol_u32) &(LEON3_IrqCtrl_Regs->force[LEON3_Cpu_Index]);
|
||||
BSP_shm_cfgtbl.Intr.value = 1 << LEON3_MP_IRQ ;
|
||||
BSP_shm_cfgtbl.Intr.length = 4;
|
||||
|
||||
if (LEON3_Cpu_Index == 0)
|
||||
{
|
||||
tmp = 0; /* ncpu = (((LEON3_IrqCtrl_Regs->mpstat) >> 28) & 0xf) + 1; */
|
||||
for (i = 1; i < (Configuration.User_multiprocessing_table)->maximum_nodes+1; i++)
|
||||
tmp |= (1 << i);
|
||||
LEON3_IrqCtrl_Regs->mpstat = tmp;
|
||||
}
|
||||
|
||||
/*
|
||||
if ((Configuration.User_multiprocessing_table)->node == 1)
|
||||
{
|
||||
tmp = 0;
|
||||
for (i = 1; i < (Configuration.User_multiprocessing_table)->maximum_nodes; i++)
|
||||
{
|
||||
tmp = tmp | (1 << (LEON3_Cpu_Index + i));
|
||||
}
|
||||
LEON3_IrqCtrl_Regs->mpstat = tmp;
|
||||
}
|
||||
*/
|
||||
|
||||
*shmcfg = &BSP_shm_cfgtbl;
|
||||
}
|
||||
97
c/src/lib/libbsp/sparc/leon3/shmsupp/lock.c
Normal file
97
c/src/lib/libbsp/sparc/leon3/shmsupp/lock.c
Normal file
@@ -0,0 +1,97 @@
|
||||
/* Shared Memory Lock Routines
|
||||
*
|
||||
* This shared memory locked queue support routine need to be
|
||||
* able to lock the specified locked queue. Interrupts are
|
||||
* disabled while the queue is locked to prevent preemption
|
||||
* and deadlock when two tasks poll for the same lock.
|
||||
* previous level.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* 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.
|
||||
*
|
||||
* lock.c,v 1.9.4.1 2003/09/04 18:44:56 joel Exp
|
||||
*/
|
||||
|
||||
#include <rtems.h>
|
||||
#include <bsp.h>
|
||||
#include <shm_driver.h>
|
||||
|
||||
|
||||
/*
|
||||
* Shm_Initialize_lock
|
||||
*
|
||||
* Initialize the lock for the specified locked queue.
|
||||
*/
|
||||
|
||||
void Shm_Initialize_lock(
|
||||
Shm_Locked_queue_Control *lq_cb
|
||||
)
|
||||
{
|
||||
lq_cb->lock = LQ_UNLOCKED;
|
||||
}
|
||||
|
||||
/* void _Shm_Lock( &lq_cb )
|
||||
*
|
||||
* This shared memory locked queue support routine locks the
|
||||
* specified locked queue. It disables interrupts to prevent
|
||||
* a deadlock condition.
|
||||
*/
|
||||
|
||||
asm(
|
||||
".text\n"
|
||||
".align 4\n"
|
||||
"LEON3_Atomic_Swap:\n"
|
||||
" retl\n"
|
||||
" swapa [%o1] 1, %o0\n"
|
||||
);
|
||||
|
||||
|
||||
|
||||
void Shm_Lock(
|
||||
Shm_Locked_queue_Control *lq_cb
|
||||
)
|
||||
{
|
||||
rtems_unsigned32 isr_level;
|
||||
rtems_unsigned32 *lockptr = (rtems_unsigned32 *) &lq_cb->lock;
|
||||
rtems_unsigned32 lock_value;
|
||||
|
||||
lock_value = SHM_LOCK_VALUE;
|
||||
rtems_interrupt_disable( isr_level );
|
||||
|
||||
Shm_isrstat = isr_level;
|
||||
while ( lock_value ) {
|
||||
lock_value = LEON3_Atomic_Swap(lock_value, lockptr);
|
||||
/* asm volatile( "" */
|
||||
/* : "=r" (lockptr), "=r" (lock_value) */
|
||||
/* : "0" (lockptr), "1" (lock_value) */
|
||||
/* ); */
|
||||
/*
|
||||
* If not available, then may want to delay to reduce load on lock.
|
||||
*/
|
||||
|
||||
/* if ( lock_value ) */
|
||||
/* rtems_bsp_delay( 10 ); /\* approximately 10 microseconds *\/ */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Shm_Unlock
|
||||
*
|
||||
* Unlock the lock for the specified locked queue.
|
||||
*/
|
||||
|
||||
void Shm_Unlock(
|
||||
Shm_Locked_queue_Control *lq_cb
|
||||
)
|
||||
{
|
||||
rtems_unsigned32 isr_level;
|
||||
|
||||
lq_cb->lock = SHM_UNLOCK_VALUE;
|
||||
isr_level = Shm_isrstat;
|
||||
rtems_interrupt_enable( isr_level );
|
||||
}
|
||||
|
||||
48
c/src/lib/libbsp/sparc/leon3/shmsupp/mpisr.c
Normal file
48
c/src/lib/libbsp/sparc/leon3/shmsupp/mpisr.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Shm_isr_nobsp()
|
||||
*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* 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.
|
||||
*
|
||||
* mpisr.c,v 1.7.8.1 2003/09/04 18:44:56 joel Exp
|
||||
*/
|
||||
|
||||
#include <rtems.h>
|
||||
#include <bsp.h>
|
||||
#include <shm_driver.h>
|
||||
|
||||
rtems_isr Shm_isr_nobsp( void )
|
||||
{
|
||||
/*
|
||||
* If this routine has to do anything other than the mpisr.c
|
||||
* found in the generic driver, then copy the contents of the generic
|
||||
* mpisr.c and augment it to satisfy this particular board. Typically,
|
||||
* you need to have a board specific mpisr.c when the interrupt
|
||||
* must be cleared.
|
||||
*
|
||||
* If the generic mpisr.c satisifies your requirements, then
|
||||
* remove this routine from your target's shmsupp/mpisb.c file.
|
||||
* Then simply install the generic Shm_isr in the Shm_setvec
|
||||
* routine below.
|
||||
*/
|
||||
}
|
||||
|
||||
/* Shm_setvec
|
||||
*
|
||||
* This driver routine sets the SHM interrupt vector to point to the
|
||||
* driver's SHM interrupt service routine.
|
||||
*
|
||||
* Input parameters: NONE
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*/
|
||||
|
||||
|
||||
void Shm_setvec( void )
|
||||
{
|
||||
LEON_Unmask_interrupt(LEON3_MP_IRQ);
|
||||
set_vector(Shm_isr, LEON_TRAP_TYPE(LEON3_MP_IRQ), 1);
|
||||
}
|
||||
Reference in New Issue
Block a user