diff options
Diffstat (limited to 'c/src/exec/libcsupport')
25 files changed, 0 insertions, 2637 deletions
diff --git a/c/src/exec/libcsupport/include/clockdrv.h b/c/src/exec/libcsupport/include/clockdrv.h deleted file mode 100644 index 258c590e0d..0000000000 --- a/c/src/exec/libcsupport/include/clockdrv.h +++ /dev/null @@ -1,51 +0,0 @@ -/* clock.h - * - * This file describes the Clock Driver for all boards. - * - * 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 __CLOCK_DRIVER_h -#define __CLOCK_DRIVER_h - -#ifdef __cplusplus -extern "C" { -#endif - -/* variables */ - -extern volatile rtems_unsigned32 Clock_driver_ticks; -extern rtems_device_major_number rtems_clock_major; -extern rtems_device_minor_number rtems_clock_minor; - -/* default clock driver entry */ - -#define CLOCK_DRIVER_TABLE_ENTRY \ - { Clock_initialize, NULL, NULL, NULL, NULL, Clock_control } - -rtems_device_driver Clock_initialize( - rtems_device_major_number, - rtems_device_minor_number, - void * -); - -rtems_device_driver Clock_control( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *pargp -); - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/c/src/exec/libcsupport/include/console.h b/c/src/exec/libcsupport/include/console.h deleted file mode 100644 index 02196de7a9..0000000000 --- a/c/src/exec/libcsupport/include/console.h +++ /dev/null @@ -1,69 +0,0 @@ -/* console.h - * - * This file describes the Console Device Driver for all boards. - * This driver provides support for the standard C Library. - * - * 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 _CONSOLE_DRIVER_h -#define _CONSOLE_DRIVER_h - -#ifdef __cplusplus -extern "C" { -#endif - -#define CONSOLE_DRIVER_TABLE_ENTRY \ - { console_initialize, console_open, console_close, \ - console_read, console_write, console_control } - -rtems_device_driver console_initialize( - rtems_device_major_number, - rtems_device_minor_number, - void * -); - -rtems_device_driver console_open( - rtems_device_major_number, - rtems_device_minor_number, - void * -); - -rtems_device_driver console_close( - rtems_device_major_number, - rtems_device_minor_number, - void * -); - -rtems_device_driver console_read( - rtems_device_major_number, - rtems_device_minor_number, - void * -); - -rtems_device_driver console_write( - rtems_device_major_number, - rtems_device_minor_number, - void * -); - -rtems_device_driver console_control( - rtems_device_major_number, - rtems_device_minor_number, - void * -); - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/c/src/exec/libcsupport/include/iosupp.h b/c/src/exec/libcsupport/include/iosupp.h deleted file mode 100644 index 5f4a83b8ca..0000000000 --- a/c/src/exec/libcsupport/include/iosupp.h +++ /dev/null @@ -1,44 +0,0 @@ -/* iosupp.h - * - * 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 __IOSUPP_h -#define __IOSUPP_h - -#ifdef __cplusplus -extern "C" { -#endif - -/* character constants */ - -#define BS 0x08 /* backspace */ -#define LF 0x0a /* line feed */ -#define CR 0x0d /* carriage return */ -#define XON 0x11 /* control-Q */ -#define XOFF 0x13 /* control-S */ - -/* structures */ - -#ifdef IOSUPP_INIT -#define IOSUPP_EXTERN -#else -#undef IOSUPP_EXTERN -#define IOSUPP_EXTERN extern -#endif - -/* functions */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/c/src/exec/libcsupport/include/ringbuf.h b/c/src/exec/libcsupport/include/ringbuf.h deleted file mode 100644 index 8c80aaf9c8..0000000000 --- a/c/src/exec/libcsupport/include/ringbuf.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * ringbuf.h - * - * This file provides simple ring buffer functionality. - * - * $Id$ - */ - -#ifndef __RINGBUF_H__ -#define __RINGBUF_H__ - -#ifndef RINGBUF_QUEUE_LENGTH -#define RINGBUF_QUEUE_LENGTH 128 -#endif - -typedef struct { - char buffer[RINGBUF_QUEUE_LENGTH]; - volatile int head; - volatile int tail; -} Ring_buffer_t; - -#define Ring_buffer_Initialize( _buffer ) \ - do { \ - (_buffer)->head = (_buffer)->tail = 0; \ - } while ( 0 ) - -#define Ring_buffer_Is_empty( _buffer ) \ - ( (_buffer)->head == (_buffer)->tail ) - -#define Ring_buffer_Is_full( _buffer ) \ - ( (_buffer)->head == ((_buffer)->tail + 1) % RINGBUF_QUEUE_LENGTH ) - -#define Ring_buffer_Add_character( _buffer, _ch ) \ - do { \ - rtems_unsigned32 isrlevel; \ - \ - rtems_interrupt_disable( isrlevel ); \ - (_buffer)->tail = ((_buffer)->tail+1) % RINGBUF_QUEUE_LENGTH; \ - (_buffer)->buffer[ (_buffer)->tail ] = (_ch); \ - rtems_interrupt_enable( isrlevel ); \ - } while ( 0 ) - -#define Ring_buffer_Remove_character( _buffer, _ch ) \ - do { \ - rtems_unsigned32 isrlevel; \ - \ - rtems_interrupt_disable( isrlevel ); \ - (_buffer)->head = ((_buffer)->head+1) % RINGBUF_QUEUE_LENGTH; \ - (_ch) = (_buffer)->buffer[ (_buffer)->head ]; \ - rtems_interrupt_enable( isrlevel ); \ - } while ( 0 ) - -#endif diff --git a/c/src/exec/libcsupport/include/rtems/assoc.h b/c/src/exec/libcsupport/include/rtems/assoc.h deleted file mode 100644 index f9a444374c..0000000000 --- a/c/src/exec/libcsupport/include/rtems/assoc.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * @(#)assoc.h 1.4 - 95/10/25 - * - * - * Rtems associativity routines. Mainly used to convert a value from - * one space to another (eg: our errno's to host errno's and v.v) - * - * - * $Id$ - */ - -#ifndef _INCLUDE_ASSOC_H -#define _INCLUDE_ASSOC_H - -typedef struct { - const char *name; - unsigned32 local_value; - unsigned32 remote_value; -} rtems_assoc_t; - -/* - * Flag/marker for optional default value in each table - */ - -#define RTEMS_ASSOC_DEFAULT_NAME "(default)" - -const rtems_assoc_t *rtems_assoc_ptr_by_name(const rtems_assoc_t *, const char *); -const rtems_assoc_t *rtems_assoc_ptr_by_value(const rtems_assoc_t *, unsigned32); -const rtems_assoc_t *rtems_assoc_ptr_by_remote(const rtems_assoc_t *, unsigned32); - -unsigned32 rtems_assoc_remote_by_local(const rtems_assoc_t *, unsigned32); -unsigned32 rtems_assoc_local_by_remote(const rtems_assoc_t *, unsigned32); -unsigned32 rtems_assoc_remote_by_name(const rtems_assoc_t *, const char *); -unsigned32 rtems_assoc_local_by_name(const rtems_assoc_t *, const char *); -const char *rtems_assoc_name_by_local(const rtems_assoc_t *, unsigned32); -const char *rtems_assoc_name_by_remote(const rtems_assoc_t *, unsigned32); - -unsigned32 rtems_assoc_remote_by_local_bitfield(const rtems_assoc_t *, unsigned32); -char *rtems_assoc_name_by_local_bitfield(const rtems_assoc_t *, unsigned32, char *); -char *rtems_assoc_name_by_remote_bitfield(const rtems_assoc_t *, unsigned32, char *); -unsigned32 rtems_assoc_local_by_remote_bitfield(const rtems_assoc_t *, unsigned32); - - -#endif /* ! _INCLUDE_ASSOC_H */ diff --git a/c/src/exec/libcsupport/include/rtems/error.h b/c/src/exec/libcsupport/include/rtems/error.h deleted file mode 100644 index 621ee16f65..0000000000 --- a/c/src/exec/libcsupport/include/rtems/error.h +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * @(#)error.h 1.3 - 95/10/25 - * - * - * Defines and externs for rtems error reporting - * - * $Id$ - */ - -#ifndef __RTEMS_ERROR_h -#define __RTEMS_ERROR_h - -/* - * rtems_error() and rtems_panic() support - */ - -#define RTEMS_ERROR_ERRNO (1<<((sizeof(int) * 8) - 2)) /* hi bit; use 'errno' */ -#define RTEMS_ERROR_PANIC (RTEMS_ERROR_ERRNO / 2) /* err fatal; no return */ -#define RTEMS_ERROR_ABORT (RTEMS_ERROR_ERRNO / 4) /* err is fatal; panic */ - -#define RTEMS_ERROR_MASK (RTEMS_ERROR_ERRNO | RTEMS_ERROR_ABORT | \ - RTEMS_ERROR_PANIC) /* all */ - -const char *rtems_status_text(rtems_status_code); -int rtems_error(int error_code, const char *printf_format, ...); -void rtems_panic(const char *printf_format, ...); - -extern int rtems_panic_in_progress; - -#endif -/* end of include file */ diff --git a/c/src/exec/libcsupport/include/rtems/libcsupport.h b/c/src/exec/libcsupport/include/rtems/libcsupport.h deleted file mode 100644 index f43cd189e1..0000000000 --- a/c/src/exec/libcsupport/include/rtems/libcsupport.h +++ /dev/null @@ -1,42 +0,0 @@ -/* libcsupport.h - * - * This include file contains the information regarding the - * RTEMS specific support for the standard C library. - * - * 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 __LIBC_SUPPORT_h -#define __LIBC_SUPPORT_h - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/types.h> - -void RTEMS_Malloc_Initialize( - void *start, - size_t length, - size_t sbrk_amount -); - -extern void malloc_dump(void); -extern void libc_init(int reentrant); -extern int host_errno(void); -extern void fix_syscall_errno(void); - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/c/src/exec/libcsupport/include/rtems/libio.h b/c/src/exec/libcsupport/include/rtems/libio.h deleted file mode 100644 index f80a1954a3..0000000000 --- a/c/src/exec/libcsupport/include/rtems/libio.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * @(#)libio.h 1.1 - 95/06/02 - * - * - * General purpose communication channel for RTEMS to allow UNIX/POSIX - * system call behavior on top of RTEMS IO devices. - * - * TODO - * stat(2) - * unlink(2) - * rename(2) - * - * $Id$ - */ - -#ifndef _RTEMS_LIBIO_H -#define _RTEMS_LIBIO_H - -typedef unsigned32 rtems_libio_offset_t; - -/* - * An open file data structure, indexed by 'fd' - * TODO: - * should really have a separate per/file data structure that this - * points to (eg: size, offset, driver, pathname should be in that) - */ - -typedef struct { - rtems_driver_name_t *driver; - rtems_libio_offset_t size; /* size of file */ - rtems_libio_offset_t offset; /* current offset into the file */ - unsigned32 flags; - char *pathname; /* opened pathname */ - Objects_Id sem; - unsigned32 data0; /* private to "driver" */ - unsigned32 data1; /* ... */ -} rtems_libio_t; - - -/* - * param block for read/write - * Note: it must include 'offset' instead of using iop's offset since - * we can have multiple outstanding i/o's on a device. - */ - -typedef struct { - rtems_libio_t *iop; - rtems_libio_offset_t offset; - unsigned8 *buffer; - unsigned32 count; - unsigned32 flags; - unsigned32 bytes_moved; -} rtems_libio_rw_args_t; - -/* - * param block for open/close - */ - -typedef struct { - rtems_libio_t *iop; - unsigned32 flags; - unsigned32 mode; -} rtems_libio_open_close_args_t; - -/* - * param block for ioctl - */ - -typedef struct { - rtems_libio_t *iop; - unsigned32 command; - void *buffer; - unsigned32 ioctl_return; -} rtems_libio_ioctl_args_t; - - -/* - * Values for 'flag' - */ - -#define LIBIO_FLAGS_NO_DELAY 0x0001 /* return immediately if no data */ -#define LIBIO_FLAGS_READ 0x0002 /* reading */ -#define LIBIO_FLAGS_WRITE 0x0004 /* writing */ -#define LIBIO_FLAGS_LINE_BUFFERED 0x0008 /* line buffered io (^h, ^u, etc) */ -#define LIBIO_FLAGS_OPEN 0x0100 /* device is open */ -#define LIBIO_FLAGS_APPEND 0x0200 /* all writes append */ -#define LIBIO_FLAGS_CREATE 0x0400 /* create file */ - -#define LIBIO_FLAGS_READ_WRITE (LIBIO_FLAGS_READ | LIBIO_FLAGS_WRITE) - -void rtems_libio_config(rtems_configuration_table *config, unsigned32 max_fds); -void rtems_libio_init(void); - -int __open(const char *pathname, unsigned32 flag, unsigned32 mode); -int __close(int fd); -int __read(int fd, void *buffer, unsigned32 count); -int __write(int fd, const void *buffer, unsigned32 count); -int __ioctl(int fd, unsigned32 command, void *buffer); -int __lseek(int fd, rtems_libio_offset_t offset, int whence); - -#endif /* _RTEMS_LIBIO_H */ diff --git a/c/src/exec/libcsupport/include/spurious.h b/c/src/exec/libcsupport/include/spurious.h deleted file mode 100644 index 428e826164..0000000000 --- a/c/src/exec/libcsupport/include/spurious.h +++ /dev/null @@ -1,38 +0,0 @@ -/* spurious.h - * - * This file describes the Spurious Interrupt Driver for all boards. - * - * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993. - * 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$ - */ - -#ifndef __SPURIOUS_h -#define __SPURIOUS_h - -#ifdef __cplusplus -extern "C" { -#endif - -#define SPURIOUS_DRIVER_TABLE_ENTRY \ - { Spurious_Initialize, NULL, NULL, NULL, NULL, NULL } - -rtems_device_driver Spurious_Initialize( - rtems_device_major_number, - rtems_device_minor_number, - void *, - rtems_id, - rtems_unsigned32 * -); - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/c/src/exec/libcsupport/include/sys/utsname.h b/c/src/exec/libcsupport/include/sys/utsname.h deleted file mode 100644 index ca15230d40..0000000000 --- a/c/src/exec/libcsupport/include/sys/utsname.h +++ /dev/null @@ -1,49 +0,0 @@ -/* sys/utsname.h - * - * $Id$ - */ - -#ifndef __POSIX_SYS_UTSNAME_h -#define __POSIX_SYS_UTSNAME_h - -#include <sys/times.h> -#include <sys/types.h> - -/* - * 4.4.1 Get System Name (Table 4-1), P1003.1b-1993, p. 90 - * - * NOTE: The lengths of the strings in this structure are - * just long enough to reliably contain the RTEMS information. - * For example, the fields are not long enough to support - * Internet hostnames. - */ - -struct utsname { - char sysname[ 32 ]; /* Name of this implementation of the operating system */ - char nodename[ 32 ]; /* Name of this node within an implementation */ - /* specified communication network */ - char release[ 32 ]; /* Current release level of this implementation */ - char version[ 32 ]; /* Current version level of this release */ - char machine[ 32 ]; /* Name of the hardware type on which the system */ - /* is running */ -}; - -/* - * 4.4.1 Get System Name, P1003.1b-1993, p. 90 - */ - -int uname( - struct utsname *name -); - -/* - * 4.5.2 Get Process Times, P1003.1b-1993, p. 92 - */ - -clock_t times( - struct tms *buffer -); - -#endif -/* end of include file */ - diff --git a/c/src/exec/libcsupport/include/timerdrv.h b/c/src/exec/libcsupport/include/timerdrv.h deleted file mode 100644 index d091b62410..0000000000 --- a/c/src/exec/libcsupport/include/timerdrv.h +++ /dev/null @@ -1,40 +0,0 @@ -/* timerdrv.h - * - * This file describes the Timer Driver for all boards. - * - * 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 __TIMER_DRIVER_h -#define __TIMER_DRIVER_h - -#ifdef __cplusplus -extern "C" { -#endif - -/* functions */ - -void Timer_initialize( void ); - -rtems_unsigned32 Read_timer( void ); - -rtems_status_code Empty_function( void ); - -void Set_find_average_overhead( - rtems_boolean find_flag -); - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/c/src/exec/libcsupport/include/vmeintr.h b/c/src/exec/libcsupport/include/vmeintr.h deleted file mode 100644 index 6148114ce8..0000000000 --- a/c/src/exec/libcsupport/include/vmeintr.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * vmeintr.h - * - * This file is the specification for the VMEbus interface library - * which should be provided by all BSPs for VMEbus Single Board - * Computers but currently only a few do so. - * - * 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 __VME_INTERRUPT_h -#define __VME_INTERRUPT_h - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This defines the mask which is used to determine which - * interrupt levels are affected by a call to this package. - * The LSB corresponds to VME interrupt 0 and the MSB - * to VME interrupt 7. - * - */ - -typedef rtems_unsigned8 VME_interrupt_Mask; - -/* - * VME_interrupt_Disable - * - */ - -void VME_interrupt_Disable ( - VME_interrupt_Mask mask /* IN */ -); - -/* - * VME_interrupt_Disable - * - */ - -void VME_interrupt_Enable ( - VME_interrupt_Mask mask /* IN */ -); - -#ifdef __cplusplus -} -#endif - -#endif /* end of include file */ diff --git a/c/src/exec/libcsupport/src/README b/c/src/exec/libcsupport/src/README deleted file mode 100644 index ee7a90501e..0000000000 --- a/c/src/exec/libcsupport/src/README +++ /dev/null @@ -1,37 +0,0 @@ --- --- $Id$ --- - -Overview of newlib support (newlib is from CYGNUS) - Each task can have its own libc state including: - open stdio files - strtok - multi precision arithmetic state - etc. - - This is implemented by a reentrancy data structure for each task. - - When a task is "started" (in RTEMS sense) the reentrancy structure - is allocated. Its address is stored in notepad[NOTEPAD_LAST]. - - When task is switched to, the value of global variable _impure_ptr - is changed to the value of the new tasks reentrancy structure. - - When a task is deleted - atexit() processing (for that task) happens - task's stdio buffers are flushed - - When exit(3) is called - calling task's atexit processing done - global libc state atexit processing done - (this will include any atexit routines installed by drivers) - executive is shutdown - causes a context switch back to bsp land - - -NOTE: - libc extension are installed by bsp_libc_init() - iff we are using clock interrupts. - This hack is necessary to allow the tmtests to avoid - timing the extensions. - diff --git a/c/src/exec/libcsupport/src/__brk.c b/c/src/exec/libcsupport/src/__brk.c deleted file mode 100644 index 5f256cb072..0000000000 --- a/c/src/exec/libcsupport/src/__brk.c +++ /dev/null @@ -1,44 +0,0 @@ -#if !defined(RTEMS_UNIX) - -/* - * RTEMS "Broken" __brk/__sbrk Implementation - * - * NOTE: sbrk is BSP provided. - * - * - * 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 <signal.h> -#include <errno.h> -#include <sys/types.h> -#ifdef RTEMS_NEWLIB -#include <reent.h> -#endif -#include <unistd.h> - -/* we use RTEMS for memory management. We don't need sbrk */ - -void * __sbrk(int incr) -{ - errno = EINVAL; - return (void *)0; -} - -int __brk( const void *endds ) -{ - errno = EINVAL; - return -1; -} - -#endif diff --git a/c/src/exec/libcsupport/src/__gettod.c b/c/src/exec/libcsupport/src/__gettod.c deleted file mode 100644 index 6c9350d41c..0000000000 --- a/c/src/exec/libcsupport/src/__gettod.c +++ /dev/null @@ -1,103 +0,0 @@ -#if !defined(RTEMS_UNIX) -/* - * RTEMS gettimeofday Implementation - * - * - * 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> - -#ifdef RTEMS_NEWLIB -#include <sys/reent.h> -#endif - -#include <time.h> -#include <sys/time.h> - -#include <errno.h> -#include <assert.h> - -/* - * NOTE: The solaris gettimeofday does not have a second parameter. - */ - -int gettimeofday( - struct timeval *tp, - struct timezone *tzp -) -{ - rtems_status_code status; - rtems_clock_time_value time; - - if ( !tp ) { - errno = EFAULT; - return -1; - } - - /* "POSIX" does not seem to allow for not having a TOD */ - status = rtems_clock_get( RTEMS_CLOCK_GET_TIME_VALUE, &time ); - if ( status != RTEMS_SUCCESSFUL ) { - assert( 0 ); - return -1; - } - - tp->tv_sec = time.seconds; - tp->tv_usec = time.microseconds; - - /* - * newlib does not have timezone and daylight savings time - * yet. When it does this needs to be fixed. - */ - -#if 0 - if ( tzp ) { - tzp->tz_minuteswest = 0; /* at UTC */ - tzp->tz_dsttime = 0; /* no daylight savings */ - tzp->minuteswest = timezone / 60; /* from seconds to minutes */ - tzp->dsttime = daylight; - } -#endif - return 0; -} - -#if defined(RTEMS_NEWLIB) - -#if 0 -/* - * "Reentrant" version - */ - -int _gettimeofday_r( - struct _reent *ignored_reentrancy_stuff, - struct timeval *tp, - struct timezone *tzp -) -{ - return gettimeofday( tp, tzp ); -} -#endif - -/* - * "System call" version - */ - -int _gettimeofday( - struct timeval *tp, - struct timezone *tzp -) -{ - return gettimeofday( tp, tzp ); -} - -#endif /* defined(RTEMS_NEWLIB) */ - -#endif diff --git a/c/src/exec/libcsupport/src/__times.c b/c/src/exec/libcsupport/src/__times.c deleted file mode 100644 index 12fd9241fe..0000000000 --- a/c/src/exec/libcsupport/src/__times.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * RTEMS _times Implementation - * - * - * 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 <sys/times.h> -#include <time.h> -#include <sys/time.h> -#include <errno.h> -#include <assert.h> - -clock_t _times( - struct tms *ptms -) -{ - rtems_status_code status; - rtems_interval ticks_since_boot; - - if ( !ptms ) { - errno = EFAULT; - return -1; - } - - /* "POSIX" does not seem to allow for not having a TOD */ - status = rtems_clock_get( - RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, - &ticks_since_boot - ); - if ( status != RTEMS_SUCCESSFUL ) { - assert( 0 ); - return -1; - } - - /* - * RTEMS has no notion of system versus user time and does - * not (as of 3.2.0) keep track of CPU usage on a per task basis. - */ - - ptms->tms_utime = ticks_since_boot; - ptms->tms_stime = 0; - ptms->tms_cutime = 0; - ptms->tms_cstime = 0; - - return 0; -} - -clock_t times( - struct tms *ptms -) -{ - return _times( ptms ); -} - diff --git a/c/src/exec/libcsupport/src/assoc.c b/c/src/exec/libcsupport/src/assoc.c deleted file mode 100644 index a3eabdb3b5..0000000000 --- a/c/src/exec/libcsupport/src/assoc.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - * @(#)assoc.c 1.6 - 95/10/25 - * - * - * assoc.c - * rtems assoc routines - * - * $Id$ - */ - -#include <rtems.h> -#include "assoc.h" - -#include <stdio.h> /* sprintf */ -#include <string.h> /* strcat, strcmp */ - -#define STREQ(a,b) (strcmp((a), (b)) == 0) -#define rtems_assoc_is_default(ap) ((ap)->name && STREQ(ap->name, RTEMS_ASSOC_DEFAULT_NAME)) - -const rtems_assoc_t * -rtems_assoc_ptr_by_name( - const rtems_assoc_t *ap, - const char *name - ) -{ - const rtems_assoc_t *default_ap = 0; - - if (rtems_assoc_is_default(ap)) - default_ap = ap++; - - for ( ; ap->name; ap++) - if (strcmp(ap->name, name) == 0) - return ap; - - return default_ap; -} - -const rtems_assoc_t * -rtems_assoc_ptr_by_local( - const rtems_assoc_t *ap, - unsigned32 local_value - ) -{ - const rtems_assoc_t *default_ap = 0; - - if (rtems_assoc_is_default(ap)) - default_ap = ap++; - - for ( ; ap->name; ap++) - if (ap->local_value == local_value) - return ap; - - return default_ap; -} - - -const rtems_assoc_t * -rtems_assoc_ptr_by_remote( - const rtems_assoc_t *ap, - unsigned32 remote_value - ) -{ - const rtems_assoc_t *default_ap = 0; - - if (rtems_assoc_is_default(ap)) - default_ap = ap++; - - for ( ; ap->name; ap++) - if (ap->remote_value == remote_value) - return ap; - - return default_ap; -} - - -/* - * Get values - */ - -unsigned32 -rtems_assoc_remote_by_local( - const rtems_assoc_t *ap, - unsigned32 local_value - ) -{ - const rtems_assoc_t *nap; - nap = rtems_assoc_ptr_by_local(ap, local_value); - if (nap) - return nap->remote_value; - - return 0; -} - -unsigned32 -rtems_assoc_local_by_remote( - const rtems_assoc_t *ap, - unsigned32 remote_value - ) -{ - const rtems_assoc_t *nap; - nap = rtems_assoc_ptr_by_remote(ap, remote_value); - if (nap) - return nap->local_value; - - return 0; -} - -unsigned32 -rtems_assoc_remote_by_name( - const rtems_assoc_t *ap, - const char *name - ) -{ - const rtems_assoc_t *nap; - nap = rtems_assoc_ptr_by_name(ap, name); - if (nap) - return nap->remote_value; - - return 0; -} - -unsigned32 -rtems_assoc_local_by_name( - const rtems_assoc_t *ap, - const char *name - ) -{ - const rtems_assoc_t *nap; - nap = rtems_assoc_ptr_by_name(ap, name); - if (nap) - return nap->local_value; - - return 0; -} - -/* - * what to return if a value is not found - * this is not reentrant, but it really shouldn't be invoked anyway - */ - -const char * -rtems_assoc_name_bad( - unsigned32 bad_value -) -{ -#ifdef RTEMS_DEBUG - static char bad_buffer[32]; - - sprintf(bad_buffer, "< %d [0x%x] >", bad_value, bad_value); -#else - static char bad_buffer[32] = "<assoc.c: BAD NAME>"; -#endif - return bad_buffer; -} - - -const char * -rtems_assoc_name_by_local( - const rtems_assoc_t *ap, - unsigned32 local_value - ) -{ - const rtems_assoc_t *nap; - nap = rtems_assoc_ptr_by_local(ap, local_value); - if (nap) - return nap->name; - - return rtems_assoc_name_bad(local_value); -} - -const char * -rtems_assoc_name_by_remote( - const rtems_assoc_t *ap, - unsigned32 remote_value - ) -{ - const rtems_assoc_t *nap; - nap = rtems_assoc_ptr_by_remote(ap, remote_value); - if (nap) - return nap->name; - - return rtems_assoc_name_bad(remote_value); -} - -/* - * Bitfield functions assume just 1 bit set in each of remote and local - * entries; they do not check for this. - */ - -unsigned32 rtems_assoc_remote_by_local_bitfield( - const rtems_assoc_t *ap, - unsigned32 local_value - ) -{ - unsigned32 b; - unsigned32 remote_value = 0; - - for (b = 1; b; b <<= 1) - if (b & local_value) - remote_value |= rtems_assoc_remote_by_local(ap, b); - - return remote_value; -} - - -unsigned32 rtems_assoc_local_by_remote_bitfield( - const rtems_assoc_t *ap, - unsigned32 remote_value - ) -{ - unsigned32 b; - unsigned32 local_value = 0; - - for (b = 1; b; b <<= 1) - if (b & remote_value) - local_value |= rtems_assoc_local_by_remote(ap, b); - - return local_value; -} - -char * -rtems_assoc_name_by_remote_bitfield( - const rtems_assoc_t *ap, - unsigned32 value, - char *buffer - ) -{ - unsigned32 b; - - *buffer = 0; - - for (b = 1; b; b <<= 1) - if (b & value) - { - if (*buffer) - strcat(buffer, " "); - strcat(buffer, rtems_assoc_name_by_remote(ap, b)); - } - - return buffer; -} - -char * -rtems_assoc_name_by_local_bitfield( - const rtems_assoc_t *ap, - unsigned32 value, - char *buffer - ) -{ - unsigned32 b; - - *buffer = 0; - - for (b = 1; b; b <<= 1) - if (b & value) - { - if (*buffer) - strcat(buffer, " "); - strcat(buffer, rtems_assoc_name_by_local(ap, b)); - } - - return buffer; -} diff --git a/c/src/exec/libcsupport/src/error.c b/c/src/exec/libcsupport/src/error.c deleted file mode 100644 index 715635072a..0000000000 --- a/c/src/exec/libcsupport/src/error.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * @(#)error.c 1.6 - 95/12/12 - * - * - * report errors and panics to RTEMS' stderr. - * Currently just used by RTEMS monitor. - * - * $Id$ - */ - - -/* - * These routines provide general purpose error reporting. - * rtems_error reports an error to stderr and allows use of - * printf style formatting. A newline is appended to all messages. - * - * error_flag can be specified as any of the following: - * - * RTEMS_ERROR_ERRNO -- include errno text in output - * RTEMS_ERROR_PANIC -- halts local system after output - * RTEMS_ERROR_ABORT -- abort after output - * - * It can also include a rtems_status value which can be OR'd - * with the above flags. * - * - * EXAMPLE - * #include <rtems.h> - * #include <rtems/error.h> - * rtems_error(0, "stray interrupt %d", intr); - * - * EXAMPLE - * if ((status = rtems_task_create(...)) != RTEMS_SUCCCESSFUL) - * { - * rtems_error(status | RTEMS_ERROR_ABORT, - * "could not create task"); - * } - * - * EXAMPLE - * if ((fd = open(pathname, O_RDNLY)) < 0) - * { - * rtems_error(RTEMS_ERROR_ERRNO, "open of '%s' failed", pathname); - * goto failed; - * } - */ - -#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ -#include <rtems.h> - -#include "error.h" -#include <rtems/assoc.h> - -#include <stdio.h> -#include <stdarg.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> /* _exit() */ - -/* bug in hpux <errno.h>: no prototypes unless you are C++ */ -#ifdef hpux9 -char *strerror(int); -#endif - -extern char *rtems_progname; -int rtems_panic_in_progress; - -rtems_assoc_t rtems_status_assoc[] = { - { "successful completion", RTEMS_SUCCESSFUL, }, - { "returned from a thread", RTEMS_TASK_EXITTED, }, - { "multiprocessing not configured", RTEMS_MP_NOT_CONFIGURED, }, - { "invalid object name", RTEMS_INVALID_NAME, }, - { "invalid object id", RTEMS_INVALID_ID, }, - { "too many", RTEMS_TOO_MANY, }, - { "timed out waiting", RTEMS_TIMEOUT, }, - { "object deleted while waiting", RTEMS_OBJECT_WAS_DELETED, }, - { "specified size was invalid", RTEMS_INVALID_SIZE, }, - { "address specified is invalid", RTEMS_INVALID_ADDRESS, }, - { "number was invalid", RTEMS_INVALID_NUMBER, }, - { "item has not been initialized", RTEMS_NOT_DEFINED, }, - { "resources still outstanding", RTEMS_RESOURCE_IN_USE, }, - { "request not satisfied", RTEMS_UNSATISFIED, }, - { "thread is in wrong state", RTEMS_INCORRECT_STATE, }, - { "thread already in state", RTEMS_ALREADY_SUSPENDED, }, - { "illegal on calling thread", RTEMS_ILLEGAL_ON_SELF, }, - { "illegal for remote object", RTEMS_ILLEGAL_ON_REMOTE_OBJECT, }, - { "called from wrong environment", RTEMS_CALLED_FROM_ISR, }, - { "invalid thread priority", RTEMS_INVALID_PRIORITY, }, - { "invalid date/time", RTEMS_INVALID_CLOCK, }, - { "invalid node id", RTEMS_INVALID_NODE, }, - { "directive not configured", RTEMS_NOT_CONFIGURED, }, - { "not owner of resource", RTEMS_NOT_OWNER_OF_RESOURCE , }, - { "directive not implemented", RTEMS_NOT_IMPLEMENTED, }, - { "RTEMS inconsistency detected", RTEMS_INTERNAL_ERROR, }, - { "could not get enough memory", RTEMS_NO_MEMORY, }, - { "internal multiprocessing only", THREAD_STATUS_PROXY_BLOCKING, }, - { 0, 0, 0 }, -}; - - -const char * -rtems_status_text( - rtems_status_code status -) -{ - return rtems_assoc_name_by_local(rtems_status_assoc, status); -} - - -static int rtems_verror( - unsigned32 error_flag, - const char *printf_format, - va_list arglist -) -{ - int local_errno = 0; - int chars_written = 0; - rtems_status_code status; - - if (error_flag & RTEMS_ERROR_PANIC) - { - rtems_panic_in_progress++; - - /* disable task switches */ - _Thread_Disable_dispatch(); - - /* don't aggravate things */ - if (rtems_panic_in_progress > 2) - return 0; - } - - (void) fflush(stdout); /* in case stdout/stderr same */ - - status = error_flag & ~RTEMS_ERROR_MASK; - if (error_flag & RTEMS_ERROR_ERRNO) /* include errno? */ - local_errno = errno; - - if (_System_state_Is_multiprocessing) - fprintf(stderr, "[%d] ", _Configuration_MP_table->node); - - if (rtems_progname && *rtems_progname) - chars_written += fprintf(stderr, "%s: ", rtems_progname); - chars_written += vfprintf(stderr, printf_format, arglist); - - if (status) - chars_written += fprintf(stderr, " (status: %s)", rtems_status_text(status)); - - if (local_errno) - if ((local_errno > 0) && *strerror(local_errno)) - chars_written += fprintf(stderr, " (errno: %s)", strerror(local_errno)); - else - chars_written += fprintf(stderr, " (unknown errno=%d)", local_errno); - - chars_written += fprintf(stderr, "\n"); - - (void) fflush(stderr); - - if (error_flag & (RTEMS_ERROR_PANIC | RTEMS_ERROR_ABORT)) - { - if (error_flag & RTEMS_ERROR_PANIC) - { - rtems_error(0, "fatal error, exiting"); - _exit(local_errno); - } - else - { - rtems_error(0, "fatal error, aborting"); - abort(); - } - } - return chars_written; -} - - -/* - * Report an error. - * error_flag is as above; printf_format is a normal - * printf(3) format string, with its concommitant arguments. - * - * Returns the number of characters written. - */ - -int rtems_error( - int error_flag, - const char *printf_format, - ... - ) -{ - va_list arglist; - int chars_written; - - va_start(arglist, printf_format); - chars_written = rtems_verror(error_flag, printf_format, arglist); - va_end(arglist); - - return chars_written; -} - -/* - * rtems_panic is shorthand for rtems_error(RTEMS_ERROR_PANIC, ...) - */ - -void rtems_panic( - const char *printf_format, - ... - ) -{ - va_list arglist; - - va_start(arglist, printf_format); - (void) rtems_verror(RTEMS_ERROR_PANIC, printf_format, arglist); - va_end(arglist); -} diff --git a/c/src/exec/libcsupport/src/hosterr.c b/c/src/exec/libcsupport/src/hosterr.c deleted file mode 100644 index 7fc2ca966e..0000000000 --- a/c/src/exec/libcsupport/src/hosterr.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Routines to access a host errno - * - * 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 <errno.h> - -int host_errno(void); - -/* - * copy host errno, if any to thread aware errno, if any - */ - -void fix_syscall_errno(void) -{ - errno = host_errno(); -} - -/* - * Get the host system errno, if any - * When using newlib (or possibly other libc's) on top of UNIX - * the errno returned by system calls may be unavailable due - * to trickery of making errno thread aware. - * This provides a kludge of getting at it. - */ - -#undef errno -extern int errno; -int host_errno(void) -{ - return errno; -} - diff --git a/c/src/exec/libcsupport/src/libio.c b/c/src/exec/libcsupport/src/libio.c deleted file mode 100644 index 73b6adf298..0000000000 --- a/c/src/exec/libcsupport/src/libio.c +++ /dev/null @@ -1,445 +0,0 @@ -/* - * @(#)libio.c 1.1 - 95/06/02 - * - * - * Provide UNIX/POSIX-like io system calls for RTEMS using the - * RTEMS IO manager - * - * TODO - * - * $Id$ - */ - -#include <rtems.h> -#include <rtems/assoc.h> /* assoc.h not included by rtems.h */ - -#include <stdio.h> /* O_RDONLY, et.al. */ -#include <fcntl.h> /* O_RDONLY, et.al. */ - -#if defined(solaris2) -#define O_NDELAY O_NONBLOCK -#elif defined(RTEMS_NEWLIB) -#define O_NDELAY _FNBIO -#endif - -#include <errno.h> -#include <string.h> /* strcmp */ -#include <unistd.h> -#include <stdlib.h> /* calloc() */ - -#include "libio.h" /* libio.h not pulled in by rtems */ - -/* - * Semaphore to protect the io table - */ - -Objects_Id rtems_libio_semaphore; - -#define RTEMS_LIBIO_SEM rtems_build_name('L', 'B', 'I', 'O') -#define RTEMS_LIBIO_IOP_SEM(n) rtems_build_name('L', 'B', 'I', n) - -unsigned32 rtems_libio_number_iops; -rtems_libio_t *rtems_libio_iops; -rtems_libio_t *rtems_libio_last_iop; - -#define rtems_libio_iop(fd) ((((unsigned32)(fd)) < rtems_libio_number_iops) ? \ - &rtems_libio_iops[fd] : 0) - -#define rtems_libio_check_fd(fd) \ - do { \ - if ((fd) >= rtems_libio_number_iops) \ - { \ - errno = EBADF; \ - return -1; \ - } \ - } while (0) - -#define rtems_libio_check_buffer(buffer) \ - do { \ - if ((buffer) == 0) \ - { \ - errno = EINVAL; \ - return -1; \ - } \ - } while (0) - -#define rtems_libio_check_count(count) \ - do { \ - if ((count) == 0) \ - { \ - return 0; \ - } \ - } while (0) - -#define rtems_libio_check_permissions(iop, flag) \ - do { \ - if (((iop)->flags & (flag)) == 0) \ - { \ - errno = EINVAL; \ - return -1; \ - } \ - } while (0) - - -void -rtems_libio_config( - rtems_configuration_table *config, - unsigned32 max_fds - ) -{ - rtems_libio_number_iops = max_fds; - - /* - * tweak config to reflect # of semaphores we will need - */ - - config->maximum_semaphores += 1; /* one for iop table */ - config->maximum_semaphores += max_fds; -} - -/* - * Called by bsp startup code to init the libio area. - */ - -void -rtems_libio_init(void) -{ - rtems_status_code rc; - - if (rtems_libio_number_iops > 0) - { - rtems_libio_iops = (rtems_libio_t *) calloc(rtems_libio_number_iops, - sizeof(rtems_libio_t)); - if (rtems_libio_iops == NULL) - rtems_fatal_error_occurred(RTEMS_NO_MEMORY); - - rtems_libio_last_iop = rtems_libio_iops + (rtems_libio_number_iops - 1); - } - - rc = rtems_semaphore_create( - RTEMS_LIBIO_SEM, - 1, - RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY, - RTEMS_NO_PRIORITY, - &rtems_libio_semaphore - ); - if (rc != RTEMS_SUCCESSFUL) - rtems_fatal_error_occurred(rc); -} - -/* - * Convert RTEMS status to a UNIX errno - */ - -rtems_assoc_t errno_assoc[] = { - { "OK", RTEMS_SUCCESSFUL, 0 }, - { "TIMEOUT", RTEMS_TIMEOUT, ETIME }, - { "NO MEMORY", RTEMS_NO_MEMORY, ENOMEM }, - { 0, 0, 0 }, -}; - -static unsigned32 -rtems_libio_errno(rtems_status_code code) -{ - int rc; - - if ((rc = rtems_assoc_remote_by_local(errno_assoc, (unsigned32) code))) - { - errno = rc; - return -1; - } - return 0; -} - -/* - * Convert UNIX fnctl(2) flags to ones that RTEMS drivers understand - */ - -rtems_assoc_t access_modes_assoc[] = { - { "READ", LIBIO_FLAGS_READ, O_RDONLY }, - { "WRITE", LIBIO_FLAGS_WRITE, O_WRONLY }, - { "READ/WRITE", LIBIO_FLAGS_READ_WRITE, O_RDWR }, - { 0, 0, 0 }, -}; - -rtems_assoc_t status_flags_assoc[] = { - { "NO DELAY", LIBIO_FLAGS_NO_DELAY, O_NDELAY }, - { "APPEND", LIBIO_FLAGS_APPEND, O_APPEND }, - { "CREATE", LIBIO_FLAGS_CREATE, O_CREAT }, - { 0, 0, 0 }, -}; - -static unsigned32 -rtems_libio_fcntl_flags(unsigned32 fcntl_flags) -{ - unsigned32 flags = 0; - unsigned32 access_modes; - - /* - * Access mode is a small integer - */ - - access_modes = fcntl_flags & O_ACCMODE; - fcntl_flags &= ~O_ACCMODE; - flags = rtems_assoc_local_by_remote(access_modes_assoc, access_modes); - - /* - * Everything else is single bits - */ - - flags |= rtems_assoc_local_by_remote_bitfield(status_flags_assoc, fcntl_flags); - return flags; -} - - -static rtems_libio_t * -rtems_libio_allocate(void) -{ - rtems_libio_t *iop; - rtems_status_code rc; - - rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); - - for (iop = rtems_libio_iops; iop <= rtems_libio_last_iop; iop++) - if ((iop->flags & LIBIO_FLAGS_OPEN) == 0) - { - /* - * Got one; create a semaphore for it - */ - - rc = rtems_semaphore_create( - RTEMS_LIBIO_IOP_SEM(iop - rtems_libio_iops), - 1, - RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY, - RTEMS_NO_PRIORITY, - &iop->sem - ); - if (rc != RTEMS_SUCCESSFUL) - goto failed; - - iop->flags = LIBIO_FLAGS_OPEN; - goto done; - } - -failed: - iop = 0; - -done: - rtems_semaphore_release(rtems_libio_semaphore); - return iop; -} - -static void -rtems_libio_free(rtems_libio_t *iop) -{ - rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); - - if (iop->sem) - rtems_semaphore_delete(iop->sem); - (void) memset(iop, 0, sizeof(*iop)); - - rtems_semaphore_release(rtems_libio_semaphore); -} - -int -__open( - const char *pathname, - unsigned32 flag, - unsigned32 mode) -{ - rtems_status_code rc; - rtems_libio_t *iop = 0; - rtems_driver_name_t *np; - rtems_libio_open_close_args_t args; - - if ((rc = rtems_io_lookup_name(pathname, &np)) != RTEMS_SUCCESSFUL) - goto done; - - iop = rtems_libio_allocate(); - if (iop == 0) - { - rc = RTEMS_TOO_MANY; - goto done; - } - - iop->driver = np; - iop->pathname = (char *) pathname; - iop->flags |= rtems_libio_fcntl_flags(flag); - - args.iop = iop; - args.flags = iop->flags; - args.mode = mode; - - rc = rtems_io_open(np->major, np->minor, (void *) &args); - -done: - if (rc != RTEMS_SUCCESSFUL) - { - if (iop) - rtems_libio_free(iop); - return rtems_libio_errno(rc); - } - - return iop - rtems_libio_iops; -} - -int -__close( - int fd - ) -{ - rtems_status_code rc; - rtems_driver_name_t *np; - rtems_libio_t *iop = rtems_libio_iop(fd); - rtems_libio_open_close_args_t args; - - rtems_libio_check_fd(fd); - - np = iop->driver; - - args.iop = iop; - args.flags = 0; - args.mode = 0; - - rc = rtems_io_close(np->major, np->minor, (void *) &args); - - if (rc != RTEMS_SUCCESSFUL) - return rtems_libio_errno(rc); - return 0; -} - -int -__read( - int fd, - void * buffer, - unsigned32 count - ) -{ - rtems_status_code rc; - rtems_driver_name_t *np; - rtems_libio_t *iop = rtems_libio_iop(fd); - rtems_libio_rw_args_t args; - - rtems_libio_check_fd(fd); - rtems_libio_check_buffer(buffer); - rtems_libio_check_count(count); - rtems_libio_check_permissions(iop, LIBIO_FLAGS_READ); - - np = iop->driver; - - args.iop = iop; - args.offset = iop->offset; - args.buffer = buffer; - args.count = count; - args.flags = iop->flags; - args.bytes_moved = 0; - - rc = rtems_io_read(np->major, np->minor, (void *) &args); - - iop->offset += args.bytes_moved; - - if (rc != RTEMS_SUCCESSFUL) - return rtems_libio_errno(rc); - - return args.bytes_moved; -} - -int -__write( - int fd, - const void *buffer, - unsigned32 count - ) -{ - rtems_status_code rc; - rtems_driver_name_t *np; - rtems_libio_t *iop = rtems_libio_iop(fd); - rtems_libio_rw_args_t args; - - rtems_libio_check_fd(fd); - rtems_libio_check_buffer(buffer); - rtems_libio_check_count(count); - rtems_libio_check_permissions(iop, LIBIO_FLAGS_WRITE); - - np = iop->driver; - - args.iop = iop; - args.offset = iop->offset; - args.buffer = (void *) buffer; - args.count = count; - args.flags = iop->flags; - args.bytes_moved = 0; - - rc = rtems_io_write(np->major, np->minor, (void *) &args); - - iop->offset += args.bytes_moved; - - if (rc != RTEMS_SUCCESSFUL) - return rtems_libio_errno(rc); - - return args.bytes_moved; -} - -int -__ioctl( - int fd, - unsigned32 command, - void * buffer) -{ - rtems_status_code rc; - rtems_driver_name_t *np; - rtems_libio_t *iop = rtems_libio_iop(fd); - rtems_libio_ioctl_args_t args; - - rtems_libio_check_fd(fd); - - np = iop->driver; - - args.iop = iop; - args.command = command; - args.buffer = buffer; - - rc = rtems_io_control(np->major, np->minor, (void *) &args); - - if (rc != RTEMS_SUCCESSFUL) - return rtems_libio_errno(rc); - - return args.ioctl_return; -} - -/* - * internal only?? - */ - - -int -__lseek( - int fd, - rtems_libio_offset_t offset, - int whence - ) -{ - rtems_libio_t *iop = rtems_libio_iop(fd); - - rtems_libio_check_fd(fd); - - switch (whence) - { - case SEEK_SET: - iop->offset = offset; - break; - - case SEEK_CUR: - iop->offset += offset; - break; - - case SEEK_END: - iop->offset = iop->size - offset; - break; - - default: - errno = EINVAL; - return -1; - } - return 0; -} diff --git a/c/src/exec/libcsupport/src/malloc.c b/c/src/exec/libcsupport/src/malloc.c deleted file mode 100644 index ed053d6e8d..0000000000 --- a/c/src/exec/libcsupport/src/malloc.c +++ /dev/null @@ -1,358 +0,0 @@ -/* - * RTEMS Malloc Family Implementation - * - * - * 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 "libcsupport.h" -#ifdef RTEMS_NEWLIB -#include <sys/reent.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <assert.h> -#include <errno.h> -#include <string.h> - -rtems_id RTEMS_Malloc_Heap; -size_t RTEMS_Malloc_Sbrk_amount; - -#ifdef RTEMS_DEBUG -#define MALLOC_STATS -#endif - -#ifdef MALLOC_STATS -#define MSBUMP(f,n) malloc_stats.f += (n) - -struct { - unsigned32 space_available; /* current size of malloc area */ - unsigned32 malloc_calls; /* # calls to malloc */ - unsigned32 free_calls; - unsigned32 realloc_calls; - unsigned32 calloc_calls; - unsigned32 max_depth; /* most ever malloc'd at 1 time */ - unsigned64 lifetime_allocated; - unsigned64 lifetime_freed; -} malloc_stats; - -#else /* No malloc_stats */ -#define MSBUMP(f,n) -#endif - -void RTEMS_Malloc_Initialize( - void *start, - size_t length, - size_t sbrk_amount -) -{ - rtems_status_code status; - void *starting_address; - rtems_unsigned32 old_address; - rtems_unsigned32 u32_address; - - /* - * If the starting address is 0 then we are to attempt to - * get length worth of memory using sbrk. Make sure we - * align the address that we get back. - */ - - starting_address = start; - RTEMS_Malloc_Sbrk_amount = sbrk_amount; - - if (!starting_address) { - u32_address = (unsigned int)sbrk(length); - - if (u32_address == -1) { - rtems_fatal_error_occurred( RTEMS_NO_MEMORY ); - /* DOES NOT RETURN!!! */ - } - - if (u32_address & (CPU_ALIGNMENT-1)) { - old_address = u32_address; - u32_address = (u32_address + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); - - /* - * adjust the length by whatever we aligned by - */ - - length -= u32_address - old_address; - } - - starting_address = (void *)u32_address; - } - - /* - * Unfortunately we cannot use assert if this fails because if this - * has failed we do not have a heap and if we do not have a heap - * STDIO cannot work because there will be no buffers. - */ - - status = rtems_region_create( - rtems_build_name( 'H', 'E', 'A', 'P' ), - starting_address, - length, - CPU_ALIGNMENT, - RTEMS_DEFAULT_ATTRIBUTES, - &RTEMS_Malloc_Heap - ); - if ( status != RTEMS_SUCCESSFUL ) - rtems_fatal_error_occurred( status ); - -#ifdef MALLOC_STATS - /* zero all the stats */ - (void) memset(&malloc_stats, 0, sizeof(malloc_stats)); -#endif - - MSBUMP(space_available, length); -} - -void *malloc( - size_t size -) -{ - void *return_this; - void *starting_address; - rtems_unsigned32 the_size; - rtems_unsigned32 sbrk_amount; - rtems_status_code status; - - MSBUMP(malloc_calls, 1); - - if ( !size ) - return (void *) 0; - - /* - * Try to give a segment in the current region if there is not - * enough space then try to grow the region using rtems_region_extend(). - * If this fails then return a NULL pointer. - */ - - status = rtems_region_get_segment( - RTEMS_Malloc_Heap, - size, - RTEMS_NO_WAIT, - RTEMS_NO_TIMEOUT, - &return_this - ); - - if ( status != RTEMS_SUCCESSFUL ) { - /* - * Round to the "requested sbrk amount" so hopefully we won't have - * to grow again for a while. This effectively does sbrk() calls - * in "page" amounts. - */ - - sbrk_amount = RTEMS_Malloc_Sbrk_amount; - - if ( sbrk_amount == 0 ) - return (void *) 0; - - the_size = ((size + sbrk_amount) / sbrk_amount * sbrk_amount); - - if (((rtems_unsigned32)starting_address = sbrk(the_size)) == -1) - return (void *) 0; - - status = rtems_region_extend( - RTEMS_Malloc_Heap, - starting_address, - the_size - ); - if ( status != RTEMS_SUCCESSFUL ) { - sbrk(-the_size); - errno = ENOMEM; - return (void *) 0; - } - - MSBUMP(space_available, the_size); - - status = rtems_region_get_segment( - RTEMS_Malloc_Heap, - size, - RTEMS_NO_WAIT, - RTEMS_NO_TIMEOUT, - &return_this - ); - if ( status != RTEMS_SUCCESSFUL ) { - errno = ENOMEM; - return (void *) 0; - } - } - -#ifdef MALLOC_STATS - if (return_this) - { - unsigned32 actual_size; - unsigned32 current_depth; - status = rtems_region_get_segment_size(RTEMS_Malloc_Heap, return_this, &actual_size); - MSBUMP(lifetime_allocated, actual_size); - current_depth = malloc_stats.lifetime_allocated - malloc_stats.lifetime_freed; - if (current_depth > malloc_stats.max_depth) - malloc_stats.max_depth = current_depth; - } -#endif - - return return_this; -} - -void *calloc( - size_t nelem, - size_t elsize -) -{ - register char *cptr; - int length; - - MSBUMP(calloc_calls, 1); - - length = nelem * elsize; - cptr = malloc( length ); - if ( cptr ) - memset( cptr, '\0', length ); - - return cptr; -} - -void *realloc( - void *ptr, - size_t size -) -{ - rtems_unsigned32 old_size; - rtems_status_code status; - char *new_area; - - MSBUMP(realloc_calls, 1); - - if ( !ptr ) - return malloc( size ); - - if ( !size ) { - free( ptr ); - return (void *) 0; - } - - new_area = malloc( size ); - if ( !new_area ) { - free( ptr ); - return (void *) 0; - } - - status = rtems_region_get_segment_size( RTEMS_Malloc_Heap, ptr, &old_size ); - if ( status != RTEMS_SUCCESSFUL ) { - errno = EINVAL; - return (void *) 0; - } - - memcpy( new_area, ptr, (size < old_size) ? size : old_size ); - free( ptr ); - - return new_area; - -} - -void free( - void *ptr -) -{ - rtems_status_code status; - - MSBUMP(free_calls, 1); - - if ( !ptr ) - return; - -#ifdef MALLOC_STATS - { - unsigned32 size; - status = rtems_region_get_segment_size( RTEMS_Malloc_Heap, ptr, &size ); - if ( status == RTEMS_SUCCESSFUL ) { - MSBUMP(lifetime_freed, size); - } - } -#endif - - status = rtems_region_return_segment( RTEMS_Malloc_Heap, ptr ); - if ( status != RTEMS_SUCCESSFUL ) { - errno = EINVAL; - assert( 0 ); - } -} - -#ifdef MALLOC_STATS -/* - * Dump the malloc statistics - * May be called via atexit() (installable by our bsp) or - * at any time by user - */ - -void malloc_dump(void) -{ - unsigned32 allocated = malloc_stats.lifetime_allocated - malloc_stats.lifetime_freed; - - printf("Malloc stats\n"); - printf(" avail:%uk allocated:%uk (%d%%) max:%uk (%d%%) lifetime:%Luk freed:%Luk\n", - (unsigned int) malloc_stats.space_available / 1024, - (unsigned int) allocated / 1024, - /* avoid float! */ - (allocated * 100) / malloc_stats.space_available, - (unsigned int) malloc_stats.max_depth / 1024, - (malloc_stats.max_depth * 100) / malloc_stats.space_available, - (unsigned long long) malloc_stats.lifetime_allocated / 1024, - (unsigned long long) malloc_stats.lifetime_freed / 1024); - printf(" Call counts: malloc:%d free:%d realloc:%d calloc:%d\n", - malloc_stats.malloc_calls, - malloc_stats.free_calls, - malloc_stats.realloc_calls, - malloc_stats.calloc_calls); -} -#endif - -/* - * "Reentrant" versions of the above routines implemented above. - */ - -#ifdef RTEMS_NEWLIB -void *malloc_r( - struct _reent *ignored, - size_t size -) -{ - return malloc( size ); -} - -void *calloc_r( - size_t nelem, - size_t elsize -) -{ - return calloc( nelem, elsize ); -} - -void *realloc_r( - void *ptr, - size_t size -) -{ - return realloc_r( ptr, size ); -} - -void free_r( - void *ptr -) -{ - free( ptr ); -} -#endif - diff --git a/c/src/exec/libcsupport/src/newlibc.c b/c/src/exec/libcsupport/src/newlibc.c deleted file mode 100644 index ddcb961015..0000000000 --- a/c/src/exec/libcsupport/src/newlibc.c +++ /dev/null @@ -1,329 +0,0 @@ -/* - * @(#)newlibc.c 1.9 - 95/05/16 - * - */ - -#if defined(RTEMS_NEWLIB) - -/* - * File: newlibc.c,v - * Project: PixelFlow - * Created: 94/12/7 - * Revision: 1.2 - * Last Mod: 1995/05/09 20:24:37 - * - * 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. - * - * Description: - * Implementation of hooks for the CYGNUS newlib libc - * These hooks set things up so that: - * '_REENT' is switched at task switch time. - * - * - * TODO: - * - * NOTE: - * - * $Id$ - * - */ - -#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ -#include <rtems.h> -#include <libcsupport.h> -#include <stdlib.h> /* for free() */ -#include <string.h> /* for memset() */ - -#include <sys/reent.h> /* for extern of _REENT (aka _impure_ptr) */ - -#ifdef RTEMS_UNIX -#include <stdio.h> /* for setvbuf() */ -#endif - -#include "internal.h" - -#define LIBC_NOTEPAD RTEMS_NOTEPAD_LAST - - -int libc_reentrant; /* do we think we are reentrant? */ -struct _reent libc_global_reent = _REENT_INIT(libc_global_reent);; - -/* - * CYGNUS newlib routine that does atexit() processing and flushes - * stdio streams - * undocumented - */ - -extern void _wrapup_reent(struct _reent *); -extern void _reclaim_reent(struct _reent *); - -void -libc_wrapup(void) -{ - _wrapup_reent(0); - if (_REENT != &libc_global_reent) - { - _wrapup_reent(&libc_global_reent); -#if 0 - /* don't reclaim this one, just in case we do printfs */ - /* on our way out to ROM */ - _reclaim_reent(&libc_global_reent); -#endif - _REENT = &libc_global_reent; - } -} - - -rtems_boolean -libc_create_hook(rtems_tcb *current_task, - rtems_tcb *creating_task) -{ - MY_task_set_note(creating_task, LIBC_NOTEPAD, 0); - return TRUE; -} - -/* - * Called for all user TASKS (system tasks are MPCI Receive Server and IDLE) - */ - -rtems_extension -libc_start_hook(rtems_tcb *current_task, - rtems_tcb *starting_task) -{ - struct _reent *ptr; - - /* NOTE: our malloc is reentrant without a reent ptr since - * it is based on region manager - */ - - ptr = (struct _reent *) malloc(sizeof(struct _reent)); - - /* GCC extension: structure constants */ - *ptr = (struct _reent) _REENT_INIT((*ptr)); - - MY_task_set_note(starting_task, LIBC_NOTEPAD, (rtems_unsigned32) ptr); -} - -/* - * Called for all user TASKS (system tasks are MPCI Receive Server and IDLE) - * - * NOTE: When using RTEMS fake stat, fstat, and isatty, all output - * is line buffered so this setvbuf is not necessary. This - * setvbuf insures that we can redirect the output of a test - * on the UNIX simulator and it is in the same order as for a - * real target. - */ - -#ifdef RTEMS_UNIX -rtems_extension -libc_begin_hook(rtems_tcb *current_task) -{ - setvbuf( stdout, NULL, _IOLBF, BUFSIZ ); -} -#endif - -rtems_extension -libc_switch_hook(rtems_tcb *current_task, - rtems_tcb *heir_task) -{ - rtems_unsigned32 impure_value; - - /* XXX We can't use rtems_task_set_note() here since SYSI task has a - * tid of 0, which is treated specially (optimized, actually) - * by rtems_task_set_note - * - * NOTE: The above comment is no longer true and we need to use - * the extension data areas added about the same time. - */ - - /* - * Don't touch the outgoing task if it has been deleted. - */ - - if ( !_States_Is_transient( current_task->current_state ) ) { - impure_value = (rtems_unsigned32) _REENT; - MY_task_set_note(current_task, LIBC_NOTEPAD, impure_value); - } - - _REENT = (struct _reent *) MY_task_get_note(heir_task, LIBC_NOTEPAD); - -} - -/* - * Function: libc_delete_hook - * Created: 94/12/10 - * - * Description: - * Called when a task is deleted. - * Must restore the new lib reentrancy state for the new current - * task. - * - * Parameters: - * - * - * Returns: - * - * - * Side Effects: - * - * Notes: - * - * - * Deficiencies/ToDo: - * - * - */ -rtems_extension -libc_delete_hook(rtems_tcb *current_task, - rtems_tcb *deleted_task) -{ - struct _reent *ptr; - - /* - * The reentrancy structure was allocated by newlib using malloc() - */ - - if (current_task == deleted_task) - { - ptr = _REENT; - } - else - { - ptr = (struct _reent *) MY_task_get_note(deleted_task, LIBC_NOTEPAD); - } - - /* if (ptr) */ - if (ptr && ptr != &libc_global_reent) - { - _wrapup_reent(ptr); - _reclaim_reent(ptr); - } - - MY_task_set_note(deleted_task, LIBC_NOTEPAD, 0); - - /* - * Require the switch back to another task to install its own - */ - - if (current_task == deleted_task) - { - _REENT = 0; - } -} - -/* - * Function: libc_init - * Created: 94/12/10 - * - * Description: - * Init libc for CYGNUS newlib - * Set up _REENT to use our global libc_global_reent. - * (newlib provides a global of its own, but we prefer our - * own name for it) - * - * If reentrancy is desired (which it should be), then - * we install the task extension hooks to maintain the - * newlib reentrancy global variable _REENT on task - * create, delete, switch, exit, etc. - * - * Parameters: - * reentrant non-zero if reentrant library desired. - * - * Returns: - * - * Side Effects: - * installs libc extensions if reentrant. - * - * Notes: - * - * - * Deficiencies/ToDo: - * - */ - -void -libc_init(int reentrant) -{ - rtems_extensions_table libc_extension; - rtems_id extension_id; - rtems_status_code rc; - - _REENT = &libc_global_reent; - - if (reentrant) - { - memset(&libc_extension, 0, sizeof(libc_extension)); - - libc_extension.thread_create = libc_create_hook; - libc_extension.thread_start = libc_start_hook; -#ifdef RTEMS_UNIX - libc_extension.thread_begin = libc_begin_hook; -#endif - libc_extension.thread_switch = libc_switch_hook; - libc_extension.thread_delete = libc_delete_hook; - - rc = rtems_extension_create(rtems_build_name('L', 'I', 'B', 'C'), - &libc_extension, &extension_id); - if (rc != RTEMS_SUCCESSFUL) - rtems_fatal_error_occurred(rc); - - libc_reentrant = reentrant; - } -} - - -void -exit(int status) -{ - libc_wrapup(); - rtems_shutdown_executive(status); -} - - -/* - * Function: _exit - * Created: 94/12/10 - * - * Description: - * Called from exit() after it does atexit() processing and stdio fflush's - * - * called from bottom of exit() to really delete the task. - * If we are using reentrant libc, then let the delete extension - * do all the work, otherwise if a shutdown is in progress, - * then just do it. - * - * Parameters: - * exit status - * - * Returns: - * does not return - * - * Side Effects: - * - * Notes: - * - * - * Deficiencies/ToDo: - * - * - */ - -#if !defined(RTEMS_UNIX) && !defined(__GO32__) -void _exit(int status) -{ - rtems_shutdown_executive(status); -} -#endif - -#endif diff --git a/c/src/exec/libcsupport/src/no_libc.c b/c/src/exec/libcsupport/src/no_libc.c deleted file mode 100644 index 9bb65f4df6..0000000000 --- a/c/src/exec/libcsupport/src/no_libc.c +++ /dev/null @@ -1,45 +0,0 @@ -#if !defined(RTEMS_NEWLIB) && !defined(RTEMS_UNIX) - -/* no_libc.h - * - * This file contains stubs for the reentrancy hooks when - * an unknown C library is used. - * - * 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 "libcsupport.h" -#include "internal.h" - -#include <stdlib.h> /* for free() */ - -void -libc_init(int reentrant) -{ -} - -void libc_suspend_main(void) -{ -} - - -void libc_global_exit(rtems_unsigned32 code) -{ -} - -void _exit(int status) -{ -} - -#endif diff --git a/c/src/exec/libcsupport/src/unixlibc.c b/c/src/exec/libcsupport/src/unixlibc.c deleted file mode 100644 index 2acd4fba8e..0000000000 --- a/c/src/exec/libcsupport/src/unixlibc.c +++ /dev/null @@ -1,11 +0,0 @@ -/* - * $Id$ - */ - -#if defined(RTEMS_UNIXLIB) - -void libc_init(int reentrant) -{ -} - -#endif diff --git a/c/src/exec/libcsupport/src/utsname.c b/c/src/exec/libcsupport/src/utsname.c deleted file mode 100644 index 98b105023e..0000000000 --- a/c/src/exec/libcsupport/src/utsname.c +++ /dev/null @@ -1,61 +0,0 @@ -/* utsname.c - * - * $Id$ - */ - -#include <stdio.h> -#include <string.h> - -#include <sys/utsname.h> - -#include <rtems/score/system.h> -#include <rtems/score/object.h> - -/*PAGE - * - * 4.4.1 Get System Name, P1003.1b-1993, p. 90 - */ - -int uname( - struct utsname *name -) -{ - /* XXX: Here is what Solaris returns... - sysname = SunOS - nodename = node_name - release = 5.3 - version = Generic_101318-12 - machine = sun4m - */ - - strcpy( name->sysname, "RTEMS" ); - - sprintf( name->nodename, "Node %d\n", _Objects_Local_node ); - - /* XXX release string is in BAD format for this routine!!! */ - strcpy( name->release, "3.2.0" ); - - /* XXX does this have any meaning for RTEMS */ - - strcpy( name->release, "" ); - - sprintf( name->machine, "%s/%s", CPU_NAME, CPU_MODEL_NAME ); - - return 0; -} - -#ifdef NOT_IMPLEMENTED_YET - -/*PAGE - * - * 4.5.2 Get Process Times, P1003.1b-1993, p. 92 - */ - -clock_t times( - struct tms *buffer -) -{ - return POSIX_NOT_IMPLEMENTED(); -} - -#endif |