summaryrefslogtreecommitdiffstats
path: root/c/src
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1995-09-27 20:53:58 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1995-09-27 20:53:58 +0000
commit37f4c2d99fbf09142aeafe3a9908a81e283f8186 (patch)
tree04dc487b28113dc17f1c3c9ab2241390b4ed95ea /c/src
parentFixed typo (diff)
downloadrtems-37f4c2d99fbf09142aeafe3a9908a81e283f8186.tar.bz2
Modified UNIX simulator port so all references to native unix
stuff is in the executive source proper in the file cpu.c. This should help avoid conflicts between RTEMS POSIX files and UNIX files.
Diffstat (limited to 'c/src')
-rw-r--r--c/src/exec/score/cpu/unix/cpu.c304
-rw-r--r--c/src/exec/score/cpu/unix/cpu.h54
-rw-r--r--c/src/exec/score/tools/unix/gensize.c116
-rw-r--r--c/src/lib/libbsp/shmdr/init.c1
-rw-r--r--c/src/lib/libbsp/unix/posix/clock/clock.c61
-rw-r--r--c/src/lib/libbsp/unix/posix/console/console.c1
-rw-r--r--c/src/lib/libbsp/unix/posix/include/bsp.h19
-rw-r--r--c/src/lib/libbsp/unix/posix/shmsupp/addrconv.c2
-rw-r--r--c/src/lib/libbsp/unix/posix/shmsupp/getcfg.c130
-rw-r--r--c/src/lib/libbsp/unix/posix/shmsupp/intr.c11
-rw-r--r--c/src/lib/libbsp/unix/posix/shmsupp/lock.c60
-rw-r--r--c/src/lib/libbsp/unix/posix/shmsupp/mpisr.c11
-rw-r--r--c/src/lib/libbsp/unix/posix/startup/bspclean.c15
-rw-r--r--c/src/lib/libbsp/unix/posix/startup/bspstart.c2
-rw-r--r--c/src/lib/libbsp/unix/posix/startup/exit.c1
-rw-r--r--c/src/lib/libbsp/unix/posix/startup/setvec.c1
-rw-r--r--c/src/lib/libbsp/unix/posix/timer/timer.c2
-rw-r--r--c/src/libchip/shmdr/init.c1
-rw-r--r--c/src/tests/sptests/sp12/sp12.scn2
-rw-r--r--c/src/tests/sptests/sp13/sp13.scn2
-rw-r--r--c/src/tests/sptests/sp15/sp15.scn4
-rw-r--r--c/src/tests/sptests/sp16/sp16.scn2
-rw-r--r--c/src/tests/sptests/sp20/sp20.scn30
-rw-r--r--c/src/tests/sptests/sp22/sp22.scn4
-rw-r--r--c/src/tests/sptests/sp23/sp23.scn2
-rw-r--r--c/src/tests/sptests/sp25/sp25.scn2
26 files changed, 535 insertions, 305 deletions
diff --git a/c/src/exec/score/cpu/unix/cpu.c b/c/src/exec/score/cpu/unix/cpu.c
index daff56a1de..54d4104ac7 100644
--- a/c/src/exec/score/cpu/unix/cpu.c
+++ b/c/src/exec/score/cpu/unix/cpu.c
@@ -20,16 +20,39 @@
#include <rtems/score/isr.h>
#include <rtems/score/interr.h>
+#if defined(solaris2)
+#undef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 3
+#undef __STRICT_ANSI__
+#define __STRICT_ANSI__
+#endif
+
+#if defined(linux)
+#define MALLOC_0_RETURNS_NULL
+#endif
+
#include <stdio.h>
#include <stdlib.h>
+#include <setjmp.h>
#include <signal.h>
#include <time.h>
#include <sys/time.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/sem.h>
#ifndef SA_RESTART
#define SA_RESTART 0
#endif
+typedef struct {
+ jmp_buf regs;
+ sigset_t isr_level;
+} Context_Control_overlay;
+
void _CPU_Signal_initialize(void);
void _CPU_Stray_signal(int);
void _CPU_ISR_Handler(int);
@@ -375,9 +398,9 @@ void _CPU_Context_Initialize(
*/
if ( _new_level == 0 )
- source = _CPU_Context_Default_with_ISRs_enabled.regs;
+ source = &_CPU_Context_Default_with_ISRs_enabled;
else
- source = _CPU_Context_Default_with_ISRs_disabled.regs;
+ source = &_CPU_Context_Default_with_ISRs_disabled;
memcpy(_the_context, source, sizeof(Context_Control) ); /* sizeof(jmp_buf)); */
@@ -452,8 +475,10 @@ void _CPU_Context_restore(
Context_Control *next
)
{
- sigprocmask( SIG_SETMASK, &next->isr_level, 0 );
- longjmp( next->regs, 0 );
+ Context_Control_overlay *nextp = (Context_Control_overlay *)next;
+
+ sigprocmask( SIG_SETMASK, &nextp->isr_level, 0 );
+ longjmp( nextp->regs, 0 );
}
/*PAGE
@@ -466,13 +491,16 @@ void _CPU_Context_switch(
Context_Control *next
)
{
+ Context_Control_overlay *currentp = (Context_Control_overlay *)current;
+ Context_Control_overlay *nextp = (Context_Control_overlay *)next;
+
int status;
/*
* Switch levels in one operation
*/
- status = sigprocmask( SIG_SETMASK, &next->isr_level, &current->isr_level );
+ status = sigprocmask( SIG_SETMASK, &nextp->isr_level, &currentp->isr_level );
if ( status )
_Internal_error_Occurred(
INTERNAL_ERROR_CORE,
@@ -480,8 +508,8 @@ void _CPU_Context_switch(
status
);
- if (setjmp(current->regs) == 0) { /* Save the current context */
- longjmp(next->regs, 0); /* Switch to the new context */
+ if (setjmp(currentp->regs) == 0) { /* Save the current context */
+ longjmp(nextp->regs, 0); /* Switch to the new context */
if ( status )
_Internal_error_Occurred(
INTERNAL_ERROR_CORE,
@@ -610,18 +638,19 @@ void _CPU_ISR_Handler(int vector)
void _CPU_Stray_signal(int sig_num)
{
- char buffer[ 80 ];
+ char buffer[ 4 ];
/*
* We avoid using the stdio section of the library.
* The following is generally safe.
*/
- write(
- 2,
- buffer,
- sprintf( buffer, "Stray signal %d\n", sig_num )
- );
+ buffer[ 0 ] = (sig_num >> 4) + 0x30;
+ buffer[ 1 ] = (sig_num & 0xf) + 0x30;
+ buffer[ 2 ] = '\n';
+
+ write( 2, "Stray signal 0x", 12 );
+ write( 2, buffer, 3 );
/*
* If it was a "fatal" signal, then exit here
@@ -680,3 +709,252 @@ int _CPU_ffs(unsigned32 value)
return output;
}
+
+
+/*
+ * Special Purpose Routines to hide the use of UNIX system calls.
+ */
+
+#if 0
+/* XXX clock had this set of #define's */
+
+/*
+ * In order to get the types and prototypes used in this file under
+ * Solaris 2.3, it is necessary to pull the following magic.
+ */
+
+#if defined(solaris)
+#warning "Ignore the undefining __STDC__ warning"
+#undef __STDC__
+#define __STDC__ 0
+#undef _POSIX_C_SOURCE
+#endif
+#endif
+
+int _CPU_Get_clock_vector( void )
+{
+ return SIGALRM;
+}
+
+
+void _CPU_Start_clock(
+ int microseconds
+)
+{
+ struct itimerval new;
+
+ new.it_value.tv_sec = 0;
+ new.it_value.tv_usec = microseconds;
+ new.it_interval.tv_sec = 0;
+ new.it_interval.tv_usec = microseconds;
+
+ setitimer(ITIMER_REAL, &new, 0);
+}
+
+void _CPU_Stop_clock( void )
+{
+ struct itimerval new;
+ struct sigaction act;
+
+ /*
+ * Set the SIGALRM signal to ignore any last
+ * signals that might come in while we are
+ * disarming the timer and removing the interrupt
+ * vector.
+ */
+
+ act.sa_handler = SIG_IGN;
+
+ sigaction(SIGALRM, &act, 0);
+
+ new.it_value.tv_sec = 0;
+ new.it_value.tv_usec = 0;
+
+ setitimer(ITIMER_REAL, &new, 0);
+}
+
+int _CPU_SHM_Semid;
+extern void fix_syscall_errno( void );
+
+void _CPU_SHM_Init(
+ unsigned32 maximum_nodes,
+ boolean is_master_node,
+ void **shm_address,
+ unsigned32 *shm_length
+)
+{
+ int i;
+ int shmid;
+ char *shm_addr;
+ key_t shm_key;
+ key_t sem_key;
+ int status;
+ int shm_size;
+
+ if (getenv("RTEMS_SHM_KEY"))
+ shm_key = strtol(getenv("RTEMS_SHM_KEY"), 0, 0);
+ else
+#ifdef RTEMS_SHM_KEY
+ shm_key = RTEMS_SHM_KEY;
+#else
+ shm_key = 0xa000;
+#endif
+
+ if (getenv("RTEMS_SHM_SIZE"))
+ shm_size = strtol(getenv("RTEMS_SHM_SIZE"), 0, 0);
+ else
+#ifdef RTEMS_SHM_SIZE
+ shm_size = RTEMS_SHM_SIZE;
+#else
+ shm_size = 64 * 1024;
+#endif
+
+ if (getenv("RTEMS_SHM_SEMAPHORE_KEY"))
+ sem_key = strtol(getenv("RTEMS_SHM_SEMAPHORE_KEY"), 0, 0);
+ else
+#ifdef RTEMS_SHM_SEMAPHORE_KEY
+ sem_key = RTEMS_SHM_SEMAPHORE_KEY;
+#else
+ sem_key = 0xa001;
+#endif
+
+ shmid = shmget(shm_key, shm_size, IPC_CREAT | 0660);
+ if ( shmid == -1 ) {
+ fix_syscall_errno(); /* in case of newlib */
+ perror( "shmget" );
+ _CPU_Fatal_halt( 0xdead0001 );
+ }
+
+ shm_addr = shmat(shmid, (char *)0, SHM_RND);
+ if ( shm_addr == (void *)-1 ) {
+ fix_syscall_errno(); /* in case of newlib */
+ perror( "shmat" );
+ _CPU_Fatal_halt( 0xdead0002 );
+ }
+
+ _CPU_SHM_Semid = semget(sem_key, maximum_nodes + 1, IPC_CREAT | 0660);
+ if ( _CPU_SHM_Semid == -1 ) {
+ fix_syscall_errno(); /* in case of newlib */
+ perror( "semget" );
+ _CPU_Fatal_halt( 0xdead0003 );
+ }
+
+ if ( is_master_node ) {
+ for ( i=0 ; i <= maximum_nodes ; i++ ) {
+#if defined(solaris2)
+ union semun {
+ int val;
+ struct semid_ds *buf;
+ ushort *array;
+ } help;
+
+ help.val = 1;
+ status = semctl( _CPU_SHM_Semid, i, SETVAL, help );
+#endif
+#if defined(hpux)
+ status = semctl( _CPU_SHM_Semid, i, SETVAL, 1 );
+#endif
+
+ fix_syscall_errno(); /* in case of newlib */
+ if ( status == -1 ) {
+ _CPU_Fatal_halt( 0xdead0004 );
+ }
+ }
+ }
+
+ *shm_address = shm_addr;
+ *shm_length = shm_size;
+
+}
+
+int _CPU_Get_pid( void )
+{
+ return getpid();
+}
+
+/*
+ * Define this to use signals for MPCI shared memory driver.
+ * If undefined, the shared memory driver will poll from the
+ * clock interrupt.
+ * Ref: ../shmsupp/getcfg.c
+ *
+ * BEWARE:: many UN*X kernels and debuggers become severely confused when
+ * debugging programs which use signals. The problem is *much*
+ * worse when using multiple signals, since ptrace(2) tends to
+ * drop all signals except 1 in the case of multiples.
+ * On hpux9, this problem was so bad, we couldn't use interrupts
+ * with the shared memory driver if we ever hoped to debug
+ * RTEMS programs.
+ * Maybe systems that use /proc don't have this problem...
+ */
+
+
+int _CPU_SHM_Get_vector( void )
+{
+#ifdef CPU_USE_SHM_INTERRUPTS
+ return SIGUSR1;
+#else
+ return 0;
+#endif
+}
+
+void _CPU_SHM_Send_interrupt(
+ int pid,
+ int vector
+)
+{
+ kill((pid_t) pid, vector);
+}
+
+void _CPU_SHM_Lock(
+ int semaphore
+)
+{
+ struct sembuf sb;
+ int status;
+
+ sb.sem_num = semaphore;
+ sb.sem_op = -1;
+ sb.sem_flg = 0;
+
+ while (1) {
+ status = semop(_CPU_SHM_Semid, &sb, 1);
+ if ( status >= 0 )
+ break;
+ if ( status == -1 ) {
+ fix_syscall_errno(); /* in case of newlib */
+ if (errno == EINTR)
+ continue;
+ perror("shm lock");
+ _CPU_Fatal_halt( 0xdead0005 );
+ }
+ }
+
+}
+
+void _CPU_SHM_Unlock(
+ int semaphore
+)
+{
+ struct sembuf sb;
+ int status;
+
+ sb.sem_num = semaphore;
+ sb.sem_op = 1;
+ sb.sem_flg = 0;
+
+ while (1) {
+ status = semop(_CPU_SHM_Semid, &sb, 1);
+ if ( status >= 0 )
+ break;
+
+ if ( status == -1 ) {
+ fix_syscall_errno(); /* in case of newlib */
+ if (errno == EINTR)
+ continue;
+ perror("shm unlock");
+ _CPU_Fatal_halt( 0xdead0006 );
+ }
+ }
+
+}
diff --git a/c/src/exec/score/cpu/unix/cpu.h b/c/src/exec/score/cpu/unix/cpu.h
index d7ff311af1..b4b34d4eff 100644
--- a/c/src/exec/score/cpu/unix/cpu.h
+++ b/c/src/exec/score/cpu/unix/cpu.h
@@ -31,6 +31,8 @@ extern "C" {
#include <rtems/score/unixtypes.h>
#endif
+#include <rtems/score/unixsize.h>
+
#if defined(solaris2)
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 3
@@ -42,10 +44,6 @@ extern "C" {
#define MALLOC_0_RETURNS_NULL
#endif
-#include <unistd.h>
-#include <setjmp.h>
-#include <signal.h>
-
/* conditional compilation parameters */
/*
@@ -431,9 +429,17 @@ extern "C" {
* a debugger such as gdb. But that is another problem.
*/
+/*
+ * This is really just the area for the following fields.
+ *
+ * jmp_buf regs;
+ * sigset_t isr_level;
+ *
+ * Doing it this way avoids conflicts between the native stuff and the
+ * RTEMS stuff.
+ */
typedef struct {
- jmp_buf regs;
- sigset_t isr_level;
+ char Area[ CPU_CONTEXT_SIZE_IN_BYTES ];
} Context_Control;
typedef struct {
@@ -968,6 +974,42 @@ static inline unsigned int CPU_swap_u32(
return( swapped );
}
+/*
+ * Special Purpose Routines to hide the use of UNIX system calls.
+ */
+
+int _CPU_Get_clock_vector( void );
+
+void _CPU_Start_clock(
+ int microseconds
+);
+
+void _CPU_Stop_clock( void );
+
+void _CPU_SHM_Init(
+ unsigned32 maximum_nodes,
+ boolean is_master_node,
+ void **shm_address,
+ unsigned32 *shm_length
+);
+
+int _CPU_Get_pid( void );
+
+int _CPU_SHM_Get_vector( void );
+
+void _CPU_SHM_Send_interrupt(
+ int pid,
+ int vector
+);
+
+void _CPU_SHM_Lock(
+ int semaphore
+);
+
+void _CPU_SHM_Unlock(
+ int semaphore
+);
+
#ifdef __cplusplus
}
#endif
diff --git a/c/src/exec/score/tools/unix/gensize.c b/c/src/exec/score/tools/unix/gensize.c
new file mode 100644
index 0000000000..0466d67b09
--- /dev/null
+++ b/c/src/exec/score/tools/unix/gensize.c
@@ -0,0 +1,116 @@
+/*
+ * gensize.c
+ *
+ * This file generates the file unixsize.h
+ *
+ * NOTE: It only prints the minimal information required.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ *
+ */
+
+/*
+ * This feels like a very crude way to determine if we are on a Solaris
+ * host but it does work.
+ */
+
+#if defined(__sun__) && defined(__sparc__) && \
+ defined(__unix__) && defined(__svr4__)
+#undef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 3
+#undef __STRICT_ANSI__
+#endif
+
+#include <stdio.h>
+#include <unistd.h>
+#include <setjmp.h>
+#include <signal.h>
+
+typedef struct {
+ jmp_buf regs;
+ sigset_t isr_level;
+} Context_Control;
+
+int main(
+ int argc,
+ char **argv
+)
+{
+ Context_Control *cc = 0;
+
+ /*
+ * Print the file header
+ */
+
+printf(
+ "/* unixsize.h\n"
+ " *\n"
+ " * This include file contans the size of the context control block\n"
+ " * C data structure. This structure must be defined in such a way\n"
+ " * that files NOT including the native header files can work.\n"
+ " *\n"
+ " * NOTE: THIS FILE IS AUTOMATICALLY GENERATED!!!!\n"
+ " * DO NOT EDIT THIS BY HAND!!!!\n"
+ " *\n"
+ " * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.\n"
+ " * On-Line Applications Research Corporation (OAR).\n"
+ " * All rights assigned to U.S. Government, 1994.\n"
+ " *\n"
+ " * This material may be reproduced by or for the U.S. Government pursuant\n"
+ " * to the copyright license under the clause at DFARS 252.227-7013. This\n"
+ " * notice must appear in all copies of this file and its derivatives.\n"
+ " */\n"
+ "\n"
+ "#ifndef __UNIXSIZE_h\n"
+ "#define __UNIXSIZE_h\n"
+ "\n"
+);
+
+#define PRINT_IT( STRING, NUMBER ) \
+ printf( "#define\t%s\t0x%x\t\t/* %d */\n", \
+ STRING, \
+ NUMBER, \
+ NUMBER );
+
+#define PRINT_SIZE( STRING, NUMBER ) \
+ printf( "#define\t%s\t0x%x\t\t/* %d */\n", \
+ STRING, \
+ NUMBER, \
+ NUMBER );
+
+#define PRINT_COMMENT( STRING ) \
+ printf( \
+ "\n" \
+ "/*\n" \
+ " * " STRING "\n" \
+ " */\n" \
+ "\n" \
+ );
+
+ PRINT_COMMENT("Context_Control information");
+
+ PRINT_SIZE("CPU_CONTEXT_SIZE_IN_BYTES", sizeof( Context_Control ) );
+ PRINT_SIZE("CPU_CONTEXT_REGISTERS_OFFSET_IN_BYTES", (int) &cc->regs );
+ PRINT_SIZE("CPU_CONTEXT_SIGNALS_OFFSET_IN_BYTES", (int) &cc->isr_level );
+
+ /*
+ * Print the end of file stuff
+ */
+
+ printf(
+ "\n"
+ "#endif /* __UNIXSIZE_h */\n"
+ "\n"
+ "/* end of include file */\n"
+ );
+
+ return 0;
+}
+
diff --git a/c/src/lib/libbsp/shmdr/init.c b/c/src/lib/libbsp/shmdr/init.c
index 14eddca0aa..8b62d6fb46 100644
--- a/c/src/lib/libbsp/shmdr/init.c
+++ b/c/src/lib/libbsp/shmdr/init.c
@@ -236,6 +236,7 @@ rtems_mpci_entry Shm_Initialization( void )
}
MPCI_Shm_extensions.fatal = MPCI_Fatal;
+
(void) rtems_extension_create(
rtems_build_name( 'M', 'P', 'E', 'X' ),
&MPCI_Shm_extensions,
diff --git a/c/src/lib/libbsp/unix/posix/clock/clock.c b/c/src/lib/libbsp/unix/posix/clock/clock.c
index 7b22424251..da0dd46807 100644
--- a/c/src/lib/libbsp/unix/posix/clock/clock.c
+++ b/c/src/lib/libbsp/unix/posix/clock/clock.c
@@ -14,33 +14,16 @@
* $Id$
*/
-#include <rtems.h>
-#include <rtems/libio.h>
#include <bsp.h>
-
-/*
- * In order to get the types and prototypes used in this file under
- * Solaris 2.3, it is necessary to pull the following magic.
- */
-
-#if defined(solaris)
-#warning "Ignore the undefining __STDC__ warning"
-#undef __STDC__
-#define __STDC__ 0
-#undef _POSIX_C_SOURCE
-#endif
-
+#include <rtems/libio.h>
#include <stdlib.h>
-#include <stdio.h>
-#include <signal.h>
-#include <time.h>
-
-extern rtems_configuration_table Configuration;
void Clock_exit(void);
volatile rtems_unsigned32 Clock_driver_ticks;
+rtems_unsigned32 Clock_driver_vector;
+
/*
* These are set by clock driver during its init
*/
@@ -51,18 +34,11 @@ rtems_device_minor_number rtems_clock_minor;
void
Install_clock(rtems_isr_entry clock_isr)
{
- struct itimerval new;
-
Clock_driver_ticks = 0;
- new.it_value.tv_sec = 0;
- new.it_value.tv_usec = Configuration.microseconds_per_tick;
- new.it_interval.tv_sec = 0;
- new.it_interval.tv_usec = Configuration.microseconds_per_tick;
+ (void)set_vector(clock_isr, Clock_driver_vector, 1);
- (void)set_vector(clock_isr, SIGALRM, 1);
-
- setitimer(ITIMER_REAL, &new, 0);
+ _CPU_Start_clock( BSP_Configuration.microseconds_per_tick );
atexit(Clock_exit);
}
@@ -73,7 +49,7 @@ ReInstall_clock(rtems_isr_entry new_clock_isr)
rtems_unsigned32 isrlevel = 0;
rtems_interrupt_disable(isrlevel);
- (void)set_vector(new_clock_isr, SIGALRM, 1);
+ (void)set_vector(new_clock_isr, Clock_driver_vector, 1);
rtems_interrupt_enable(isrlevel);
}
@@ -92,26 +68,9 @@ Clock_isr(int vector)
void
Clock_exit(void)
{
- struct itimerval new;
- struct sigaction act;
-
- /*
- * Set the SIGALRM signal to ignore any last
- * signals that might come in while we are
- * disarming the timer and removing the interrupt
- * vector.
- */
-
- act.sa_handler = SIG_IGN;
-
- sigaction(SIGALRM, &act, 0);
+ _CPU_Stop_clock();
- new.it_value.tv_sec = 0;
- new.it_value.tv_usec = 0;
-
- setitimer(ITIMER_REAL, &new, 0);
-
- (void)set_vector(0, SIGALRM, 1);
+ (void)set_vector(0, Clock_driver_vector, 1);
}
rtems_device_driver
@@ -121,6 +80,8 @@ Clock_initialize(
void *pargp
)
{
+ Clock_driver_vector = _CPU_Get_clock_vector();
+
Install_clock((rtems_isr_entry) Clock_isr);
/*
@@ -150,7 +111,7 @@ rtems_device_driver Clock_control(
if (args->command == rtems_build_name('I', 'S', 'R', ' '))
{
- Clock_isr(SIGALRM);
+ Clock_isr(Clock_driver_vector);
}
else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
{
diff --git a/c/src/lib/libbsp/unix/posix/console/console.c b/c/src/lib/libbsp/unix/posix/console/console.c
index 61bbe08c78..de478328bb 100644
--- a/c/src/lib/libbsp/unix/posix/console/console.c
+++ b/c/src/lib/libbsp/unix/posix/console/console.c
@@ -21,7 +21,6 @@
* $Id$
*/
-#include <rtems.h>
#include <bsp.h>
#include <unistd.h>
diff --git a/c/src/lib/libbsp/unix/posix/include/bsp.h b/c/src/lib/libbsp/unix/posix/include/bsp.h
index 6ebec41276..0b3556c80f 100644
--- a/c/src/lib/libbsp/unix/posix/include/bsp.h
+++ b/c/src/lib/libbsp/unix/posix/include/bsp.h
@@ -25,7 +25,6 @@ extern "C" {
#include <console.h>
#include <iosupp.h>
#include <libcsupport.h>
-#include <signal.h>
/*
* Define the time limits for RTEMS Test Suite test durations.
@@ -63,24 +62,6 @@ extern "C" {
extern rtems_configuration_table BSP_Configuration;
/*
- * Define this to use signals for MPCI shared memory driver.
- * If undefined, the shared memory driver will poll from the
- * clock interrupt.
- * Ref: ../shmsupp/getcfg.c
- *
- * BEWARE:: many UN*X kernels and debuggers become severely confused when
- * debugging programs which use signals. The problem is *much*
- * worse when using multiple signals, since ptrace(2) tends to
- * drop all signals except 1 in the case of multiples.
- * On hpux9, this problem was so bad, we couldn't use interrupts
- * with the shared memory driver if we ever hoped to debug
- * RTEMS programs.
- * Maybe systems that use /proc don't have this problem...
- */
-
-/* #define INTERRUPT_EXTERNAL_MPCI SIGUSR1 */
-
-/*
* Device Driver Table Entries
*/
diff --git a/c/src/lib/libbsp/unix/posix/shmsupp/addrconv.c b/c/src/lib/libbsp/unix/posix/shmsupp/addrconv.c
index fd3ba689bd..8af7498b64 100644
--- a/c/src/lib/libbsp/unix/posix/shmsupp/addrconv.c
+++ b/c/src/lib/libbsp/unix/posix/shmsupp/addrconv.c
@@ -19,8 +19,6 @@
* $Id$
*/
-#include <rtems.h>
-
#include <bsp.h>
#include <shm.h>
diff --git a/c/src/lib/libbsp/unix/posix/shmsupp/getcfg.c b/c/src/lib/libbsp/unix/posix/shmsupp/getcfg.c
index b66e3c2287..c912447631 100644
--- a/c/src/lib/libbsp/unix/posix/shmsupp/getcfg.c
+++ b/c/src/lib/libbsp/unix/posix/shmsupp/getcfg.c
@@ -25,19 +25,8 @@
* $Id$
*/
-#include <rtems.h>
-
-#include <shm.h>
#include <bsp.h>
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/sem.h>
+#include <shm.h>
shm_config_table BSP_shm_cfgtbl;
@@ -47,124 +36,39 @@ void Shm_Cause_interrupt_unix(
rtems_unsigned32 node
);
-void fix_semaphores( void )
-{
- rtems_unsigned32 maximum_nodes;
- int i;
-
- int shmid;
- char *shm_addr;
- key_t shm_key;
- key_t sem_key;
- int status;
- int shm_size;
-
- if (getenv("RTEMS_SHM_KEY"))
- shm_key = strtol(getenv("RTEMS_SHM_KEY"), 0, 0);
- else
-#ifdef RTEMS_SHM_KEY
- shm_key = RTEMS_SHM_KEY;
-#else
- shm_key = 0xa000;
-#endif
-
- if (getenv("RTEMS_SHM_SIZE"))
- shm_size = strtol(getenv("RTEMS_SHM_SIZE"), 0, 0);
- else
-#ifdef RTEMS_SHM_SIZE
- shm_size = RTEMS_SHM_SIZE;
-#else
- shm_size = 64 * KILOBYTE;
-#endif
-
- if (getenv("RTEMS_SHM_SEMAPHORE_KEY"))
- sem_key = strtol(getenv("RTEMS_SHM_SEMAPHORE_KEY"), 0, 0);
- else
-#ifdef RTEMS_SHM_SEMAPHORE_KEY
- sem_key = RTEMS_SHM_SEMAPHORE_KEY;
-#else
- sem_key = 0xa001;
-#endif
-
- shmid = shmget(shm_key, shm_size, IPC_CREAT | 0660);
- if ( shmid == -1 ) {
- fix_syscall_errno(); /* in case of newlib */
- perror( "shmget" );
- rtems_fatal_error_occurred(RTEMS_UNSATISFIED);
- }
-
- shm_addr = shmat(shmid, (char *)0, SHM_RND);
- if ( shm_addr == (void *)-1 ) {
- fix_syscall_errno(); /* in case of newlib */
- perror( "shmat" );
- rtems_fatal_error_occurred(RTEMS_UNSATISFIED);
- }
-
- maximum_nodes = Shm_RTEMS_MP_Configuration->maximum_nodes;
- semid = semget(sem_key, maximum_nodes + 1, IPC_CREAT | 0660);
- if ( semid == -1 ) {
- fix_syscall_errno(); /* in case of newlib */
- perror( "semget" );
- rtems_fatal_error_occurred(RTEMS_UNSATISFIED);
- }
-
- if ( Shm_Is_master_node() ) {
- for ( i=0 ; i <= maximum_nodes ; i++ ) {
-
-#if defined(solaris2)
- union semun {
- int val;
- struct semid_ds *buf;
- ushort *array;
- } help;
-
- help.val = 1;
- semctl( semid, i, SETVAL, help );
-#endif
-#if defined(hpux)
- semctl( semid, i, SETVAL, 1 );
-#endif
-
- fix_syscall_errno(); /* in case of newlib */
- if ( status == -1 ) {
- fprintf( stderr, "Sem init failed %d\n", errno ); fflush( stderr );
- rtems_fatal_error_occurred(RTEMS_UNSATISFIED);
- }
- }
- }
-
- BSP_shm_cfgtbl.base = (vol_u32 *)shm_addr;
- BSP_shm_cfgtbl.length = shm_size;
-}
-
void Shm_Get_configuration(
rtems_unsigned32 localnode,
shm_config_table **shmcfg
)
{
- fix_semaphores();
+ _CPU_SHM_Init(
+ Shm_Maximum_nodes,
+ Shm_Is_master_node(),
+ (void **)&BSP_shm_cfgtbl.base,
+ (unsigned32 *)&BSP_shm_cfgtbl.length
+ );
- BSP_shm_cfgtbl.format = SHM_BIG;
+ BSP_shm_cfgtbl.format = SHM_BIG;
- BSP_shm_cfgtbl.cause_intr = Shm_Cause_interrupt_unix;
+ BSP_shm_cfgtbl.cause_intr = Shm_Cause_interrupt_unix;
#ifdef NEUTRAL_BIG
- BSP_shm_cfgtbl.convert = NULL_CONVERT;
+ BSP_shm_cfgtbl.convert = NULL_CONVERT;
#else
- BSP_shm_cfgtbl.convert = CPU_swap_u32;
+ BSP_shm_cfgtbl.convert = CPU_swap_u32;
#endif
-#ifdef INTERRUPT_EXTERNAL_MPCI
+ if ( _CPU_SHM_Get_vector() ) {
BSP_shm_cfgtbl.poll_intr = INTR_MODE;
- BSP_shm_cfgtbl.Intr.address = (vol_u32 *) getpid(); /* process id */
- BSP_shm_cfgtbl.Intr.value = INTERRUPT_EXTERNAL_MPCI; /* signal to send */
+ BSP_shm_cfgtbl.Intr.address = (vol_u32 *) _CPU_Get_pid(); /* process id */
+ BSP_shm_cfgtbl.Intr.value = _CPU_SHM_Get_vector(); /* signal to send */
BSP_shm_cfgtbl.Intr.length = LONG;
-#else
+ } else {
BSP_shm_cfgtbl.poll_intr = POLLED_MODE;
BSP_shm_cfgtbl.Intr.address = NO_INTERRUPT;
BSP_shm_cfgtbl.Intr.value = NO_INTERRUPT;
BSP_shm_cfgtbl.Intr.length = NO_INTERRUPT;
-#endif
+ }
- *shmcfg = &BSP_shm_cfgtbl;
+ *shmcfg = &BSP_shm_cfgtbl;
}
diff --git a/c/src/lib/libbsp/unix/posix/shmsupp/intr.c b/c/src/lib/libbsp/unix/posix/shmsupp/intr.c
index 2f8cd6db11..243af403d9 100644
--- a/c/src/lib/libbsp/unix/posix/shmsupp/intr.c
+++ b/c/src/lib/libbsp/unix/posix/shmsupp/intr.c
@@ -19,18 +19,15 @@
* $Id$
*/
-#include <rtems.h>
+#include <bsp.h>
#include <shm.h>
-#include <stdio.h>
-#include <signal.h>
-
void Shm_Cause_interrupt_unix(
rtems_unsigned32 node
)
{
- Shm_Interrupt_information *intr;
- intr = &Shm_Interrupt_table[node];
+ Shm_Interrupt_information *intr;
+ intr = &Shm_Interrupt_table[node];
- kill((pid_t) intr->address, intr->value);
+ _CPU_SHM_Send_interrupt( (int) intr->address, (int) intr->value );
}
diff --git a/c/src/lib/libbsp/unix/posix/shmsupp/lock.c b/c/src/lib/libbsp/unix/posix/shmsupp/lock.c
index 0dd0cbd8b3..76a57d0a06 100644
--- a/c/src/lib/libbsp/unix/posix/shmsupp/lock.c
+++ b/c/src/lib/libbsp/unix/posix/shmsupp/lock.c
@@ -17,18 +17,9 @@
* $Id$
*/
-#include <rtems.h>
-
#include <bsp.h>
#include <shm.h>
-#include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/sem.h>
-
extern int semid;
/*
@@ -55,30 +46,13 @@ void Shm_Lock(
Shm_Locked_queue_Control *lq_cb
)
{
- rtems_unsigned32 isr_level;
- struct sembuf sb;
- int status;
-
- sb.sem_num = lq_cb->lock;
- sb.sem_op = -1;
- sb.sem_flg = 0;
+ rtems_unsigned32 isr_level;
- rtems_interrupt_disable( isr_level );
+ rtems_interrupt_disable( isr_level );
- Shm_isrstat = isr_level;
+ Shm_isrstat = isr_level;
- while (1) {
- status = semop(semid, &sb, 1);
- if ( status >= 0 )
- break;
- if ( status == -1 ) {
- fix_syscall_errno(); /* in case of newlib */
- if (errno == EINTR)
- continue;
- perror("shm lock");
- rtems_fatal_error_occurred(RTEMS_UNSATISFIED);
- }
- }
+ _CPU_SHM_Lock( lq_cb->lock );
}
/*
@@ -91,28 +65,10 @@ void Shm_Unlock(
Shm_Locked_queue_Control *lq_cb
)
{
- rtems_unsigned32 isr_level;
- struct sembuf sb;
- int status;
-
- sb.sem_num = lq_cb->lock;
- sb.sem_op = 1;
- sb.sem_flg = 0;
-
- while (1) {
- status = semop(semid, &sb, 1);
- if ( status >= 0 )
- break;
+ rtems_unsigned32 isr_level;
- if ( status == -1 ) {
- fix_syscall_errno(); /* in case of newlib */
- if (errno == EINTR)
- continue;
- perror("shm unlock");
- rtems_fatal_error_occurred(RTEMS_UNSATISFIED);
- }
- }
+ _CPU_SHM_Unlock( lq_cb->lock );
- isr_level = Shm_isrstat;
- rtems_interrupt_enable( isr_level );
+ isr_level = Shm_isrstat;
+ rtems_interrupt_enable( isr_level );
}
diff --git a/c/src/lib/libbsp/unix/posix/shmsupp/mpisr.c b/c/src/lib/libbsp/unix/posix/shmsupp/mpisr.c
index ff24bfa31c..a047edf2f2 100644
--- a/c/src/lib/libbsp/unix/posix/shmsupp/mpisr.c
+++ b/c/src/lib/libbsp/unix/posix/shmsupp/mpisr.c
@@ -18,14 +18,15 @@
* $Id$
*/
-#include <rtems.h>
-
#include <bsp.h>
#include <shm.h>
void Shm_setvec( void )
{
-#ifdef INTERRUPT_EXTERNAL_MPCI
- set_vector( Shm_isr, INTERRUPT_EXTERNAL_MPCI, 1 );
-#endif
+ int vector;
+
+ vector = _CPU_SHM_Get_vector();
+
+ if ( vector )
+ set_vector( Shm_isr, vector, 1 );
}
diff --git a/c/src/lib/libbsp/unix/posix/startup/bspclean.c b/c/src/lib/libbsp/unix/posix/startup/bspclean.c
index 47d9548694..1fe2de4439 100644
--- a/c/src/lib/libbsp/unix/posix/startup/bspclean.c
+++ b/c/src/lib/libbsp/unix/posix/startup/bspclean.c
@@ -19,7 +19,6 @@
* $Id$
*/
-#include <rtems.h>
#include <bsp.h>
#include <stdio.h>
@@ -30,13 +29,13 @@
void bsp_cleanup( void )
{
- /*
- * Invoke any fatal error extension and "halt"
- * By definition, rtems_fatal_error_occurred does not return.
- */
+ /*
+ * Invoke any fatal error extension and "halt"
+ * By definition, rtems_fatal_error_occurred does not return.
+ */
-fflush(stdout);
-fflush(stderr);
+ fflush(stdout);
+ fflush(stderr);
- rtems_fatal_error_occurred(0);
+ rtems_fatal_error_occurred(0);
}
diff --git a/c/src/lib/libbsp/unix/posix/startup/bspstart.c b/c/src/lib/libbsp/unix/posix/startup/bspstart.c
index ed687f7319..f948d5a038 100644
--- a/c/src/lib/libbsp/unix/posix/startup/bspstart.c
+++ b/c/src/lib/libbsp/unix/posix/startup/bspstart.c
@@ -27,8 +27,6 @@
* $Id$
*/
-#include <rtems.h>
-
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
diff --git a/c/src/lib/libbsp/unix/posix/startup/exit.c b/c/src/lib/libbsp/unix/posix/startup/exit.c
index ac3c840832..8e07dc0577 100644
--- a/c/src/lib/libbsp/unix/posix/startup/exit.c
+++ b/c/src/lib/libbsp/unix/posix/startup/exit.c
@@ -14,7 +14,6 @@
* $Id$
*/
-#include <rtems.h>
#include <bsp.h>
#include <clockdrv.h>
diff --git a/c/src/lib/libbsp/unix/posix/startup/setvec.c b/c/src/lib/libbsp/unix/posix/startup/setvec.c
index 8d3aedceb9..6be1e50555 100644
--- a/c/src/lib/libbsp/unix/posix/startup/setvec.c
+++ b/c/src/lib/libbsp/unix/posix/startup/setvec.c
@@ -24,7 +24,6 @@
* $Id$
*/
-#include <rtems.h>
#include <bsp.h>
/*
diff --git a/c/src/lib/libbsp/unix/posix/timer/timer.c b/c/src/lib/libbsp/unix/posix/timer/timer.c
index 223a82a5d6..e1b9704072 100644
--- a/c/src/lib/libbsp/unix/posix/timer/timer.c
+++ b/c/src/lib/libbsp/unix/posix/timer/timer.c
@@ -16,8 +16,8 @@
* $Id$
*/
-#include <rtems.h>
+#include <bsp.h>
#include <time.h>
#include <sys/time.h>
diff --git a/c/src/libchip/shmdr/init.c b/c/src/libchip/shmdr/init.c
index 14eddca0aa..8b62d6fb46 100644
--- a/c/src/libchip/shmdr/init.c
+++ b/c/src/libchip/shmdr/init.c
@@ -236,6 +236,7 @@ rtems_mpci_entry Shm_Initialization( void )
}
MPCI_Shm_extensions.fatal = MPCI_Fatal;
+
(void) rtems_extension_create(
rtems_build_name( 'M', 'P', 'E', 'X' ),
&MPCI_Shm_extensions,
diff --git a/c/src/tests/sptests/sp12/sp12.scn b/c/src/tests/sptests/sp12/sp12.scn
index ff120e7545..e87a729259 100644
--- a/c/src/tests/sptests/sp12/sp12.scn
+++ b/c/src/tests/sptests/sp12/sp12.scn
@@ -35,7 +35,7 @@ PRI5 - rtems_semaphore_release - nested
PRI5 - rtems_semaphore_release - restore priority
PRI5 - priority of PRI5 is 68
<pause>
-TA1 - rtems_semaphore_ident - smid => 10010002
+TA1 - rtems_semaphore_ident - smid => 14010002
TA1 - rtems_semaphore_obtain - wait forever on SM2
TA1 - got SM2
TA1 - rtems_semaphore_obtain - wait forever on SM3
diff --git a/c/src/tests/sptests/sp13/sp13.scn b/c/src/tests/sptests/sp13/sp13.scn
index 0cd60c9f1d..11adfb8eb3 100644
--- a/c/src/tests/sptests/sp13/sp13.scn
+++ b/c/src/tests/sptests/sp13/sp13.scn
@@ -1,5 +1,5 @@
*** TEST 13 ***
-TA1 - rtems_message_queue_ident - qid => 14010001
+TA1 - rtems_message_queue_ident - qid => 18010001
TA1 - rtems_message_queue_send - BUFFER 1 TO Q 1
TA1 - rtems_message_queue_send - BUFFER 2 TO Q 1
TA1 - rtems_task_wake_after - sleep 5 seconds
diff --git a/c/src/tests/sptests/sp15/sp15.scn b/c/src/tests/sptests/sp15/sp15.scn
index 4ae8989215..f1a800dc0d 100644
--- a/c/src/tests/sptests/sp15/sp15.scn
+++ b/c/src/tests/sptests/sp15/sp15.scn
@@ -1,8 +1,8 @@
*** TEST 15 ***
INIT - rtems_partition_create - partition 1
INIT - rtems_partition_create - partition 2
-TA1 - rtems_partition_ident - partition 1 id = 18010001
-TA1 - rtems_partition_ident - partition 2 id = 18010002
+TA1 - rtems_partition_ident - partition 1 id = 1c010001
+TA1 - rtems_partition_ident - partition 2 id = 1c010002
TA1 - rtems_partition_get_buffer - buffer 1 from partition 1 - 0x00000000
TA1 - rtems_partition_get_buffer - buffer 2 from partition 1 - 0x00000200
TA1 - rtems_partition_get_buffer - buffer 1 from partition 2 - 0x00000000
diff --git a/c/src/tests/sptests/sp16/sp16.scn b/c/src/tests/sptests/sp16/sp16.scn
index cb994c7300..36d533c2b4 100644
--- a/c/src/tests/sptests/sp16/sp16.scn
+++ b/c/src/tests/sptests/sp16/sp16.scn
@@ -1,5 +1,5 @@
*** TEST 16 ***
-TA1 - rtems_region_ident - rnid => 1c010002
+TA1 - rtems_region_ident - rnid => 20010002
TA1 - rtems_region_get_segment - wait on 100 byte segment from region 2
TA1 - got segment from region 2 - 0x00000f78
TA1 - rtems_region_get_segment - wait on 3K segment from region 3
diff --git a/c/src/tests/sptests/sp20/sp20.scn b/c/src/tests/sptests/sp20/sp20.scn
index 7c948c5469..bb4e8814da 100644
--- a/c/src/tests/sptests/sp20/sp20.scn
+++ b/c/src/tests/sptests/sp20/sp20.scn
@@ -1,19 +1,19 @@
*** TEST 20 ***
-TA1 - rtems_rate_monotonic_create id = 0x24010001
-TA1 - rtems_rate_monotonic_ident id = 0x24010001
-TA1 - (0x24010001) period 2
-TA2 - rtems_rate_monotonic_create id = 0x24010002
-TA2 - rtems_rate_monotonic_ident id = 0x24010002
-TA2 - (0x24010002) period 2
-TA3 - rtems_rate_monotonic_create id = 0x24010003
-TA3 - rtems_rate_monotonic_ident id = 0x24010003
-TA3 - (0x24010003) period 2
-TA4 - rtems_rate_monotonic_create id = 0x24010004
-TA4 - rtems_rate_monotonic_ident id = 0x24010004
-TA4 - (0x24010004) period 2
-TA5 - rtems_rate_monotonic_create id = 0x24010005
-TA5 - rtems_rate_monotonic_ident id = 0x24010005
-TA5 - (0x24010005) period 100
+TA1 - rtems_rate_monotonic_create id = 0x28010001
+TA1 - rtems_rate_monotonic_ident id = 0x28010001
+TA1 - (0x28010001) period 2
+TA2 - rtems_rate_monotonic_create id = 0x28010002
+TA2 - rtems_rate_monotonic_ident id = 0x28010002
+TA2 - (0x28010002) period 2
+TA3 - rtems_rate_monotonic_create id = 0x28010003
+TA3 - rtems_rate_monotonic_ident id = 0x28010003
+TA3 - (0x28010003) period 2
+TA4 - rtems_rate_monotonic_create id = 0x28010004
+TA4 - rtems_rate_monotonic_ident id = 0x28010004
+TA4 - (0x28010004) period 2
+TA5 - rtems_rate_monotonic_create id = 0x28010005
+TA5 - rtems_rate_monotonic_ident id = 0x28010005
+TA5 - (0x28010005) period 100
TA5 - PERIODS CHECK OK (1)
TA5 - PERIODS CHECK OK (2)
TA5 - PERIODS CHECK OK (3)
diff --git a/c/src/tests/sptests/sp22/sp22.scn b/c/src/tests/sptests/sp22/sp22.scn
index 8d2acd1867..6fb08156c5 100644
--- a/c/src/tests/sptests/sp22/sp22.scn
+++ b/c/src/tests/sptests/sp22/sp22.scn
@@ -1,8 +1,8 @@
*** TEST 22 ***
INIT - rtems_timer_create - creating timer 1
-INIT - timer 1 has id (0xc010001)
+INIT - timer 1 has id (0x10010001)
TA1 - rtems_timer_ident - identing timer 1
-TA1 - timer 1 has id (0xc010001)
+TA1 - timer 1 has id (0x10010001)
TA1 - rtems_clock_get - 09:00:00 12/31/1988
TA1 - rtems_timer_fire_after - timer 1 in 3 seconds
TA1 - rtems_task_suspend( RTEMS_SELF )
diff --git a/c/src/tests/sptests/sp23/sp23.scn b/c/src/tests/sptests/sp23/sp23.scn
index 70522d79ab..b8b5633855 100644
--- a/c/src/tests/sptests/sp23/sp23.scn
+++ b/c/src/tests/sptests/sp23/sp23.scn
@@ -1,6 +1,6 @@
*** TEST 23 ***
INIT - rtems_port_create - DP1 - int = 0x00001000 ext = 0x00002000
-TA1 - rtems_port_ident - 0x20010001
+TA1 - rtems_port_ident - 0x24010001
TA1 - rtems_port_external_to_internal - 0x0000200e => 0x0000100e
TA1 - rtems_port_internal_to_external - 0x0000100e => 0x0000200e
TA1 - rtems_port_external_to_internal - 0x0000300e => 0x0000300e
diff --git a/c/src/tests/sptests/sp25/sp25.scn b/c/src/tests/sptests/sp25/sp25.scn
index f72da25944..af2599663d 100644
--- a/c/src/tests/sptests/sp25/sp25.scn
+++ b/c/src/tests/sptests/sp25/sp25.scn
@@ -1,5 +1,5 @@
*** TEST 25 ***
-TA1 - rtems_region_ident - 0x1c010002
+TA1 - rtems_region_ident - 0x20010002
TA1 - rtems_region_get_segment - wait on 64 byte segment from region 1
TA1 - got segment from region 1 - 0x0000f9b8
TA1 - rtems_region_get_segment - wait on 128 byte segment from region 1