summaryrefslogtreecommitdiffstats
path: root/c/src/exec
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/exec')
-rw-r--r--c/src/exec/libcsupport/include/rtems/libio.h22
-rw-r--r--c/src/exec/libcsupport/src/libio.c106
-rw-r--r--c/src/exec/score/cpu/a29k/cpu.h12
-rw-r--r--c/src/exec/score/cpu/hppa1.1/cpu.h9
-rw-r--r--c/src/exec/score/cpu/i386/cpu.h9
-rw-r--r--c/src/exec/score/cpu/i960/cpu.h10
-rw-r--r--c/src/exec/score/cpu/m68k/cpu.h9
-rw-r--r--c/src/exec/score/cpu/mips64orion/cpu.h9
-rw-r--r--c/src/exec/score/cpu/no_cpu/cpu.h9
-rw-r--r--c/src/exec/score/cpu/powerpc/cpu.h12
-rw-r--r--c/src/exec/score/cpu/sparc/cpu.h9
-rw-r--r--c/src/exec/score/cpu/unix/cpu.h17
-rw-r--r--c/src/exec/score/headers/Makefile.in7
-rw-r--r--c/src/exec/score/include/rtems/score/Makefile.in7
14 files changed, 228 insertions, 19 deletions
diff --git a/c/src/exec/libcsupport/include/rtems/libio.h b/c/src/exec/libcsupport/include/rtems/libio.h
index b518100484..c79dfc2e33 100644
--- a/c/src/exec/libcsupport/include/rtems/libio.h
+++ b/c/src/exec/libcsupport/include/rtems/libio.h
@@ -99,4 +99,26 @@ int __rtems_lseek(int fd, rtems_libio_offset_t offset, int whence);
int __rtems_fstat(int _fd, struct stat* _sbuf);
int __rtems_isatty(int _fd);
+/*
+ * External I/O handlers
+ */
+typedef struct {
+ 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);
+} rtems_libio_handler_t;
+
+void rtems_register_libio_handler(int handler_flag,
+ const rtems_libio_handler_t *handler);
+
+#define RTEMS_FILE_DESCRIPTOR_TYPE_FILE 0x0000
+#define RTEMS_FILE_DESCRIPTOR_TYPE_SOCKET 0x1000
+#define rtems_make_file_descriptor(fd,flags) ((fd)|(flags))
+#define rtems_file_descriptor_base(fd) ((fd) & 0x0FFF)
+#define rtems_file_descriptor_type(fd) ((fd) & 0xF000)
+#define rtems_file_descriptor_type_index(fd) ((((fd) & 0xF000) >> 12) - 1)
+
#endif /* _RTEMS_LIBIO_H */
diff --git a/c/src/exec/libcsupport/src/libio.c b/c/src/exec/libcsupport/src/libio.c
index 3a7325c422..ec10184a10 100644
--- a/c/src/exec/libcsupport/src/libio.c
+++ b/c/src/exec/libcsupport/src/libio.c
@@ -79,12 +79,34 @@ rtems_libio_t *rtems_libio_last_iop;
} \
} while (0)
+/*
+ * External I/O handlers
+ *
+ * Space for all possible handlers is preallocated
+ * to speed up dispatch to external handlers.
+ */
+
+static rtems_libio_handler_t handlers[15];
+
+void
+rtems_register_libio_handler(
+ int handler_flag,
+ const rtems_libio_handler_t *handler
+)
+{
+ int handler_index = rtems_file_descriptor_type_index(handler_flag);
+
+ if ((handler_index < 0) || (handler_index >= 15))
+ rtems_fatal_error_occurred( RTEMS_INVALID_NUMBER );
+ handlers[handler_index] = *handler;
+}
+
void
rtems_libio_config(
rtems_configuration_table *config,
unsigned32 max_fds
- )
+)
{
rtems_libio_number_iops = max_fds;
@@ -253,15 +275,16 @@ __rtems_open(
rtems_driver_name_t *np;
rtems_libio_open_close_args_t args;
- if ((rc = rtems_io_lookup_name(pathname, &np)) != RTEMS_SUCCESSFUL) {
-/*
- if ( rc == RTEMS_UNSATISFIED ) {
- puts( "open -- ENOSYS case" );
- assert( 0 );
- }
-*/
+ /*
+ * Additional external I/O handlers would be supported by
+ * adding code to pick apart the pathname appropriately.
+ * The networking code does not require changes here since
+ * network file descriptors are obtained using socket(), not
+ * open().
+ */
+
+ if ((rc = rtems_io_lookup_name(pathname, &np)) != RTEMS_SUCCESSFUL)
goto done;
- }
iop = rtems_libio_allocate();
if (iop == 0)
@@ -299,9 +322,20 @@ __rtems_close(
{
rtems_status_code rc;
rtems_driver_name_t *np;
- rtems_libio_t *iop = rtems_libio_iop(fd);
+ rtems_libio_t *iop;
rtems_libio_open_close_args_t args;
+ if (rtems_file_descriptor_type(fd)) {
+ int (*fp)(int fd);
+
+ fp = handlers[rtems_file_descriptor_type_index(fd)].close;
+ if (fp == NULL) {
+ errno = EBADF;
+ return -1;
+ }
+ return (*fp)(fd);
+ }
+ iop = rtems_libio_iop(fd);
rtems_libio_check_fd(fd);
np = iop->driver;
@@ -326,9 +360,20 @@ __rtems_read(
{
rtems_status_code rc;
rtems_driver_name_t *np;
- rtems_libio_t *iop = rtems_libio_iop(fd);
+ rtems_libio_t *iop;
rtems_libio_rw_args_t args;
+ if (rtems_file_descriptor_type(fd)) {
+ int (*fp)(int fd, void *buffer, unsigned32 count);
+
+ fp = handlers[rtems_file_descriptor_type_index(fd)].read;
+ if (fp == NULL) {
+ errno = EBADF;
+ return -1;
+ }
+ return (*fp)(fd, buffer, count);
+ }
+ iop = rtems_libio_iop(fd);
rtems_libio_check_fd(fd);
rtems_libio_check_buffer(buffer);
rtems_libio_check_count(count);
@@ -362,9 +407,20 @@ __rtems_write(
{
rtems_status_code rc;
rtems_driver_name_t *np;
- rtems_libio_t *iop = rtems_libio_iop(fd);
+ rtems_libio_t *iop;
rtems_libio_rw_args_t args;
+ if (rtems_file_descriptor_type(fd)) {
+ int (*fp)(int fd, const void *buffer, unsigned32 count);
+
+ fp = handlers[rtems_file_descriptor_type_index(fd)].write;
+ if (fp == NULL) {
+ errno = EBADF;
+ return -1;
+ }
+ return (*fp)(fd, buffer, count);
+ }
+ iop = rtems_libio_iop(fd);
rtems_libio_check_fd(fd);
rtems_libio_check_buffer(buffer);
rtems_libio_check_count(count);
@@ -397,9 +453,20 @@ __rtems_ioctl(
{
rtems_status_code rc;
rtems_driver_name_t *np;
- rtems_libio_t *iop = rtems_libio_iop(fd);
+ rtems_libio_t *iop;
rtems_libio_ioctl_args_t args;
+ if (rtems_file_descriptor_type(fd)) {
+ int (*fp)(int fd, unsigned32 command, void *buffer);
+
+ fp = handlers[rtems_file_descriptor_type_index(fd)].ioctl;
+ if (fp == NULL) {
+ errno = EBADF;
+ return -1;
+ }
+ return (*fp)(fd, command, buffer);
+ }
+ iop = rtems_libio_iop(fd);
rtems_libio_check_fd(fd);
np = iop->driver;
@@ -428,8 +495,19 @@ __rtems_lseek(
int whence
)
{
- rtems_libio_t *iop = rtems_libio_iop(fd);
+ rtems_libio_t *iop;
+
+ if (rtems_file_descriptor_type(fd)) {
+ int (*fp)(int fd, rtems_libio_offset_t offset, int whence);
+ fp = handlers[rtems_file_descriptor_type_index(fd)].lseek;
+ if (fp == NULL) {
+ errno = EBADF;
+ return -1;
+ }
+ return (*fp)(fd, offset, whence);
+ }
+ iop = rtems_libio_iop(fd);
rtems_libio_check_fd(fd);
switch (whence)
diff --git a/c/src/exec/score/cpu/a29k/cpu.h b/c/src/exec/score/cpu/a29k/cpu.h
index e988e6e9ed..3e7a9788f1 100644
--- a/c/src/exec/score/cpu/a29k/cpu.h
+++ b/c/src/exec/score/cpu/a29k/cpu.h
@@ -297,6 +297,18 @@ extern void a29k_sigdfl_sup(void);
#define CPU_STRUCTURE_ALIGNMENT
/*
+ * Define what is required to specify how the network to host conversion
+ * routines are handled.
+ *
+ */
+
+#error "Check these definitions!!!"
+
+#define CPU_CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE
+#define CPU_BIG_ENDIAN TRUE
+#define CPU_LITTLE_ENDIAN FALSE
+
+/*
* The following defines the number of bits actually used in the
* interrupt field of the task mode. How those bits map to the
* CPU interrupt levels is defined by the routine _CPU_ISR_Set_level().
diff --git a/c/src/exec/score/cpu/hppa1.1/cpu.h b/c/src/exec/score/cpu/hppa1.1/cpu.h
index 2d35735ad4..848fbe6994 100644
--- a/c/src/exec/score/cpu/hppa1.1/cpu.h
+++ b/c/src/exec/score/cpu/hppa1.1/cpu.h
@@ -64,6 +64,15 @@ extern "C" {
#define CPU_STACK_GROWS_UP TRUE
#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((__aligned__ (32)))
+/*
+ * Define what is required to specify how the network to host conversion
+ * routines are handled.
+ */
+
+#define CPU_CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE
+#define CPU_BIG_ENDIAN TRUE
+#define CPU_LITTLE_ENDIAN FALSE
+
/* constants */
#define CPU_MODES_INTERRUPT_LEVEL 0x00000001 /* interrupt level in mode */
diff --git a/c/src/exec/score/cpu/i386/cpu.h b/c/src/exec/score/cpu/i386/cpu.h
index 15aa3ee7e2..014b7aae90 100644
--- a/c/src/exec/score/cpu/i386/cpu.h
+++ b/c/src/exec/score/cpu/i386/cpu.h
@@ -58,6 +58,15 @@ extern "C" {
#define CPU_STACK_GROWS_UP FALSE
#define CPU_STRUCTURE_ALIGNMENT
+/*
+ * Define what is required to specify how the network to host conversion
+ * routines are handled.
+ */
+
+#define CPU_CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE
+#define CPU_BIG_ENDIAN FALSE
+#define CPU_LITTLE_ENDIAN TRUE
+
/* structures */
/*
diff --git a/c/src/exec/score/cpu/i960/cpu.h b/c/src/exec/score/cpu/i960/cpu.h
index b8e22942ea..323e40c2a8 100644
--- a/c/src/exec/score/cpu/i960/cpu.h
+++ b/c/src/exec/score/cpu/i960/cpu.h
@@ -61,6 +61,16 @@ extern "C" {
#define CPU_STACK_GROWS_UP TRUE
#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (16)))
+/*
+ * Define what is required to specify how the network to host conversion
+ * routines are handled.
+ */
+
+#define CPU_CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE
+#define CPU_BIG_ENDIAN TRUE
+#define CPU_LITTLE_ENDIAN FALSE
+
+
/* structures */
/*
diff --git a/c/src/exec/score/cpu/m68k/cpu.h b/c/src/exec/score/cpu/m68k/cpu.h
index 1cd1b73c37..5f2311b16b 100644
--- a/c/src/exec/score/cpu/m68k/cpu.h
+++ b/c/src/exec/score/cpu/m68k/cpu.h
@@ -75,6 +75,15 @@ extern "C" {
#define CPU_STACK_GROWS_UP FALSE
#define CPU_STRUCTURE_ALIGNMENT
+/*
+ * Define what is required to specify how the network to host conversion
+ * routines are handled.
+ */
+
+#define CPU_CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE
+#define CPU_BIG_ENDIAN TRUE
+#define CPU_LITTLE_ENDIAN FALSE
+
#ifndef ASM
/* structures */
diff --git a/c/src/exec/score/cpu/mips64orion/cpu.h b/c/src/exec/score/cpu/mips64orion/cpu.h
index 8c9c380cf1..cb80f3fbd9 100644
--- a/c/src/exec/score/cpu/mips64orion/cpu.h
+++ b/c/src/exec/score/cpu/mips64orion/cpu.h
@@ -291,6 +291,15 @@ extern void mips_fatal_error ( int error );
#endif
/*
+ * Define what is required to specify how the network to host conversion
+ * routines are handled.
+ */
+
+#define CPU_CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE
+#define CPU_BIG_ENDIAN TRUE
+#define CPU_LITTLE_ENDIAN FALSE
+
+/*
* The following defines the number of bits actually used in the
* interrupt field of the task mode. How those bits map to the
* CPU interrupt levels is defined by the routine _CPU_ISR_Set_level().
diff --git a/c/src/exec/score/cpu/no_cpu/cpu.h b/c/src/exec/score/cpu/no_cpu/cpu.h
index 545627bbbd..b02e12879d 100644
--- a/c/src/exec/score/cpu/no_cpu/cpu.h
+++ b/c/src/exec/score/cpu/no_cpu/cpu.h
@@ -260,6 +260,15 @@ extern "C" {
#define CPU_STRUCTURE_ALIGNMENT
/*
+ * Define what is required to specify how the network to host conversion
+ * routines are handled.
+ */
+
+#define CPU_CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE
+#define CPU_BIG_ENDIAN TRUE
+#define CPU_LITTLE_ENDIAN FALSE
+
+/*
* The following defines the number of bits actually used in the
* interrupt field of the task mode. How those bits map to the
* CPU interrupt levels is defined by the routine _CPU_ISR_Set_level().
diff --git a/c/src/exec/score/cpu/powerpc/cpu.h b/c/src/exec/score/cpu/powerpc/cpu.h
index b64ad914d8..0716f29e9d 100644
--- a/c/src/exec/score/cpu/powerpc/cpu.h
+++ b/c/src/exec/score/cpu/powerpc/cpu.h
@@ -284,7 +284,17 @@ struct CPU_Interrupt_frame;
* in the executive to justify turning this on.
*/
-#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (PPC_CACHE_ALIGNMENT)))
+#define CPU_STRUCTURE_ALIGNMENT \
+ __attribute__ ((aligned (PPC_CACHE_ALIGNMENT)))
+
+/*
+ * Define what is required to specify how the network to host conversion
+ * routines are handled.
+ */
+
+#define CPU_CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE
+#define CPU_BIG_ENDIAN TRUE
+#define CPU_LITTLE_ENDIAN FALSE
/*
* The following defines the number of bits actually used in the
diff --git a/c/src/exec/score/cpu/sparc/cpu.h b/c/src/exec/score/cpu/sparc/cpu.h
index fe849c79d0..00f12a8ecb 100644
--- a/c/src/exec/score/cpu/sparc/cpu.h
+++ b/c/src/exec/score/cpu/sparc/cpu.h
@@ -185,6 +185,15 @@ extern "C" {
#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (16)))
/*
+ * Define what is required to specify how the network to host conversion
+ * routines are handled.
+ */
+
+#define CPU_CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE
+#define CPU_BIG_ENDIAN TRUE
+#define CPU_LITTLE_ENDIAN FALSE
+
+/*
* The following defines the number of bits actually used in the
* interrupt field of the task mode. How those bits map to the
* CPU interrupt levels is defined by the routine _CPU_ISR_Set_level().
diff --git a/c/src/exec/score/cpu/unix/cpu.h b/c/src/exec/score/cpu/unix/cpu.h
index 9565bbca63..b473a23727 100644
--- a/c/src/exec/score/cpu/unix/cpu.h
+++ b/c/src/exec/score/cpu/unix/cpu.h
@@ -285,6 +285,23 @@ extern "C" {
#endif
/*
+ * Define what is required to specify how the network to host conversion
+ * routines are handled.
+ */
+
+#if defined(hppa1_1) || defined(sparc)
+#define CPU_CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE
+#define CPU_BIG_ENDIAN TRUE
+#define CPU_LITTLE_ENDIAN FALSE
+#elif defined(i386) || defined(__i386__)
+#define CPU_CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE
+#define CPU_BIG_ENDIAN FALSE
+#define CPU_LITTLE_ENDIAN TRUE
+#else
+#error "Unknown CPU!!!"
+#endif
+
+/*
* The following defines the number of bits actually used in the
* interrupt field of the task mode. How those bits map to the
* CPU interrupt levels is defined by the routine _CPU_ISR_Set_level().
diff --git a/c/src/exec/score/headers/Makefile.in b/c/src/exec/score/headers/Makefile.in
index 1bafab677c..1be9ef5221 100644
--- a/c/src/exec/score/headers/Makefile.in
+++ b/c/src/exec/score/headers/Makefile.in
@@ -10,7 +10,7 @@ VPATH=@srcdir@
# H_FILES that get installed in the rtems/score subdirectoy
H_PIECES= address apiext bitfield chain context copyrt coremsg coremutex \
coresem heap interr isr mpci mppkt object objectmp \
- priority stack states sysstate system thread threadmp threadq \
+ priority stack states sysstate thread threadmp threadq \
tod tqdata userext watchdog wkspace
H_FILES=$(H_PIECES:%=$(srcdir)/%.h)
@@ -19,10 +19,12 @@ SAPI_H_PIECES=debug system
SAPI_H_FILES=$(SAPI_H_PIECES:%=$(srcdir)/%.h)
# H_FILES that get installed at the top level
-# system.h is handled specially
EXTERNAL_H_PIECES =
EXTERNAL_H_FILES=$(EXTERNAL_H_PIECES:%=$(srcdir)/%.h)
+NET_H_PIECES = in
+NET_H_FILES=$(NET_H_PIECES:%=$(srcdir)/%.h)
+
SRCS=$(H_FILES) $(SAPI_H_FILES) $(EXTERNAL_H_FILES)
include $(RTEMS_CUSTOM)
@@ -41,4 +43,5 @@ CLOBBER_ADDITIONS +=
all: $(SRCS)
$(INSTALL) -m 444 ${H_FILES} ${PROJECT_RELEASE}/include/rtems/score
$(INSTALL) -m 444 ${SAPI_H_FILES} ${PROJECT_RELEASE}/include/rtems/
+ $(INSTALL) -m 444 ${NET_H_FILES} ${PROJECT_RELEASE}/include/netinet
# $(INSTALL) -m 444 ${EXTERNAL_H_FILES} ${PROJECT_RELEASE}/include
diff --git a/c/src/exec/score/include/rtems/score/Makefile.in b/c/src/exec/score/include/rtems/score/Makefile.in
index 1bafab677c..1be9ef5221 100644
--- a/c/src/exec/score/include/rtems/score/Makefile.in
+++ b/c/src/exec/score/include/rtems/score/Makefile.in
@@ -10,7 +10,7 @@ VPATH=@srcdir@
# H_FILES that get installed in the rtems/score subdirectoy
H_PIECES= address apiext bitfield chain context copyrt coremsg coremutex \
coresem heap interr isr mpci mppkt object objectmp \
- priority stack states sysstate system thread threadmp threadq \
+ priority stack states sysstate thread threadmp threadq \
tod tqdata userext watchdog wkspace
H_FILES=$(H_PIECES:%=$(srcdir)/%.h)
@@ -19,10 +19,12 @@ SAPI_H_PIECES=debug system
SAPI_H_FILES=$(SAPI_H_PIECES:%=$(srcdir)/%.h)
# H_FILES that get installed at the top level
-# system.h is handled specially
EXTERNAL_H_PIECES =
EXTERNAL_H_FILES=$(EXTERNAL_H_PIECES:%=$(srcdir)/%.h)
+NET_H_PIECES = in
+NET_H_FILES=$(NET_H_PIECES:%=$(srcdir)/%.h)
+
SRCS=$(H_FILES) $(SAPI_H_FILES) $(EXTERNAL_H_FILES)
include $(RTEMS_CUSTOM)
@@ -41,4 +43,5 @@ CLOBBER_ADDITIONS +=
all: $(SRCS)
$(INSTALL) -m 444 ${H_FILES} ${PROJECT_RELEASE}/include/rtems/score
$(INSTALL) -m 444 ${SAPI_H_FILES} ${PROJECT_RELEASE}/include/rtems/
+ $(INSTALL) -m 444 ${NET_H_FILES} ${PROJECT_RELEASE}/include/netinet
# $(INSTALL) -m 444 ${EXTERNAL_H_FILES} ${PROJECT_RELEASE}/include