diff options
Diffstat (limited to 'c/src/lib/libbsp')
52 files changed, 4487 insertions, 44 deletions
diff --git a/c/src/lib/libbsp/i386/ts_386ex/README b/c/src/lib/libbsp/i386/ts_386ex/README index b164be92d0..bfe757eff2 100644 --- a/c/src/lib/libbsp/i386/ts_386ex/README +++ b/c/src/lib/libbsp/i386/ts_386ex/README @@ -11,8 +11,8 @@ http://www.t-systems.com. The BSP uses software floating-point emulation, so one must build the cross-compilation tools with this support. The BSP also supports the on-board RTC, and an NE2000 compatible network card. It has been used -successfully with C (gcc-2.8.1) and Ada95 (gnat-3.11p), including -networking applications in both languages. +successfully with C/C++ (egcs-1.1.2) and Ada95 (gnat-3.11p), including +networking applications. The TS-1325 runs a version of DOS, and should be configured with a RAM disk and Zmodem software (see WWW site). RTEMS executables are loaded @@ -25,19 +25,20 @@ to 115200 baud (see WWW site). A typical development cycle involves these steps: -1. Cross-compile the application, yielding a COFF executable. Convert this - to raw binary format, using objcopy or the coff2bin script (see the - tools subdirectory in the BSP). +1. Cross-compile the application, yielding an ELF executable. Convert + this to raw binary format, using objcopy or the elf2exe script (see + the tools subdirectory in the BSP). -2. Use Zmodem to download the raw exec to the TS-1325's ram-disk +2. Use Zmodem to download the raw executable to the TS-1325's ram-disk (faster than the A: flash disk). A terminal program supporting Zmodem is needed on the host e.g. minicom under Linux. 3. Use the DOS-based RTEMS loader "loader.com" (see tools - subdirectory) to load and run the executable. + subdirectory) to load and run the executable on the TS-1325. -Additional documentation and support software is in the tools BSP subdirectory. +Additional documentation and support software is in the tools subdirectory +of the BSP. Happy Coding! -Tony Ambardar, 4/21/99 +Tony Ambardar, 8/8/99 diff --git a/c/src/lib/libbsp/i386/ts_386ex/bsp_specs b/c/src/lib/libbsp/i386/ts_386ex/bsp_specs index 64ef6d2731..03a3df6874 100644 --- a/c/src/lib/libbsp/i386/ts_386ex/bsp_specs +++ b/c/src/lib/libbsp/i386/ts_386ex/bsp_specs @@ -16,8 +16,10 @@ *startfile: %{!qrtems: %(old_startfile)} %{qrtems: \ %{!qrtems_debug: start.o%s} \ -%{qrtems_debug: start_g.o%s}} +%{qrtems_debug: start_g.o%s} crti.o%s crtbegin.o%s} *link: %{!qrtems: %(old_link)} %{qrtems: -dc -dp -N -e _init_i386ex} +*endfile: +%{!qrtems: %(old_endfile)} %{qrtems: crtend.o%s crtn.o%s} diff --git a/c/src/lib/libbsp/i386/ts_386ex/console/console.c b/c/src/lib/libbsp/i386/ts_386ex/console/console.c index 2db6b52bd0..d10a6138cf 100644 --- a/c/src/lib/libbsp/i386/ts_386ex/console/console.c +++ b/c/src/lib/libbsp/i386/ts_386ex/console/console.c @@ -218,7 +218,7 @@ console_open(rtems_device_major_number major, NULL, /* firstOpen */ console_last_close, /* lastClose */ NULL, /* poll read */ - BSP_uart_termios_write_com2, /* write */ + BSP_uart_termios_write_com1, /* write */ conSetAttr, /* setAttributes */ NULL, /* stopRemoteTx */ NULL, /* startRemoteTx */ diff --git a/c/src/lib/libbsp/i386/ts_386ex/startup/Makefile.in b/c/src/lib/libbsp/i386/ts_386ex/startup/Makefile.in index e3aec0984f..92699fa3ec 100644 --- a/c/src/lib/libbsp/i386/ts_386ex/startup/Makefile.in +++ b/c/src/lib/libbsp/i386/ts_386ex/startup/Makefile.in @@ -51,7 +51,7 @@ $(INSTALLDIRS): #DEFINES += -DPRINTON -DEFINES += -I$(srcdir) +DEFINES += -DUSE_INIT_FINI CPPFLAGS += CFLAGS += diff --git a/c/src/lib/libbsp/i386/ts_386ex/startup/bspstart.c b/c/src/lib/libbsp/i386/ts_386ex/startup/bspstart.c index c0e92617e8..0d878fcc45 100644 --- a/c/src/lib/libbsp/i386/ts_386ex/startup/bspstart.c +++ b/c/src/lib/libbsp/i386/ts_386ex/startup/bspstart.c @@ -78,7 +78,6 @@ void bsp_pretasking_hook(void) heap_size = BSP_Configuration.work_space_start -(void *) heap_start ; heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */ - heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */ bsp_libc_init((void *) heap_start, heap_size, 0); diff --git a/c/src/lib/libbsp/i386/ts_386ex/startup/linkcmds b/c/src/lib/libbsp/i386/ts_386ex/startup/linkcmds index 99911126bb..6710fe92e7 100644 --- a/c/src/lib/libbsp/i386/ts_386ex/startup/linkcmds +++ b/c/src/lib/libbsp/i386/ts_386ex/startup/linkcmds @@ -21,45 +21,49 @@ */ ENTRY(_init_i386ex) ; + SECTIONS { /*************************************************************************** * initial section: * - * This section is the first in memory, preceding the text and data sections. - * It initializes the i386ex, sets up the gdt in RAM, loads the gdt, + * This subsection of ".text" is the first in memory, and executed by the DOS + * loader. It initializes the i386ex, sets up the gdt in RAM, loads the gdt, * jumps to protected mode, loads the idt, zeros the bss section, sets up * the stack and calls the rest of the RTEMS initialization. ***************************************************************************/ _DOS_ld_addr = 0x0008000 ; - .initial _DOS_ld_addr : - { - *(.initial); - } - /*************************************************************************** * text section: * * Nobody here but us opcodes. ***************************************************************************/ - .text BLOCK(0x10) : + .text _DOS_ld_addr : { - CREATE_OBJECT_SYMBOLS + CREATE_OBJECT_SYMBOLS text_start = . ; _text_start = . ; - *(.text ) ; - . = ALIGN (16); - *(.eh_fram) - . = ALIGN (16); + *(.initial); + . = ALIGN(0x20); + + *(.text ); + . = ALIGN (0x20); + + *(.eh_frame) + . = ALIGN (0x20); + + *(.gnu.linkonce.t*) + . = ALIGN(0x20); /* * C++ constructors */ + __CTOR_LIST__ = .; LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) *(.ctors) @@ -71,24 +75,48 @@ SECTIONS *(.dtors) LONG(0) __DTOR_END__ = .; + _rodata_start = . ; *(.rodata) + . = ALIGN(0x20); + _erodata = .; + *(.gnu.linkonce.r*) - _erodata = ALIGN( 0x10 ) ; - _etext = ALIGN( 0x10 ); + . = ALIGN(0x20); _endtext = . ; } /*************************************************************************** + * ctor/dtor sections: + * + * These sections house the global constructors and destructors. + ***************************************************************************/ + + .init BLOCK(0x20) : + { + *(.init) + } = 0x9090 + + .fini BLOCK(0x20) : + { + *(.fini) + } = 0x9090 + +/*************************************************************************** * data section: * * This section defines the location of the data section in RAM. ***************************************************************************/ - .data BLOCK(0x10) : + .data BLOCK(0x20) : { _sdata = .; *(.data); + . = ALIGN(0x20); + *(.gnu.linkonce.d*) + . = ALIGN(0x20); + *(.gcc_except_table) + . = ALIGN(0x20); _edata = .; } _data_size = _edata - _sdata ; @@ -104,11 +132,23 @@ SECTIONS _bss_start = .; *(.bss); *(COMMON); - _ebss = ALIGN(0x10); + _ebss = ALIGN(0x20); } _bss_size = _ebss - _bss_start ; /*************************************************************************** + * discard section: + * + * This section is used to throw away stuff we don't want. + ***************************************************************************/ + + /DISCARD/ : + { + *(.comment); + *(.note); + } + +/*************************************************************************** * General variables: * * The stack_size variable is customizable here. The heap is located directly diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/README b/c/src/lib/libbsp/i386/ts_386ex/tools/README index 97f54cc0f0..dbc4ed86b4 100644 --- a/c/src/lib/libbsp/i386/ts_386ex/tools/README +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/README @@ -9,7 +9,7 @@ The dos_sup directory contains a DOS-based loader (loader.com) for RTEMS executables on the TS-1325. Fully commented source code is included. -Once an application has been compiled and the resulting COFF +Once an application has been compiled and the resulting ELF format executable converted to raw binary format and transferred to the TS-1325, the DOS loader program must be used to load and execute it. The loader is simply invoked as "loader filename", where the @@ -20,21 +20,22 @@ the A: flash disk. Since Zmodem transfers to the C: ram disk are much faster than to the A: disk, most development work will be done using the C: disk. Once completed, an application may copied to the (non-volatile) A: disk. Additionally, one may add the line "loader -filename" to the AUTOEXEC.BAT file, allow ing the application to be +filename" to the AUTOEXEC.BAT file, allowing the application to be run automatically at boot time. Note that the DOS loader will abort and exit if it detects that the push-button switch is pressed, thus allowing one to break out of a -patho logical "boot loop" situation. +pathological "boot loop" situation i.e. abort an automatic load from +the AUTOEXEC.BAT file. -coff2bin +elf2exe ======== -The coff2bin script is just a convenient wrapper for the objcopy -command. It can convert a list of RTEMS-generated COFF files to raw +The elf2exe script is just a convenient wrapper for the objcopy +command. It can convert a list of RTEMS-generated ELF files to raw binary images that can be loaded on the TS-1325. The converted files -are saved in the current directory with a ".bin" extension. +are saved in the current directory with a ".exe" extension. TS-1325 Ada95 Support @@ -42,7 +43,7 @@ TS-1325 Ada95 Support The TS-1325 includes a few peripherals which are very useful for embedded development: a push-button switch, an LED, and a parallel -port which may be used for digital I/O. Note that the pinout for the +port which may be used for digital I/O. Note that the pin-out for the parallel port is given in the TS-1325 manual. These devices are all supported by Ada packages allowing easy access; @@ -64,5 +65,49 @@ Brief descriptions of the main packages are as follows: inline assembly. -Tony Ambardar, 4/21/99 +Serial Debugging Support +======================== +RTEMS supports an Ada95 and RTEMS aware version of the GNU gdb +debugger, which can be configured to debug targets over a serial +line. + +The port COM2 on the TS-1325 is normally used for console I/O, leaving +COM1 for use by gdb; an appropriate cable should be connected from the +development host to the TS-1325's COM1. The serial port used on the host +should match the line "target remote /dev/tty??" in the "cmds" file. + +Sample C and Ada95 applications showing how to add debugging support +are given in the debug_c and debug_ada sub-directories. Once the +debugging-enabled executable is running on the TS-1325, gdb must be +started on the Linux host, taking as argument the RTEMS ELF executable. + +Using a graphical front end to gdb such as the program ddd is highly +recommended. The script ddd-rtems shows how to invoke gdb using ddd as +a front end. + + +Ada95 Networking Support +======================== + +The sub-directory network_ada contains code and examples for an Ada95 +binding to BSD network sockets. The code is based on Samuel Tardieu's +adasockets-0.1.3 package, but has been modified to work under RTEMS. + +The binding itself is in the adasockets sub-directory. Edit the +Makefile to reflect your choice of installation directory, then type +the command "make install" to compile and install the binding. The +file networkconfig.h should also be edited according to the RTEMS +networking document. + +The directories listener and tcprelay contain networking examples that +use the binding. The listener application simply accepts connections +on a certain port and echoes back any received data. The tcprelay +program accepts connections on a port and then relays all subsequent +data to and from another remote host. The makefiles in both +directories should be edited to reflect the installation point of the +adasockets binding. + + + +Tony Ambardar, 8/8/99 diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/Makefile b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/Makefile new file mode 100644 index 0000000000..4effbc7f75 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/Makefile @@ -0,0 +1,42 @@ +# +# Makefile for debug example +# + +MAIN=debug + +# Tool paths +tooldir=/usr/local/rtems +rtemsdir=${tooldir}/ts_386ex + +# Tool names +GCC=${tooldir}/bin/i386-rtemself-gcc +GNATMAKE=${tooldir}/bin/i386-rtemself-gnatmake +SIZE=${tooldir}/bin/i386-rtemself-size +SIS=${tooldir}/bin/sis +GDB=${tooldir}/bin/sis-gdb + +CINCLUDES= + +AINCLUDES=-i -I../ts_1325_ada + +CARGS=-B${rtemsdir}/lib/ -specs bsp_specs -qrtems \ + -msoft-float -mno-fp-ret-in-387 + +all: init.o + $(GNATMAKE) -O2 -g -gnata -gnatE -gnato -gnatn $(AINCLUDES) $(MAIN) \ + -bargs -r \ + -cargs $(CARGS) \ + -largs $(CARGS) init.o + $(SIZE) $(MAIN) + +init.o: init.c + $(GCC) -O2 -g -Wall -ansi -fasm $(CARGS) $(CINCLUDES) -c init.c + +run: + $(SIS) $(MAIN) + +gdb: + $(GDB) $(MAIN) + +clean: + rm -f b_$(MAIN).c b_$(MAIN).o *.o *.ali $(MAIN) diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/Makefile.ts_386ex b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/Makefile.ts_386ex new file mode 100644 index 0000000000..4effbc7f75 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/Makefile.ts_386ex @@ -0,0 +1,42 @@ +# +# Makefile for debug example +# + +MAIN=debug + +# Tool paths +tooldir=/usr/local/rtems +rtemsdir=${tooldir}/ts_386ex + +# Tool names +GCC=${tooldir}/bin/i386-rtemself-gcc +GNATMAKE=${tooldir}/bin/i386-rtemself-gnatmake +SIZE=${tooldir}/bin/i386-rtemself-size +SIS=${tooldir}/bin/sis +GDB=${tooldir}/bin/sis-gdb + +CINCLUDES= + +AINCLUDES=-i -I../ts_1325_ada + +CARGS=-B${rtemsdir}/lib/ -specs bsp_specs -qrtems \ + -msoft-float -mno-fp-ret-in-387 + +all: init.o + $(GNATMAKE) -O2 -g -gnata -gnatE -gnato -gnatn $(AINCLUDES) $(MAIN) \ + -bargs -r \ + -cargs $(CARGS) \ + -largs $(CARGS) init.o + $(SIZE) $(MAIN) + +init.o: init.c + $(GCC) -O2 -g -Wall -ansi -fasm $(CARGS) $(CINCLUDES) -c init.c + +run: + $(SIS) $(MAIN) + +gdb: + $(GDB) $(MAIN) + +clean: + rm -f b_$(MAIN).c b_$(MAIN).o *.o *.ali $(MAIN) diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/cmds b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/cmds new file mode 100644 index 0000000000..13573f86e4 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/cmds @@ -0,0 +1,293 @@ +dir /usr/local/rtems/tools/rtems-19990709/c/src/ +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/src +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/include/wrap +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/include/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/inline +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/inline/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/macros +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/macros/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/optman +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/src +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/include/sys +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/include/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/include/rtems/posix +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/include/wrap +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/inline +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/inline/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/inline/rtems/posix +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/macros +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/macros/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/macros/rtems/posix +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/optman +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/src +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/include/wrap +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/include/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/include/rtems/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/inline +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/inline/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/inline/rtems/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/macros +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/macros/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/macros/rtems/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/optman +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/cpu +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/cpu/i386 +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/cpu/i386/wrap +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/cpu/i386/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/cpu/i386/rtems/score +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/include/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/include/rtems/wrap +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/include/rtems/score +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/inline +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/inline/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/inline/rtems/score +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/macros +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/macros/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/macros/rtems/score +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/src +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/tools +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/tools/sh +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/tools/generic +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/tools/hppa1.1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/tools/unix +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/wrapup/posix +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/wrapup/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libc +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/include/rdbg +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/include/rdbg/i386 +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/include/rpc +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/include/rtems++ +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/include/sys +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/bare +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/bare/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/bare/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386 +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/shared +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/shared/comm +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/shared/io +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/shared/irq +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/shared/pci +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/clock +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/console +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/network +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/start +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/startup +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/timer +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/tools +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/tools/dos_sup +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libchip +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libchip/rtc +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libchip/network +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libchip/serial +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libcpu +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libcpu/i386 +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libcpu/i386/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/assoc +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/cpuuse +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/dumpbuf +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/error +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/monitor +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/rtmonuse +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/stackchk +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/untar +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/arpa +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/kern +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/lib +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/libc +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/machine +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/net +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/netinet +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/nfs +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/rtems_servers +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/sys +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/vm +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/librdbg +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/librdbg/i386 +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/librdbg/i386/pc386 +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/librpc +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/librtems++ +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/start +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests/cpuuse +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests/malloctest +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests/monitor +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests/rtems++ +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests/rtmonuse +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests/stackchk +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests/termios +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp01 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp01/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp01/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp02 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp02/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp02/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp03 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp03/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp03/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp04 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp04/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp04/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp05 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp05/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp05/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp06 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp06/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp06/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp07 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp07/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp07/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp08 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp08/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp08/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp09 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp09/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp09/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp10 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp10/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp10/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp11 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp11/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp11/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp12 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp12/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp12/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp13 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp13/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp13/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp14 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp14/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp14/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/filesupp +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx01 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx02 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx03 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx04 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx05 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx06 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx07 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx08 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx09 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx10 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx11 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx12 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx13 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxfile01 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxfile02 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxhdrs +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxmount +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxreaddir +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxstat +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxtime +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxtimer +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/support +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/support/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/base_mp +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/base_mp/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/base_mp/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/base_sp +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/cdtest +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/hello +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/paranoia +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/ticker +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/unlimited +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/minimum +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp01 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp02 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp03 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp04 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp05 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp06 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp07 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp08 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp09 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp11 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp12 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp13 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp14 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp15 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp16 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp17 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp19 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp20 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp21 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp22 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp23 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp24 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp25 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/spfatal +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/spsize +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/support +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/support/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/support/stubdr +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/support/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm01 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm02 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm03 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm04 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm05 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm06 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm07 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm08 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm09 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm10 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm11 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm12 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm13 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm14 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm15 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm16 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm17 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm18 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm19 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm20 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm21 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm22 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm23 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm24 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm25 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm26 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm27 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm28 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm29 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tmck +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tmoverhd +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tools +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tools/generic + +dir /usr/local/rtems/include +dir /usr/local/rtems/include/g++ +dir /usr/local/rtems/include/g++/std + +set remotebaud 38400 +target remote /dev/ttyS0 diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/ddd-rtems b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/ddd-rtems new file mode 100644 index 0000000000..84b343b13d --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/ddd-rtems @@ -0,0 +1 @@ +ddd --debugger "i386-rtemself-gdb --nx --command=./cmds" $* diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/debug.adb b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/debug.adb new file mode 100644 index 0000000000..fd9215c978 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/debug.adb @@ -0,0 +1,32 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Numerics.Discrete_Random; + +with TS1325.LED; use TS1325.LED; + +with Serial_Debug; use Serial_Debug; + +procedure Debug is + + package Random_LED_Colour is + new Ada.Numerics.Discrete_Random (LED_Colour); + use Random_LED_Colour; + + Colour_Gen: Random_LED_Colour.Generator; + + New_Colour: LED_Colour; + + Count: Integer := 0; + +begin + Breakpoint; + + Put_Line ("******* Starting Random LED Debug Test *******"); + + for I in 1 .. 10_000 loop + Count := Count + 1; + New_Colour := Random_LED_Colour.Random (Colour_Gen); + LED_State.Set (New_Colour); + end loop; + + Put_Line ("******* Finished Random LED Debug Test *******"); +end Debug; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/init.c b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/init.c new file mode 100644 index 0000000000..0f52a84156 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/init.c @@ -0,0 +1,85 @@ +/* + * COPYRIGHT (c) 1989-1997. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be found in + * the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <bsp.h> + +#include <assert.h> +#include <pthread.h> + +#include <stdio.h> + +#ifdef GNAT_PID +#include <unistd.h> +pid_t getpid() +{ + return GNAT_PID; +} +#endif + +/* + * By having the POSIX_Init thread create a second thread just + * to invoke gnat_main, we can override all default attributes + * of the "Ada environment task". Otherwise, we would be + * stuck with the defaults set by RTEMS. + */ + +void *start_gnat_main( void * argument ) +{ + extern int gnat_main ( int argc, char **argv, char **envp ); + + (void) gnat_main ( 0, 0, 0 ); + + exit( 0 ); + + return 0; +} + +void *POSIX_Init( void *argument ) +{ + pthread_t thread_id; + pthread_attr_t attr; + int status; + + status = pthread_attr_init( &attr ); + assert( !status ); + +#ifdef GNAT_MAIN_STACKSPACE + status = pthread_attr_setstacksize( &attr, GNAT_MAIN_STACKSPACE ); + assert( !status ); +#endif + + status = pthread_create( &thread_id, &attr, start_gnat_main, NULL ); + assert( !status ); + + pthread_exit( 0 ); + + return 0; +} + +/* configuration information */ + +#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_MICROSECONDS_PER_TICK RTEMS_MILLISECONDS_TO_MICROSECONDS(1) + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 20 +#define CONFIGURE_MAXIMUM_POSIX_KEYS 20 +#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 30 +#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 20 + +#define CONFIGURE_INIT + +#include <confdefs.h> + diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/serial_debug.adb b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/serial_debug.adb new file mode 100644 index 0000000000..f89e290764 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/serial_debug.adb @@ -0,0 +1,66 @@ +with Ada.Text_IO; use Ada.Text_IO; +with System.Machine_Code; use System.Machine_Code; + +package body Serial_Debug is + + ---------------- + -- Breakpoint -- + ---------------- + + procedure Breakpoint is + begin + Asm ("int $3", + No_Output_Operands, + No_Input_Operands, + Volatile => True); + end Breakpoint; + + + -- This type is from uart.h + -- Equivalent to an int, with (COM1, COM2) => (0, 1) + + type BSP_Uart is (COM1, COM2); + pragma Convention (C, BSP_Uart); + + + -- The serial port currently used for console I/O + + BSP_Console_Port: BSP_Uart; + pragma Import (C, BSP_Console_Port, "BSPConsolePort"); + + + -- C utility routines to set up serial-port debugging + + procedure I386_Stub_Glue_Init (Debug_Port: in BSP_Uart); + pragma Import (C, I386_Stub_Glue_Init, "i386_stub_glue_init"); + + procedure Set_Debug_Traps; + pragma Import (C, Set_Debug_Traps, "set_debug_traps"); + + procedure I386_Stub_Glue_Init_Breakin; + pragma Import (C, I386_Stub_Glue_Init_Breakin, + "i386_stub_glue_init_breakin"); + +begin + + if BSP_Console_Port /= COM2 + then + I386_Stub_Glue_Init (COM2); + + Put_Line ("Remote GDB using COM2..."); + else + I386_Stub_Glue_Init (COM1); + + Put_Line ("Remote GDB using COM1..."); + end if; + + Put_Line ("Remote GDB setting traps..."); + + Set_Debug_Traps; + + Put_Line ("Remote GDB waiting for connection..."); + + I386_Stub_Glue_Init_Breakin; + +end Serial_Debug; + diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/serial_debug.ads b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/serial_debug.ads new file mode 100644 index 0000000000..d645ca52c5 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_ada/serial_debug.ads @@ -0,0 +1,17 @@ +-- This package allows one to easily add serial debugging support to any +-- Ada program by simply adding "with Serial_Debug; use Serial_Debug". +-- Debugging will be automatically initialized when the program is run, +-- and it should be possible to interrupt the running program from ddd/gdb. +-- +-- Additionally, one can place explicit breakpoints for the debugger using +-- the procedure Breakpoint + +package Serial_Debug is + + procedure Breakpoint; + +private + + pragma Inline (Breakpoint); + +end Serial_Debug; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/Makefile b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/Makefile new file mode 100644 index 0000000000..ac26e4f4a5 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/Makefile @@ -0,0 +1,46 @@ +# +# Makefile +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +RTEMS_MAKEFILE_PATH=/usr/local/rtems/ts_386ex + +EXEC=debug.exe +PGM=${ARCH}/$(EXEC) + +# optional managers required +MANAGERS=io + +# C source names +CSRCS = init.c debug_test.c serial_gdb.c +COBJS_ = $(CSRCS:.c=.o) +COBJS = $(COBJS_:%=${ARCH}/%) + +# C++ source names +CXXSRCS = +CXXOBJS_ = $(CXXSRCS:.cc=.o) +CXXOBJS = $(CXXOBJS_:%=${ARCH}/%) + +# AS source names +ASSRCS = +ASOBJS_ = $(ASSRCS:.s=.o) +ASOBJS = $(ASOBJS_:%=${ARCH}/%) + +# Libraries +LIBS = -lrtemsall -lc + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc + +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) + diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/cmds b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/cmds new file mode 100644 index 0000000000..13573f86e4 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/cmds @@ -0,0 +1,293 @@ +dir /usr/local/rtems/tools/rtems-19990709/c/src/ +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/src +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/include/wrap +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/include/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/inline +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/inline/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/macros +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/macros/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/sapi/optman +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/src +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/include/sys +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/include/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/include/rtems/posix +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/include/wrap +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/inline +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/inline/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/inline/rtems/posix +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/macros +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/macros/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/macros/rtems/posix +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/posix/optman +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/src +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/include/wrap +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/include/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/include/rtems/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/inline +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/inline/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/inline/rtems/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/macros +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/macros/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/macros/rtems/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/rtems/optman +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/cpu +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/cpu/i386 +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/cpu/i386/wrap +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/cpu/i386/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/cpu/i386/rtems/score +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/include/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/include/rtems/wrap +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/include/rtems/score +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/inline +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/inline/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/inline/rtems/score +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/macros +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/macros/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/macros/rtems/score +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/src +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/tools +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/tools/sh +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/tools/generic +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/tools/hppa1.1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/score/tools/unix +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/wrapup/posix +dir /usr/local/rtems/tools/rtems-19990709/c/src/exec/wrapup/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libc +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/include/rdbg +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/include/rdbg/i386 +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/include/rpc +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/include/rtems++ +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/include/sys +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/bare +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/bare/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/bare/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386 +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/shared +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/shared/comm +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/shared/io +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/shared/irq +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/shared/pci +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/clock +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/console +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/network +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/start +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/startup +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/timer +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/tools +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/tools/dos_sup +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libbsp/i386/ts_386ex/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libchip +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libchip/rtc +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libchip/network +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libchip/serial +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libcpu +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libcpu/i386 +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libcpu/i386/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/assoc +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/cpuuse +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/dumpbuf +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/error +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/monitor +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/rtmonuse +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/stackchk +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/untar +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libmisc/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/arpa +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/kern +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/lib +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/libc +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/machine +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/net +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/netinet +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/nfs +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/rtems +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/rtems_servers +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/sys +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/vm +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/libnetworking/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/librdbg +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/librdbg/i386 +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/librdbg/i386/pc386 +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/librpc +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/librtems++ +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/start +dir /usr/local/rtems/tools/rtems-19990709/c/src/lib/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests/cpuuse +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests/malloctest +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests/monitor +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests/rtems++ +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests/rtmonuse +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests/stackchk +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/libtests/termios +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp01 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp01/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp01/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp02 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp02/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp02/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp03 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp03/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp03/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp04 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp04/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp04/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp05 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp05/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp05/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp06 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp06/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp06/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp07 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp07/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp07/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp08 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp08/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp08/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp09 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp09/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp09/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp10 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp10/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp10/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp11 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp11/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp11/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp12 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp12/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp12/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp13 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp13/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp13/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp14 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp14/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/mptests/mp14/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/filesupp +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx01 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx02 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx03 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx04 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx05 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx06 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx07 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx08 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx09 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx10 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx11 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx12 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psx13 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxfile01 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxfile02 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxhdrs +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxmount +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxreaddir +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxstat +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxtime +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/psxtimer +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/support +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/psxtests/support/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/base_mp +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/base_mp/node1 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/base_mp/node2 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/base_sp +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/cdtest +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/hello +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/paranoia +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/ticker +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/unlimited +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/samples/minimum +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp01 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp02 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp03 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp04 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp05 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp06 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp07 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp08 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp09 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp11 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp12 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp13 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp14 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp15 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp16 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp17 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp19 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp20 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp21 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp22 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp23 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp24 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/sp25 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/spfatal +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/sptests/spsize +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/support +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/support/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/support/stubdr +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/support/wrapup +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm01 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/include +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm02 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm03 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm04 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm05 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm06 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm07 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm08 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm09 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm10 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm11 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm12 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm13 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm14 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm15 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm16 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm17 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm18 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm19 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm20 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm21 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm22 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm23 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm24 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm25 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm26 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm27 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm28 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tm29 +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tmck +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tmtests/tmoverhd +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tools +dir /usr/local/rtems/tools/rtems-19990709/c/src/tests/tools/generic + +dir /usr/local/rtems/include +dir /usr/local/rtems/include/g++ +dir /usr/local/rtems/include/g++/std + +set remotebaud 38400 +target remote /dev/ttyS0 diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/ddd-rtems b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/ddd-rtems new file mode 100644 index 0000000000..84b343b13d --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/ddd-rtems @@ -0,0 +1 @@ +ddd --debugger "i386-rtemself-gdb --nx --command=./cmds" $* diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/debug_test.c b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/debug_test.c new file mode 100644 index 0000000000..a6e812cfcf --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/debug_test.c @@ -0,0 +1,25 @@ +/* + * Simple debug test program. + */ + +#include <stdio.h> + +#include "serial_gdb.h" + +void debug_test(void) +{ + unsigned i, sum; + + /* Initialize debugging support and insert breakpoint. */ + + init_serial_gdb(); + + breakpoint(); + + sum = 1; + for(i=1; i <= 100; i++) { + sum += sum % i; + printf("Current sum = %d\n", sum); + } +} + diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/init.c b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/init.c new file mode 100644 index 0000000000..42e7259bec --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/init.c @@ -0,0 +1,40 @@ +/* Init + * + * This routine is the initialization task for this test program. + * It is called from init_exec and has the responsibility for creating + * and starting the tasks that make up the test. If the time of day + * clock is required for the test, it should also be set to a known + * value by this function. + * + * Input parameters: NONE + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#define TEST_INIT +#include "system.h" + +extern void debug_test(void); + +rtems_task Init( + rtems_task_argument ignored +) +{ + printf( "\n\n*** C DEBUG TEST ***\n" ); + + debug_test(); + + printf( "\n*** END OF C DEBUG TEST ***\n" ); + + exit( 0 ); +} diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/serial_gdb.c b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/serial_gdb.c new file mode 100644 index 0000000000..ce90bb7d7e --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/serial_gdb.c @@ -0,0 +1,62 @@ +/* serial_gdb + * + * Interface to initialize the GDB. + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <uart.h> +#include <bspIo.h> + +extern int BSPConsolePort; + +void i386_stub_glue_init(int); +void i386_stub_glue_init_breakin(void); +void set_debug_traps(void); + + + /* Init GDB glue */ + +void init_serial_gdb( void ) +{ + if(BSPConsolePort != BSP_UART_COM2) + { + /* + * If com2 is not used as console use it for + * debugging + */ + + i386_stub_glue_init(BSP_UART_COM2); + printk( "Remote GDB using COM2...\n" ); + + } + else + { + /* Otherwise use com1 */ + i386_stub_glue_init(BSP_UART_COM1); + printk( "Remote GDB using COM1...\n" ); + } + + printk( "Remote GDB: setting traps...\n" ); + /* Init GDB stub itself */ + set_debug_traps(); + + + printk( "Remote GDB: waiting for remote connection...\n" ); + + /* + * Init GDB break in capability, + * has to be called after + * set_debug_traps + */ + i386_stub_glue_init_breakin(); + +} diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/serial_gdb.h b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/serial_gdb.h new file mode 100644 index 0000000000..48367263a1 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/serial_gdb.h @@ -0,0 +1,18 @@ +/* serial_gdb.h + * + * Interface to invoke and initialize GDB support. + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +void init_serial_gdb( void ); + +#define breakpoint() asm("int $3") + +#ifdef __cplusplus +} +#endif + diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/system.h b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/system.h new file mode 100644 index 0000000000..94a854da15 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/debug_c/system.h @@ -0,0 +1,37 @@ +/* system.h + * + * This include file contains information that is included in every + * function in the test set. + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <tmacros.h> + +/* functions */ + +rtems_task Init( + rtems_task_argument argument +); + +/* configuration information */ + +#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#include <confdefs.h> + +/* global variables */ + +TEST_EXTERN rtems_id Global_variable; /* example global variable */ + +/* end of include file */ diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/elf2exe b/c/src/lib/libbsp/i386/ts_386ex/tools/elf2exe new file mode 100755 index 0000000000..fc0d5a995c --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/elf2exe @@ -0,0 +1,23 @@ +#!/bin/sh +# Just a Q&D prog to convert a bunch of RTEMS generated ELF files to raw +# binary images that can be loaded on the TS-1325. The converted files are +# saved in the current directory. +# +# Tony Ambardar + +OBJCOPY=/usr/local/rtems/bin/i386-rtemself-objcopy + +if [ $# = 0 ] +then + echo "Description: Convert RTEMS elf files to raw binary files." + echo "Usage: elf2exe <list-of-elf-files>" + echo + exit 1 +fi + +for i in $* +do + OUTFILE=$(basename `echo $i | sed 's/\.[a-zA-Z0-9]*$//g'`.exe) + $OBJCOPY -O binary $i $OUTFILE +done + diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/README b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/README new file mode 100644 index 0000000000..f13242d945 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/README @@ -0,0 +1,8 @@ +The code and examples in this sub-directory have been adapted from +Samuel Tardieu's adasockets-0.1.3 library to work with RTEMS and +FreeBSD sockets. + +The Ada source files which were modified are sockets-multicast.adb, +sockets-thin.ads, sockets-constants.ads, and sockets-naming.adb + +Tony Ambardar, 8/8/99
\ No newline at end of file diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/AUTHORS b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/AUTHORS new file mode 100644 index 0000000000..c56bddd690 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/AUTHORS @@ -0,0 +1,7 @@ +Samuel Tardieu +ENST -- Département Informatique +46, rue Barrault +75634 Paris Cedex 13 +E-mail: sam@inf.enst.fr +URL: http://www.inf.enst.fr/~tardieu/ + diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/COPYING b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/COPYING new file mode 100644 index 0000000000..60549be514 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) 19yy <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/Makefile b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/Makefile new file mode 100644 index 0000000000..7d0713176f --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/Makefile @@ -0,0 +1,121 @@ +# Generated automatically from Makefile.in by configure. +# Makefile.in generated automatically by automake 1.3 from Makefile.am + +# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = /bin/sh + +prefix = /usr/local/rtems +exec_prefix = ${prefix} + +libdir = ${exec_prefix}/lib + +NORMAL_INSTALL = : + +ADA = /usr/local/rtems/bin/i386-rtemself-gcc +ADAFLAGS = -O2 -gnata -gnatE -gnato -msoft-float -mno-fp-ret-in-387 + +VERSION = 0.1.3 + +privatelibdir = $(libdir)/adasockets + +SOURCES = \ + sockets-constants.ads \ + sockets-link.ads \ + sockets-multicast.ads \ + sockets-multicast.adb \ + sockets-naming.ads \ + sockets-naming.adb \ + sockets-thin.ads \ + sockets-utils.ads \ + sockets-utils.adb \ + sockets.ads \ + sockets.adb + +OBJECTS = \ + sockets-constants.o \ + sockets-link.o \ + sockets-multicast.o \ + sockets-naming.o \ + sockets-thin.o \ + sockets-utils.o \ + sockets.o + +ALIS = $(OBJECTS:.o=.ali) + +CLEANFILES = $(OBJECTS) $(ALIS) + +.SUFFIXES: + +all: $(OBJECTS) $(ALI) + +install-exec: + @$(NORMAL_INSTALL) + +install-data: install-data-local + @$(NORMAL_INSTALL) + +install: install-exec install-data all + @: + +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +mostlyclean: mostlyclean-generic + +clean: clean-generic mostlyclean + +.PHONY: tags distdir info dvi installcheck install-exec install-data \ +install uninstall all installdirs mostlyclean-generic distclean-generic \ +clean-generic maintainer-clean-generic clean mostlyclean distclean \ +maintainer-clean + + +%.o %.ali: %.adb %.ads + $(ADA) -c $(ADAFLAGS) $< + +%.o %.ali: %.adb + $(ADA) -c $(ADAFLAGS) $< + +%.o %.ali: %.ads + $(ADA) -c $(ADAFLAGS) $< + + +install-data-local: all + rm -rf $(privatelibdir) + mkdir $(privatelibdir) + cp -p $(OBJECTS) $(ALIS) $(privatelibdir) + for i in $(SOURCES); do \ + if test -f $$i; then \ + cp -p $$i $(privatelibdir); \ + else \ + cp -p $(srcdir)/$$i $(privatelibdir); \ + fi \ + done + + +### DO NOT REMOVE THIS LINE, IT IS USED BY MAKEDEPEND ### +sockets-constants.o: sockets.ads sockets-constants.ads +sockets-link.o: sockets.ads sockets-link.ads +sockets-multicast.o: sockets.ads sockets.adb sockets-constants.ads sockets-link.ads sockets-multicast.ads sockets-multicast.adb sockets-naming.ads sockets-thin.ads sockets-utils.ads +sockets-naming.o: sockets.ads sockets-constants.ads sockets-naming.ads sockets-naming.adb sockets-thin.ads +sockets-thin.o: sockets.ads sockets-thin.ads +sockets-utils.o: sockets.ads sockets-utils.ads sockets-utils.adb +sockets.o: sockets.ads sockets.adb sockets-constants.ads sockets-link.ads sockets-naming.ads sockets-thin.ads sockets-utils.ads +split.o: split.adb + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/NEWS b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/NEWS new file mode 100644 index 0000000000..6990e32019 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/NEWS @@ -0,0 +1,44 @@ +-*- outline -*- + +* New in AdaSockets 0.1.3 + +** Support for IP multicast + +The package Sockets.Multicast can be used to create Multicast +interfaces on machine that support it. + +** Interface changes + +Some functions have been transformed into procedures to ease the +addition of multicast sockets. + +** New example + +The multi example can be used as both a multicast sender and receiver. + +* New in AdaSockets 0.1.2 + +** Warning suppressed + +Some versions of GNAT were detecting incorrectly a missing raise in +some cases. Signaled by Nicolas Ollinger <Nicolas.Ollinger@ens-lyon.fr>. + +** New example + +A listener example which is only a server has been added to avoid any +confusion between clients and servers. Suggestion by Scott Moody +<scott@plato.ds.boeing.com>. + +* New in AdaSockets 0.1.1 + +** `aux' -> `support' + +The subdirectory `aux' in the distribution has been renamed into +`support' to avoid a name clash on Windows NT with the standard +peripherical `aux'. Suggestion from Juanma Barranquero +<barranquero@laley-actualidad.es>. + +** Better error messages + +Exception raised during the connection now have messages in many cases +explaining why the connexion could not be made. diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/README b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/README new file mode 100644 index 0000000000..2192f8d334 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/README @@ -0,0 +1,35 @@ +README file for adasockets version 0.1.3 (beta) + +AdaSockets is a medium binding (it is not a thin binding because it uses Ada +types and not a thick binding because you have the same subprogram names as +in C) for using BSD-style sockets in Ada. + +This package is in no way complete! This is a half-day work that will be +extended in the future. If there is an extension that you would like to see in, +drop a note to the author (Samuel Tardieu <sam@inf.enst.fr>). + +As you may have noticed, the name is not really original. If you have a better +name, send me a note with your suggestion. + +AdaSockets is free software; you can redistribute it and/or modify it +under terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. AdaSockets is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. You should have received a +copy of the GNU General Public License distributed with AdaSockets; +see file COPYING. If not, write to the Free Software Foundation, 59 +Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As a special exception, if other files instantiate generics from this +unit, or you link this unit with other files to produce an executable, +this unit does not by itself cause the resulting executable to be +covered by the GNU General Public License. This exception does not +however invalidate any other reasons why the executable file might be +covered by the GNU Public License. + +The main repository for this software is located at: + http://www-inf.enst.fr/ANC/ + +The author, Samuel Tardieu <sam@inf.enst.fr> diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-constants.ads b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-constants.ads new file mode 100644 index 0000000000..b5c07b79c5 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-constants.ads @@ -0,0 +1,50 @@ +-- This package has been generated automatically on: +-- Linux wasp 2.0.36 #1 Tue Dec 29 13:11:13 EST 1998 i586 +-- unknown +-- Generation date: Fri Mar 5 00:03:14 PST 1999 +-- Any change you make here is likely to be lost ! +package Sockets.Constants is + Tcp_Nodelay : constant := 16#0001#; + Af_Inet : constant := 16#0002#; + Sock_Stream : constant := 16#0001#; + Sock_Dgram : constant := 16#0002#; + Eintr : constant := 16#0004#; + Eagain : constant := 16#000B#; + Ewouldblock : constant := 16#000B#; + Einprogress : constant := 16#0077#; + Ealready : constant := 16#0078#; + Eisconn : constant := 16#007F#; + Econnrefused : constant := 16#006F#; + Fndelay : constant := 16#0004#; + Fasync : constant := 16#0040#; + F_Getfl : constant := 16#0003#; + F_Setfl : constant := 16#0004#; + F_Setown : constant := 16#0006#; + So_Rcvbuf : constant := 16#1002#; + So_Reuseaddr : constant := 16#0004#; + Sol_Socket : constant := 16#FFFF#; + Sigterm : constant := 16#000F#; + Sigkill : constant := 16#0009#; + O_Rdonly : constant := 16#0000#; + O_Wronly : constant := 16#0001#; + O_Rdwr : constant := 16#0002#; + Host_Not_Found : constant := 16#0001#; + Try_Again : constant := 16#0002#; + No_Recovery : constant := 16#0003#; + No_Data : constant := 16#0004#; + No_Address : constant := 16#0004#; + Pollin : constant := 16#0001#; + Pollpri : constant := 16#0002#; + Pollout : constant := 16#0004#; + Pollerr : constant := 16#0008#; + Pollhup : constant := 16#0010#; + Pollnval : constant := 16#0020#; + I_Setsig : constant := -1; + S_Rdnorm : constant := -1; + S_Wrnorm : constant := -1; + Ipproto_Ip : constant := 16#0000#; + Ip_Add_Membership : constant := 16#000C#; + Ip_Multicast_Loop : constant := 16#000B#; + Ip_Multicast_Ttl : constant := 16#000A#; + Ip_Drop_Membership : constant := 16#000D#; +end Sockets.Constants; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-link.ads b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-link.ads new file mode 100644 index 0000000000..9439cdb90e --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-link.ads @@ -0,0 +1,42 @@ +----------------------------------------------------------------------------- +-- -- +-- ADASOCKETS COMPONENTS -- +-- -- +-- S O C K E T S . L I N K -- +-- -- +-- S p e c -- +-- -- +-- $ReleaseVersion: 0.1.3 $ -- +-- -- +-- Copyright (C) 1998 École Nationale Supérieure des Télécommunications -- +-- -- +-- AdaSockets is free software; you can redistribute it and/or modify -- +-- it under terms of the GNU General Public License as published by -- +-- the Free Software Foundation; either version 2, or (at your option) -- +-- any later version. AdaSockets is distributed in the hope that it -- +-- will be useful, but WITHOUT ANY WARRANTY; without even the implied -- +-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- +-- See the GNU General Public License for more details. You should -- +-- have received a copy of the GNU General Public License distributed -- +-- with AdaSockets; see file COPYING. If not, write to the Free -- +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- +-- 02111-1307, USA. -- +-- -- +-- As a special exception, if other files instantiate generics from -- +-- this unit, or you link this unit with other files to produce an -- +-- executable, this unit does not by itself cause the resulting -- +-- executable to be covered by the GNU General Public License. This -- +-- exception does not however invalidate any other reasons why the -- +-- executable file might be covered by the GNU Public License. -- +-- -- +-- The main repository for this software is located at: -- +-- http://www-inf.enst.fr/ANC/ -- +-- -- +----------------------------------------------------------------------------- + +private package Sockets.Link is + + -- pragma Linker_Options ("-lnsl"); + -- pragma Linker_Options ("-lsocket"); + +end Sockets.Link; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-multicast.adb b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-multicast.adb new file mode 100644 index 0000000000..22ad608e96 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-multicast.adb @@ -0,0 +1,130 @@ +----------------------------------------------------------------------------- +-- -- +-- ADASOCKETS COMPONENTS -- +-- -- +-- S O C K E T S . M U L T I C A S T -- +-- -- +-- B o d y -- +-- -- +-- $ReleaseVersion: 0.1.3 $ -- +-- -- +-- Copyright (C) 1998 École Nationale Supérieure des Télécommunications -- +-- -- +-- AdaSockets is free software; you can redistribute it and/or modify -- +-- it under terms of the GNU General Public License as published by -- +-- the Free Software Foundation; either version 2, or (at your option) -- +-- any later version. AdaSockets is distributed in the hope that it -- +-- will be useful, but WITHOUT ANY WARRANTY; without even the implied -- +-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- +-- See the GNU General Public License for more details. You should -- +-- have received a copy of the GNU General Public License distributed -- +-- with AdaSockets; see file COPYING. If not, write to the Free -- +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- +-- 02111-1307, USA. -- +-- -- +-- As a special exception, if other files instantiate generics from -- +-- this unit, or you link this unit with other files to produce an -- +-- executable, this unit does not by itself cause the resulting -- +-- executable to be covered by the GNU General Public License. This -- +-- exception does not however invalidate any other reasons why the -- +-- executable file might be covered by the GNU Public License. -- +-- -- +-- The main repository for this software is located at: -- +-- http://www-inf.enst.fr/ANC/ -- +-- -- +----------------------------------------------------------------------------- + +with Ada.Exceptions; use Ada.Exceptions; +with Interfaces.C; use Interfaces.C; +with Sockets.Constants; use Sockets.Constants; +with Sockets.Naming; use Sockets.Naming; +with Sockets.Thin; use Sockets.Thin; +with Sockets.Utils; use Sockets.Utils; + +package body Sockets.Multicast is + + use Ada.Streams; + + procedure Setsockopt_Add_Membership is + new Customized_Setsockopt (IPPROTO_IP, IP_ADD_MEMBERSHIP, Ip_Mreq); + + ----------------------------- + -- Create_Multicast_Socket -- + ----------------------------- + + function Create_Multicast_Socket + (Group : String; + Port : Positive; + TTL : Positive := 16; + Self_Loop : Boolean := True) + return Multicast_Socket_FD + is + Result : Multicast_Socket_FD; + Mreq : aliased Ip_Mreq; + C_Self_Loop : Integer; + begin + Socket (Socket_FD (Result), AF_INET, SOCK_DGRAM); + if Self_Loop then + C_Self_Loop := 1; + else + C_Self_Loop := 0; + end if; + Setsockopt (Result, SOL_SOCKET, SO_REUSEADDR, 1); + Bind (Result, Port); + Mreq.Imr_Multiaddr := To_In_Addr (Address_Of (Group)); + Setsockopt_Add_Membership (Result, Mreq); + Setsockopt (Result, IPPROTO_IP, IP_MULTICAST_TTL, TTL); + Setsockopt (Result, IPPROTO_IP, IP_MULTICAST_LOOP, C_Self_Loop); + Result.Target := (Result.Target'Size / 8, + Constants.Af_Inet, + Port_To_Network (unsigned_short (Port)), + To_In_Addr (Address_Of (Group)), + (others => char'Val (0))); + return Result; + end Create_Multicast_Socket; + + ---------- + -- Send -- + ---------- + + procedure Send (Socket : in Multicast_Socket_FD; + Data : in Stream_Element_Array) + is + Sin : aliased Sockaddr_In := Socket.Target; + Index : Stream_Element_Offset := Data'First; + Rest : Stream_Element_Count := Data'Length; + Count : int; + begin + while Rest > 0 loop + Count := C_Sendto (Socket.FD, + Data (Index) 'Address, + int (Rest), + 0, + Sin'Address, + Sin'Size / 8); + if Count < 0 then + Raise_With_Message ("Send failed"); + elsif Count = 0 then + raise Connection_Closed; + end if; + Index := Index + Stream_Element_Count (Count); + Rest := Rest - Stream_Element_Count (Count); + end loop; + end Send; + + ------------ + -- Socket -- + ------------ + + procedure Socket + (Sock : out Multicast_Socket_FD; + Domain : in Socket_Domain := AF_INET; + Typ : in Socket_Type := SOCK_STREAM) + is + begin + Raise_Exception (Program_Error'Identity, + "Use Create_Multicast_Socket instead"); + Sock := Sock; -- To keep the compiler happy + end Socket; + +end Sockets.Multicast; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-multicast.ads b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-multicast.ads new file mode 100644 index 0000000000..ae2215fbca --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-multicast.ads @@ -0,0 +1,71 @@ +----------------------------------------------------------------------------- +-- -- +-- ADASOCKETS COMPONENTS -- +-- -- +-- S O C K E T S . M U L T I C A S T -- +-- -- +-- S p e c -- +-- -- +-- $ReleaseVersion: 0.1.3 $ -- +-- -- +-- Copyright (C) 1998 École Nationale Supérieure des Télécommunications -- +-- -- +-- AdaSockets is free software; you can redistribute it and/or modify -- +-- it under terms of the GNU General Public License as published by -- +-- the Free Software Foundation; either version 2, or (at your option) -- +-- any later version. AdaSockets is distributed in the hope that it -- +-- will be useful, but WITHOUT ANY WARRANTY; without even the implied -- +-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- +-- See the GNU General Public License for more details. You should -- +-- have received a copy of the GNU General Public License distributed -- +-- with AdaSockets; see file COPYING. If not, write to the Free -- +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- +-- 02111-1307, USA. -- +-- -- +-- As a special exception, if other files instantiate generics from -- +-- this unit, or you link this unit with other files to produce an -- +-- executable, this unit does not by itself cause the resulting -- +-- executable to be covered by the GNU General Public License. This -- +-- exception does not however invalidate any other reasons why the -- +-- executable file might be covered by the GNU Public License. -- +-- -- +-- The main repository for this software is located at: -- +-- http://www-inf.enst.fr/ANC/ -- +-- -- +----------------------------------------------------------------------------- + +with Sockets.Thin; + +package Sockets.Multicast is + + pragma Elaborate_Body; + + -- This package aims at helping the creation of multicast sockets + + type Multicast_Socket_FD is new Socket_FD with private; + + function Create_Multicast_Socket + (Group : String; + Port : Positive; + TTL : Positive := 16; + Self_Loop : Boolean := True) + return Multicast_Socket_FD; + -- Create a multicast socket + + procedure Send (Socket : in Multicast_Socket_FD; + Data : in Ada.Streams.Stream_Element_Array); + -- Send data over a multicast socket + +private + + procedure Socket + (Sock : out Multicast_Socket_FD; + Domain : in Socket_Domain := AF_INET; + Typ : in Socket_Type := SOCK_STREAM); + -- Do not call this one, it will raise Program_Error + + type Multicast_Socket_FD is new Socket_FD with record + Target : Sockets.Thin.Sockaddr_In; + end record; + +end Sockets.Multicast; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-naming.adb b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-naming.adb new file mode 100644 index 0000000000..4faa989138 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-naming.adb @@ -0,0 +1,411 @@ +----------------------------------------------------------------------------- +-- -- +-- ADASOCKETS COMPONENTS -- +-- -- +-- S O C K E T S . N A M I N G -- +-- -- +-- B o d y -- +-- -- +-- $ReleaseVersion: 0.1.3 $ -- +-- -- +-- Copyright (C) 1996-1998 Free Software Foundation -- +-- -- +-- AdaSockets is free software; you can redistribute it and/or modify -- +-- it under terms of the GNU General Public License as published by -- +-- the Free Software Foundation; either version 2, or (at your option) -- +-- any later version. AdaSockets is distributed in the hope that it -- +-- will be useful, but WITHOUT ANY WARRANTY; without even the implied -- +-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- +-- See the GNU General Public License for more details. You should -- +-- have received a copy of the GNU General Public License distributed -- +-- with AdaSockets; see file COPYING. If not, write to the Free -- +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- +-- 02111-1307, USA. -- +-- -- +-- As a special exception, if other files instantiate generics from -- +-- this unit, or you link this unit with other files to produce an -- +-- executable, this unit does not by itself cause the resulting -- +-- executable to be covered by the GNU General Public License. This -- +-- exception does not however invalidate any other reasons why the -- +-- executable file might be covered by the GNU Public License. -- +-- -- +-- The main repository for this software is located at: -- +-- http://www-inf.enst.fr/ANC/ -- +-- -- +----------------------------------------------------------------------------- + +with Ada.Exceptions; +with Interfaces.C; use Interfaces.C; +with Interfaces.C.Strings; use Interfaces.C.Strings; +with Sockets.Constants; use Sockets.Constants; +with Ada.Unchecked_Conversion; +with Ada.Unchecked_Deallocation; + +package body Sockets.Naming is + + use Sockets.Constants, Sockets.Thin; + + Default_Buffer_Size : constant := 16384; + + procedure Free is + new Ada.Unchecked_Deallocation (String, String_Access); + + procedure Free is + new Ada.Unchecked_Deallocation (char_array, char_array_access); + + function Allocate (Size : Positive := Default_Buffer_Size) + return char_array_access; + -- Allocate a buffer + + function Parse_Entry (Host : Hostent) + return Host_Entry; + -- Parse an entry + + procedure Raise_Naming_Error + (Errno : in C.int; + Message : in String); + -- Raise the exception Naming_Error with an appropriate error message + + C_Errno : C.int; + pragma Import (C, C_Errno, "h_errno"); + + ---------------- + -- Address_Of -- + ---------------- + + function Address_Of (Something : String) + return Address + is + begin + if Is_IP_Address (Something) then + return Value (Something); + else + return Info_Of (Something) .Addresses (1); + end if; + end Address_Of; + + ------------ + -- Adjust -- + ------------ + + procedure Adjust (Object : in out Host_Entry) + is + Aliases : String_Array renames Object.Aliases; + begin + Object.Name := new String'(Object.Name.all); + for I in Aliases'Range loop + Aliases (I) := new String'(Aliases (I) .all); + end loop; + end Adjust; + + -------------- + -- Allocate -- + -------------- + + function Allocate + (Size : Positive := Default_Buffer_Size) + return char_array_access + is + begin + return new char_array (1 .. size_t (Size)); + end Allocate; + + ----------------- + -- Any_Address -- + ----------------- + + function Any_Address return Address + is + begin + return To_Address (Inaddr_Any); + end Any_Address; + + -------------- + -- Finalize -- + -------------- + + procedure Finalize (Object : in out Host_Entry) + is + Aliases : String_Array renames Object.Aliases; + begin + Free (Object.Name); + for I in Aliases'Range loop + Free (Aliases (I)); + end loop; + end Finalize; + + --------------- + -- Host_Name -- + --------------- + + function Host_Name return String + is + Buff : char_array_access := Allocate; + Buffer : constant chars_ptr := To_Chars_Ptr (Buff); + Res : constant int := C_Gethostname (Buffer, Buff'Length); + begin + if Res = Failure then + Free (Buff); + Raise_Naming_Error (C_Errno, ""); + end if; + declare + Result : constant String := Value (Buffer); + begin + Free (Buff); + return Result; + end; + end Host_Name; + + ----------- + -- Image -- + ----------- + + function Image (Add : Address) return String + is + + function Image (A : Address_Component) return String; + -- Return the string corresponding to its argument without + -- the leading space. + + ----------- + -- Image -- + ----------- + + function Image (A : Address_Component) + return String + is + Im : constant String := Address_Component'Image (A); + begin + return Im (Im'First + 1 .. Im'Last); + end Image; + + begin + return Image (Add.H1) & "." & Image (Add.H2) & "." & + Image (Add.H3) & "." & Image (Add.H4); + end Image; + + ----------- + -- Image -- + ----------- + + function Image (Add : Thin.In_Addr) return String is + begin + return Image (To_Address (Add)); + end Image; + + ------------- + -- Info_Of -- + ------------- + + function Info_Of (Name : String) + return Host_Entry + is + Res : Hostent_Access; + C_Name : chars_ptr := New_String (Name); + begin + Res := C_Gethostbyname (C_Name); + Free (C_Name); + if Res = null then + Raise_Naming_Error (C_Errno, Name); + end if; + declare + Result : constant Host_Entry := Parse_Entry (Res.all); + begin + return Result; + end; + end Info_Of; + + ------------- + -- Info_Of -- + ------------- + + function Info_Of (Addr : Address) + return Host_Entry + is + function Convert is + new Ada.Unchecked_Conversion (Source => In_Addr_Access, + Target => chars_ptr); + Temp : aliased In_Addr := To_In_Addr (Addr); + C_Addr : constant chars_ptr := Convert (Temp'Unchecked_Access); + Res : Hostent_Access; + begin + Res := C_Gethostbyaddr (C_Addr, + C.int (Temp'Size / CHAR_BIT), + Constants.Af_Inet); + if Res = null then + Raise_Naming_Error (C_Errno, Image (Addr)); + end if; + declare + Result : constant Host_Entry := Parse_Entry (Res.all); + begin + return Result; + end; + end Info_Of; + + ------------------------ + -- Info_Of_Name_Or_IP -- + ------------------------ + + function Info_Of_Name_Or_IP (Something : String) + return Host_Entry + is + begin + if Is_IP_Address (Something) then + return Info_Of (Value (Something)); + else + return Info_Of (Something); + end if; + end Info_Of_Name_Or_IP; + + ------------------- + -- Is_Ip_Address -- + ------------------- + + function Is_IP_Address (Something : String) + return Boolean + is + begin + for Index in Something'Range loop + declare + Current : Character renames Something (Index); + begin + if (Current < '0' + or else Current > '9') + and then Current /= '.' then + return False; + end if; + end; + end loop; + return True; + end Is_IP_Address; + + ------------- + -- Name_Of -- + ------------- + + function Name_Of (Something : String) + return String + is + Hostent : constant Host_Entry := Info_Of_Name_Or_IP (Something); + begin + if Hostent.Name = null then + Ada.Exceptions.Raise_Exception (Naming_Error'Identity, + "No name for " & Something); + end if; + return Hostent.Name.all; + end Name_Of; + + ----------------- + -- Parse_Entry -- + ----------------- + + function Parse_Entry (Host : Hostent) + return Host_Entry + is + C_Aliases : constant Thin.Chars_Ptr_Array := + Chars_Ptr_Pointers.Value (Host.H_Aliases); + C_Addr : constant In_Addr_Access_Array := + In_Addr_Access_Pointers.Value + (Host.H_Addr_List); + Result : Host_Entry (N_Aliases => C_Aliases'Length - 1, + N_Addresses => C_Addr'Length - 1); + begin + Result.Name := new String'(Value (Host.H_Name)); + for I in 1 .. Result.Aliases'Last loop + declare + Index : Natural := I - 1 + Natural (C_Aliases'First); + Current : chars_ptr renames C_Aliases (size_t (Index)); + begin + Result.Aliases (I) := new String'(Value (Current)); + end; + end loop; + for I in Result.Addresses'Range loop + declare + Index : Natural := I - 1 + Natural (C_Addr'First); + Current : In_Addr_Access renames C_Addr (Index); + begin + Result.Addresses (I) := To_Address (Current.all); + end; + end loop; + return Result; + end Parse_Entry; + + ------------------------ + -- Raise_Naming_Error -- + ------------------------ + + procedure Raise_Naming_Error + (Errno : in C.int; + Message : in String) + is + + function Error_Message return String; + -- Return the message according to Errno. + + ------------------- + -- Error_Message -- + ------------------- + + function Error_Message return String is + begin + case Errno is + when Host_Not_Found => return "Host not found"; + when Try_Again => return "Try again"; + when No_Recovery => return "No recovery"; + when No_Address => return "No address"; + when others => return "Unknown error" & + C.int'Image (Errno); + end case; + end Error_Message; + + begin + Ada.Exceptions.Raise_Exception (Naming_Error'Identity, + Error_Message & ": " & Message); + end Raise_Naming_Error; + + ---------------- + -- To_Address -- + ---------------- + + function To_Address (Addr : In_Addr) return Address + is + begin + return (H1 => Address_Component (Addr.S_B1), + H2 => Address_Component (Addr.S_B2), + H3 => Address_Component (Addr.S_B3), + H4 => Address_Component (Addr.S_B4)); + end To_Address; + + ---------------- + -- To_In_Addr -- + ---------------- + + function To_In_Addr (Addr : Address) return In_Addr + is + begin + return (S_B1 => unsigned_char (Addr.H1), + S_B2 => unsigned_char (Addr.H2), + S_B3 => unsigned_char (Addr.H3), + S_B4 => unsigned_char (Addr.H4)); + end To_In_Addr; + + ----------- + -- Value -- + ----------- + + function Value (Add : String) return Address + is + function Convert is + new Ada.Unchecked_Conversion (Source => Interfaces.Unsigned_32, + Target => In_Addr); + C_Add : chars_ptr := New_String (Add); + Converted : constant In_Addr := Convert (C_Inet_Addr (C_Add)); + begin + Free (C_Add); + return (H1 => Address_Component (Converted.S_B1), + H2 => Address_Component (Converted.S_B2), + H3 => Address_Component (Converted.S_B3), + H4 => Address_Component (Converted.S_B4)); + end Value; + +end Sockets.Naming; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-naming.ads b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-naming.ads new file mode 100644 index 0000000000..e66927172e --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-naming.ads @@ -0,0 +1,113 @@ +----------------------------------------------------------------------------- +-- -- +-- ADASOCKETS COMPONENTS -- +-- -- +-- S O C K E T S . N A M I N G -- +-- -- +-- S p e c -- +-- -- +-- $ReleaseVersion: 0.1.3 $ -- +-- -- +-- Copyright (C) 1996-1998 Free Software Foundation -- +-- -- +-- AdaSockets is free software; you can redistribute it and/or modify -- +-- it under terms of the GNU General Public License as published by -- +-- the Free Software Foundation; either version 2, or (at your option) -- +-- any later version. AdaSockets is distributed in the hope that it -- +-- will be useful, but WITHOUT ANY WARRANTY; without even the implied -- +-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- +-- See the GNU General Public License for more details. You should -- +-- have received a copy of the GNU General Public License distributed -- +-- with AdaSockets; see file COPYING. If not, write to the Free -- +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- +-- 02111-1307, USA. -- +-- -- +-- As a special exception, if other files instantiate generics from -- +-- this unit, or you link this unit with other files to produce an -- +-- executable, this unit does not by itself cause the resulting -- +-- executable to be covered by the GNU General Public License. This -- +-- exception does not however invalidate any other reasons why the -- +-- executable file might be covered by the GNU Public License. -- +-- -- +-- The main repository for this software is located at: -- +-- http://www-inf.enst.fr/ANC/ -- +-- -- +----------------------------------------------------------------------------- + +with Ada.Finalization; +with Sockets.Thin; + +package Sockets.Naming is + + type String_Access is access String; + + type String_Array is array (Positive range <>) of String_Access; + + subtype Address_Component is Natural range 0 .. 255; + + type Address is record + H1, H2, H3, H4 : Address_Component; + end record; + -- An IPv4 address such as 137.194.160.12 + + type Address_Array is array (Positive range <>) of Address; + + type Host_Entry (N_Aliases, N_Addresses : Natural) is + new Ada.Finalization.Controlled with record + Name : String_Access; + Aliases : String_Array (1 .. N_Aliases); + Addresses : Address_Array (1 .. N_Addresses); + end record; + -- A complete host structure. A host may have several IP addresses as + -- well as several aliases. + + procedure Adjust (Object : in out Host_Entry); + procedure Finalize (Object : in out Host_Entry); + + Naming_Error : exception; + -- This exception is raised when a name cannot be resolved + + function Image (Add : Address) return String; + -- The dotted form corresponding to an IP address + + function Image (Add : Thin.In_Addr) return String; + -- The dotted form corresponding to the packed form of an IP address + + function Value (Add : String) return Address; + -- The IP address corresponding to a dotted form + + function Info_Of (Name : String) + return Host_Entry; + -- Host entry of an IP name + + function Info_Of (Addr : Address) + return Host_Entry; + -- Host entry of an IP address + + function Is_IP_Address (Something : String) + return Boolean; + -- Return True if the name looks like an IP address, False otherwise + + function Info_Of_Name_Or_IP (Something : String) + return Host_Entry; + -- Host entry of an IP name or a dotted form + + function Address_Of (Something : String) return Address; + -- Address of an IP name or a dotted form + + function Host_Name return String; + -- Return the name of the current host + + function Name_Of (Something : String) return String; + -- Return the official name of an IP name or a dotted form + + function To_In_Addr (Addr : Address) return Thin.In_Addr; + -- Convert an IP address to a In_Addr structure + + function To_Address (Addr : Thin.In_Addr) return Address; + -- Convert a In_Addr structure to an IP address + + function Any_Address return Address; + -- Return the value of inaddr_any + +end Sockets.Naming; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-thin.ads b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-thin.ads new file mode 100644 index 0000000000..cb0b006dd8 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-thin.ads @@ -0,0 +1,440 @@ +----------------------------------------------------------------------------- +-- -- +-- ADASOCKETS COMPONENTS -- +-- -- +-- S O C K E T S . T H I N -- +-- -- +-- S p e c -- +-- -- +-- $ReleaseVersion: 0.1.3 $ -- +-- -- +-- Copyright (C) 1996-1998 Free Software Foundation -- +-- -- +-- AdaSockets is free software; you can redistribute it and/or modify -- +-- it under terms of the GNU General Public License as published by -- +-- the Free Software Foundation; either version 2, or (at your option) -- +-- any later version. AdaSockets is distributed in the hope that it -- +-- will be useful, but WITHOUT ANY WARRANTY; without even the implied -- +-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- +-- See the GNU General Public License for more details. You should -- +-- have received a copy of the GNU General Public License distributed -- +-- with AdaSockets; see file COPYING. If not, write to the Free -- +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- +-- 02111-1307, USA. -- +-- -- +-- As a special exception, if other files instantiate generics from -- +-- this unit, or you link this unit with other files to produce an -- +-- executable, this unit does not by itself cause the resulting -- +-- executable to be covered by the GNU General Public License. This -- +-- exception does not however invalidate any other reasons why the -- +-- executable file might be covered by the GNU Public License. -- +-- -- +-- The main repository for this software is located at: -- +-- http://www-inf.enst.fr/ANC/ -- +-- -- +----------------------------------------------------------------------------- + +with Interfaces.C.Pointers; +with Interfaces.C.Strings; +with System; + +package Sockets.Thin is + + package C renames Interfaces.C; + package Strings renames C.Strings; + generic package Pointers renames C.Pointers; + + use type C.int; + -- This is an ugly hack to be able to declare the Failure constant + -- below. + + Success : constant C.int := 0; + Failure : constant C.int := -1; + + type Int_Access is access all C.int; + pragma Convention (C, Int_Access); + -- Access to C integers + + type pid_t is new C.int; + pragma Convention (C, pid_t); + + type mode_t is new C.int; + pragma Convention (C, mode_t); + + type key_t is new C.int; + pragma Convention (C, key_t); + + type Chars_Ptr_Array is array (C.size_t range <>) of + aliased Strings.chars_ptr; + + package Chars_Ptr_Pointers is + new Pointers (C.size_t, Strings.chars_ptr, Chars_Ptr_Array, + Strings.Null_Ptr); + -- Arrays of C (char *) + + type In_Addr is record + S_B1, S_B2, S_B3, S_B4 : C.unsigned_char; + end record; + pragma Convention (C, In_Addr); + -- Internet address + + type In_Addr_Access is access all In_Addr; + pragma Convention (C, In_Addr_Access); + -- Access to internet address + + Inaddr_Any : aliased constant In_Addr := (others => 0); + -- Any internet address (all the interfaces) + + type In_Addr_Access_Array is array (Positive range <>) + of aliased In_Addr_Access; + pragma Convention (C, In_Addr_Access_Array); + package In_Addr_Access_Pointers is + new Pointers (Positive, In_Addr_Access, In_Addr_Access_Array, + null); + -- Array of internet addresses + + type Sockaddr is record + Sa_Len : C.unsigned_char; + Sa_Family : C.unsigned_char; + Sa_Data : C.char_array (1 .. 14); + end record; + pragma Convention (C, Sockaddr); + -- Socket address + + type Sockaddr_Access is access all Sockaddr; + pragma Convention (C, Sockaddr_Access); + -- Access to socket address + + type Sockaddr_In is record + Sin_Len : C.unsigned_char; + Sin_Family : C.unsigned_char; + Sin_Port : C.unsigned_short := 0; + Sin_Addr : In_Addr := Inaddr_Any; + Sin_Zero : C.char_array (1 .. 8) := (others => C.char'Val (0)); + end record; + pragma Convention (C, Sockaddr_In); + -- Internet socket address + + type Sockaddr_In_Access is access all Sockaddr_In; + pragma Convention (C, Sockaddr_In_Access); + -- Access to internet socket address + + type Ip_Mreq is record + Imr_Multiaddr : In_Addr; + Imr_Interface : In_Addr := Inaddr_Any; + end record; + pragma Convention (C, Ip_Mreq); + -- Multicast structure + + type Hostent is record + H_Name : Strings.chars_ptr; + H_Aliases : Chars_Ptr_Pointers.Pointer; + H_Addrtype : C.int; + H_Length : C.int; + H_Addr_List : In_Addr_Access_Pointers.Pointer; + end record; + pragma Convention (C, Hostent); + -- Host entry + + type Hostent_Access is access all Hostent; + pragma Convention (C, Hostent_Access); + -- Access to host entry + + type Caddr_T is new Strings.chars_ptr; + -- Type Caddr_T is in fact a (char *) + + type Iovec is record + Iov_Base : Caddr_T; + Iov_Len : C.int; + end record; + pragma Convention (C, Iovec); + -- Iovec C type + + type Iovec_Access is access all Iovec; + pragma Convention (C, Iovec_Access); + -- Access to Iovec structure + + type Msghdr is record + Msg_Name : Caddr_T; + Msg_Namelen : C.int; + Msg_Iov : Iovec_Access; + Msg_Iovlen : C.int; + Msg_Accrights : Caddr_T; + Msg_Accrightslen : C.int; + end record; + pragma Convention (C, Msghdr); + -- Message header + + type Msghdr_Access is access all Msghdr; + pragma Convention (C, Msghdr_Access); + -- Access to message header. + + type Two_Int is array (0 .. 1) of C.int; + pragma Convention (C, Two_Int); + -- Used with pipe() + + type Pollfd is record + Fd : C.int; + Events : C.short; + Revents : C.short; + end record; + pragma Convention (C, Pollfd); + + type Pollfd_Array is array (Positive range <>) of Pollfd; + pragma Convention (C, Pollfd_Array); + + function C_Accept + (S : C.int; + Addr : System.Address; + Addrlen : access C.int) + return C.int; + + function C_Bind + (S : C.int; + Name : System.Address; + Namelen : C.int) + return C.int; + + procedure C_Close (Fildes : C.int); + + function C_Connect + (S : C.int; + Name : System.Address; + Namelen : C.int) + return C.int; + + function C_Dup2 (Fildes, Fildes2 : C.int) return C.int; + + function C_Fcntl + (Fildes : C.int; + Cmd : C.int; + Arg : C.int := 0) + return C.int; + + function C_Getenv + (Name : Strings.chars_ptr) + return Strings.chars_ptr; + + function C_Gethostbyaddr + (Addr : Strings.chars_ptr; + Length : C.int; + Typ : C.int) + return Hostent_Access; + + function C_Gethostbyname + (Name : Strings.chars_ptr) + return Hostent_Access; + + function C_Gethostname + (Name : Strings.chars_ptr; + Namelen : C.int) + return C.int; + + function C_Getpeername + (S : C.int; + Name : Sockaddr_Access; + Namelen : access C.int) + return C.int; + + function C_Getpid return pid_t; + + function C_Getsockname + (S : C.int; + Name : Sockaddr_Access; + Namelen : access C.int) + return C.int; + + function C_Getsockopt + (S : C.int; + Level : C.int; + Optname : C.int; + Optval : Strings.chars_ptr; + Optlen : access C.int) + return C.int; + + function C_Inet_Addr + (Cp : Strings.chars_ptr) + return Interfaces.Unsigned_32; + + function C_Inet_Network + (Cp : Strings.chars_ptr) + return Interfaces.Unsigned_32; + + function C_Inet_Makeaddr + (Net : C.int; + Lna : C.int) + return In_Addr; + + function C_Inet_Lnaof (I : In_Addr) return C.int; + + function C_Inet_Netof (I : In_Addr) return C.int; + + function C_Inet_Ntoa (I : In_Addr) return Strings.chars_ptr; + + function C_Kill (Pid : pid_t; Sig : C.int) return C.int; + + function C_Listen (S, Backlog : C.int) return C.int; + + function C_Msgget + (Key : key_t; + Msgflg : C.int) + return C.int; + + function C_Msgrcv + (Msqid : C.int; + Msgp : Strings.chars_ptr; + Msgsz : C.int; + Msgtyp : C.long; + Msgflg : C.int) + return C.int; + + function C_Msgsnd + (Msqid : C.int; + Msgp : Strings.chars_ptr; + Msgsz : C.int; + Msgflg : C.int) + return C.int; + + function C_Open + (Path : Strings.chars_ptr; + Oflag : C.int; + Mode : mode_t := 0) + return C.int; + + function C_Pipe (Filedes : access Two_Int) return C.int; + + function C_Poll + (Fds : System.Address; + Nfds : C.unsigned_long; + Timeout : C.int) + return C.int; + + function C_Read + (Fildes : C.int; + Buf : System.Address; + Nbyte : C.int) + return C.int; + + function C_Readv + (Fildes : C.int; + Iov : Iovec_Access; + Iovcnt : C.int) + return C.int; + + function C_Recv (S : C.int; Buf : System.Address; Len, Flags : C.int) + return C.int; + + function C_Recvfrom + (S : C.int; + Buf : System.Address; + Len : C.int; + Flags : C.int; + From : System.Address; + Fromlen : access C.int) + return C.int; + + function C_Recvmsg + (S : C.int; + Msg : Msghdr_Access; + Flags : C.int) + return C.int; + + function C_Send + (S : C.int; + Msg : System.Address; + Len : C.int; + Flags : C.int) + return C.int; + + function C_Sendmsg + (S : C.int; + Msg : Msghdr_Access; + Flags : C.int) + return C.int; + + function C_Sendto + (S : C.int; + Msg : System.Address; + Len : C.int; + Flags : C.int; + To : System.Address; + Tolen : C.int) + return C.int; + + function C_Setsid return pid_t; + + function C_Setsockopt + (S : C.int; + Level : C.int; + Optname : C.int; + Optval : System.Address; + Optlen : C.int) + return C.int; + + procedure C_Shutdown + (S : in C.int; + How : in C.int); + + function C_Socket (Domain, Typ, Protocol : C.int) return C.int; + + function C_Strerror (Errnum : C.int) return Strings.chars_ptr; + + function C_Write + (Fildes : C.int; + Buf : System.Address; + Nbyte : C.int) + return C.int; + + function C_Writev + (Fildes : C.int; + Iov : Iovec_Access; + Iovcnt : C.int) + return C.int; + +private + + pragma Import (C, C_Accept, "accept"); + pragma Import (C, C_Bind, "bind"); + pragma Import (C, C_Close, "close"); + pragma Import (C, C_Connect, "connect"); + pragma Import (C, C_Dup2, "dup2"); + pragma Import (C, C_Fcntl, "fcntl"); + pragma Import (C, C_Getenv, "getenv"); + pragma Import (C, C_Gethostbyaddr, "gethostbyaddr"); + pragma Import (C, C_Gethostbyname, "gethostbyname"); + pragma Import (C, C_Gethostname, "gethostname"); + pragma Import (C, C_Getpeername, "getpeername"); + pragma Import (C, C_Getpid, "getpid"); + pragma Import (C, C_Getsockname, "getsockname"); + pragma Import (C, C_Getsockopt, "getsockopt"); + pragma Import (C, C_Inet_Addr, "inet_addr"); + pragma Import (C, C_Inet_Network, "inet_network"); + pragma Import (C, C_Inet_Makeaddr, "inet_makeaddr"); + pragma Import (C, C_Inet_Lnaof, "inet_lnaof"); + pragma Import (C, C_Inet_Netof, "inet_netof"); + pragma Import (C, C_Inet_Ntoa, "inet_ntoa"); + pragma Import (C, C_Kill, "kill"); + pragma Import (C, C_Listen, "listen"); + pragma Import (C, C_Msgget, "msgget"); + pragma Import (C, C_Msgrcv, "msgrcv"); + pragma Import (C, C_Msgsnd, "msgsnd"); + pragma Import (C, C_Open, "open"); + pragma Import (C, C_Pipe, "pipe"); + pragma Import (C, C_Poll, "poll"); + pragma Import (C, C_Read, "read"); + pragma Import (C, C_Readv, "readv"); + pragma Import (C, C_Recv, "recv"); + pragma Import (C, C_Recvfrom, "recvfrom"); + pragma Import (C, C_Recvmsg, "recvmsg"); + pragma Import (C, C_Send, "send"); + pragma Import (C, C_Sendmsg, "sendmsg"); + pragma Import (C, C_Sendto, "sendto"); + pragma Import (C, C_Setsid, "setsid"); + pragma Import (C, C_Setsockopt, "setsockopt"); + pragma Import (C, C_Shutdown, "shutdown"); + pragma Import (C, C_Socket, "socket"); + pragma Import (C, C_Strerror, "strerror"); + pragma Import (C, C_Write, "write"); + pragma Import (C, C_Writev, "writev"); + +end Sockets.Thin; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-utils.adb b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-utils.adb new file mode 100644 index 0000000000..7c8417dcd4 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-utils.adb @@ -0,0 +1,84 @@ +----------------------------------------------------------------------------- +-- -- +-- ADASOCKETS COMPONENTS -- +-- -- +-- S O C K E T S . U T I L S -- +-- -- +-- B o d y -- +-- -- +-- $ReleaseVersion: 0.1.3 $ -- +-- -- +-- Copyright (C) 1998 École Nationale Supérieure des Télécommunications -- +-- -- +-- AdaSockets is free software; you can redistribute it and/or modify -- +-- it under terms of the GNU General Public License as published by -- +-- the Free Software Foundation; either version 2, or (at your option) -- +-- any later version. AdaSockets is distributed in the hope that it -- +-- will be useful, but WITHOUT ANY WARRANTY; without even the implied -- +-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- +-- See the GNU General Public License for more details. You should -- +-- have received a copy of the GNU General Public License distributed -- +-- with AdaSockets; see file COPYING. If not, write to the Free -- +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- +-- 02111-1307, USA. -- +-- -- +-- As a special exception, if other files instantiate generics from -- +-- this unit, or you link this unit with other files to produce an -- +-- executable, this unit does not by itself cause the resulting -- +-- executable to be covered by the GNU General Public License. This -- +-- exception does not however invalidate any other reasons why the -- +-- executable file might be covered by the GNU Public License. -- +-- -- +-- The main repository for this software is located at: -- +-- http://www-inf.enst.fr/ANC/ -- +-- -- +----------------------------------------------------------------------------- + +with Ada.Exceptions; use Ada.Exceptions; +with GNAT.OS_Lib; use GNAT.OS_Lib; +with System; use System; + +package body Sockets.Utils is + + use Interfaces.C; + + --------------------- + -- Port_To_Network -- + --------------------- + + function Port_To_Network (Port : unsigned_short) + return unsigned_short + is + begin + if Default_Bit_Order = High_Order_First then + return Port; + else + return (Port / 256) + (Port mod 256) * 256; + end if; + end Port_To_Network; + + ------------------------ + -- Raise_With_Message -- + ------------------------ + + procedure Raise_With_Message (Message : in String; + With_Errno : in Boolean := True) + is + begin + if With_Errno then + Raise_Exception (Constraint_Error'Identity, + Message & " (errno is" & Integer'Image (Errno) & + ")"); + else + Raise_Exception (Constraint_Error'Identity, Message); + end if; + + -- The following line works around a bug in GNAT that does not + -- recognize Ada.Exceptions.Raise_Exception as raising an exception, + -- even if it can compute statically that the occurrence cannot + -- be Null_Occurrence ??? + + raise Program_Error; + end Raise_With_Message; + +end Sockets.Utils; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-utils.ads b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-utils.ads new file mode 100644 index 0000000000..51a8f031bf --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets-utils.ads @@ -0,0 +1,52 @@ +----------------------------------------------------------------------------- +-- -- +-- ADASOCKETS COMPONENTS -- +-- -- +-- S O C K E T S . U T I L S -- +-- -- +-- S p e c -- +-- -- +-- $ReleaseVersion: 0.1.3 $ -- +-- -- +-- Copyright (C) 1998 École Nationale Supérieure des Télécommunications -- +-- -- +-- AdaSockets is free software; you can redistribute it and/or modify -- +-- it under terms of the GNU General Public License as published by -- +-- the Free Software Foundation; either version 2, or (at your option) -- +-- any later version. AdaSockets is distributed in the hope that it -- +-- will be useful, but WITHOUT ANY WARRANTY; without even the implied -- +-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- +-- See the GNU General Public License for more details. You should -- +-- have received a copy of the GNU General Public License distributed -- +-- with AdaSockets; see file COPYING. If not, write to the Free -- +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- +-- 02111-1307, USA. -- +-- -- +-- As a special exception, if other files instantiate generics from -- +-- this unit, or you link this unit with other files to produce an -- +-- executable, this unit does not by itself cause the resulting -- +-- executable to be covered by the GNU General Public License. This -- +-- exception does not however invalidate any other reasons why the -- +-- executable file might be covered by the GNU Public License. -- +-- -- +-- The main repository for this software is located at: -- +-- http://www-inf.enst.fr/ANC/ -- +-- -- +----------------------------------------------------------------------------- + +with Interfaces.C; + +private package Sockets.Utils is + + pragma Elaborate_Body; + + procedure Raise_With_Message (Message : in String; + With_Errno : in Boolean := True); + pragma No_Return (Raise_With_Message); + -- Raise Constraint_Error with an associated error message + + function Port_To_Network (Port : Interfaces.C.unsigned_short) + return Interfaces.C.unsigned_short; + pragma Inline (Port_To_Network); + +end Sockets.Utils; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets.adb b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets.adb new file mode 100644 index 0000000000..3172307163 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets.adb @@ -0,0 +1,409 @@ +----------------------------------------------------------------------------- +-- -- +-- ADASOCKETS COMPONENTS -- +-- -- +-- S O C K E T S -- +-- -- +-- B o d y -- +-- -- +-- $ReleaseVersion: 0.1.3 $ -- +-- -- +-- Copyright (C) 1998 École Nationale Supérieure des Télécommunications -- +-- -- +-- AdaSockets is free software; you can redistribute it and/or modify -- +-- it under terms of the GNU General Public License as published by -- +-- the Free Software Foundation; either version 2, or (at your option) -- +-- any later version. AdaSockets is distributed in the hope that it -- +-- will be useful, but WITHOUT ANY WARRANTY; without even the implied -- +-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- +-- See the GNU General Public License for more details. You should -- +-- have received a copy of the GNU General Public License distributed -- +-- with AdaSockets; see file COPYING. If not, write to the Free -- +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- +-- 02111-1307, USA. -- +-- -- +-- As a special exception, if other files instantiate generics from -- +-- this unit, or you link this unit with other files to produce an -- +-- executable, this unit does not by itself cause the resulting -- +-- executable to be covered by the GNU General Public License. This -- +-- exception does not however invalidate any other reasons why the -- +-- executable file might be covered by the GNU Public License. -- +-- -- +-- The main repository for this software is located at: -- +-- http://www-inf.enst.fr/ANC/ -- +-- -- +----------------------------------------------------------------------------- + +with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; +with Sockets.Constants; use Sockets.Constants; +with Sockets.Link; +pragma Warnings (Off, Sockets.Link); +with Sockets.Naming; use Sockets.Naming; +with Sockets.Thin; use Sockets.Thin; +with Sockets.Utils; use Sockets.Utils; + +package body Sockets is + + use Ada.Streams, Interfaces.C; + + Socket_Domain_Match : constant array (Socket_Domain) of int := + (AF_INET => Constants.Af_Inet); + + Socket_Type_Match : constant array (Socket_Type) of int := + (SOCK_STREAM => Constants.Sock_Stream, + SOCK_DGRAM => Constants.Sock_Dgram); + + Shutdown_Type_Match : constant array (Shutdown_Type) of int := + (Receive => 0, + Send => 1, + Both => 2); + + Socket_Level_Match : constant array (Socket_Level) of int := + (SOL_SOCKET => Constants.Sol_Socket, + IPPROTO_IP => Constants.Ipproto_Ip); + + Socket_Option_Match : constant array (Socket_Option) of int := + (SO_REUSEADDR => Constants.So_Reuseaddr, + IP_MULTICAST_TTL => Constants.Ip_Multicast_Ttl, + IP_ADD_MEMBERSHIP => Constants.Ip_Add_Membership, + IP_DROP_MEMBERSHIP => Constants.Ip_Drop_Membership, + IP_MULTICAST_LOOP => Constants.Ip_Multicast_Loop); + + Socket_Option_Size : constant array (Socket_Option) of Natural := + (SO_REUSEADDR => 4, + IP_MULTICAST_TTL => 1, + IP_ADD_MEMBERSHIP => 8, + IP_DROP_MEMBERSHIP => 8, + IP_MULTICAST_LOOP => 1); + + function "*" (Left : String; Right : Natural) return String; + pragma Inline ("*"); + + CRLF : constant String := CR & LF; + + --------- + -- "*" -- + --------- + + function "*" (Left : String; Right : Natural) return String is + Result : String (1 .. Left'Length * Right); + First : Positive := 1; + Last : Natural := First + Left'Length - 1; + begin + for I in 1 .. Right loop + Result (First .. Last) := Left; + First := First + Left'Length; + Last := Last + Left'Length; + end loop; + return Result; + end "*"; + + ------------------- + -- Accept_Socket -- + ------------------- + + procedure Accept_Socket (Socket : in Socket_FD; + New_Socket : out Socket_FD) + is + Sin : aliased Sockaddr_In; + Size : aliased int := Sin'Size / 8; + Code : int; + begin + Code := C_Accept (Socket.FD, Sin'Address, Size'Access); + if Code = Failure then + Raise_With_Message ("Accept system call failed"); + else + New_Socket := (FD => Code); + end if; + end Accept_Socket; + + ---------- + -- Bind -- + ---------- + + procedure Bind + (Socket : in Socket_FD; + Port : in Positive) + is + Sin : aliased Sockaddr_In; + begin + Sin.Sin_Family := Constants.Af_Inet; + Sin.Sin_Port := Port_To_Network (unsigned_short (Port)); + if C_Bind (Socket.FD, Sin'Address, Sin'Size / 8) = Failure then + Raise_With_Message ("Bind failed"); + end if; + end Bind; + + ------------- + -- Connect -- + ------------- + + procedure Connect + (Socket : in Socket_FD; + Host : in String; + Port : in Positive) + is + Sin : aliased Sockaddr_In; + begin + Sin.Sin_Family := Constants.Af_Inet; + Sin.Sin_Addr := To_In_Addr (Address_Of (Host)); + Sin.Sin_Port := Port_To_Network (unsigned_short (Port)); + if C_Connect (Socket.FD, Sin'Address, Sin'Size / 8) = Failure then + raise Connection_Refused; + end if; + end Connect; + + --------------------------- + -- Customized_Setsockopt -- + --------------------------- + + procedure Customized_Setsockopt (Socket : in Socket_FD'Class; + Optval : in Opt_Type) + is + begin + pragma Assert (Optval'Size / 8 = Socket_Option_Size (Optname)); + if C_Setsockopt (Socket.FD, Socket_Level_Match (Level), + Socket_Option_Match (Optname), + Optval'Address, Optval'Size / 8) = Failure + then + Raise_With_Message ("Setsockopt failed"); + end if; + end Customized_Setsockopt; + + --------- + -- Get -- + --------- + + function Get (Socket : Socket_FD'Class) return String + is + Stream : constant Stream_Element_Array := Receive (Socket); + Result : String (Positive (Stream'First) .. Positive (Stream'Last)); + begin + for I in Stream'Range loop + Result (Positive (I)) := + Character'Val (Stream_Element'Pos (Stream (I))); + end loop; + return Result; + end Get; + + -------------- + -- Get_Line -- + -------------- + + function Get_Line (Socket : Socket_FD'Class) return String is + Result : String (1 .. 1024); + Index : Positive := Result'First; + Byte : Stream_Element_Array (1 .. 1); + Char : Character; + begin + loop + Receive (Socket, Byte); + Char := Character'Val (Stream_Element'Pos (Byte (Byte'First))); + if Char = LF then + return Result (1 .. Index - 1); + elsif Char /= CR then + Result (Index) := Char; + Index := Index + 1; + if Index > Result'Last then + return Result & Get_Line (Socket); + end if; + end if; + end loop; + end Get_Line; + + ------------ + -- Listen -- + ------------ + + procedure Listen + (Socket : in Socket_FD; + Queue_Size : in Positive := 5) + is + begin + if C_Listen (Socket.FD, int (Queue_Size)) = Failure then + Raise_With_Message ("Listen failed"); + end if; + end Listen; + + -------------- + -- New_Line -- + -------------- + + procedure New_Line (Socket : in Socket_FD'Class; + Count : in Natural := 1) + is + begin + Put (Socket, CRLF * Count); + end New_Line; + + --------- + -- Put -- + --------- + + procedure Put (Socket : in Socket_FD'Class; + Str : in String) + is + Stream : Stream_Element_Array (Stream_Element_Offset (Str'First) .. + Stream_Element_Offset (Str'Last)); + begin + for I in Str'Range loop + Stream (Stream_Element_Offset (I)) := + Stream_Element'Val (Character'Pos (Str (I))); + end loop; + Send (Socket, Stream); + end Put; + + -------------- + -- Put_Line -- + -------------- + + procedure Put_Line (Socket : in Socket_FD'Class; Str : in String) + is + begin + Put (Socket, Str & CRLF); + end Put_Line; + + ------------- + -- Receive -- + ------------- + + function Receive (Socket : Socket_FD; Max : Stream_Element_Count := 4096) + return Ada.Streams.Stream_Element_Array + is + Buffer : Stream_Element_Array (1 .. Max); + Addr : aliased In_Addr; + Addrlen : aliased int := Addr'Size / 8; + Count : constant int := + C_Recvfrom (Socket.FD, Buffer'Address, Buffer'Length, 0, + Addr'Address, Addrlen'Access); + begin + if Count < 0 then + Raise_With_Message ("Receive error"); + elsif Count = 0 then + raise Connection_Closed; + end if; + return Buffer (1 .. Stream_Element_Offset (Count)); + end Receive; + + ------------- + -- Receive -- + ------------- + + procedure Receive (Socket : in Socket_FD'Class; + Data : out Ada.Streams.Stream_Element_Array) + is + Index : Stream_Element_Offset := Data'First; + Rest : Stream_Element_Count := Data'Length; + begin + while Rest > 0 loop + declare + Sub_Buffer : constant Stream_Element_Array := + Receive (Socket, Rest); + Length : constant Stream_Element_Count := Sub_Buffer'Length; + begin + Data (Index .. Index + Length - 1) := Sub_Buffer; + Index := Index + Length; + Rest := Rest - Length; + end; + end loop; + end Receive; + + ---------- + -- Send -- + ---------- + + procedure Send (Socket : in Socket_FD; + Data : in Stream_Element_Array) + is + Index : Stream_Element_Offset := Data'First; + Rest : Stream_Element_Count := Data'Length; + Count : int; + begin + while Rest > 0 loop + Count := C_Send (Socket.FD, Data (Index) 'Address, int (Rest), 0); + if Count < 0 then + Raise_With_Message ("Send failed"); + elsif Count = 0 then + raise Connection_Closed; + end if; + Index := Index + Stream_Element_Count (Count); + Rest := Rest - Stream_Element_Count (Count); + end loop; + end Send; + + ---------------- + -- Setsockopt -- + ---------------- + + procedure Setsockopt + (Socket : in Socket_FD'Class; + Level : in Socket_Level := Sol_Socket; + Optname : in Socket_Option; + Optval : in Integer) + is + begin + case Socket_Option_Size (Optname) is + + when 1 => + declare + C_Char_Optval : aliased char := char'Val (Optval); + begin + pragma Assert (C_Char_Optval'Size = 8); + if C_Setsockopt (Socket.FD, Socket_Level_Match (Level), + Socket_Option_Match (Optname), + C_Char_Optval'Address, 1) = Failure + then + Raise_With_Message ("Setsockopt failed"); + end if; + end; + + when 4 => + declare + C_Int_Optval : aliased int := int (Optval); + begin + pragma Assert (C_Int_Optval'Size = 32); + if C_Setsockopt (Socket.FD, Socket_Level_Match (Level), + Socket_Option_Match (Optname), + C_Int_Optval'Address, 4) = Failure + then + Raise_With_Message ("Setsockopt failed"); + end if; + end; + + when others => + Raise_With_Message ("Setsockopt called with wrong arguments", + False); + + end case; + end Setsockopt; + + -------------- + -- Shutdown -- + -------------- + + procedure Shutdown (Socket : in Socket_FD; + How : in Shutdown_Type := Both) + is + begin + C_Shutdown (Socket.FD, Shutdown_Type_Match (How)); + end Shutdown; + + ------------ + -- Socket -- + ------------ + + procedure Socket + (Sock : out Socket_FD; + Domain : in Socket_Domain := AF_INET; + Typ : in Socket_Type := SOCK_STREAM) + is + Result : constant int := + C_Socket (Socket_Domain_Match (Domain), Socket_Type_Match (Typ), 0); + begin + if Result = Failure then + Raise_With_Message ("Unable to create socket"); + end if; + Sock := (FD => Result); + end Socket; + +end Sockets; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets.ads b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets.ads new file mode 100644 index 0000000000..4f159634d7 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/adasockets/sockets.ads @@ -0,0 +1,155 @@ +----------------------------------------------------------------------------- +-- -- +-- ADASOCKETS COMPONENTS -- +-- -- +-- S O C K E T S -- +-- -- +-- S p e c -- +-- -- +-- $ReleaseVersion: 0.1.3 $ -- +-- -- +-- Copyright (C) 1998 École Nationale Supérieure des Télécommunications -- +-- -- +-- AdaSockets is free software; you can redistribute it and/or modify -- +-- it under terms of the GNU General Public License as published by -- +-- the Free Software Foundation; either version 2, or (at your option) -- +-- any later version. AdaSockets is distributed in the hope that it -- +-- will be useful, but WITHOUT ANY WARRANTY; without even the implied -- +-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- +-- See the GNU General Public License for more details. You should -- +-- have received a copy of the GNU General Public License distributed -- +-- with AdaSockets; see file COPYING. If not, write to the Free -- +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- +-- 02111-1307, USA. -- +-- -- +-- As a special exception, if other files instantiate generics from -- +-- this unit, or you link this unit with other files to produce an -- +-- executable, this unit does not by itself cause the resulting -- +-- executable to be covered by the GNU General Public License. This -- +-- exception does not however invalidate any other reasons why the -- +-- executable file might be covered by the GNU Public License. -- +-- -- +-- The main repository for this software is located at: -- +-- http://www-inf.enst.fr/ANC/ -- +-- -- +----------------------------------------------------------------------------- + +with Ada.Streams; +with Interfaces.C; + +package Sockets is + + type Socket_FD is tagged private; + -- A socket + + type Socket_Domain is (AF_INET); + -- AF_INET: Internet sockets (yes, should be PF_INET, but they hold the + -- same value) + + type Socket_Type is (SOCK_STREAM, SOCK_DGRAM); + -- SOCK_STREAM: Stream mode (TCP) + -- SOCK_DGRAM: Datagram mode (UDP, Multicast) + + procedure Socket + (Sock : out Socket_FD; + Domain : in Socket_Domain := AF_INET; + Typ : in Socket_Type := SOCK_STREAM); + -- Create a socket of the given mode + + Connection_Refused : exception; + + procedure Connect + (Socket : in Socket_FD; + Host : in String; + Port : in Positive); + -- Connect a socket on a given host/port. Raise Connection_Refused if + -- the connection has not been accepted by the other end. + + procedure Bind + (Socket : in Socket_FD; + Port : in Positive); + -- Bind a socket on a given port + + procedure Listen + (Socket : in Socket_FD; + Queue_Size : in Positive := 5); + -- Create a socket's listen queue + + type Socket_Level is (SOL_SOCKET, IPPROTO_IP); + + type Socket_Option is (SO_REUSEADDR, IP_MULTICAST_TTL, + IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, + IP_MULTICAST_LOOP); + + procedure Setsockopt + (Socket : in Socket_FD'Class; + Level : in Socket_Level := SOL_SOCKET; + Optname : in Socket_Option; + Optval : in Integer); + -- Set a socket option + + generic + Level : Socket_Level; + Optname : Socket_Option; + type Opt_Type is private; + procedure Customized_Setsockopt (Socket : in Socket_FD'Class; + Optval : in Opt_Type); + -- Low level control on setsockopt + + procedure Accept_Socket (Socket : in Socket_FD; + New_Socket : out Socket_FD); + -- Accept a connection on a socket + + Connection_Closed : exception; + + procedure Send (Socket : in Socket_FD; + Data : in Ada.Streams.Stream_Element_Array); + -- Send data on a socket. Raise Connection_Closed if the socket + -- has been closed. + + function Receive (Socket : Socket_FD; + Max : Ada.Streams.Stream_Element_Count := 4096) + return Ada.Streams.Stream_Element_Array; + -- Receive data from a socket. May raise Connection_Closed + + procedure Receive (Socket : in Socket_FD'Class; + Data : out Ada.Streams.Stream_Element_Array); + -- Fill data from a socket. Raise Connection_Closed if the socket has + -- been closed before the end of the array. + + type Shutdown_Type is (Receive, Send, Both); + + procedure Shutdown (Socket : in Socket_FD; + How : in Shutdown_Type := Both); + -- Close a previously opened socket + + --------------------------------- + -- String-oriented subprograms -- + --------------------------------- + + procedure Put (Socket : in Socket_FD'Class; + Str : in String); + -- Send a string on the socket + + procedure New_Line (Socket : in Socket_FD'Class; + Count : in Natural := 1); + -- Send CR/LF sequences on the socket + + procedure Put_Line (Socket : in Socket_FD'Class; + Str : in String); + -- Send a string + CR/LF on the socket + + function Get (Socket : Socket_FD'Class) return String; + -- Get a string from the socket + + function Get_Line (Socket : Socket_FD'Class) return String; + -- Get a full line from the socket. CR is ignored and LF is considered + -- as an end-of-line marker. + +private + + type Socket_FD is tagged record + FD : Interfaces.C.int; + end record; + +end Sockets; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/listener/Makefile b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/listener/Makefile new file mode 100644 index 0000000000..05077b74c0 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/listener/Makefile @@ -0,0 +1,43 @@ +# +# Makefile for network listener example +# + +MAIN=listener + +# Tool paths +tooldir=/usr/local/rtems +rtemsdir=${tooldir}/ts_386ex + +# Tool names +GCC=${tooldir}/bin/i386-rtemself-gcc +GNATMAKE=${tooldir}/bin/i386-rtemself-gnatmake +SIZE=${tooldir}/bin/i386-rtemself-size +SIS=${tooldir}/bin/sis +GDB=${tooldir}/bin/sis-gdb + +CINCLUDES=-I/usr/local/rtems/ts_386ex/lib/include/networking + +AINCLUDES=-i -I/usr/local/rtems/lib/adasockets + +CARGS=-B${rtemsdir}/lib/ -specs bsp_specs -qrtems + +all: init.o + $(GNATMAKE) -v -O -gnata -gnatE -gnato $(AINCLUDES) $(MAIN) -g \ + -bargs -r \ + -cargs $(CARGS) \ + -largs $(CARGS) init.o + $(SIZE) $(MAIN) + + + +init.o: init.c + $(GCC) -O4 -g -Wall -ansi -fasm $(CARGS) $(CINCLUDES) -c init.c + +run: + $(SIS) $(MAIN) + +gdb: + $(GDB) $(MAIN) + +clean: + rm -f b_$(MAIN).c b_$(MAIN).o *.o *.ali $(MAIN) diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/listener/Makefile.ts_386ex b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/listener/Makefile.ts_386ex new file mode 100644 index 0000000000..05077b74c0 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/listener/Makefile.ts_386ex @@ -0,0 +1,43 @@ +# +# Makefile for network listener example +# + +MAIN=listener + +# Tool paths +tooldir=/usr/local/rtems +rtemsdir=${tooldir}/ts_386ex + +# Tool names +GCC=${tooldir}/bin/i386-rtemself-gcc +GNATMAKE=${tooldir}/bin/i386-rtemself-gnatmake +SIZE=${tooldir}/bin/i386-rtemself-size +SIS=${tooldir}/bin/sis +GDB=${tooldir}/bin/sis-gdb + +CINCLUDES=-I/usr/local/rtems/ts_386ex/lib/include/networking + +AINCLUDES=-i -I/usr/local/rtems/lib/adasockets + +CARGS=-B${rtemsdir}/lib/ -specs bsp_specs -qrtems + +all: init.o + $(GNATMAKE) -v -O -gnata -gnatE -gnato $(AINCLUDES) $(MAIN) -g \ + -bargs -r \ + -cargs $(CARGS) \ + -largs $(CARGS) init.o + $(SIZE) $(MAIN) + + + +init.o: init.c + $(GCC) -O4 -g -Wall -ansi -fasm $(CARGS) $(CINCLUDES) -c init.c + +run: + $(SIS) $(MAIN) + +gdb: + $(GDB) $(MAIN) + +clean: + rm -f b_$(MAIN).c b_$(MAIN).o *.o *.ali $(MAIN) diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/listener/init.c b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/listener/init.c new file mode 100644 index 0000000000..852a2a962d --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/listener/init.c @@ -0,0 +1,99 @@ +/* + * COPYRIGHT (c) 1989-1997. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be found in + * the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <bsp.h> + +#include <assert.h> +#include <pthread.h> + +#include <stdio.h> +#include <rtems/rtems_bsdnet.h> +#include "../networkconfig.h" + +#ifdef GNAT_PID +#include <unistd.h> +pid_t getpid() +{ + return GNAT_PID; +} +#endif + +/* + * By having the POSIX_Init thread create a second thread just + * to invoke gnat_main, we can override all default attributes + * of the "Ada environment task". Otherwise, we would be + * stuck with the defaults set by RTEMS. + */ + +void *start_gnat_main( void * argument ) +{ + extern int gnat_main ( int argc, char **argv, char **envp ); + + (void) gnat_main ( 0, 0, 0 ); + + exit( 0 ); + + return 0; +} + +void *POSIX_Init( void *argument ) +{ + pthread_t thread_id; + pthread_attr_t attr; + int status; + + rtems_bsdnet_initialize_network (); + + status = pthread_attr_init( &attr ); + assert( !status ); + +#ifdef GNAT_MAIN_STACKSPACE + status = pthread_attr_setstacksize( &attr, GNAT_MAIN_STACKSPACE ); + assert( !status ); +#endif + + status = pthread_create( &thread_id, &attr, start_gnat_main, NULL ); + assert( !status ); + + pthread_exit( 0 ); + + return 0; +} + +/* configuration information */ + +#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER + +/* +#define CONFIGURE_MICROSECONDS_PER_TICK RTEMS_MILLISECONDS_TO_MICROSECONDS(1) +*/ + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_EXECUTIVE_RAM_SIZE (512*1024) +#define CONFIGURE_INIT_TASK_STACK_SIZE (10*1024) +#define CONFIGURE_INIT_TASK_PRIORITY 120 +#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \ + RTEMS_NO_TIMESLICE | \ + RTEMS_NO_ASR | \ + RTEMS_INTERRUPT_LEVEL(0)) + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 20 +#define CONFIGURE_MAXIMUM_POSIX_KEYS 20 +#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 30 +#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 20 + +#define CONFIGURE_INIT + +#include <confdefs.h> + diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/listener/listener.adb b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/listener/listener.adb new file mode 100644 index 0000000000..97b8c106de --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/listener/listener.adb @@ -0,0 +1,114 @@ +----------------------------------------------------------------------------- +-- -- +-- ADASOCKETS COMPONENTS -- +-- -- +-- L I S T E N E R -- +-- -- +-- B o d y -- +-- -- +-- $ReleaseVersion: 0.1.3 $ -- +-- -- +-- Copyright (C) 1998 École Nationale Supérieure des Télécommunications -- +-- -- +-- AdaSockets is free software; you can redistribute it and/or modify -- +-- it under terms of the GNU General Public License as published by -- +-- the Free Software Foundation; either version 2, or (at your option) -- +-- any later version. AdaSockets is distributed in the hope that it -- +-- will be useful, but WITHOUT ANY WARRANTY; without even the implied -- +-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- +-- See the GNU General Public License for more details. You should -- +-- have received a copy of the GNU General Public License distributed -- +-- with AdaSockets; see file COPYING. If not, write to the Free -- +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- +-- 02111-1307, USA. -- +-- -- +-- As a special exception, if other files instantiate generics from -- +-- this unit, or you link this unit with other files to produce an -- +-- executable, this unit does not by itself cause the resulting -- +-- executable to be covered by the GNU General Public License. This -- +-- exception does not however invalidate any other reasons why the -- +-- executable file might be covered by the GNU Public License. -- +-- -- +-- The main repository for this software is located at: -- +-- http://www-inf.enst.fr/ANC/ -- +-- -- +----------------------------------------------------------------------------- + +with Ada.Exceptions; use Ada.Exceptions; +with Ada.Text_IO; use Ada.Text_IO; +with Sockets; use Sockets; + +procedure Listener is + + -- Usage: listener + -- Example: listener + -- then telnet localhost `listen_port' + + Listen_Port : Positive := 5000; + + task type Echo is + entry Start (FD : in Socket_FD); + end Echo; + + function Rev (S : String) return String; + -- Reverse a string + + ---------- + -- Echo -- + ---------- + + task body Echo is + Sock : Socket_FD; + begin + select + accept Start (FD : in Socket_FD) do + Sock := FD; + end Start; + or + terminate; + end select; + + loop + Put_Line (Sock, Rev (Get_Line (Sock))); + end loop; + + exception + when Connection_Closed => + Put_Line ("Connection closed"); + Shutdown (Sock, Both); + end Echo; + + Accepting_Socket : Socket_FD; + Incoming_Socket : Socket_FD; + + type Echo_Access is access Echo; + Dummy : Echo_Access; + + --------- + -- Rev -- + --------- + + function Rev (S : String) return String is + Result : String (1 .. S'Length); + Index : Natural := 0; + begin + for I in reverse S'Range loop + Index := Index + 1; + Result (Index) := S (I); + end loop; + return Result; + end Rev; + +begin + Socket (Accepting_Socket, AF_INET, SOCK_STREAM); + Setsockopt (Accepting_Socket, SOL_SOCKET, SO_REUSEADDR, 1); + Bind (Accepting_Socket, Listen_Port); + Listen (Accepting_Socket); + loop + Put_Line ("Waiting for new connection"); + Accept_Socket (Accepting_Socket, Incoming_Socket); + Put_Line ("New connection acknowledged"); + Dummy := new Echo; + Dummy.Start (Incoming_Socket); + end loop; +end Listener; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/networkconfig.h b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/networkconfig.h new file mode 100644 index 0000000000..41dfbe11d4 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/networkconfig.h @@ -0,0 +1,104 @@ +/* + * Network configuration + * + ************************************************************ + * EDIT THIS FILE TO REFLECT YOUR NETWORK CONFIGURATION * + * BEFORE RUNNING ANY RTEMS PROGRAMS WHICH USE THE NETWORK! * + ************************************************************ + * + * $Id$ + */ + +#ifndef _RTEMS_NETWORKCONFIG_H_ +#define _RTEMS_NETWORKCONFIG_H_ + +#define RTEMS_USE_BOOTP + +#include <bsp.h> + +/* + * Define RTEMS_SET_ETHERNET_ADDRESS if you want to specify the + * Ethernet address here. If RTEMS_SET_ETHERNET_ADDRESS is not + * defined the driver will choose an address. + */ + +/*#define RTEMS_SET_ETHERNET_ADDRESS*/ + +#if (defined (RTEMS_SET_ETHERNET_ADDRESS)) +static char ethernet_address[6] = { 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX }; +#endif + +/* + * Default network interface + */ +static struct rtems_bsdnet_ifconfig netdriver_config = { + RTEMS_BSP_NETWORK_DRIVER_NAME, /* name */ + RTEMS_BSP_NETWORK_DRIVER_ATTACH, /* attach function */ + + NULL, /* link to next interface */ + +#if (defined (RTEMS_USE_BOOTP)) + NULL, /* BOOTP supplies IP address */ + NULL, /* BOOTP supplies IP net mask */ +#else + "127.37.12.19", /* IP address of device */ + "255.255.255.0", /* IP net mask */ +#endif /* !RTEMS_USE_BOOTP */ + +#if (defined (RTEMS_SET_ETHERNET_ADDRESS)) + ethernet_address, /* Ethernet hardware address */ +#else + NULL, /* Driver supplies hardware address */ +#endif + 0, /* TRUE == Ignore broadcast packets */ + + 0, /* Default MTU */ + 0, /* Default rbufs */ + 0, /* Default xbufs */ + + 0x300, /* I/O port on ethernet card */ + 5, /* IRQ */ + 0x0000 /* Shared memory start */ + +}; + +/* + * Network configuration + */ +struct rtems_bsdnet_config rtems_bsdnet_config = { + &netdriver_config, + +#if (defined (RTEMS_USE_BOOTP)) + rtems_bsdnet_do_bootp, +#else + NULL, +#endif + + 0, /* Default network task priority */ + 0, /* Default mbuf capacity */ + 0, /* Default mbuf cluster capacity */ + +#if defined (RTEMS_USE_BOOTP) + NULL, + NULL, + NULL, + NULL, + {NULL,NULL,NULL}, +#else + "rtems0", /* Host name */ + "ece.ubc.ca", /* Domain name */ + "127.37.12.254", /* Gateway: */ + "127.37.12.19", /* Log host: */ + {"127.37.15.9"}, /* Name server(s) */ +#endif /* RTEMS_USE_BOOTP */ +}; + +/* + * For TFTP test application + */ +#if (!defined (RTEMS_USE_BOOTP)) +#define RTEMS_TFTP_TEST_HOST_NAME "127.37.12.19" +#define RTEMS_TFTP_TEST_FILE_NAME "bootfiles/xxx" +#endif + +#endif /* _RTEMS_NETWORKCONFIG_H_ */ diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/Makefile b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/Makefile new file mode 100644 index 0000000000..1de940b9c5 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/Makefile @@ -0,0 +1,46 @@ +# +# Makefile for tcprelay example +# + +MAIN=tcprelay + +# Tool paths +tooldir=/usr/local/rtems +rtemsdir=${tooldir}/ts_386ex + +# Tool names +GCC=${tooldir}/bin/i386-rtemself-gcc +GNATMAKE=${tooldir}/bin/i386-rtemself-gnatmake +SIZE=${tooldir}/bin/i386-rtemself-size +SIS=${tooldir}/bin/sis +GDB=${tooldir}/bin/sis-gdb + +CINCLUDES=-I/usr/local/rtems/ts_386ex/lib/include/networking + +AINCLUDES=-i -I/usr/local/rtems/lib/adasockets + +CARGS=-B${rtemsdir}/lib/ -specs bsp_specs -qrtems + +all: init.o print_error.o + $(GNATMAKE) -O -gnata -gnatE -gnato $(AINCLUDES) $(MAIN) -g \ + -bargs -r \ + -cargs $(CARGS) \ + -largs $(CARGS) init.o print_error.o + $(SIZE) $(MAIN) + + + +init.o: init.c + $(GCC) -O4 -g -Wall -ansi -fasm $(CARGS) $(CINCLUDES) -c init.c + +print_error.o: print_error.c + $(GCC) -O4 -g -Wall -ansi -fasm $(CARGS) $(CINCLUDES) -c print_error.c + +run: + $(SIS) $(MAIN) + +gdb: + $(GDB) $(MAIN) + +clean: + rm -f b_$(MAIN).c b_$(MAIN).o *.o *.ali $(MAIN) diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/Makefile.ts_386ex b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/Makefile.ts_386ex new file mode 100644 index 0000000000..1de940b9c5 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/Makefile.ts_386ex @@ -0,0 +1,46 @@ +# +# Makefile for tcprelay example +# + +MAIN=tcprelay + +# Tool paths +tooldir=/usr/local/rtems +rtemsdir=${tooldir}/ts_386ex + +# Tool names +GCC=${tooldir}/bin/i386-rtemself-gcc +GNATMAKE=${tooldir}/bin/i386-rtemself-gnatmake +SIZE=${tooldir}/bin/i386-rtemself-size +SIS=${tooldir}/bin/sis +GDB=${tooldir}/bin/sis-gdb + +CINCLUDES=-I/usr/local/rtems/ts_386ex/lib/include/networking + +AINCLUDES=-i -I/usr/local/rtems/lib/adasockets + +CARGS=-B${rtemsdir}/lib/ -specs bsp_specs -qrtems + +all: init.o print_error.o + $(GNATMAKE) -O -gnata -gnatE -gnato $(AINCLUDES) $(MAIN) -g \ + -bargs -r \ + -cargs $(CARGS) \ + -largs $(CARGS) init.o print_error.o + $(SIZE) $(MAIN) + + + +init.o: init.c + $(GCC) -O4 -g -Wall -ansi -fasm $(CARGS) $(CINCLUDES) -c init.c + +print_error.o: print_error.c + $(GCC) -O4 -g -Wall -ansi -fasm $(CARGS) $(CINCLUDES) -c print_error.c + +run: + $(SIS) $(MAIN) + +gdb: + $(GDB) $(MAIN) + +clean: + rm -f b_$(MAIN).c b_$(MAIN).o *.o *.ali $(MAIN) diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/init.c b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/init.c new file mode 100644 index 0000000000..a3d3752568 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/init.c @@ -0,0 +1,101 @@ +/* + * COPYRIGHT (c) 1989-1997. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be found in + * the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <bsp.h> + +#include <assert.h> +#include <pthread.h> + +#include <stdio.h> +#include <rtems/rtems_bsdnet.h> +#include "../networkconfig.h" + +#ifdef GNAT_PID +#include <unistd.h> +pid_t getpid() +{ + return GNAT_PID; +} +#endif + +/* + * By having the POSIX_Init thread create a second thread just + * to invoke gnat_main, we can override all default attributes + * of the "Ada environment task". Otherwise, we would be + * stuck with the defaults set by RTEMS. + */ + +void *start_gnat_main( void * argument ) +{ + extern int gnat_main ( int argc, char **argv, char **envp ); + + (void) gnat_main ( 0, 0, 0 ); + + exit( 0 ); + + return 0; +} + +#define GNAT_MAIN_STACKSPACE (32*1024) + +void *POSIX_Init( void *argument ) +{ + pthread_t thread_id; + pthread_attr_t attr; + int status; + + rtems_bsdnet_initialize_network (); + + status = pthread_attr_init( &attr ); + assert( !status ); + +#ifdef GNAT_MAIN_STACKSPACE + status = pthread_attr_setstacksize( &attr, GNAT_MAIN_STACKSPACE ); + assert( !status ); +#endif + + status = pthread_create( &thread_id, &attr, start_gnat_main, NULL ); + assert( !status ); + + pthread_exit( 0 ); + + return 0; +} + +/* configuration information */ + +#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER + +/* +#define CONFIGURE_MICROSECONDS_PER_TICK RTEMS_MILLISECONDS_TO_MICROSECONDS(1) +*/ + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_EXECUTIVE_RAM_SIZE (384*1024) +#define CONFIGURE_INIT_TASK_STACK_SIZE (10*1024) +#define CONFIGURE_INIT_TASK_PRIORITY 120 +#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \ + RTEMS_NO_TIMESLICE | \ + RTEMS_NO_ASR | \ + RTEMS_INTERRUPT_LEVEL(0)) + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 20 +#define CONFIGURE_MAXIMUM_POSIX_KEYS 20 +#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 30 +#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 20 + +#define CONFIGURE_INIT + +#include <confdefs.h> + diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/print_error.c b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/print_error.c new file mode 100644 index 0000000000..5dab06aad8 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/print_error.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <string.h> +#include <errno.h> + +void +print_error (void) { + printf("Problem connecting socket: %s\n", strerror (errno)); +} + +void +dump_sin (unsigned char *dp) { + int i; + + printf("Dump of sockaddr_in =\n"); + for(i=0; i<16; i++) + printf("%x ", *dp++); + printf("\n"); +} diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/tcprelay.adb b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/tcprelay.adb new file mode 100644 index 0000000000..d0c2594c0f --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/network_ada/tcprelay/tcprelay.adb @@ -0,0 +1,108 @@ +----------------------------------------------------------------------------- +-- -- +-- ADASOCKETS COMPONENTS -- +-- -- +-- T C P R E L A Y -- +-- -- +-- B o d y -- +-- -- +-- $ReleaseVersion: 0.1.3 $ -- +-- -- +-- Copyright (C) 1998 École Nationale Supérieure des Télécommunications -- +-- -- +-- AdaSockets is free software; you can redistribute it and/or modify -- +-- it under terms of the GNU General Public License as published by -- +-- the Free Software Foundation; either version 2, or (at your option) -- +-- any later version. AdaSockets is distributed in the hope that it -- +-- will be useful, but WITHOUT ANY WARRANTY; without even the implied -- +-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- +-- See the GNU General Public License for more details. You should -- +-- have received a copy of the GNU General Public License distributed -- +-- with AdaSockets; see file COPYING. If not, write to the Free -- +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- +-- 02111-1307, USA. -- +-- -- +-- As a special exception, if other files instantiate generics from -- +-- this unit, or you link this unit with other files to produce an -- +-- executable, this unit does not by itself cause the resulting -- +-- executable to be covered by the GNU General Public License. This -- +-- exception does not however invalidate any other reasons why the -- +-- executable file might be covered by the GNU Public License. -- +-- -- +-- The main repository for this software is located at: -- +-- http://www-inf.enst.fr/ANC/ -- +-- -- +----------------------------------------------------------------------------- + +with Ada.Exceptions; use Ada.Exceptions; +with Ada.Text_IO; use Ada.Text_IO; +with Sockets; use Sockets; + +procedure TCPRelay is + + Relay_Host : String := "host.domain"; + + procedure Print_Error; + pragma Import (C, Print_Error, "print_error"); + + task type Relay is + pragma Storage_Size (8192); + entry Start (From, To : Socket_FD); + end Relay; + + ----------- + -- Relay -- + ----------- + + task body Relay + is + From_FD, To_FD : Socket_FD; + begin + select + accept Start (From, To : Socket_FD) do + From_FD := From; + To_FD := To; + end Start; + or + terminate; + end select; + + loop + Send (To_FD, Receive (From_FD)); + end loop; + exception + when Connection_Closed => + Put_Line ("Connection closed"); + Shutdown (From_FD, Receive); + Shutdown (To_FD, Send); + end Relay; + + Accepting_Socket, + Incoming_Socket, + Outgoing_Socket : Socket_FD; + + type Relay_Access is access Relay; + Dummy : Relay_Access; + +begin + Socket (Accepting_Socket, AF_INET, SOCK_STREAM); + Setsockopt (Accepting_Socket, SOL_SOCKET, SO_REUSEADDR, 1); + Bind (Accepting_Socket, 4567); + Listen (Accepting_Socket); + loop + Put_Line ("Waiting for new connection"); + Accept_Socket (Accepting_Socket, Incoming_Socket); + Put_Line ("New connection acknowledged"); + Socket (Outgoing_Socket, AF_INET, SOCK_STREAM); + Put_Line ("Connecting to remote host"); + Connect (Outgoing_Socket, Relay_Host, 5000); + Put_Line ("Connection established"); + Dummy := new Relay; + Dummy.Start (Incoming_Socket, Outgoing_Socket); + Dummy := new Relay; + Dummy.Start (Outgoing_Socket, Incoming_Socket); + end loop; +exception + when others => + Print_Error; +end TCPRelay; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/Makefile.ts_386ex b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/Makefile.ts_386ex index 1ce881e04e..5df8c8fe03 100644 --- a/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/Makefile.ts_386ex +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/Makefile.ts_386ex @@ -6,18 +6,17 @@ MAIN=ts1325_test # Tool paths tooldir=/usr/local/rtems -rtemsdir=${tooldir}/rtems/ts_386ex +rtemsdir=${tooldir}/ts_386ex # Tool names -GCC=${tooldir}/bin/i386-rtems-gcc -GNATMAKE=${tooldir}/bin/i386-rtems-gnatmake -SIZE=${tooldir}/bin/i386-rtems-size +GCC=${tooldir}/bin/i386-rtemself-gcc +GNATMAKE=${tooldir}/bin/i386-rtemself-gnatmake +SIZE=${tooldir}/bin/i386-rtemself-size SIS=${tooldir}/bin/sis GDB=${tooldir}/bin/sis-gdb CARGS=-B${rtemsdir}/lib/ -specs bsp_specs -qrtems \ -msoft-float -mno-fp-ret-in-387 -#CARGS=-B/usr/local/rtems/tools/build-i386-rtems/ts_386ex/lib/ -specs bsp_specs -qrtems all: init.o $(GNATMAKE) -O -gnata -gnatE -gnato $(MAIN) -g \ |