diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-04-23 16:35:11 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-04-23 16:35:11 +0000 |
commit | 16a384cfb161f6a3dbcd69fc3b788b6dbc229669 (patch) | |
tree | dbbb2e908c64a7f8de5d4c99c16559158b99f1cf /c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada | |
parent | Added lstat(). (diff) | |
download | rtems-16a384cfb161f6a3dbcd69fc3b788b6dbc229669.tar.bz2 |
New BSP from Tony R. Ambardar <tonya@ece.ubc.ca> from the
University of British Columbia. The BSP is for:
Yes, this is the "entry model" of a series of boards from Technologic
Systems. Costs <$200 I believe. They have a WWW page at www.t-systems.com.
I am letting them know about the availability of this BSP too.
Diffstat (limited to 'c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada')
13 files changed, 511 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/Makefile b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/Makefile new file mode 100644 index 0000000000..1ce881e04e --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/Makefile @@ -0,0 +1,41 @@ +# +# Makefile for TS-1325 Utilities example +# + +MAIN=ts1325_test + +# Tool paths +tooldir=/usr/local/rtems +rtemsdir=${tooldir}/rtems/ts_386ex + +# Tool names +GCC=${tooldir}/bin/i386-rtems-gcc +GNATMAKE=${tooldir}/bin/i386-rtems-gnatmake +SIZE=${tooldir}/bin/i386-rtems-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 \ + -bargs -r \ + -cargs $(CARGS) \ + -largs $(CARGS) init.o + $(SIZE) $(MAIN) + + + +init.o: init.c + $(GCC) -O4 -g -Wall -ansi -fasm $(CARGS) -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/ts_1325_ada/Makefile.ts_386ex b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/Makefile.ts_386ex new file mode 100644 index 0000000000..1ce881e04e --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/Makefile.ts_386ex @@ -0,0 +1,41 @@ +# +# Makefile for TS-1325 Utilities example +# + +MAIN=ts1325_test + +# Tool paths +tooldir=/usr/local/rtems +rtemsdir=${tooldir}/rtems/ts_386ex + +# Tool names +GCC=${tooldir}/bin/i386-rtems-gcc +GNATMAKE=${tooldir}/bin/i386-rtems-gnatmake +SIZE=${tooldir}/bin/i386-rtems-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 \ + -bargs -r \ + -cargs $(CARGS) \ + -largs $(CARGS) init.o + $(SIZE) $(MAIN) + + + +init.o: init.c + $(GCC) -O4 -g -Wall -ansi -fasm $(CARGS) -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/ts_1325_ada/i386_ports.adb b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/i386_ports.adb new file mode 100644 index 0000000000..9705d069d8 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/i386_ports.adb @@ -0,0 +1,29 @@ +with System.Machine_Code; +use System.Machine_Code; + +package body I386_Ports is + + procedure Outport (Addr: in Port_Address; Data: in Byte) is + begin + Asm ("movb %0, %%al;" & + "movw %1, %%dx;" & + "outb %%al, %%dx", + No_Output_Operands, + (Byte'Asm_Input ("g", Data), + Port_Address'Asm_Input ("g", Addr)), + Clobber => "al dx", + Volatile => True); + end Outport; + + procedure Inport (Addr: in Port_Address; Data: out Byte) is + begin + Asm ("movw %1, %%dx;" & + "inb %%dx, %%al;" & + "movb %%al, %0", + Byte'Asm_Output ("=g", Data), + Port_Address'Asm_Input ("g", Addr), + Clobber => "dx al", + Volatile => True); + end Inport; + +end I386_Ports; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/i386_ports.ads b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/i386_ports.ads new file mode 100644 index 0000000000..c27ea646e7 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/i386_ports.ads @@ -0,0 +1,47 @@ +with Interfaces; + +package I386_Ports is + + type Port_Address is new Interfaces.Unsigned_16; + + type Byte is new Interfaces.Unsigned_8; + + type Word is new Interfaces.Unsigned_16; + + type Long is new Interfaces.Unsigned_32; + + procedure Outport (Addr: in Port_Address; Data: in Byte); + + procedure Inport (Addr: in Port_Address; Data: out Byte); + + P1PIN: constant Port_Address; + P1LTC: constant Port_Address; + P1DIR: constant Port_Address; + + P2PIN: constant Port_Address; + P2LTC: constant Port_Address; + P2DIR: constant Port_Address; + + P3PIN: constant Port_Address; + P3LTC: constant Port_Address; + P3DIR: constant Port_Address; + +private + + pragma Inline (Outport, Inport); + + P1PIN: constant Port_Address := 16#F860#; + P1LTC: constant Port_Address := 16#F862#; + P1DIR: constant Port_Address := 16#F864#; + + P2PIN: constant Port_Address := 16#F868#; + P2LTC: constant Port_Address := 16#F86A#; + P2DIR: constant Port_Address := 16#F86C#; + + P3PIN: constant Port_Address := 16#F870#; + P3LTC: constant Port_Address := 16#F872#; + P3DIR: constant Port_Address := 16#F874#; + +end I386_Ports; + + diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/init.c b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/init.c new file mode 100644 index 0000000000..89e1652f3f --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/init.c @@ -0,0 +1,86 @@ +/* + * 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> + +#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_SPTEST +#define CONFIGURE_GNAT_RTEMS + +#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_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/ts_1325_ada/ts1325-button.adb b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-button.adb new file mode 100644 index 0000000000..cc273b0b3f --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-button.adb @@ -0,0 +1,22 @@ +package body TS1325.Button is + + function Is_Button_Pressed return Boolean is + State: Byte; + begin + Inport (Button_Port, State); + return (State and Button_Mask) /= Button_Mask; + end Is_Button_Pressed; + + procedure Wait_For_Button_Press is + begin + Poll_Loop: + loop + if Is_Button_Pressed then + delay Minimum_Press_Time; + exit Poll_Loop when Is_Button_Pressed; + end if; + delay Poll_Interval; + end loop Poll_Loop; + end Wait_For_Button_Press; + +end TS1325.Button; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-button.ads b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-button.ads new file mode 100644 index 0000000000..568710b32f --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-button.ads @@ -0,0 +1,22 @@ +with I386_Ports; +use I386_Ports; + +package TS1325.Button is + + function Is_Button_Pressed return Boolean; + + procedure Wait_For_Button_Press; + +private + + pragma Inline (Is_Button_Pressed, Wait_For_Button_Press); + + Poll_Interval: constant Duration := 0.3; + + Minimum_Press_Time: constant Duration := 0.3; + + Button_Mask: constant Byte := 2#0000_0001#; + + Button_Port: Port_Address renames P1PIN; + +end TS1325.Button; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-led.adb b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-led.adb new file mode 100644 index 0000000000..1a213ac2ff --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-led.adb @@ -0,0 +1,46 @@ +package body TS1325.LED is + + protected body LED_State is + + function Get return LED_Colour is + State: Byte; + Red_On, Green_On: Boolean; + begin + Inport (LED_Port, State); + + Green_On := (State and Green_Bit) = Green_Bit; + Red_On := (State and Red_Bit) /= Red_Bit; + + if not (Green_On or Red_On) then + return Off; + elsif Green_On and not Red_On then + return Green; + elsif Green_On and Red_On then + return Yellow; + else + return Red; + end if; + end Get; + + procedure Set (Col: in LED_Colour) is + State: Byte; + begin + Inport (LED_Port, State); + + case Col is + when Off => + State := (State and not Green_Bit) or Red_Bit; + when Green => + State := State or Green_Bit or Red_Bit; + when Yellow => + State := (State or Green_Bit) and not Red_Bit; + when Red => + State := State and not (Green_Bit or Red_Bit); + end case; + + Outport (LED_Port, State); + end Set; + + end LED_State; + +end TS1325.LED; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-led.ads b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-led.ads new file mode 100644 index 0000000000..6856bc4520 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-led.ads @@ -0,0 +1,26 @@ +with I386_Ports; +use I386_Ports; + +package TS1325.LED is + + type LED_Colour is (Off, Green, Yellow, Red); + + protected LED_State is + + function Get return LED_Colour; + + procedure Set (Col: in LED_Colour); + + end LED_State; + +private + + Green_Bit: constant Byte := 2#0010_0000#; -- bit set = LED on + + Red_Bit: constant Byte := 2#0100_0000#; -- bit clear = LED on + + LED_Mask: constant Byte := 2#0110_0000#; + + LED_Port: Port_Address renames P1LTC; + +end TS1325.LED; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-parallel.adb b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-parallel.adb new file mode 100644 index 0000000000..c0a76bcadf --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-parallel.adb @@ -0,0 +1,13 @@ +package body TS1325.Parallel is + + procedure Read_Parallel_Port (Data: out Byte) is + begin + Inport (Parallel_Port_In, Data); + end Read_Parallel_Port; + + procedure Write_Parallel_Port (Data: in Byte) is + begin + Outport (Parallel_Port_Out, Data); + end Write_Parallel_Port; + +end TS1325.Parallel; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-parallel.ads b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-parallel.ads new file mode 100644 index 0000000000..b6b18d6b55 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325-parallel.ads @@ -0,0 +1,21 @@ +with I386_Ports; +use I386_Ports; + +package TS1325.Parallel is + + procedure Read_Parallel_Port (Data: out Byte); + + procedure Write_Parallel_Port (Data: in Byte); + +private + + pragma Inline (Read_Parallel_Port, Write_Parallel_Port); + + -- These are non-standard IO locations, which is why they are here instead + -- of in the I386_Ports package. + + Parallel_Port_In: constant Port_Address := 16#75#; + + Parallel_Port_Out: constant Port_Address := 16#74#; + +end TS1325.Parallel; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325.ads b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325.ads new file mode 100644 index 0000000000..5ef01b7449 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325.ads @@ -0,0 +1,2 @@ +package TS1325 is +end TS1325; diff --git a/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325_test.adb b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325_test.adb new file mode 100644 index 0000000000..0cb621c880 --- /dev/null +++ b/c/src/lib/libbsp/i386/ts_386ex/tools/ts_1325_ada/ts1325_test.adb @@ -0,0 +1,115 @@ +-- +-- A test program that uses the TS1325 Button and LED packages. +-- + +with Text_IO; + +with I386_Ports; +use I386_Ports; + +with TS1325.LED; +use TS1325.LED; + +with TS1325.Button; +use TS1325.Button; + +with TS1325.Parallel; +use TS1325.Parallel; + +procedure Ts1325_Test is + + Test_Parallel_Interval: Duration := 1.0; + Read_Button_Interval: Duration := 1.0; + Read_LED_Interval: Duration := 1.0; + Set_LED_Interval: Duration := 0.2; + + task Test_Parallel is + entry Start; + end Test_Parallel; + + task body Test_Parallel is + W_Data, R_Data: I386_Ports.Byte := 0; + begin + accept Start; + + loop + W_Data := W_Data + 1; + Write_Parallel_Port (W_Data); + Read_Parallel_Port (R_Data); + Text_IO.Put_Line ("Parallel Port Loopback: Data Write = " & + I386_Ports.Byte'Image (W_Data) & + ", Data Read = " & + I386_Ports.Byte'Image (R_Data)); + delay Test_Parallel_Interval; + end loop; + end Test_Parallel; + + task Read_Button is + entry Start; + end Read_Button; + + task body Read_Button is + begin + accept Start; + + loop + if Is_Button_Pressed then + Text_IO.Put_Line ("Button is pressed."); + else + Text_IO.Put_Line ("Button is not pressed."); + end if; + delay Read_Button_Interval; + end loop; + end Read_Button; + + task Read_Colour is + entry Start; + end Read_Colour; + + task body Read_Colour is + begin + accept Start; + + loop + Text_IO.Put_Line ("Reading LED colour as " & + LED_Colour'Image (LED_State.Get)); + delay Read_LED_Interval; + end loop; + end Read_Colour; + + task Set_Colour is + entry Start; + end Set_Colour; + + task body Set_Colour is + Colour: LED_Colour := Off; + begin + accept Start; + + loop + LED_State.Set (Colour); + + if Colour = LED_Colour'Last then + Colour := LED_Colour'First; + else + Colour := LED_Colour'Succ (Colour); + end if; + + delay Set_LED_Interval; + end loop; + end Set_Colour; + +begin + Text_IO.Put_Line ("TS-1325 Utilities Test"); + Text_IO.Put_Line ("======================"); + Text_IO.New_Line; + Text_IO.Put_Line ("-=> Press the button to begin."); + Text_IO.New_Line; + + Wait_For_Button_Press; + + Set_Colour.Start; + Read_Colour.Start; + Read_Button.Start; + Test_Parallel.Start; +end Ts1325_Test; |