summaryrefslogtreecommitdiffstats
path: root/c/src
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1997-04-09 14:05:50 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1997-04-09 14:05:50 +0000
commite2d795597310f976af211f9bac2466dbf89b50c8 (patch)
tree7d3053fa42d08569c75a1add4c5715a5fc8ff4fa /c/src
parentbed475e288765cbfafffe79a3cb69ea7f3027c86 (diff)
downloadrtems-e2d795597310f976af211f9bac2466dbf89b50c8.tar.bz2
Added ka9q tcpip stack and network driver for the gen68360. This effort
was done based on the 3.6.0 release and had to be autoconf'ed locally. It is turned on is the bsp enables it and it is not explicitly disabled via the configure option --disable-tcpip. As many warnings as possible were removed locally after the code was merged. Only the gen68360 and mvme136 bsps were compiled this way. The ka9q port and network driver were submitted by Eric Norum (eric@skatter.USask.Ca). The network demo programs are not included in the tree at this point.
Diffstat (limited to 'c/src')
-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
-rw-r--r--c/src/lib/Makefile.in6
-rw-r--r--c/src/lib/include/Makefile.in20
-rw-r--r--c/src/lib/include/rtems/libio.h22
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/Makefile.in6
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/README38
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/console/console.c19
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/include/bsp.h19
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/include/sio.h62
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/start/start360.s20
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/start360/start360.s20
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/startup/Makefile.in5
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/startup/alloc360.c96
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/startup/init68360.c168
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/startup/linkcmds56
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.bootp146
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.prom63
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/wrapup/Makefile.in9
-rw-r--r--c/src/lib/libc/libio.c106
-rw-r--r--c/src/lib/libc/libio.h22
-rw-r--r--c/src/lib/wrapup/Makefile.in1
-rw-r--r--c/src/wrapup/Makefile.in1
35 files changed, 1020 insertions, 132 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
diff --git a/c/src/lib/Makefile.in b/c/src/lib/Makefile.in
index d57b1c955f..7407251c0e 100644
--- a/c/src/lib/Makefile.in
+++ b/c/src/lib/Makefile.in
@@ -10,4 +10,8 @@ VPATH=@srcdir@
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/directory.cfg
-SUB_DIRS=start include libmisc libc libcpu libbsp wrapup
+# We only build the ka9q library if HAS_KA9Q was defined
+LIBKA9Q_yes_V = libka9q
+LIBKA9Q = $(LIBKA9Q_$(HAS_KA9Q)_V)
+
+SUB_DIRS=start include libmisc libc libcpu libbsp $(LIBKA9Q) wrapup
diff --git a/c/src/lib/include/Makefile.in b/c/src/lib/include/Makefile.in
index 60dad03bc6..092b7c9766 100644
--- a/c/src/lib/include/Makefile.in
+++ b/c/src/lib/include/Makefile.in
@@ -7,14 +7,20 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH=@srcdir@
-H_FILES=console.h clockdrv.h iosupp.h ringbuf.h \
- spurious.h timerdrv.h vmeintr.h z8036.h z8530.h z8536.h
+H_PIECES=console clockdrv iosupp ringbuf \
+ spurious timerdrv vmeintr z8036 z8530 z8536
+H_FILES=$(H_PIECES:%=$(srcdir)/%.h)
-HH_FILES=$(H_FILES:%=$(srcdir)/%)
+KA9Q_H_PIECES= arp asy ax25 ax25mail bootp cmdparse commands config \
+ daemon dialer domain enet ftp ftpcli global hardware icmp iface \
+ internet ip kiss lapb lzw mailbox mbuf netuser nospc nr4 nr4mail \
+ nrs ping pktdrvr ppp proc rip rtems_ka9q sb session slhc slip smtp \
+ sockaddr socket tcp telnet tftp timer tipmail trace udp usock
+KA9Q_H_FILES=$(KA9Q_H_PIECES:%=$(srcdir)/ka9q/%.h)
SYS_H_FILES=
-SRCS=$(HH_FILES) $(SYS_H_FILES)
+SRCS=$(H_FILES) $(SYS_H_FILES)
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/leaf.cfg
@@ -23,6 +29,8 @@ CLEAN_ADDITIONS +=
CLOBBER_ADDITIONS +=
all: $(SRCS)
- $(INSTALL) -m 444 $(HH_FILES) ${PROJECT_RELEASE}/include
+ $(INSTALL) -m 444 $(H_FILES) ${PROJECT_RELEASE}/include
$(INSTALL) -m 444 $(SYS_H_FILES) ${PROJECT_RELEASE}/include/sys
-
+ifeq ($(HAS_KA9Q),yes)
+ $(INSTALL) -m 444 $(KA9Q_H_FILES) ${PROJECT_RELEASE}/include/ka9q
+endif
diff --git a/c/src/lib/include/rtems/libio.h b/c/src/lib/include/rtems/libio.h
index b518100484..c79dfc2e33 100644
--- a/c/src/lib/include/rtems/libio.h
+++ b/c/src/lib/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/lib/libbsp/m68k/gen68360/Makefile.in b/c/src/lib/libbsp/m68k/gen68360/Makefile.in
index 9581a49c3b..02c21db8d8 100644
--- a/c/src/lib/libbsp/m68k/gen68360/Makefile.in
+++ b/c/src/lib/libbsp/m68k/gen68360/Makefile.in
@@ -12,8 +12,12 @@ include $(PROJECT_ROOT)/make/directory.cfg
SRCS=README
+# We only build the ka9q device driver if HAS_KA9Q was defined
+LIBKA9Q_yes_V = network
+LIBKA9Q = $(LIBKA9Q_$(HAS_KA9Q)_V)
+
all: $(SRCS)
# wrapup is the one that actually builds and installs the library
# from the individual .rel files built in other directories
-SUB_DIRS=include start360 startup clock console timer wrapup
+SUB_DIRS=include start360 startup clock console timer $(LIBKA9Q) wrapup
diff --git a/c/src/lib/libbsp/m68k/gen68360/README b/c/src/lib/libbsp/m68k/gen68360/README
index cbbc295fab..131a85651f 100644
--- a/c/src/lib/libbsp/m68k/gen68360/README
+++ b/c/src/lib/libbsp/m68k/gen68360/README
@@ -3,7 +3,7 @@
#
#
-# This package requires a version of GCC that has been modified
+# This package works best with a version of GCC that has been modified
# to support the `-mcpu32' argument. I have submitted the required
# changes to the GCC maintainers.
#
@@ -19,8 +19,37 @@
# eric@skatter.usask.ca
#
+#
+# This board support package works with several different versions of
+# MC68360 systems. The choice of hardware is made at the final link-edit
+# phase by setting the Makefile LDFLAGS definition appropriately.
+#
+# Decisions to be made a link-edit time include:
+# - The version of hardware on which the application is to run.
+# This is selected by defining the MC68360HardwareType variable.
+# Supported values are:
+# MC68360HardwareTypeMotorolaGeneric (default)
+# MC68360HardwareTypeAtlasHSB
+# To select the Atlas Computer Equipment HSB,
+# --defsym MC68360HardwareType=MC68360HardwareTypeAtlasHSB
+#
+# - The amount of dynamic RAM in the system. This value applies
+# only to hardware versions which support different sizes of RAM.
+# The default value is 4 Mbytes. To specify 16 Mbytes of memory,
+# --defsym RamSize=0x1000000
+#
+# - The size of the memory allocator heap. The default value is
+# 64 kbytes. If the KA9Q network package is used the heap
+# should be at least 256 kbytes. If your network is large, or
+# busy, the heap should be even larger.
+# To choose a heap size of 256 kbytes,
+# --defsym HeapSize=0x40000
+#
+
BSP NAME: gen68360
-BOARD: home-built
+BOARD: Generic 68360 as described in Motorola MC68360 User's Manual
+BOARD: Atlas Computer Equipment Inc. High Speed Bridge (HSB)
+BOARD: Atlas Computer Equipment Inc. Advanced Communication Engine (ACE)
BUS: none
CPU FAMILY: Motorola CPU32+
COPROCESSORS: none
@@ -63,7 +92,7 @@ Board description
clock rate: 25 MHz
bus width: 8-bit PROM, 32-bit DRAM
ROM: To 1 MByte, 180 nsec (3 wait states), chip select 0
-RAM: 4 MByte DRAM SIMM, 60 nsec (0 wait states), parity
+RAM: 1 to 64 MByte DRAM SIMM, 60 nsec (0 wait states), parity or nonparity
Host System
-----------
@@ -252,13 +281,14 @@ Porting
-------
This board support package is written for a 68360 system similar to that
described in chapter 9 of the Motorola MC68360 Quad Integrated Communication
-Processor Users' Manual. The salient details of this hardware are:
+Processor Users' Manual. The salient features of this hardware are:
25 MHz external clock
DRAM address multiplexing provided by 68360
8-bit 180nsec PROM to CS0*
4 MBytes of 60 nsec parity DRAM (1Mx36) to RAS1*/CAS1*
Console serial port on SMC1
+ Ethernet interface on SCC1
The board support package has been tested with a home-built board and with an
ACE360A board produced by:
diff --git a/c/src/lib/libbsp/m68k/gen68360/console/console.c b/c/src/lib/libbsp/m68k/gen68360/console/console.c
index bc451e2609..c840d78fd9 100644
--- a/c/src/lib/libbsp/m68k/gen68360/console/console.c
+++ b/c/src/lib/libbsp/m68k/gen68360/console/console.c
@@ -42,17 +42,10 @@
*/
/*
- * Place buffer descriptors at end of User Data/BD space in dual-port RAM
- */
-#define consoleRxBd ((volatile m360BufferDescriptor_t *)((char *)m360.dpram1 + \
- (sizeof(m360.dpram2) - 2*sizeof(m360BufferDescriptor_t))))
-#define consoleTxBd ((volatile m360BufferDescriptor_t *)((char *)m360.dpram1 + \
- (sizeof(m360.dpram2) - sizeof(m360BufferDescriptor_t))))
-
-/*
* I/O buffers can be in ordindary RAM
*/
static volatile char rxBuf, txBuf;
+static volatile m360BufferDescriptor_t *consoleRxBd, *consoleTxBd;
rtems_device_driver console_initialize(
rtems_device_major_number major,
@@ -63,6 +56,12 @@ rtems_device_driver console_initialize(
rtems_status_code status;
/*
+ * Allocate buffer descriptors
+ */
+ consoleRxBd = M360AllocateBufferDescriptors (1);
+ consoleTxBd = M360AllocateBufferDescriptors (1);
+
+ /*
* Configure port B pins to enable SMTXD1 and SMRXD1 pins
*/
m360.pbpar |= 0xC0;
@@ -121,9 +120,7 @@ rtems_device_driver console_initialize(
/*
* Send "Init parameters" command
*/
- m360.cr = M360_CR_OP_INIT_RX_TX | M360_CR_CHAN_SMC1 | M360_CR_FLG;
- while (m360.cr & M360_CR_FLG)
- continue;
+ M360ExecuteRISC (M360_CR_OP_INIT_RX_TX | M360_CR_CHAN_SMC1);
/*
* Enable receiver and transmitter
diff --git a/c/src/lib/libbsp/m68k/gen68360/include/bsp.h b/c/src/lib/libbsp/m68k/gen68360/include/bsp.h
index 508501e6e8..209c71aebe 100644
--- a/c/src/lib/libbsp/m68k/gen68360/include/bsp.h
+++ b/c/src/lib/libbsp/m68k/gen68360/include/bsp.h
@@ -119,6 +119,8 @@ extern m68k_isr_entry M68Kvec[]; /* vector table address */
void bsp_cleanup( void );
void M360ExecuteRISC( rtems_unsigned16 command );
+void *M360AllocateBufferDescriptors( int count );
+void *M360AllocateRiscTimers( int count );
m68k_isr_entry set_vector(
rtems_isr_entry handler,
@@ -126,6 +128,23 @@ m68k_isr_entry set_vector(
int type
);
+/*
+ * Values assigned by link editor
+ */
+extern void *_RomBase, *_RamBase, *_RamSize;
+extern void *_MC68360HardwareType;
+extern void *_MC68360HardwareTypeMotorolaGeneric;
+extern void *_MC68360HardwareTypeAtlasHSB;
+
+/*
+ * Definitions for Atlas Computer Equipment Inc. High Speed Bridge (HSB)
+ */
+#define ATLASHSB_ESR 0x20010000L
+#define ATLASHSB_USICR 0x20010001L
+#define ATLASHSB_DSRR 0x20010002L
+#define ATLASHSB_LED4 0x20010004L
+#define ATLASHSB_ROM_U6 0xFF080000L /* U6 flash ROM socket */
+
#ifdef __cplusplus
}
#endif
diff --git a/c/src/lib/libbsp/m68k/gen68360/include/sio.h b/c/src/lib/libbsp/m68k/gen68360/include/sio.h
new file mode 100644
index 0000000000..a93544c312
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/gen68360/include/sio.h
@@ -0,0 +1,62 @@
+/* sio.h
+ *
+ * sio device driver for UART SCC and SMC
+ *
+ * COPYRIGHT (c) 1997 Pacific Computing
+ *
+ * $Id$
+ */
+
+#ifndef _SIO_DRIVER_h
+#define _SIO_DRIVER_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SIO_DRIVER_TABLE_ENTRY \
+ { sio_initialize, sio_open, sio_close, \
+ sio_read, sio_write, sio_control }
+
+rtems_device_driver sio_initialize(
+ rtems_device_major_number,
+ rtems_device_minor_number,
+ void *
+);
+
+rtems_device_driver sio_open(
+ rtems_device_major_number,
+ rtems_device_minor_number,
+ void *
+);
+
+rtems_device_driver sio_close(
+ rtems_device_major_number,
+ rtems_device_minor_number,
+ void *
+);
+
+rtems_device_driver sio_read(
+ rtems_device_major_number,
+ rtems_device_minor_number,
+ void *
+);
+
+rtems_device_driver sio_write(
+ rtems_device_major_number,
+ rtems_device_minor_number,
+ void *
+);
+
+rtems_device_driver sio_control(
+ rtems_device_major_number,
+ rtems_device_minor_number,
+ void *
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/c/src/lib/libbsp/m68k/gen68360/start/start360.s b/c/src/lib/libbsp/m68k/gen68360/start/start360.s
index 89ab98a806..77c4ff3115 100644
--- a/c/src/lib/libbsp/m68k/gen68360/start/start360.s
+++ b/c/src/lib/libbsp/m68k/gen68360/start/start360.s
@@ -56,7 +56,7 @@ Entry:
.long uhoh | 21:
.long uhoh | 22:
.long uhoh | 23:
- .long uhoh | 24: Spurious interrupt
+ .long spurious_interrupt | 24: Spurious interrupt
.long uhoh | 25: Level 1 interrupt autovector
.long uhoh | 26: Level 2 interrupt autovector
.long uhoh | 27: Level 3 interrupt autovector
@@ -298,6 +298,13 @@ uhoh: nop | Leave spot for breakpoint
bra.s uhoh | Stuck forever
/*
+ * Log, but otherwise ignore, spurious interrupts
+ */
+spurious_interrupt:
+ addql #1,SYM(_M68kSpuriousInterruptCount)
+ rte
+
+/*
* Place the low-order 3 octets of the board's ethernet address at
* a `well-known' fixed location relative to the beginning of ROM.
*/
@@ -307,7 +314,7 @@ uhoh: nop | Leave spot for breakpoint
/*
* Initial PC
*/
- .global start
+ .global start
start:
/*
* Step 2: Stay in Supervisor Mode
@@ -386,6 +393,8 @@ ZEROLOOPTEST:
| Should this just force a reset?
mainDone: nop | Leave spot for breakpoint
+ movew #1,a7 | Force a double bus error
+ movel d0,a7@- | This should cause a RESET
stop #0x2700 | Stop with interrupts disabled
bra.s mainDone | Stuck forever
@@ -398,9 +407,14 @@ SYM (_StackSize):
.long StackSize
END_CODE
-BEGIN_BSS
+BEGIN_DATA_DCL
.align 2
PUBLIC (environ)
SYM (environ):
.long 0
+ PUBLIC (_M68kSpuriousInterruptCount)
+SYM (_M68kSpuriousInterruptCount):
+ .long 0
+END_DATA_DCL
+
END
diff --git a/c/src/lib/libbsp/m68k/gen68360/start360/start360.s b/c/src/lib/libbsp/m68k/gen68360/start360/start360.s
index 89ab98a806..77c4ff3115 100644
--- a/c/src/lib/libbsp/m68k/gen68360/start360/start360.s
+++ b/c/src/lib/libbsp/m68k/gen68360/start360/start360.s
@@ -56,7 +56,7 @@ Entry:
.long uhoh | 21:
.long uhoh | 22:
.long uhoh | 23:
- .long uhoh | 24: Spurious interrupt
+ .long spurious_interrupt | 24: Spurious interrupt
.long uhoh | 25: Level 1 interrupt autovector
.long uhoh | 26: Level 2 interrupt autovector
.long uhoh | 27: Level 3 interrupt autovector
@@ -298,6 +298,13 @@ uhoh: nop | Leave spot for breakpoint
bra.s uhoh | Stuck forever
/*
+ * Log, but otherwise ignore, spurious interrupts
+ */
+spurious_interrupt:
+ addql #1,SYM(_M68kSpuriousInterruptCount)
+ rte
+
+/*
* Place the low-order 3 octets of the board's ethernet address at
* a `well-known' fixed location relative to the beginning of ROM.
*/
@@ -307,7 +314,7 @@ uhoh: nop | Leave spot for breakpoint
/*
* Initial PC
*/
- .global start
+ .global start
start:
/*
* Step 2: Stay in Supervisor Mode
@@ -386,6 +393,8 @@ ZEROLOOPTEST:
| Should this just force a reset?
mainDone: nop | Leave spot for breakpoint
+ movew #1,a7 | Force a double bus error
+ movel d0,a7@- | This should cause a RESET
stop #0x2700 | Stop with interrupts disabled
bra.s mainDone | Stuck forever
@@ -398,9 +407,14 @@ SYM (_StackSize):
.long StackSize
END_CODE
-BEGIN_BSS
+BEGIN_DATA_DCL
.align 2
PUBLIC (environ)
SYM (environ):
.long 0
+ PUBLIC (_M68kSpuriousInterruptCount)
+SYM (_M68kSpuriousInterruptCount):
+ .long 0
+END_DATA_DCL
+
END
diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/Makefile.in b/c/src/lib/libbsp/m68k/gen68360/startup/Makefile.in
index a26be2b371..aa3058786c 100644
--- a/c/src/lib/libbsp/m68k/gen68360/startup/Makefile.in
+++ b/c/src/lib/libbsp/m68k/gen68360/startup/Makefile.in
@@ -10,13 +10,14 @@ VPATH=@srcdir@
PGM=${ARCH}/startup.rel
# C source names, if any, go here -- minus the .c
-C_PIECES=bspstart bspclean init68360 sbrk setvec
+C_PIECES=alloc360 bspstart bspclean init68360 sbrk setvec
C_FILES=$(C_PIECES:%=%.c)
C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
H_FILES=
-SRCS=$(srcdir)/linkcmds $(srcdir)/linkcmds.prom $(C_FILES) $(H_FILES)
+SRCS=$(srcdir)/linkcmds $(srcdir)/linkcmds.prom $(srcdir)/linkcmds.bootp \
+ $(C_FILES) $(H_FILES)
OBJS=$(C_O_FILES) $(CC_O_FILES)
include $(RTEMS_CUSTOM)
diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/alloc360.c b/c/src/lib/libbsp/m68k/gen68360/startup/alloc360.c
new file mode 100644
index 0000000000..99bfb3352e
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/gen68360/startup/alloc360.c
@@ -0,0 +1,96 @@
+/*
+ * MC68360 buffer descriptor allocation routines
+ *
+ * W. Eric Norum
+ * Saskatchewan Accelerator Laboratory
+ * University of Saskatchewan
+ * Saskatoon, Saskatchewan, CANADA
+ * eric@skatter.usask.ca
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include <m68360.h>
+#include <rtems/error.h>
+
+/*
+ * Allocation order:
+ * - Dual-Port RAM section 1
+ * - Dual-Port RAM section 3
+ * - Dual-Port RAM section 0
+ * - Dual-Port RAM section 2
+ */
+static struct {
+ char *base;
+ unsigned int size;
+ unsigned int used;
+} bdregions[] = {
+ { (char *)&m360.dpram1[0], sizeof m360.dpram1, 0 },
+ { (char *)&m360.dpram3[0], sizeof m360.dpram3, 0 },
+ { (char *)&m360.dpram0[0], sizeof m360.dpram0, 0 },
+ { (char *)&m360.dpram2[0], sizeof m360.dpram2, 0 },
+};
+
+/*
+ * Send a command to the CPM RISC processer
+ */
+void *
+M360AllocateBufferDescriptors (int count)
+{
+ unsigned int i;
+ ISR_Level level;
+ void *bdp = NULL;
+ unsigned int want = count * sizeof(m360BufferDescriptor_t);
+
+ /*
+ * Running with interrupts disabled is usually considered bad
+ * form, but this routine is probably being run as part of an
+ * initialization sequence so the effect shouldn't be too severe.
+ */
+ _ISR_Disable (level);
+ for (i = 0 ; i < sizeof(bdregions) / sizeof(bdregions[0]) ; i++) {
+ /*
+ * Verify that the region exists.
+ * This test is necessary since some chips have
+ * less dual-port RAM.
+ */
+ if (bdregions[i].used == 0) {
+ volatile unsigned char *cp = bdregions[i].base;
+ *cp = 0xAA;
+ if (*cp != 0xAA) {
+ bdregions[i].used = bdregions[i].size;
+ continue;
+ }
+ *cp = 0x55;
+ if (*cp != 0x55) {
+ bdregions[i].used = bdregions[i].size;
+ continue;
+ }
+ *cp = 0x0;
+ }
+ if (bdregions[i].size - bdregions[i].used >= want) {
+ bdp = bdregions[i].base + bdregions[i].used;
+ bdregions[i].used += want;
+ break;
+ }
+ }
+ _ISR_Enable (level);
+ if (bdp == NULL)
+ rtems_panic ("Can't allocate %d buffer descriptor(s).\n", count);
+ return bdp;
+}
+
+void *
+M360AllocateRiscTimers (int count)
+{
+ /*
+ * Convert the count to the number of buffer descriptors
+ * of equal or larger size. This ensures that all buffer
+ * descriptors are allocated with appropriate alignment.
+ */
+ return M360AllocateBufferDescriptors (((count * 4) +
+ sizeof(m360BufferDescriptor_t) - 1) /
+ sizeof(m360BufferDescriptor_t));
+}
diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c b/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c
index 2c22b931bd..5326cc0307 100644
--- a/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c
+++ b/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c
@@ -36,7 +36,7 @@ void M360ExecuteRISC(rtems_unsigned16 command)
void _Init68360 (void)
{
int i;
- extern void *_RomBase, *_RamBase;
+ unsigned long l;
m68k_isr_entry *vbr;
extern void _CopyDataClearBSSAndStart (void);
@@ -58,20 +58,20 @@ void _Init68360 (void)
* Change if you're not using an external 25 MHz oscillator.
*/
m360.clkocr = 0x8F; /* No more writes, no clock outputs */
- m360.pllcr = 0xD000; /* PLL, no writes, no prescale, */
- /* no LPSTOP slowdown, PLL X1 */
+ m360.pllcr = 0xD000; /* PLL, no writes, no prescale,
+ no LPSTOP slowdown, PLL X1 */
m360.cdvcr = 0x8000; /* No more writes, no clock division */
/*
* Step 8: Initialize system protection
* Disable watchdog FIXME: Should use watchdog!!!!
* Watchdog causes system reset
- * Fastest watchdog timeout
+ * Slowest watchdog timeout
* Enable double bus fault monitor
* Enable bus monitor external
* 128 clocks for external timeout
*/
- m360.sypcr = 0x4F;
+ m360.sypcr = 0x7F;
/*
* Step 9: Clear parameter RAM and reset communication processor module
@@ -89,60 +89,139 @@ void _Init68360 (void)
* SINTOUT not used (CPU32+ mode)
* CF1MODE=00 (CONFIG1 input)
* RAS1* double drive
- * A31-A28
+ * WE0* - WE3*
* OE* output
- * CAS2* / CAS3*
- * CAS0* / CAS1*
+ * CAS2* - CAS3*
+ * CAS0* - CAS1*
* CS7*
* AVEC*
* HARDWARE:
* Change if you are using a different memory configuration
* (static RAM, external address multiplexing, etc).
*/
- m360.pepar = 0x0100;
+ m360.pepar = 0x0180;
/*
* Step 11: Remap Chip Select 0 (CS0*), set up GMR
- * 1024 addresses per DRAM page (1M DRAM chips)
- * 60 nsec DRAM
- * 180 nsec ROM (3 wait states)
- * HARDWARE:
- * Change if you are using a different memory configuration
*/
- m360.gmr = M360_GMR_RCNT(24) | M360_GMR_RFEN | M360_GMR_RCYC(0) |
- M360_GMR_PGS(3) | M360_GMR_DPS_32BIT | M360_GMR_NCS |
- M360_GMR_GAMX;
- m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP |
- M360_MEMC_BR_V;
- m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_512KB |
+ if (&_MC68360HardwareType == &_MC68360HardwareTypeAtlasHSB) {
+ m360.gmr = M360_GMR_RCNT(12) | M360_GMR_RFEN |
+ M360_GMR_RCYC(0) | M360_GMR_PGS(1) |
+ M360_GMR_DPS_32BIT | M360_GMR_DWQ |
+ M360_GMR_GAMX;
+ m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP |
+ M360_MEMC_BR_V;
+ m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_1MB |
+ M360_MEMC_OR_8BIT;
+ }
+ else {
+ /*
+ * 1024/2048/4096 addresses per DRAM page (1M/4M/16M DRAM chips)
+ * 60 nsec DRAM
+ * 180 nsec ROM (3 wait states)
+ */
+ switch ((unsigned long)&_RamSize) {
+ default:
+ case 4*1024*1024:
+ m360.gmr = M360_GMR_RCNT(24) | M360_GMR_RFEN |
+ M360_GMR_RCYC(0) | M360_GMR_PGS(3) |
+ M360_GMR_DPS_32BIT | M360_GMR_NCS |
+ M360_GMR_GAMX;
+ break;
+
+ case 16*1024*1024:
+ m360.gmr = M360_GMR_RCNT(24) | M360_GMR_RFEN |
+ M360_GMR_RCYC(0) | M360_GMR_PGS(5) |
+ M360_GMR_DPS_32BIT | M360_GMR_NCS |
+ M360_GMR_GAMX;
+ break;
+
+ case 64*1024*1024:
+ m360.gmr = M360_GMR_RCNT(24) | M360_GMR_RFEN |
+ M360_GMR_RCYC(0) | M360_GMR_PGS(7) |
+ M360_GMR_DPS_32BIT | M360_GMR_NCS |
+ M360_GMR_GAMX;
+ break;
+ }
+ m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP |
+ M360_MEMC_BR_V;
+ m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_1MB |
M360_MEMC_OR_8BIT;
+ }
/*
* Step 12: Initialize the system RAM
- * Set up option/base registers
- * 4 MB DRAM
- * 60 nsec DRAM
- * Wait for chips to power up
- * Perform 8 read cycles
- * Set all parity bits to correct state
- * Enable parity checking
- * HARDWARE:
- * Change if you are using a different memory configuration
*/
- m360.memc[1].or = M360_MEMC_OR_TCYC(0) | M360_MEMC_OR_4MB |
- M360_MEMC_OR_DRAM;
- m360.memc[1].br = (unsigned long)&_RamBase | M360_MEMC_BR_V;
- for (i = 0; i < 50000; i++)
- continue;
- for (i = 0; i < 8; ++i)
- *((volatile unsigned long *)(unsigned long)&_RamBase);
- for (i = 0 ; i < 4*1024*1024 ; i += sizeof (unsigned long)) {
- volatile unsigned long *lp;
- lp = (unsigned long *)((unsigned char *)&_RamBase + i);
- *lp = *lp;
- }
- m360.memc[1].br = (unsigned long)&_RamBase | M360_MEMC_BR_PAREN |
+ if (&_MC68360HardwareType == &_MC68360HardwareTypeAtlasHSB) {
+ /* first bank 1MByte DRAM */
+ m360.memc[1].or = M360_MEMC_OR_TCYC(2) | M360_MEMC_OR_1MB |
+ M360_MEMC_OR_PGME | M360_MEMC_OR_DRAM;
+ m360.memc[1].br = (unsigned long)&_RamBase | M360_MEMC_BR_V;
+
+ /* second bank 1MByte DRAM */
+ m360.memc[2].or = M360_MEMC_OR_TCYC(2) | M360_MEMC_OR_1MB |
+ M360_MEMC_OR_PGME | M360_MEMC_OR_DRAM;
+ m360.memc[2].br = ((unsigned long)&_RamBase + 0x100000) |
+ M360_MEMC_BR_V;
+
+ /* flash rom socket U6 on CS5 */
+ m360.memc[5].br = (unsigned long)ATLASHSB_ROM_U6 | M360_MEMC_BR_WP |
M360_MEMC_BR_V;
+ m360.memc[5].or = M360_MEMC_OR_WAITS(2) | M360_MEMC_OR_512KB |
+ M360_MEMC_OR_8BIT;
+
+ /* CSRs on CS7 */
+ m360.memc[7].or = M360_MEMC_OR_TCYC(4) | M360_MEMC_OR_64KB |
+ M360_MEMC_OR_8BIT;
+ m360.memc[7].br = ATLASHSB_ESR | 0x01;
+ for (i = 0; i < 50000; i++)
+ continue;
+ for (i = 0; i < 8; ++i)
+ *((volatile unsigned long *)(unsigned long)&_RamBase);
+ }
+ else {
+ /*
+ * Set up option/base registers
+ * 4M/16M/64M DRAM
+ * 60 nsec DRAM
+ * Wait for chips to power up
+ * Perform 8 read cycles
+ * Set all parity bits to correct state
+ * Enable parity checking
+ */
+ switch ((unsigned long)&_RamSize) {
+ default:
+ case 4*1024*1024:
+ m360.memc[1].or = M360_MEMC_OR_TCYC(0) |
+ M360_MEMC_OR_4MB |
+ M360_MEMC_OR_DRAM;
+ break;
+
+ case 16*1024*1024:
+ m360.memc[1].or = M360_MEMC_OR_TCYC(0) |
+ M360_MEMC_OR_16MB |
+ M360_MEMC_OR_DRAM;
+ break;
+
+ case 64*1024*1024:
+ m360.memc[1].or = M360_MEMC_OR_TCYC(0) |
+ M360_MEMC_OR_64MB |
+ M360_MEMC_OR_DRAM;
+ break;
+ }
+ m360.memc[1].br = (unsigned long)&_RamBase | M360_MEMC_BR_V;
+ for (i = 0; i < 50000; i++)
+ continue;
+ for (i = 0; i < 8; ++i)
+ *((volatile unsigned long *)(unsigned long)&_RamBase);
+ for (l = 0 ; l < (unsigned long)&_RamSize ; l += sizeof (unsigned long)) {
+ volatile unsigned long *lp;
+ lp = (unsigned long *)((unsigned char *)&_RamBase + i);
+ *lp = *lp;
+ }
+ m360.memc[1].br = (unsigned long)&_RamBase |
+ M360_MEMC_BR_PAREN | M360_MEMC_BR_V;
+ }
/*
* Step 13: Copy the exception vector table to system RAM
@@ -155,6 +234,7 @@ void _Init68360 (void)
/*
* Step 14: More system initialization
* SDCR (Serial DMA configuration register)
+ * Disable SDMA during FREEZE
* Give SDMA priority over all interrupt handlers
* Set DMA arbiration level to 4
* CICR (CPM interrupt configuration register):
@@ -167,7 +247,7 @@ void _Init68360 (void)
* Vector base 128
* SCCs priority grouped at top of table
*/
- m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4;
+ m360.sdcr = M360_SDMA_FREEZE | M360_SDMA_SISM_7 | M360_SDMA_SAID_4;
m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) |
(4 << 13) | (0x1F << 8) | (128);
@@ -178,7 +258,7 @@ void _Init68360 (void)
* BCLRO* arbitration level 3
* No show cycles
* User/supervisor access
- * Bus clear interupt service level 7
+ * Bus clear interrupt service level 7
* SIM60 interrupt sources higher priority than CPM
*/
m360.mcr = 0x4C7F;
diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds
index 8869c380a7..6a2d950853 100644
--- a/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds
+++ b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds
@@ -1,5 +1,7 @@
/*
- * This file contains GNU linker directives for a generic MC68360 board.
+ * This file contains GNU linker directives for a generic MC68360 board.
+ * Variations in hardware type and dynamic memory size can be made
+ * by overriding some values with linker command-line arguments.
*
* Saskatchewan Accelerator Laboratory
* University of Saskatchewan
@@ -10,32 +12,64 @@
*/
/*
- * Declare on-board memory
+ * Declare some sizes.
+ * XXX: The assignment of ". += XyzSize;" fails in older gld's if the
+ * number used there is not constant. If this happens to you, edit
+ * the lines marked XXX below to use a constant value.
+ */
+RamSize = DEFINED(RamSize) ? RamSize : 4M;
+HeapSize = DEFINED(HeapSize) ? HeapSize : 0x10000;
+StackSize = DEFINED(StackSize) ? StackSize : 0x1000;
+
+/*
+ * Declare hardware type
+ */
+MC68360HardwareTypeMotorolaGeneric = 0;
+MC68360HardwareTypeAtlasHSB = 1;
+MC68360HardwareType = DEFINED(MC68360HardwareType) ? MC68360HardwareType : 0;
+
+/*
+ * Declare on-board memory.
+ * It would be nice if the ram length could be given as
+ * LENGTH=RamSize, but gld doesn't allow non-constant
+ * values in the LENGTH expression.
*/
MEMORY {
- ram : ORIGIN = 0x00000000, LENGTH = 4M
+ ram : ORIGIN = 0x00000000, LENGTH = 64M
rom : ORIGIN = 0xFF000000, LENGTH = 1M
dpram : ORIGIN = 0xFE000000, LENGTH = 8k
}
/*
- * Declare some sizes
- * XXX: The assignment of ". += XyzSize;" fails in older gld's if the
- * number used there is not constant. If this happens to you, edit
- * the lines marked below to use a constant value.
+ * Declare low-order three octets of Ethernet address.
*/
-HeapSize = DEFINED(HeapSize) ? HeapSize : 0x10000;
-StackSize = DEFINED(StackSize) ? StackSize : 0x1000;
+ETHERNET_ADDRESS = DEFINED(ETHERNET_ADDRESS) ? ETHERNET_ADDRESS : 0xDEAD12;
/*
- * Declare low-order three octets of Ethernet address
+ * Declare hardware type.
+ * Acceptable values are:
+ * 0 - Generic system as described in the MC68360 User's Manual
+ * (MC68360UM/AD Rev. 1).
+ * 1 - ATLAS Computer Equipment Incorporated ACE360/HSB.
*/
-ETHERNET_ADDRESS = DEFINED(ETHERNET_ADDRESS) ? ETHERNET_ADDRESS : 0xDEAD12;
+MC68360HardwareType = DEFINED(MC68360HardwareType) ? MC68360HardwareType : 0;
/*
* Load objects
*/
SECTIONS {
+ /*
+ * Hardware variations
+ */
+ _RamSize = RamSize;
+ __RamSize = RamSize;
+ _MC68360HardwareType = MC68360HardwareType;
+ __MC68360HardwareType = MC68360HardwareType;
+ _MC68360HardwareTypeMotorolaGeneric = MC68360HardwareTypeMotorolaGeneric;
+ __MC68360HardwareTypeMotorolaGeneric = MC68360HardwareTypeMotorolaGeneric;
+ _MC68360HardwareTypeAtlasHSB = MC68360HardwareTypeAtlasHSB;
+ __MC68360HardwareTypeAtlasHSB = MC68360HardwareTypeAtlasHSB;
+
/*
* Boot PROM
*/
diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.bootp b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.bootp
new file mode 100644
index 0000000000..0fb1008376
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.bootp
@@ -0,0 +1,146 @@
+/*
+ * This file contains GNU linker directives for a generic MC68360 board.
+ * Variations in hardware type and dynamic memory size can be made
+ * by overriding some values with linker command-line arguments.
+ *
+ * These linker directives are for producing a PROM version.
+ * To create the PROM image from the linker output you must use objcopy
+ * (--adjust-section-vma) to place the data segment at the end of the text
+ * segment in the PROM. The start-up code takes care of copying this region
+ * to RAM.
+ *
+ * Saskatchewan Accelerator Laboratory
+ * University of Saskatchewan
+ * Saskatoon, Saskatchewan, CANADA
+ * eric@skatter.usask.ca
+ *
+ * $Id$
+ */
+
+/*
+ * Declare some sizes.
+ * XXX: The assignment of ". += XyzSize;" fails in older gld's if the
+ * number used there is not constant. If this happens to you, edit
+ * the lines marked XXX below to use a constant value.
+ */
+RamSize = DEFINED(RamSize) ? RamSize : 4M;
+HeapSize = DEFINED(HeapSize) ? HeapSize : 0x10000;
+StackSize = DEFINED(StackSize) ? StackSize : 0x1000;
+
+/*
+ * Declare hardware type
+ */
+MC68360HardwareTypeMotorolaGeneric = 0;
+MC68360HardwareTypeAtlasHSB = 1;
+MC68360HardwareType = DEFINED(MC68360HardwareType) ? MC68360HardwareType : 0;
+
+/*
+ * Declare on-board memory.
+ * It would be nice if the ram length could be given as
+ * LENGTH=RamSize, but gld doesn't allow non-constant
+ * values in the LENGTH expression.
+ */
+MEMORY {
+ ram : ORIGIN = 0x00000000, LENGTH = 64M
+ myram : ORIGIN = 4M-512k, LENGTH = 512k
+ rom : ORIGIN = 0xFF000000, LENGTH = 1M
+ dpram : ORIGIN = 0xFE000000, LENGTH = 8k
+}
+
+/*
+ * Declare low-order three octets of Ethernet address.
+ */
+ETHERNET_ADDRESS = DEFINED(ETHERNET_ADDRESS) ? ETHERNET_ADDRESS : 0xDEAD12;
+
+/*
+ * Declare hardware type.
+ * Acceptable values are:
+ * 0 - Generic system as described in the MC68360 User's Manual
+ * (MC68360UM/AD Rev. 1).
+ * 1 - ATLAS Computer Equipment Incorporated ACE360/HSB.
+ */
+MC68360HardwareType = DEFINED(MC68360HardwareType) ? MC68360HardwareType : 0;
+
+/*
+ * Load objects
+ */
+SECTIONS {
+ /*
+ * Hardware variations
+ */
+ _RamSize = RamSize;
+ __RamSize = RamSize;
+ _MC68360HardwareType = MC68360HardwareType;
+ __MC68360HardwareType = MC68360HardwareType;
+ _MC68360HardwareTypeMotorolaGeneric = MC68360HardwareTypeMotorolaGeneric;
+ __MC68360HardwareTypeMotorolaGeneric = MC68360HardwareTypeMotorolaGeneric;
+ _MC68360HardwareTypeAtlasHSB = MC68360HardwareTypeAtlasHSB;
+ __MC68360HardwareTypeAtlasHSB = MC68360HardwareTypeAtlasHSB;
+
+ /*
+ * Boot PROM
+ */
+ rom : {
+ _RomBase = .;
+ __RomBase = .;
+ } >rom
+
+ /*
+ * Dynamic RAM
+ */
+ ram : {
+ _RamBase = .;
+ __RamBase = .;
+ } >ram
+
+ /*
+ * Text, data and bss segments
+ */
+ .text : AT (0x00000000) {
+ CREATE_OBJECT_SYMBOLS
+ *(.text)
+ . = ALIGN (16);
+ etext = .;
+ _etext = .;
+ } >rom
+ .data : AT(SIZEOF(.text)) {
+ copy_start = .;
+ *(.data)
+ . = ALIGN (16);
+ _edata = .;
+ copy_end = .;
+ } >myram
+ .bss : {
+ M68Kvec = .;
+ _M68Kvec = .;
+ . += (256 * 4);
+ clear_start = .;
+ *(.bss)
+ *(COMMON)
+ . = ALIGN (16);
+ _end = .;
+
+ _HeapStart = .;
+ __HeapStart = .;
+ . += HeapSize; /* XXX -- Old gld can't handle this */
+ . += StackSize; /* XXX -- Old gld can't handle this */
+ /* . += 0x10000; */ /* HeapSize for old gld */
+ /* . += 0x1000; */ /* StackSize for old gld */
+ . = ALIGN (16);
+ stack_init = .;
+ clear_end = .;
+
+ _WorkspaceBase = .;
+ __WorkspaceBase = .;
+ } >myram
+
+ /*
+ * On-chip memory/peripherals
+ */
+ dpram : {
+ m360 = .;
+ _m360 = .;
+ . += (8 * 1024);
+
+ } >dpram
+}
diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.prom b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.prom
index ef1c3ee6e2..64d5fe91a1 100644
--- a/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.prom
+++ b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.prom
@@ -1,7 +1,10 @@
/*
* This file contains GNU linker directives for a generic MC68360 board.
- * These linker directives are for producing a PROM version..
- * To create the PROM image from the linkter output you must use objcopy
+ * Variations in hardware type and dynamic memory size can be made
+ * by overriding some values with linker command-line arguments.
+ *
+ * These linker directives are for producing a BOOTP PROM.
+ * To create the PROM image from the linker output you must use objcopy
* (--adjust-section-vma) to place the data segment at the end of the text
* segment in the PROM. The start-up code takes care of copying this region
* to RAM.
@@ -20,29 +23,64 @@
OUTPUT_FORMAT(coff-m68k)
/*
- * Declare on-board memory
+ * Declare some sizes.
+ * XXX: The assignment of ". += XyzSize;" fails in older gld's if the
+ * number used there is not constant. If this happens to you, edit
+ * the lines marked XXX below to use a constant value.
+ */
+RamSize = DEFINED(RamSize) ? RamSize : 4M;
+HeapSize = DEFINED(HeapSize) ? HeapSize : 0x10000;
+StackSize = DEFINED(StackSize) ? StackSize : 0x1000;
+
+/*
+ * Declare hardware type
+ */
+MC68360HardwareTypeMotorolaGeneric = 0;
+MC68360HardwareTypeAtlasHSB = 1;
+MC68360HardwareType = DEFINED(MC68360HardwareType) ? MC68360HardwareType : 0;
+
+/*
+ * Declare on-board memory.
+ * It would be nice if the ram length could be given as
+ * LENGTH=RamSize, but gld doesn't allow non-constant
+ * values in the LENGTH expression.
*/
MEMORY {
- ram : ORIGIN = 0x00000000, LENGTH = 4M
+ ram : ORIGIN = 0x00000000, LENGTH = 64M
rom : ORIGIN = 0xFF000000, LENGTH = 1M
dpram : ORIGIN = 0xFE000000, LENGTH = 8k
}
/*
- * Declare some sizes
+ * Declare low-order three octets of Ethernet address.
*/
-HeapSize = DEFINED(HeapSize) ? HeapSize : 0x10000;
-StackSize = DEFINED(StackSize) ? StackSize : 0x1000;
+ETHERNET_ADDRESS = DEFINED(ETHERNET_ADDRESS) ? ETHERNET_ADDRESS : 0xDEAD12;
/*
- * Declare low-order three octets of Ethernet address
+ * Declare hardware type.
+ * Acceptable values are:
+ * 0 - Generic system as described in the MC68360 User's Manual
+ * (MC68360UM/AD Rev. 1).
+ * 1 - ATLAS Computer Equipment Incorporated ACE360/HSB.
*/
-ETHERNET_ADDRESS = DEFINED(ETHERNET_ADDRESS) ? ETHERNET_ADDRESS : 0xDEAD12;
+MC68360HardwareType = DEFINED(MC68360HardwareType) ? MC68360HardwareType : 0;
/*
* Load objects
*/
SECTIONS {
+ /*
+ * Hardware variations
+ */
+ _RamSize = RamSize;
+ __RamSize = RamSize;
+ _MC68360HardwareType = MC68360HardwareType;
+ __MC68360HardwareType = MC68360HardwareType;
+ _MC68360HardwareTypeMotorolaGeneric = MC68360HardwareTypeMotorolaGeneric;
+ __MC68360HardwareTypeMotorolaGeneric = MC68360HardwareTypeMotorolaGeneric;
+ _MC68360HardwareTypeAtlasHSB = MC68360HardwareTypeAtlasHSB;
+ __MC68360HardwareTypeAtlasHSB = MC68360HardwareTypeAtlasHSB;
+
/*
* Boot PROM
*/
@@ -88,8 +126,10 @@ SECTIONS {
_HeapStart = .;
__HeapStart = .;
- . += HeapSize;
- . += StackSize;
+ . += HeapSize; /* XXX -- Old gld can't handle this */
+ . += StackSize; /* XXX -- Old gld can't handle this */
+ /* . += 0x10000; */ /* HeapSize for old gld */
+ /* . += 0x1000; */ /* StackSize for old gld */
. = ALIGN (16);
stack_init = .;
clear_end = .;
@@ -107,5 +147,4 @@ SECTIONS {
. += (8 * 1024);
} >dpram
-
}
diff --git a/c/src/lib/libbsp/m68k/gen68360/wrapup/Makefile.in b/c/src/lib/libbsp/m68k/gen68360/wrapup/Makefile.in
index bd06f5f90f..19e418ee06 100644
--- a/c/src/lib/libbsp/m68k/gen68360/wrapup/Makefile.in
+++ b/c/src/lib/libbsp/m68k/gen68360/wrapup/Makefile.in
@@ -7,11 +7,18 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH=@srcdir@
-BSP_PIECES=startup clock console timer
+# We only build the ka9q device driver if HAS_KA9Q was defined
+LIBKA9Q_yes_V = network
+LIBKA9Q = $(LIBKA9Q_$(HAS_KA9Q)_V)
+
+BSP_PIECES=startup clock console $(LIBKA9Q) timer
+CPU_PIECES=
GENERIC_PIECES=
# bummer; have to use $foreach since % pattern subst rules only replace 1x
OBJS=$(foreach piece, $(BSP_PIECES), ../$(piece)/$(ARCH)/$(piece).rel) \
+ $(foreach piece, $(CPU_PIECES), \
+ ../../../../libcpu/$(RTEMS_CPU)/$(piece)/$(ARCH)/$(piece).rel) \
$(foreach piece, $(GENERIC_PIECES), ../../../$(piece)/$(ARCH)/$(piece).rel)
LIB=$(ARCH)/libbsp.a
diff --git a/c/src/lib/libc/libio.c b/c/src/lib/libc/libio.c
index 3a7325c422..ec10184a10 100644
--- a/c/src/lib/libc/libio.c
+++ b/c/src/lib/libc/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/lib/libc/libio.h b/c/src/lib/libc/libio.h
index b518100484..c79dfc2e33 100644
--- a/c/src/lib/libc/libio.h
+++ b/c/src/lib/libc/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/lib/wrapup/Makefile.in b/c/src/lib/wrapup/Makefile.in
index 0316d5c56b..2446f24015 100644
--- a/c/src/lib/wrapup/Makefile.in
+++ b/c/src/lib/wrapup/Makefile.in
@@ -17,6 +17,7 @@ LIB=$(PROJECT_HOME)/lib/librtemsall.a
SRCS=$(wildcard $(PROJECT_HOME)/lib/libbsp$(LIB_VARIANT).a) \
$(PROJECT_HOME)/lib/librtems$(LIB_VARIANT).a \
$(wildcard $(PROJECT_HOME)/lib/libposix$(LIB_VARIANT).a) \
+ $(wildcard $(PROJECT_HOME)/lib/libka9q$(LIB_VARIANT).a) \
$(PROJECT_HOME)/lib/libcsupport$(LIB_VARIANT).a \
$(wildcard $(PROJECT_HOME)/lib/rtems-ctor$(LIB_VARIANT).o) \
$(wildcard $(PROJECT_HOME)/lib/libno-ctor$(LIB_VARIANT).a)
diff --git a/c/src/wrapup/Makefile.in b/c/src/wrapup/Makefile.in
index 0316d5c56b..2446f24015 100644
--- a/c/src/wrapup/Makefile.in
+++ b/c/src/wrapup/Makefile.in
@@ -17,6 +17,7 @@ LIB=$(PROJECT_HOME)/lib/librtemsall.a
SRCS=$(wildcard $(PROJECT_HOME)/lib/libbsp$(LIB_VARIANT).a) \
$(PROJECT_HOME)/lib/librtems$(LIB_VARIANT).a \
$(wildcard $(PROJECT_HOME)/lib/libposix$(LIB_VARIANT).a) \
+ $(wildcard $(PROJECT_HOME)/lib/libka9q$(LIB_VARIANT).a) \
$(PROJECT_HOME)/lib/libcsupport$(LIB_VARIANT).a \
$(wildcard $(PROJECT_HOME)/lib/rtems-ctor$(LIB_VARIANT).o) \
$(wildcard $(PROJECT_HOME)/lib/libno-ctor$(LIB_VARIANT).a)