summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/unix
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1995-07-12 19:47:25 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1995-07-12 19:47:25 +0000
commit637df35f96d8023056369fcf2c9943419f1a1b74 (patch)
treea12bd461bf892ccaff6c67571432f0535eb03e96 /c/src/lib/libbsp/unix
parentadded David Glessner's 68302 work. (diff)
downloadrtems-637df35f96d8023056369fcf2c9943419f1a1b74.tar.bz2
Ada95, gnat, go32
Diffstat (limited to 'c/src/lib/libbsp/unix')
-rw-r--r--c/src/lib/libbsp/unix/posix/clock/clock.c122
-rw-r--r--c/src/lib/libbsp/unix/posix/console/console.c37
-rw-r--r--c/src/lib/libbsp/unix/posix/include/bsp.h88
-rw-r--r--c/src/lib/libbsp/unix/posix/include/coverhd.h111
-rw-r--r--c/src/lib/libbsp/unix/posix/shmsupp/README9
-rw-r--r--c/src/lib/libbsp/unix/posix/shmsupp/addrconv.c32
-rw-r--r--c/src/lib/libbsp/unix/posix/shmsupp/getcfg.c136
-rw-r--r--c/src/lib/libbsp/unix/posix/shmsupp/intr.c31
-rw-r--r--c/src/lib/libbsp/unix/posix/shmsupp/lock.c117
-rw-r--r--c/src/lib/libbsp/unix/posix/shmsupp/mpisr.c29
-rw-r--r--c/src/lib/libbsp/unix/posix/startup/bspclean.c37
-rw-r--r--c/src/lib/libbsp/unix/posix/startup/bspstart.c314
-rw-r--r--c/src/lib/libbsp/unix/posix/startup/exit.c28
-rw-r--r--c/src/lib/libbsp/unix/posix/startup/rtems-ctor.cc108
-rw-r--r--c/src/lib/libbsp/unix/posix/startup/setvec.c60
15 files changed, 1259 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/unix/posix/clock/clock.c b/c/src/lib/libbsp/unix/posix/clock/clock.c
new file mode 100644
index 0000000000..846d223c19
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/clock/clock.c
@@ -0,0 +1,122 @@
+/* Clock
+ *
+ * This routine initializes the interval timer on the
+ * PA-RISC CPU. The tick frequency is specified by the bsp.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * 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$
+ */
+
+#include <rtems.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <signal.h>
+#include <time.h>
+
+extern rtems_configuration_table Configuration;
+extern sigset_t UNIX_SIGNAL_MASK;
+
+/*
+ * Function prototypes
+ */
+
+void Install_clock();
+void Clock_isr();
+void Clock_exit();
+
+/*
+ * CPU_HPPA_CLICKS_PER_TICK is either a #define or an rtems_unsigned32
+ * allocated and set by bsp_start()
+ */
+
+#ifndef CPU_HPPA_CLICKS_PER_TICK
+extern rtems_unsigned32 CPU_HPPA_CLICKS_PER_TICK;
+#endif
+
+volatile rtems_unsigned32 Clock_driver_ticks;
+
+struct itimerval new;
+
+rtems_device_driver
+Clock_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *pargp,
+ rtems_id tid,
+ rtems_unsigned32 *rval
+)
+{
+ Install_clock(Clock_isr);
+}
+
+void
+ReInstall_clock(rtems_isr_entry new_clock_isr)
+{
+ rtems_unsigned32 isrlevel = 0;
+
+ rtems_interrupt_disable(isrlevel);
+ (void)set_vector(new_clock_isr, SIGALRM, 1);
+ rtems_interrupt_enable(isrlevel);
+}
+
+void
+Install_clock(rtems_isr_entry clock_isr)
+{
+ 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, SIGALRM, 1);
+
+ setitimer(ITIMER_REAL, &new, 0);
+
+ atexit(Clock_exit);
+}
+
+void
+Clock_isr(int vector)
+{
+ Clock_driver_ticks++;
+
+ rtems_clock_tick();
+}
+
+/*
+ * Called via atexit()
+ * Remove the clock signal
+ */
+
+void
+Clock_exit(void)
+{
+ 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);
+
+ (void)set_vector(0, SIGALRM, 1);
+}
diff --git a/c/src/lib/libbsp/unix/posix/console/console.c b/c/src/lib/libbsp/unix/posix/console/console.c
new file mode 100644
index 0000000000..7b6ee1b33d
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/console/console.c
@@ -0,0 +1,37 @@
+/*
+ * Console IO Support Routines
+ *
+ * These provide UNIX-like read and write calls for the C library.
+ *
+ * COPYRIGHT (c) 1994 by Division Incorporated
+ *
+ * To anyone who acknowledges that this file is provided "AS IS"
+ * without any express or implied warranty:
+ * permission to use, copy, modify, and distribute this file
+ * for any purpose is hereby granted without fee, provided that
+ * the above copyright notice and this notice appears in all
+ * copies, and that the name of Division Incorporated not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific, written prior permission.
+ * Division Incorporated makes no representations about the
+ * suitability of this software for any purpose.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+
+#include <unistd.h>
+#include <errno.h>
+
+rtems_device_driver
+console_initialize(rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg,
+ rtems_id self,
+ rtems_unsigned32 * status)
+{
+ *status = RTEMS_SUCCESSFUL;
+}
+
diff --git a/c/src/lib/libbsp/unix/posix/include/bsp.h b/c/src/lib/libbsp/unix/posix/include/bsp.h
new file mode 100644
index 0000000000..84cdb1f260
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/include/bsp.h
@@ -0,0 +1,88 @@
+/* bsp.h
+ *
+ * This include file contains all Solaris 2.3 UNIX definitions.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * 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$
+ */
+
+#ifndef __SOLARIS23_h
+#define __SOLARIS23_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems.h>
+#include <iosupp.h>
+
+/*
+ * Define the time limits for RTEMS Test Suite test durations.
+ * Long test and short test duration limits are provided. These
+ * values are in seconds and need to be converted to ticks for the
+ * application.
+ *
+ */
+
+#define MAX_LONG_TEST_DURATION 300 /* 5 minutes = 300 seconds */
+#define MAX_SHORT_TEST_DURATION 3 /* 3 seconds */
+
+/*
+ * Stuff for Time Test 27
+ */
+
+#define MUST_WAIT_FOR_INTERRUPT 1
+
+#define Install_tm27_vector( handler ) \
+ set_vector( (handler), 16, 1 )
+
+#define Cause_tm27_intr() \
+ raise( 16 )
+
+#define Clear_tm27_intr()
+
+#define Lower_tm27_intr() \
+ _ISR_Set_level( 0 );
+
+#define RAM_START 0
+#define RAM_END 0x100000
+
+/* miscellaneous stuff assumed to exist */
+
+extern rtems_configuration_table BSP_Configuration;
+
+#define INTERRUPT_EXTERNAL_MPCI 0
+
+/* functions */
+
+void bsp_start( void );
+void bsp_cleanup( void );
+
+/* miscellaneous stuff assumed to exist */
+
+extern rtems_configuration_table BSP_Configuration; /* owned by BSP */
+extern rtems_cpu_table Cpu_table; /* owned by BSP */
+
+extern int rtems_argc;
+extern char **rtems_argv;
+extern char **rtems_envp;
+
+extern rtems_unsigned32 bsp_isr_level;
+
+extern char *rtems_progname; /* UNIX executable name */
+
+extern int cpu_number;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/c/src/lib/libbsp/unix/posix/include/coverhd.h b/c/src/lib/libbsp/unix/posix/include/coverhd.h
new file mode 100644
index 0000000000..16d62e5e75
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/include/coverhd.h
@@ -0,0 +1,111 @@
+/* coverhd.h
+ *
+ * This include file has defines to represent the overhead associated
+ * with calling a particular directive from C. These are used in the
+ * Timing Test Suite to ignore the overhead required to pass arguments
+ * to directives. On some CPUs and/or target boards, this overhead
+ * is significant and makes it difficult to distinguish internal
+ * RTEMS execution time from that used to call the directive.
+ *
+ * NOTE: If these are all zero, then the times reported include all
+ * all calling overhead including passing of arguments.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * 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$
+ */
+
+#ifndef __COVERHD_h
+#define __COVERHD_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CALLING_OVERHEAD_INITIALIZE_EXECUTIVE 0
+#define CALLING_OVERHEAD_SHUTDOWN_EXECUTIVE 0
+#define CALLING_OVERHEAD_TASK_CREATE 0
+#define CALLING_OVERHEAD_TASK_IDENT 0
+#define CALLING_OVERHEAD_TASK_START 0
+#define CALLING_OVERHEAD_TASK_RESTART 0
+#define CALLING_OVERHEAD_TASK_DELETE 0
+#define CALLING_OVERHEAD_TASK_SUSPEND 0
+#define CALLING_OVERHEAD_TASK_RESUME 0
+#define CALLING_OVERHEAD_TASK_SET_PRIORITY 0
+#define CALLING_OVERHEAD_TASK_MODE 0
+#define CALLING_OVERHEAD_TASK_GET_NOTE 0
+#define CALLING_OVERHEAD_TASK_SET_NOTE 0
+#define CALLING_OVERHEAD_TASK_WAKE_WHEN 0
+#define CALLING_OVERHEAD_TASK_WAKE_AFTER 0
+#define CALLING_OVERHEAD_INTERRUPT_CATCH 0
+#define CALLING_OVERHEAD_CLOCK_GET 0
+#define CALLING_OVERHEAD_CLOCK_SET 0
+#define CALLING_OVERHEAD_CLOCK_TICK 0
+
+#define CALLING_OVERHEAD_TIMER_CREATE 0
+#define CALLING_OVERHEAD_TIMER_IDENT 0
+#define CALLING_OVERHEAD_TIMER_DELETE 0
+#define CALLING_OVERHEAD_TIMER_FIRE_AFTER 0
+#define CALLING_OVERHEAD_TIMER_FIRE_WHEN 0
+#define CALLING_OVERHEAD_TIMER_RESET 0
+#define CALLING_OVERHEAD_TIMER_CANCEL 0
+#define CALLING_OVERHEAD_SEMAPHORE_CREATE 0
+#define CALLING_OVERHEAD_SEMAPHORE_IDENT 0
+#define CALLING_OVERHEAD_SEMAPHORE_DELETE 0
+#define CALLING_OVERHEAD_SEMAPHORE_OBTAIN 0
+#define CALLING_OVERHEAD_SEMAPHORE_RELEASE 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_CREATE 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_IDENT 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_DELETE 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_SEND 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH 0
+
+#define CALLING_OVERHEAD_EVENT_SEND 0
+#define CALLING_OVERHEAD_EVENT_RECEIVE 0
+#define CALLING_OVERHEAD_SIGNAL_CATCH 0
+#define CALLING_OVERHEAD_SIGNAL_SEND 0
+#define CALLING_OVERHEAD_PARTITION_CREATE 0
+#define CALLING_OVERHEAD_PARTITION_IDENT 0
+#define CALLING_OVERHEAD_PARTITION_DELETE 0
+#define CALLING_OVERHEAD_PARTITION_GET_BUFFER 0
+#define CALLING_OVERHEAD_PARTITION_RETURN_BUFFER 0
+#define CALLING_OVERHEAD_REGION_CREATE 0
+#define CALLING_OVERHEAD_REGION_IDENT 0
+#define CALLING_OVERHEAD_REGION_DELETE 0
+#define CALLING_OVERHEAD_REGION_GET_SEGMENT 0
+#define CALLING_OVERHEAD_REGION_RETURN_SEGMENT 0
+#define CALLING_OVERHEAD_PORT_CREATE 0
+#define CALLING_OVERHEAD_PORT_IDENT 0
+#define CALLING_OVERHEAD_PORT_DELETE 0
+#define CALLING_OVERHEAD_PORT_EXTERNAL_TO_INTERNAL 0
+#define CALLING_OVERHEAD_PORT_INTERNAL_TO_EXTERNAL 0
+
+#define CALLING_OVERHEAD_IO_INITIALIZE 0
+#define CALLING_OVERHEAD_IO_OPEN 0
+#define CALLING_OVERHEAD_IO_CLOSE 0
+#define CALLING_OVERHEAD_IO_READ 0
+#define CALLING_OVERHEAD_IO_WRITE 0
+#define CALLING_OVERHEAD_IO_CONTROL 0
+#define CALLING_OVERHEAD_FATAL_ERROR_OCCURRED 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_CREATE 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_IDENT 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_DELETE 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_CANCEL 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD 0
+#define CALLING_OVERHEAD_MULTIPROCESSING_ANNOUNCE 0
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/c/src/lib/libbsp/unix/posix/shmsupp/README b/c/src/lib/libbsp/unix/posix/shmsupp/README
new file mode 100644
index 0000000000..93d6fcbe8c
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/shmsupp/README
@@ -0,0 +1,9 @@
+#
+# $Id$
+#
+
+This directory contains the SHM driver support files for
+System V/POSIX derived UNIX flavors.
+
+WARNING: The interrupt support in this directory currently will
+ only work in a homogeneous system.
diff --git a/c/src/lib/libbsp/unix/posix/shmsupp/addrconv.c b/c/src/lib/libbsp/unix/posix/shmsupp/addrconv.c
new file mode 100644
index 0000000000..fd3ba689bd
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/shmsupp/addrconv.c
@@ -0,0 +1,32 @@
+/* rtems_unsigned32 *Shm_Convert_address( addr )
+ *
+ * No address range conversion is required.
+ *
+ * Input parameters:
+ * addr - address to convert
+ *
+ * Output parameters:
+ * returns - converted address
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * 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$
+ */
+
+#include <rtems.h>
+
+#include <bsp.h>
+#include <shm.h>
+
+void *Shm_Convert_address(
+ void *addr
+)
+{
+ return ( addr );
+}
diff --git a/c/src/lib/libbsp/unix/posix/shmsupp/getcfg.c b/c/src/lib/libbsp/unix/posix/shmsupp/getcfg.c
new file mode 100644
index 0000000000..14158f4516
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/shmsupp/getcfg.c
@@ -0,0 +1,136 @@
+/* void Shm_get_config( localnode, &shmcfg )
+ *
+ * This routine initializes, if necessary, and returns a pointer
+ * to the Shared Memory Configuration Table for the UNIX
+ * simulator.
+ *
+ * INPUT PARAMETERS:
+ * localnode - local node number
+ * shmcfg - address of pointer to SHM Config Table
+ *
+ * OUTPUT PARAMETERS:
+ * *shmcfg - pointer to SHM Config Table
+ *
+ * NOTES: The MP interrupt used is the Runway bus' ability to directly
+ * address the control registers of up to four CPUs and cause
+ * interrupts on them.
+ *
+ * The following table illustrates the configuration limitations:
+ *
+ * BUS MAX
+ * MODE ENDIAN NODES
+ * ========= ====== =======
+ * POLLED BIG 2+
+ * INTERRUPT BIG 2..4
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * 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$
+ */
+
+#include <rtems.h>
+
+#include <shm.h>
+#include <bsp.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/sem.h>
+
+#define INTERRUPT 0 /* can be interrupt or polling */
+#define POLLING 1
+
+shm_config_table BSP_shm_cfgtbl;
+
+int semid;
+
+void Shm_Cause_interrupt_unix(
+ rtems_unsigned32 node
+);
+
+void Shm_Get_configuration(
+ rtems_unsigned32 localnode,
+ shm_config_table **shmcfg
+)
+{
+ rtems_unsigned32 maximum_nodes;
+ int i;
+ int shmid;
+ char *shm_addr;
+ key_t shm_key;
+ key_t sem_key;
+ struct sembuf sb;
+ int status;
+
+ shm_key = 0xa000;
+
+ shmid = shmget(shm_key, 16 * KILOBYTE, IPC_CREAT | 0660);
+ if ( shmid == -1 ) {
+ perror( "shmget" );
+ exit( 0 );
+ }
+
+ shm_addr = shmat(shmid, (char *)0, SHM_RND);
+ if ( shm_addr == (void *)-1 ) {
+ perror( "shmat" );
+ exit( 0 );
+ }
+
+ sem_key = 0xa001;
+
+ maximum_nodes = Shm_RTEMS_MP_Configuration->maximum_nodes;
+ semid = semget(sem_key, maximum_nodes + 1, IPC_CREAT | 0660);
+ if ( semid == -1 ) {
+ perror( "semget" );
+ exit( 0 );
+ }
+
+ if ( Shm_Is_master_node() ) {
+ for ( i=0 ; i <= maximum_nodes ; i++ ) {
+ sb.sem_op = 1;
+ sb.sem_num = i;
+ sb.sem_flg = 0;
+ status = semop( semid, &sb, 1 );
+ if ( status == -1 ) {
+ fprintf( stderr, "Sem init failed %d\n", errno ); fflush( stderr );
+ exit( 0 );
+ }
+ }
+ }
+
+ BSP_shm_cfgtbl.base = (vol_u32 *)shm_addr;
+ BSP_shm_cfgtbl.length = 16 * KILOBYTE;
+ BSP_shm_cfgtbl.format = SHM_BIG;
+
+ BSP_shm_cfgtbl.cause_intr = Shm_Cause_interrupt_unix;
+
+#ifdef NEUTRAL_BIG
+ BSP_shm_cfgtbl.convert = NULL_CONVERT;
+#else
+ BSP_shm_cfgtbl.convert = CPU_swap_u32;
+#endif
+
+#if ( POLLING == 1 )
+ 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;
+#else
+ BSP_shm_cfgtbl.poll_intr = INTR_MODE;
+ BSP_shm_cfgtbl.Intr.address = 0; /* process id? */
+ BSP_shm_cfgtbl.Intr.value = 0; /* signal to send? */
+ BSP_shm_cfgtbl.Intr.length = LONG;
+#endif
+
+ *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
new file mode 100644
index 0000000000..44259479db
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/shmsupp/intr.c
@@ -0,0 +1,31 @@
+/* void Shm_interrupt_unix( node )
+ *
+ * This routine is the shared memory driver routine which
+ * generates interrupts to other CPUs.
+ *
+ * Input parameters:
+ * node - destination of this packet (0 = broadcast)
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * 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$
+ */
+
+#include <rtems.h>
+#include <shm.h>
+
+#include <stdio.h>
+
+void Shm_Cause_interrupt_unix(
+ rtems_unsigned32 node
+)
+{
+}
diff --git a/c/src/lib/libbsp/unix/posix/shmsupp/lock.c b/c/src/lib/libbsp/unix/posix/shmsupp/lock.c
new file mode 100644
index 0000000000..da39cc86f5
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/shmsupp/lock.c
@@ -0,0 +1,117 @@
+/* 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, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * 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$
+ */
+
+#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;
+
+/*
+ * 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_cb - Shm_Locked_queues ) / sizeof( Shm_Locked_queue_Control );
+}
+
+/* Shm_Lock( &lq_cb )
+ *
+ * This shared memory locked queue support routine locks the
+ * specified locked queue. It disables interrupts to prevent
+ * a deadlock condition.
+ */
+
+void Shm_Lock(
+ Shm_Locked_queue_Control *lq_cb
+)
+{
+ rtems_unsigned32 isr_level;
+ struct sembuf sb;
+ int status;
+
+ isr_level = 0;
+
+ sb.sem_num = lq_cb->lock;
+ sb.sem_op = -1;
+ sb.sem_flg = 0;
+ rtems_interrupt_disable( isr_level );
+
+ Shm_isrstat = isr_level;
+
+ while (1) {
+ status = semop(semid, &sb, 1);
+ if ( status == 0 )
+ break;
+ if ( status == -1 && errno == EINTR )
+ continue;
+
+ fprintf( stderr, "shm lock (%d %d)\n", status, errno );
+ exit( 0 );
+ }
+}
+
+/*
+ * Shm_Unlock
+ *
+ * Unlock the lock for the specified locked queue.
+ */
+
+void Shm_Unlock(
+ Shm_Locked_queue_Control *lq_cb
+)
+{
+ rtems_unsigned32 isr_level;
+ struct sembuf sb;
+ int status;
+
+ isr_level = 0;
+
+ 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;
+ if ( status == -1 && errno == EINTR )
+ continue;
+
+ fprintf( stderr, "shm lock (%d %d)\n", status, errno ); fflush( stderr );
+ exit( 0 );
+ }
+
+ 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
new file mode 100644
index 0000000000..02bee168a6
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/shmsupp/mpisr.c
@@ -0,0 +1,29 @@
+/* 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
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * 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$
+ */
+
+#include <rtems.h>
+
+#include <bsp.h>
+#include <shm.h>
+
+void Shm_setvec( void )
+{
+ set_vector( Shm_isr, INTERRUPT_EXTERNAL_MPCI, 1 );
+}
diff --git a/c/src/lib/libbsp/unix/posix/startup/bspclean.c b/c/src/lib/libbsp/unix/posix/startup/bspclean.c
new file mode 100644
index 0000000000..22feedb7ad
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/startup/bspclean.c
@@ -0,0 +1,37 @@
+/* bsp_cleanup()
+ *
+ * This routine normally is part of start.s and returns
+ * control to a monitor but on the UNIX simulator
+ * we do that directly from main.c.
+ *
+ * INPUT: NONE
+ *
+ * OUTPUT: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * 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$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+
+/*
+ * The app has "exited" (called rtems_shutdown_executive)
+ */
+
+void bsp_cleanup( void )
+{
+ /*
+ * Invoke any fatal error extension and "halt"
+ * By definition, rtems_fatal_error_occurred does not return.
+ */
+
+ 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
new file mode 100644
index 0000000000..a2ec1b1911
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/startup/bspstart.c
@@ -0,0 +1,314 @@
+/*
+ * @(#)bspstart.c 1.7 - 95/04/07
+ *
+ */
+
+/* bsp_start()
+ *
+ * This routine starts the application. It includes application,
+ * board, and monitor specific initialization and configuration.
+ * The generic CPU dependent initialization has been performed
+ * before this routine is invoked.
+ *
+ * Called by RTEMS::RTEMS constructor in startup-ctor.cc
+ *
+ * INPUT: NONE
+ *
+ * OUTPUT: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * 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$
+ */
+
+#include <rtems.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include <bsp.h>
+#include <libcsupport.h>
+
+#ifdef STACK_CHECKER_ON
+#include <stackchk.h>
+#endif
+
+extern rtems_configuration_table Configuration;
+
+/*
+ * A copy of the configuration table from the application
+ * with some changes applied to it.
+ */
+
+rtems_configuration_table BSP_Configuration;
+rtems_multiprocessing_table BSP_Multiprocessing;
+rtems_cpu_table Cpu_table;
+rtems_unsigned32 bsp_isr_level;
+rtems_unsigned32 Heap_size;
+int rtems_argc;
+char **rtems_argv;
+char **rtems_envp;
+
+
+#define WORKSPACE_SIZE (WORKSPACE_MB * (1024 * 1024))
+#define HEAPSPACE_SIZE (HEAPSPACE_MB * (1024 * 1024))
+
+rtems_unsigned8 MY_WORK_SPACE[ WORKSPACE_SIZE ] CPU_STRUCTURE_ALIGNMENT;
+
+/*
+ * Amount to increment itimer by each pass
+ * It is a variable instead of a #define to allow the 'looptest'
+ * script to bump it without recompiling rtems
+ */
+
+rtems_unsigned32 CPU_CLICKS_PER_TICK;
+
+/*
+ * Function: bsp_libc_init
+ * Created: 94/12/6
+ *
+ * Description:
+ * Initialize whatever libc we are using
+ * called from bsp_postdriver_hook
+ *
+ *
+ * Parameters:
+ * none
+ *
+ * Returns:
+ * none.
+ *
+ * Side Effects:
+ *
+ *
+ * Notes:
+ *
+ * Deficiencies/ToDo:
+ *
+ *
+ */
+
+void
+bsp_libc_init(void)
+{
+ void *heap_start;
+
+ Heap_size = HEAPSPACE_SIZE;
+ heap_start = 0;
+
+ RTEMS_Malloc_Initialize((void *)heap_start, Heap_size, 1024 * 1024);
+
+ libc_init(1);
+}
+
+
+/*
+ * 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.
+ *
+ * Parameters:
+ * none
+ *
+ * Returns:
+ * nada
+ *
+ * Side Effects:
+ * installs a few extensions
+ *
+ * Notes:
+ * Must not use libc (to do io) from here, since drivers are
+ * not yet initialized.
+ *
+ * Deficiencies/ToDo:
+ *
+ *
+ */
+
+void
+bsp_pretasking_hook(void)
+{
+ bsp_libc_init();
+
+#ifdef STACK_CHECKER_ON
+ /*
+ * Initialize the stack bounds checker
+ * We can either turn it on here or from the app.
+ */
+
+ Stack_check_Initialize();
+#endif
+
+#ifdef RTEMS_DEBUG
+ rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
+#endif
+}
+
+/*
+ * Function: bsp_start
+ * Created: 94/12/6
+ *
+ * Description:
+ * called by crt0 as our "main" equivalent
+ *
+ *
+ *
+ * Parameters:
+ *
+ *
+ * Returns:
+ *
+ *
+ * Side Effects:
+ *
+ *
+ * Notes:
+ *
+ *
+ * Deficiencies/ToDo:
+ *
+ *
+ */
+
+void
+bsp_start(void)
+{
+ struct stat stat_buf;
+ char buf[256];
+ char node[6];
+ char *home;
+ int fd;
+
+ /*
+ * Copy the table
+ */
+
+ BSP_Configuration = Configuration;
+
+ /*
+ * If the node number is -1 then the application better provide
+ * it through the file $HOME/rtems_node
+ */
+
+ BSP_Multiprocessing.node = -1;
+
+ if (BSP_Configuration.User_multiprocessing_table) {
+ if (BSP_Configuration.User_multiprocessing_table->node == -1) {
+ home = getenv("HOME");
+ sprintf(buf, "%s/%s", home, "rtems_node");
+ if ((stat(buf, &stat_buf)) == 0) {
+ fd = open(buf, O_RDONLY);
+ read(fd, node, 5);
+ close(fd);
+ unlink(buf);
+ BSP_Multiprocessing = *BSP_Configuration.User_multiprocessing_table;
+ BSP_Multiprocessing.node = atoi(node);
+ BSP_Configuration.User_multiprocessing_table = &BSP_Multiprocessing;
+ }
+ if (BSP_Configuration.User_multiprocessing_table->maximum_nodes == -1) {
+ home = getenv("HOME");
+ sprintf(buf, "%s/%s", home, "rtems_max_node");
+ if ((stat(buf, &stat_buf)) == 0) {
+ fd = open(buf, O_RDONLY);
+ read(fd, node, 5);
+ close(fd);
+ BSP_Multiprocessing.maximum_nodes = atoi(node);
+ }
+ }
+ }
+ }
+
+ /*
+ * Set cpu_number to accurately reflect our cpu number
+ */
+
+ if (BSP_Configuration.User_multiprocessing_table)
+ cpu_number = BSP_Configuration.User_multiprocessing_table->node - 1;
+ else
+ cpu_number = 0;
+
+ BSP_Configuration.work_space_start = (void *)MY_WORK_SPACE;
+ if (BSP_Configuration.work_space_size)
+ BSP_Configuration.work_space_size = WORKSPACE_SIZE;
+
+ /*
+ * Set up our hooks
+ * Make sure libc_init is done before drivers init'd so that
+ * they can use atexit()
+ */
+
+ Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */
+
+ Cpu_table.predriver_hook = NULL;
+
+ Cpu_table.postdriver_hook = NULL;
+
+ Cpu_table.idle_task = NULL; /* do not override system IDLE task */
+
+ /*
+ * Don't zero out the workspace since it is in the BSS under UNIX.
+ */
+
+ Cpu_table.do_zero_of_workspace = FALSE;
+
+ /*
+ * XXX; interrupt stack not currently used, so this doesn't matter
+ */
+
+ Cpu_table.interrupt_stack_size = (12 * 1024);
+
+ Cpu_table.extra_system_initialization_stack = 0;
+
+ /*
+ * Add 1 region for RTEMS Malloc
+ */
+
+ BSP_Configuration.maximum_regions++;
+
+#ifdef RTEMS_NEWLIB
+ /*
+ * Add 1 extension for newlib libc
+ */
+
+ BSP_Configuration.maximum_extensions++;
+#endif
+
+#ifdef STACK_CHECKER_ON
+ /*
+ * Add 1 extension for stack checker
+ */
+
+ BSP_Configuration.maximum_extensions++;
+#endif
+
+ /*
+ * Add 1 extension for MPCI_fatal
+ */
+
+ if (BSP_Configuration.User_multiprocessing_table)
+ BSP_Configuration.maximum_extensions++;
+
+ CPU_CLICKS_PER_TICK = 1;
+
+ /*
+ * Start most of RTEMS
+ * main() will start the rest
+ */
+
+ bsp_isr_level = rtems_initialize_executive_early(
+ &BSP_Configuration,
+ &Cpu_table
+ );
+}
diff --git a/c/src/lib/libbsp/unix/posix/startup/exit.c b/c/src/lib/libbsp/unix/posix/startup/exit.c
new file mode 100644
index 0000000000..ac3c840832
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/startup/exit.c
@@ -0,0 +1,28 @@
+/*
+ * exit
+ *
+ * This routine returns control to "the pre-RTEMS environment".
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * 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$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include <clockdrv.h>
+
+void _exit( void )
+{
+ /* Clock or Timer cleanup is run by at_exit() */
+
+ Io_cleanup();
+
+ bsp_cleanup();
+}
diff --git a/c/src/lib/libbsp/unix/posix/startup/rtems-ctor.cc b/c/src/lib/libbsp/unix/posix/startup/rtems-ctor.cc
new file mode 100644
index 0000000000..4c55f3798f
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/startup/rtems-ctor.cc
@@ -0,0 +1,108 @@
+// @(#)rtems-ctor.cc 1.6 - 95/04/25
+//
+//
+
+/*
+ * rtems-ctor.cc
+ *
+ * Description:
+ * This file exists solely to (try to) ensure RTEMS is initialized
+ * before any global constructors are run.
+ *
+ * The problem:
+ * Global constructors might reasonably expect that new() will
+ * work, but since new() uses malloc() which uses RTEMS regions,
+ * it can not be called until after initialize_executive().
+ *
+ * Global constructors are called in GNU systems one of 2 ways:
+ *
+ * an "invisible" call to __main() inserted by compiler
+ * This __main() calls __do_global_ctors() which
+ * walks thru the table and calls all global
+ * constructors.
+ *
+ * or -
+ * A special section is put into the linked binary. The
+ * system startup code knows to run the constructors in
+ * this special section before calling main().
+ *
+ * By making RTEMS initialization a constructor, we avoid having
+ * too much about all this. All we have to guarantee is that
+ * this constructor is the first one run.
+ *
+ *
+ * So for the first case above, this is what happens
+ *
+ * host crt0
+ * main()
+ * __main()
+ * __do_global_ctors()
+ * bsp_start()
+ * init_executive_early()
+ * <<any other constructors>>
+ *
+ * init_executive_late()
+ * bsp_cleanup()
+ *
+ * TODO:
+ *
+ */
+
+#include <bsp.h>
+
+/*
+ * RTEMS program name
+ * Probably not used by anyone, but it is nice to have it.
+ * Actually the UNIX version of CPU_INVOKE_DEBUGGER will probably
+ * need to use it
+ */
+
+char *rtems_progname;
+
+class RTEMS {
+ public:
+ RTEMS();
+ ~RTEMS();
+};
+
+RTEMS rtems_constructor;
+
+RTEMS::RTEMS()
+{
+ bsp_start();
+}
+
+RTEMS::~RTEMS()
+{
+ bsp_cleanup();
+}
+
+extern "C" {
+ int
+ main(int argc,
+ char **argv,
+ char **environp)
+ {
+ rtems_argc = argc;
+ rtems_argv = argv;
+ rtems_envp = environp;
+
+ if ((argc > 0) && argv && argv[0])
+ rtems_progname = argv[0];
+ else
+ rtems_progname = "RTEMS";
+
+ /*
+ * Start multitasking
+ */
+
+ rtems_initialize_executive_late( bsp_isr_level );
+
+ /*
+ * Returns when multitasking is stopped
+ * This allows our destructors to get run normally
+ */
+
+ return 0;
+ }
+}
diff --git a/c/src/lib/libbsp/unix/posix/startup/setvec.c b/c/src/lib/libbsp/unix/posix/startup/setvec.c
new file mode 100644
index 0000000000..fef64752d5
--- /dev/null
+++ b/c/src/lib/libbsp/unix/posix/startup/setvec.c
@@ -0,0 +1,60 @@
+/* set_vector
+ *
+ * This routine installs an interrupt vector on UNIX.
+ *
+ * INPUT:
+ * handler - interrupt handler entry point
+ * vector - vector number
+ * type - 0 indicates raw hardware connect
+ * 1 indicates RTEMS interrupt connect
+ *
+ * NOTE 'type' is ignored on hppa; all interrupts are owned by RTEMS
+ *
+ * RETURNS:
+ * address of previous interrupt handler
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * 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$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+
+/*
+ * Install an interrupt handler in the right place
+ * given its vector number from cpu/hppa.h
+ * There are 2 places an interrupt can be installed
+ * _ISR_Vector_table
+ * bsp interrupt XXX: nyi
+ *
+ * We decide which based on the vector number
+ */
+
+unix_isr_entry
+set_vector( /* returns old vector */
+ rtems_isr_entry handler, /* isr routine */
+ rtems_vector_number vector, /* vector number */
+ int type /* RTEMS or RAW intr */
+)
+{
+ rtems_isr_entry rtems_isr_ptr;
+ proc_ptr raw_isr_ptr;
+
+ if ( type ) {
+ rtems_interrupt_catch( handler, vector, &rtems_isr_ptr );
+ return (unix_isr_entry) rtems_isr_ptr;
+ } else {
+ _CPU_ISR_install_vector( vector, (proc_ptr) handler, &raw_isr_ptr );
+ return (unix_isr_entry) raw_isr_ptr;
+ }
+
+}
+
+