summaryrefslogtreecommitdiffstats
path: root/c/src/exec/libcsupport
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/exec/libcsupport')
-rw-r--r--c/src/exec/libcsupport/Makefile.am3
-rw-r--r--c/src/exec/libcsupport/include/console.h4
-rw-r--r--c/src/exec/libcsupport/include/rtems/error.h9
-rw-r--r--c/src/exec/libcsupport/include/sys/termios.h10
-rw-r--r--c/src/exec/libcsupport/src/Makefile.am33
-rw-r--r--c/src/exec/libcsupport/src/gxx_wrappers.c219
-rw-r--r--c/src/exec/libcsupport/src/libio.c4
-rw-r--r--c/src/exec/libcsupport/src/malloc.c2
-rw-r--r--c/src/exec/libcsupport/src/scandir.c2
-rw-r--r--c/src/exec/libcsupport/src/termios.c15
-rw-r--r--c/src/exec/libcsupport/src/termiosreserveresources.c5
-rw-r--r--c/src/exec/libcsupport/src/unmount.c12
12 files changed, 273 insertions, 45 deletions
diff --git a/c/src/exec/libcsupport/Makefile.am b/c/src/exec/libcsupport/Makefile.am
index f65729290b..2d2f16cd26 100644
--- a/c/src/exec/libcsupport/Makefile.am
+++ b/c/src/exec/libcsupport/Makefile.am
@@ -5,8 +5,7 @@
AUTOMAKE_OPTIONS = foreign 1.4
ACLOCAL_AMFLAGS = -I $(RTEMS_TOPdir)/aclocal
-SUBDIRS = include libc libcpu libbsp \
- $(LIBHWAPI)
+SUBDIRS = include libc libcpu libbsp
include $(top_srcdir)/../../../automake/subdirs.am
include $(top_srcdir)/../../../automake/local.am
diff --git a/c/src/exec/libcsupport/include/console.h b/c/src/exec/libcsupport/include/console.h
index 7bc6b5e3d4..2d2f380012 100644
--- a/c/src/exec/libcsupport/include/console.h
+++ b/c/src/exec/libcsupport/include/console.h
@@ -24,10 +24,6 @@ extern "C" {
{ console_initialize, console_open, console_close, \
console_read, console_write, console_control }
-void console_reserve_resources(
- rtems_configuration_table *configuration
-);
-
rtems_device_driver console_initialize(
rtems_device_major_number,
rtems_device_minor_number,
diff --git a/c/src/exec/libcsupport/include/rtems/error.h b/c/src/exec/libcsupport/include/rtems/error.h
index a0698afb5d..de6e1715db 100644
--- a/c/src/exec/libcsupport/include/rtems/error.h
+++ b/c/src/exec/libcsupport/include/rtems/error.h
@@ -7,6 +7,10 @@
#ifndef __RTEMS_ERROR_h
#define __RTEMS_ERROR_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* rtems_error() and rtems_panic() support
*/
@@ -34,5 +38,10 @@ void rtems_panic(const char *printf_format, ...);
extern int rtems_panic_in_progress;
+#ifdef __cplusplus
+}
+#endif
+
+
#endif
/* end of include file */
diff --git a/c/src/exec/libcsupport/include/sys/termios.h b/c/src/exec/libcsupport/include/sys/termios.h
index bb64d55433..7cc28d7d38 100644
--- a/c/src/exec/libcsupport/include/sys/termios.h
+++ b/c/src/exec/libcsupport/include/sys/termios.h
@@ -14,6 +14,8 @@
#ifndef TERMIOS_H
#define TERMIOS_H
+#include <sys/types.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -174,9 +176,15 @@ struct termios {
#define TCSADRAIN 1
#define TCSAFLUSH 2
+int tcdrain(int);
+int tcflow(int, int);
+int tcflush(int, int);
int tcgetattr(int, struct termios *);
int tcsetattr(int, int, struct termios *);
-int tcdrain(int);
+pid_t tcgetprgrp(int);
+int tcsetprgrp(int, pid_t);
+int tcsendbreak(int, int);
+
speed_t cfgetospeed(const struct termios *tp);
int cfsetospeed(struct termios *tp, speed_t speed);
speed_t cfgetispeed(const struct termios *tp);
diff --git a/c/src/exec/libcsupport/src/Makefile.am b/c/src/exec/libcsupport/src/Makefile.am
index 20893f29eb..54b674b2f7 100644
--- a/c/src/exec/libcsupport/src/Makefile.am
+++ b/c/src/exec/libcsupport/src/Makefile.am
@@ -48,15 +48,14 @@ LIBC_GLUE_C_FILES = __getpid.c __gettod.c __times.c truncate.c access.c \
UNIX_LIBC_C_FILES = unixlibc.c hosterr.c
-COMMON_C_FILES = $(BASE_FS_C_FILES) $(MALLOC_C_FILES) \
- $(TERMIOS_C_FILES) $(ERROR_C_FILES) $(ASSOCIATION_C_FILES)
+COMMON_C_FILES = gxx_wrappers.c $(BASE_FS_C_FILES) $(MALLOC_C_FILES) $(TERMIOS_C_FILES) \
+ $(ERROR_C_FILES) $(ASSOCIATION_C_FILES)
UNIX_C_FILES = $(UNIX_LIBC_C_FILES) imfs_unixstub.c
-EMBEDDED_C_FILES = $(LIBC_GLUE_C_FILES) \
- $(PASSWORD_GROUP_C_FILES) $(TERMINAL_IDENTIFICATION_C_FILES) \
- $(SYSTEM_CALL_C_FILES) $(DIRECTORY_SCAN_C_FILES) \
- $(IMFS_C_FILES)
+EMBEDDED_C_FILES = $(LIBC_GLUE_C_FILES) $(PASSWORD_GROUP_C_FILES) \
+ $(TERMINAL_IDENTIFICATION_C_FILES) $(SYSTEM_CALL_C_FILES) \
+ $(DIRECTORY_SCAN_C_FILES) $(IMFS_C_FILES)
if UNIX
C_FILES = $(COMMON_C_FILES) $(UNIX_C_FILES)
@@ -73,13 +72,10 @@ noinst_HEADERS = libio_.h
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(top_srcdir)/../../../automake/lib.am
-PREINSTALL_FILES = \
-$(PROJECT_INCLUDE) \
-$(PROJECT_INCLUDE)/rtems \
-$(PROJECT_INCLUDE)/sys \
-$(H_FILES:%=$(PROJECT_INCLUDE)/%) \
-$(RTEMS_H_FILES:%=$(PROJECT_INCLUDE)/rtems/%) \
-$(SYS_H_FILES:%=$(PROJECT_INCLUDE)/sys/%)
+PREINSTALL_FILES += $(PROJECT_INCLUDE) $(PROJECT_INCLUDE)/rtems \
+ $(PROJECT_INCLUDE)/sys $(H_FILES:%=$(PROJECT_INCLUDE)/%) \
+ $(RTEMS_H_FILES:%=$(PROJECT_INCLUDE)/rtems/%) \
+ $(SYS_H_FILES:%=$(PROJECT_INCLUDE)/sys/%)
$(PROJECT_INCLUDE):
@$(mkinstalldirs) $@
@@ -95,8 +91,7 @@ $(PROJECT_INCLUDE)/rtems/%.h: %.h
$(PROJECT_INCLUDE)/sys/%.h: %.h
$(INSTALL_DATA) $< $@
-TMPINSTALL_FILES += \
-$(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a
+TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a
OBJS = $(C_O_FILES)
@@ -106,7 +101,7 @@ OBJS = $(C_O_FILES)
AM_CFLAGS += $(LIBC_DEFINES)
-all: ${ARCH} $(TMPINSTALL_FILES)
+all-local: ${ARCH} $(TMPINSTALL_FILES)
$(LIB): ${OBJS}
$(make-library)
@@ -116,9 +111,7 @@ $(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a: $(LIB)
DOC_FILES = TODO CASES
-EXTRA_DIST = \
-$(DOC_FILES) \
-$(COMMON_C_FILES) $(EMBEDDED_C_FILES) $(UNIX_C_FILES) \
-$(H_FILES) $(RTEMS_H_FILES) $(SYS_H_FILES)
+EXTRA_DIST = $(DOC_FILES) $(COMMON_C_FILES) $(EMBEDDED_C_FILES) \
+ $(UNIX_C_FILES) $(H_FILES) $(RTEMS_H_FILES) $(SYS_H_FILES)
include $(top_srcdir)/../../../automake/local.am
diff --git a/c/src/exec/libcsupport/src/gxx_wrappers.c b/c/src/exec/libcsupport/src/gxx_wrappers.c
index e69de29bb2..323da73e7f 100644
--- a/c/src/exec/libcsupport/src/gxx_wrappers.c
+++ b/c/src/exec/libcsupport/src/gxx_wrappers.c
@@ -0,0 +1,219 @@
+/*
+ * RTEMS threads compatibily routines for libgcc2.
+ *
+ * by: Rosimildo da Silva ( rdasilva@connecttel.com
+ *
+ * Used ideas from:
+ * W. Eric Norum
+ * Canadian Light Source
+ * University of Saskatchewan
+ * Saskatoon, Saskatchewan, CANADA
+ * eric@cls.usask.ca
+ *
+ * Eric sent some e-mail in the rtems-list as a start point for this
+ * module implementation.
+ *
+ *
+ */
+
+/* We might not need, defined just in case */
+#define __RTEMS_INSIDE__ 1
+
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <rtems.h>
+#include <rtems/system.h>
+#include <rtems/rtems/tasks.h>
+
+/*
+ * These typedefs should match with the ones defined in the file
+ * gcc/gthr-rtems.h in the gcc distribution.
+ */
+typedef void *__gthread_key_t;
+typedef int __gthread_once_t;
+typedef void *__gthread_mutex_t;
+
+
+/* uncomment this if you need to debug this interface */
+
+/*
+#define DEBUG_GXX_WRAPPERS 1
+*/
+
+
+/* prototype for the terminate() */
+extern void __terminate( void );
+
+
+#ifdef DEBUG_GXX_WRAPPERS
+/* local function to return the ID of the calling thread */
+static rtems_id get_tid( void )
+{
+ rtems_id id = 0;
+ rtems_task_ident( RTEMS_SELF, 0, &id );
+ return id;
+}
+#endif
+
+
+int rtems_gxx_once(__gthread_once_t *once, void (*func) ())
+{
+#ifdef DEBUG_GXX_WRAPPERS
+ printk( "gxx_wrappers: once=%x, func=%x\n", *once, func );
+#endif
+ if( *once == 0 )
+ {
+ /*
+ * NOTE: could not use the call to disable "preemption", it causes
+ * one exception. Somebody might want to investiage it further
+ * sometime later.
+ */
+ _Thread_Disable_dispatch();
+ *once = 1;
+ (*func)();
+ _Thread_Enable_dispatch();
+ }
+ return 0;
+}
+
+
+int rtems_gxx_key_create (__gthread_key_t *key, void (*dtor) (void *))
+{
+ /* Ok, this can be a bit tricky. We are going to return a "key" as a
+ * pointer to the buffer that will hold the value of the key itself.
+ * We have to to this, becuase the others functions on this interface
+ * deal with the value of the key, as used with the POSIX API.
+ */
+ /* Do not pull your hair, trust me this works. :-) */
+ __gthread_key_t *new_key = ( __gthread_key_t * )malloc( sizeof( __gthread_key_t ) );
+ *key = ( __gthread_key_t )new_key;
+ *new_key = NULL;
+
+#ifdef DEBUG_GXX_WRAPPERS
+ printk( "gxx_wrappers: create key=%x, dtor=%x, new_key=%x\n", key, dtor, new_key );
+#endif
+ /* register with RTEMS the buffer that will hold the key values */
+ if( rtems_task_variable_add( RTEMS_SELF, (void **)new_key, NULL ) == RTEMS_SUCCESSFUL )
+ return 0;
+ return -1;
+}
+
+int rtems_gxx_key_dtor (__gthread_key_t key, void *ptr)
+{
+#ifdef DEBUG_GXX_WRAPPERS
+ printk( "gxx_wrappers: dtor key=%x, ptr=%x\n", key, ptr );
+#endif
+ *(void **)key = 0;
+ return 0;
+}
+
+int rtems_gxx_key_delete (__gthread_key_t key)
+{
+#ifdef DEBUG_GXX_WRAPPERS
+ printk( "gxx_wrappers: delete key=%x\n", key );
+#endif
+ /* register with RTEMS the buffer that will hold the key values */
+ if( rtems_task_variable_delete( RTEMS_SELF, (void **)key ) == RTEMS_SUCCESSFUL )
+ {
+ if( key ) free( (void *)key );
+ return 0;
+ }
+ return 0;
+}
+
+
+void *rtems_gxx_getspecific(__gthread_key_t key)
+{
+ void *p= 0;
+
+ /* register with RTEMS the buffer that will hold the key values */
+ if( rtems_task_variable_get( RTEMS_SELF, (void **)key, &p ) == RTEMS_SUCCESSFUL )
+ {
+ /* We do not have to do this, but what the heck ! */
+ p= *( void **)key;
+ }
+ else
+ {
+ /* fisrt time, always set to zero, it is unknown the value that the others
+ * threads are using at the moment of this call
+ */
+ if( rtems_task_variable_add( RTEMS_SELF, (void **)key, NULL ) != RTEMS_SUCCESSFUL )
+ {
+ __terminate ();
+ }
+ *( void ** )key = (void *)0;
+ }
+
+#ifdef DEBUG_GXX_WRAPPERS
+ printk( "gxx_wrappers: getspecific key=%x, ptr=%x, id=%x\n", key, p, get_tid() );
+#endif
+ return p;
+}
+
+
+int rtems_gxx_setspecific(__gthread_key_t key, const void *ptr)
+{
+#ifdef DEBUG_GXX_WRAPPERS
+ printk( "gxx_wrappers: setspecific key=%x, ptr=%x, id=%x\n", key, ptr, get_tid() );
+#endif
+ /* register with RTEMS the buffer that will hold the key values */
+ if( rtems_task_variable_add( RTEMS_SELF, (void **)key, NULL ) == RTEMS_SUCCESSFUL )
+ {
+ /* now let's set the proper value */
+ *( void ** )key = (void *)ptr;
+ return 0;
+ }
+ return -1;
+}
+
+
+/*
+ * MUTEX support
+ */
+void rtems_gxx_mutex_init (__gthread_mutex_t *mutex)
+{
+#ifdef DEBUG_GXX_WRAPPERS
+ printk( "gxx_wrappers: mutex init =%X\n", *mutex );
+#endif
+ if( rtems_semaphore_create( rtems_build_name ('G', 'C', 'C', '2'),
+ 1,
+ RTEMS_PRIORITY|RTEMS_BINARY_SEMAPHORE
+ |RTEMS_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING|RTEMS_LOCAL,
+ 0,
+ (rtems_id *)mutex ) != RTEMS_SUCCESSFUL )
+ {
+ __terminate ();
+ }
+#ifdef DEBUG_GXX_WRAPPERS
+ printk( "gxx_wrappers: mutex init complete =%X\n", *mutex );
+#endif
+}
+
+int rtems_gxx_mutex_lock (__gthread_mutex_t *mutex)
+{
+#ifdef DEBUG_GXX_WRAPPERS
+ printk( "gxx_wrappers: lock mutex=%X\n", *mutex );
+#endif
+ return ( rtems_semaphore_obtain( (rtems_id)*mutex,
+ RTEMS_WAIT, RTEMS_NO_TIMEOUT ) == RTEMS_SUCCESSFUL) ? 0 : -1;
+}
+
+int rtems_gxx_mutex_trylock (__gthread_mutex_t *mutex)
+{
+#ifdef DEBUG_GXX_WRAPPERS
+ printk( "gxx_wrappers: trylock mutex=%X\n", *mutex );
+#endif
+ return (rtems_semaphore_obtain ((rtems_id)*mutex,
+ RTEMS_NO_WAIT, 0) == RTEMS_SUCCESSFUL) ? 0 : -1;
+}
+
+int rtems_gxx_mutex_unlock (__gthread_mutex_t *mutex)
+{
+#ifdef DEBUG_GXX_WRAPPERS
+ printk( "gxx_wrappers: unlock mutex=%X\n", *mutex );
+#endif
+ return (rtems_semaphore_release( (rtems_id)*mutex ) == RTEMS_SUCCESSFUL) ? 0 :-1;
+}
+
diff --git a/c/src/exec/libcsupport/src/libio.c b/c/src/exec/libcsupport/src/libio.c
index 9e075c9f0b..c878db6247 100644
--- a/c/src/exec/libcsupport/src/libio.c
+++ b/c/src/exec/libcsupport/src/libio.c
@@ -260,7 +260,7 @@ int rtems_libio_is_open_files_in_fs(
* Look for any active file descriptor entry.
*/
- for (iop=rtems_libio_iops,i=0; i <= rtems_libio_number_iops; iop++, i++){
+ for (iop=rtems_libio_iops,i=0; i < rtems_libio_number_iops; iop++, i++){
if ((iop->flags & LIBIO_FLAGS_OPEN) != 0) {
@@ -304,7 +304,7 @@ int rtems_libio_is_file_open(
* Look for any active file descriptor entry.
*/
- for (iop=rtems_libio_iops,i=0; i <= rtems_libio_number_iops; iop++, i++){
+ for (iop=rtems_libio_iops,i=0; i < rtems_libio_number_iops; iop++, i++){
if ((iop->flags & LIBIO_FLAGS_OPEN) != 0) {
/*
diff --git a/c/src/exec/libcsupport/src/malloc.c b/c/src/exec/libcsupport/src/malloc.c
index cc63b6c7d0..08660d75cc 100644
--- a/c/src/exec/libcsupport/src/malloc.c
+++ b/c/src/exec/libcsupport/src/malloc.c
@@ -120,7 +120,7 @@ void RTEMS_Malloc_Initialize(
rtems_build_name( 'H', 'E', 'A', 'P' ),
starting_address,
length,
- CPU_ALIGNMENT,
+ CPU_HEAP_ALIGNMENT,
RTEMS_DEFAULT_ATTRIBUTES,
&RTEMS_Malloc_Heap
);
diff --git a/c/src/exec/libcsupport/src/scandir.c b/c/src/exec/libcsupport/src/scandir.c
index 43c7c51747..25f3263187 100644
--- a/c/src/exec/libcsupport/src/scandir.c
+++ b/c/src/exec/libcsupport/src/scandir.c
@@ -112,7 +112,7 @@ scandir(dirname, namelist, select, dcomp)
p->d_ino = d->d_ino;
p->d_reclen = d->d_reclen;
p->d_namlen = d->d_namlen;
- strncpy(p->d_name, d->d_name, p->d_namlen + 1);
+ strncpy(d->d_name, p->d_name, p->d_namlen + 1);
/*
* Check to make sure the array has space left and
* realloc the maximum size.
diff --git a/c/src/exec/libcsupport/src/termios.c b/c/src/exec/libcsupport/src/termios.c
index 6d334ecd23..7883e94b63 100644
--- a/c/src/exec/libcsupport/src/termios.c
+++ b/c/src/exec/libcsupport/src/termios.c
@@ -28,7 +28,6 @@
* FreeBSD does not support a full POSIX termios so we have to help it out
*/
-
#if defined(__FreeBSD__)
#define XTABS 0
#define ONLRET 0
@@ -41,6 +40,14 @@
#endif
/*
+ * Cygwin does not define these
+ */
+
+#if defined(__CYGWIN__)
+#define ECHOPRT 0
+#endif
+
+/*
* The size of the cooked buffer
*/
#define CBUFSIZE 256
@@ -238,7 +245,7 @@ rtems_termios_open (
*/
tty->termios.c_iflag = BRKINT | ICRNL | IMAXBEL;
tty->termios.c_oflag = OPOST | ONLCR | XTABS;
- tty->termios.c_cflag = B9600 | CS8 | CREAD;
+ tty->termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL;
tty->termios.c_lflag = ISIG | ICANON | IEXTEN | ECHO | ECHOK | ECHOE | ECHOCTL;
tty->termios.c_cc[VINTR] = '\003';
@@ -256,8 +263,8 @@ rtems_termios_open (
tty->termios.c_cc[VWERASE] = '\027';
tty->termios.c_cc[VLNEXT] = '\026';
- /* setup flow control mode, clear flow control flags */
- tty->flow_ctrl = FL_MDXON;
+ /* start with no flow control, clear flow control flags */
+ tty->flow_ctrl = 0;
/*
* set low/highwater mark for XON/XOFF support
*/
diff --git a/c/src/exec/libcsupport/src/termiosreserveresources.c b/c/src/exec/libcsupport/src/termiosreserveresources.c
index 2d9c05c988..664bdd1f62 100644
--- a/c/src/exec/libcsupport/src/termiosreserveresources.c
+++ b/c/src/exec/libcsupport/src/termiosreserveresources.c
@@ -6,15 +6,19 @@
#include <rtems.h>
+#if 0
static int first_time; /* assumed to be zeroed by BSS initialization */
+#endif
void rtems_termios_reserve_resources (
rtems_configuration_table *configuration,
rtems_unsigned32 number_of_devices
)
{
+#if 0
rtems_api_configuration_table *rtems_config;
+
if (!configuration)
rtems_fatal_error_occurred (0xFFF0F001);
rtems_config = configuration->RTEMS_api_configuration;
@@ -24,5 +28,6 @@ void rtems_termios_reserve_resources (
rtems_config->maximum_semaphores += 1;
first_time = 1;
rtems_config->maximum_semaphores += (4 * number_of_devices);
+#endif
}
diff --git a/c/src/exec/libcsupport/src/unmount.c b/c/src/exec/libcsupport/src/unmount.c
index c4b6bdae7d..46b11d1848 100644
--- a/c/src/exec/libcsupport/src/unmount.c
+++ b/c/src/exec/libcsupport/src/unmount.c
@@ -62,7 +62,6 @@ int unmount(
int status;
rtems_filesystem_location_info_t temp_loc;
rtems_filesystem_mount_table_entry_t temp_mt_entry;
- int result;
/*
* Are there any file systems below the mount_path specified
@@ -101,7 +100,7 @@ int unmount(
/*
* Allow the file system being mounted on to do its cleanup.
* XXX - Did I change these correctly ??? It looks like either I did
- * XXX this backwards or the IMFS_unmount and IMFS_fsumount are swaped.
+ * XXX this backwards or the IMFS_unmount and IMFS_fsumount are swapped.
* XXX Add to the mt_point_node unmount to set the mt_entry back to null
* XXX I will step off in space when evaluating past the end of the node.
*/
@@ -121,12 +120,6 @@ int unmount(
}
/*
- * Allow the file system to clean up.
- */
-
- result = (*temp_loc.ops->fsunmount_me)( temp_loc.mt_entry );
-
- /*
* Extract the mount table entry from the chain
*/
@@ -140,8 +133,7 @@ int unmount(
free( temp_loc.mt_entry );
rtems_filesystem_freenode( &temp_loc );
- return result;
-
+ return 0;
}