diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1998-08-21 13:22:35 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1998-08-21 13:22:35 +0000 |
commit | 0c9330e967a2926a2424155c941904e7d4d5815f (patch) | |
tree | f245bdd9ac409389b1054bf0862028a1ba969be2 /tftpTest | |
parent | 4cfe89f76ef8c5331ad83c32e3e8fd3aa193471a (diff) |
KA9Q -> FreeBSD changes from Eric Norum
Diffstat (limited to 'tftpTest')
-rw-r--r-- | tftpTest/Makefile | 4 | ||||
-rw-r--r-- | tftpTest/init.c | 127 | ||||
-rw-r--r-- | tftpTest/test.c | 57 |
3 files changed, 39 insertions, 149 deletions
diff --git a/tftpTest/Makefile b/tftpTest/Makefile index e9f7bdd..7750586 100644 --- a/tftpTest/Makefile +++ b/tftpTest/Makefile @@ -1,7 +1,7 @@ SAMPLE=tftp PGM=${ARCH}/$(SAMPLE).exe -MANAGERS=io event semaphore timer rate_monotonic +MANAGERS=io event semaphore # C source names, if any, go here -- minus the .c C_PIECES= init test @@ -31,7 +31,7 @@ include $(PROJECT_ROOT)/make/leaf.cfg DEFINES += CPPFLAGS += CFLAGS += -CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0x40000 # KA9Q needs more space +CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0x40000 CFLAGS_OPTIMIZE_V += CFLAGS_DEBUG_V += -qrtems_debug # -v diff --git a/tftpTest/init.c b/tftpTest/init.c index 569a03d..2ff7a67 100644 --- a/tftpTest/init.c +++ b/tftpTest/init.c @@ -1,10 +1,10 @@ /* - * Test RTEMS/KA9Q TFTP device driver - * + * RTEMS configuration/initialization + * * This program may be distributed and used for any purpose. * I ask only that you: - * 1. Leave this author information intact. - * 2. Document any changes you make. + * 1. Leave this author information intact. + * 2. Document any changes you make. * * W. Eric Norum * Saskatchewan Accelerator Laboratory @@ -13,23 +13,26 @@ * eric@skatter.usask.ca */ -#include "../usercfg.h" - #include <bsp.h> -#include <rtems/error.h> -#include <tftp.h> -#include <rtems_ka9q.h> -#include <stdio.h> +#include <rtems/tftp.h> +#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER #define CONFIGURE_RTEMS_INIT_TASKS_TABLE -#define CONFIGURE_EXECUTIVE_RAM_SIZE (128*1024) -#define CONFIGURE_MAXIMUM_SEMAPHORES 10 -#define CONFIGURE_MAXIMUM_TIMERS 5 -#define CONFIGURE_MAXIMUM_PERIODS 1 +#define CONFIGURE_EXECUTIVE_RAM_SIZE (512*1024) +#define CONFIGURE_MAXIMUM_SEMAPHORES 20 +#define CONFIGURE_MAXIMUM_TASKS 20 #define CONFIGURE_MICROSECONDS_PER_TICK 10486 +#define CONFIGURE_INIT_TASK_STACK_SIZE (10*1024) +#define CONFIGURE_INIT_TASK_PRIORITY 100 +#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \ + RTEMS_NO_TIMESLICE | \ + RTEMS_NO_ASR | \ + RTEMS_INTERRUPT_LEVEL(0)) + #define CONFIGURE_INIT rtems_task Init (rtems_task_argument argument); @@ -42,10 +45,9 @@ rtems_driver_address_table Device_drivers[] = { #include <confdefs.h> -#if (defined (USE_BOOTP)) -#include <bootp.h> -#endif -extern void testTFTP (void); +#include <stdio.h> +#include <rtems/rtems_bsdnet.h> +#include "../networkconfig.h" /* * RTEMS Startup Task @@ -53,91 +55,18 @@ extern void testTFTP (void); rtems_task Init (rtems_task_argument ignored) { - int i; - rtems_task_priority oldPri; - rtems_interval ticksPerSecond; - - /* - * Get some timing information - */ - rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond); - - /* - * Start KA9Q - */ - rtems_task_set_priority (RTEMS_SELF, 30, &oldPri); - rtems_ka9q_start (20); + const char *hostname, *filename; - /* - * Hook up drivers - */ -#if (defined (USE_BOOTP)) - if (rtems_ka9q_execute_command ("attach rtems broadcast y" - " ether " MY_ETHERNET_ADDRESS)) -#else - if (rtems_ka9q_execute_command ("attach rtems broadcast y" - " ip " MY_IP_ADDRESS - " ether " MY_ETHERNET_ADDRESS)) -#endif - rtems_panic ("Can't attach Ethernet driver.\n"); - - /* - * Configure the driver - */ - if (rtems_ka9q_execute_command ("ifconfig rtems broadcast 255.255.255.255")) - rtems_panic ("Can't configure Ethernet driver.\n"); - - /* - * Add the ethernet broadcast address to the ARP table. - */ - if (rtems_ka9q_execute_command ("arp add 255.255.255.255 ether FF:FF:FF:FF:FF:FF")) - rtems_panic ("Can't add broadcast entry to ARP table.\n"); + rtems_bsdnet_initialize_network (); -#if (defined (USE_BOOTP)) - { - int i; - /* - * Get BOOTP information - */ - for (i = 0 ; ; ) { - if (rtems_ka9q_execute_command ("bootp") == 0) - break; - if (++i == 10) - rtems_panic ("Can't get information from BOOTP server.\n"); - delay_task (i); - } - if (BootpFileName) - printf ("BOOTP filename: `%s'\n", BootpFileName); - else - printf ("BOOTP -- No filename!\n"); - } +#if (defined (RTEMS_USE_BOOTP)) + hostname = NULL; + filename = rtems_bsdnet_bootp_boot_file_name; #else - if (rtems_ka9q_execute_command ("ifconfig rtems netmask 255.255.255.0")) - rtems_panic ("Can't set netmask.\n"); - if (rtems_ka9q_execute_command ("route add default rtems")) - rtems_panic ("Can't add default route.\n"); - printf ("Routing table after adding default route\n"); - rtems_ka9q_execute_command ("route"); + hostname = RTEMS_TFTP_TEST_HOST_NAME; + filename = RTEMS_TFTP_TEST_FILE_NAME; #endif - /* - * Issue a gratuitous ARP request to update tables in - * other hosts on this network. - */ - - if (rtems_ka9q_execute_command ("arp gratuitous rtems")) - rtems_panic ("Can't send gratuitous ARP.\n"); - - - /* - * Test TFTP driver - */ - testTFTP (); - - /* - * Wind things up - */ - rtems_task_wake_after (2 * ticksPerSecond); - rtems_ka9q_execute_command ("detach rtems"); + testTFTP (hostname, filename); exit (0); } diff --git a/tftpTest/test.c b/tftpTest/test.c index 1d40af8..a17183a 100644 --- a/tftpTest/test.c +++ b/tftpTest/test.c @@ -14,14 +14,12 @@ */ #include <stdio.h> +#include <errno.h> +#include <string.h> #include <rtems.h> #include <rtems/error.h> #include <sys/fcntl.h> #include <unistd.h> -#include <bootp.h> -#include <netuser.h> - -#include "../usercfg.h" static char cbuf[1024]; static char *fullname; @@ -42,7 +40,6 @@ showRate (unsigned long totalRead) / elapsed)); } printf (".\n"); -rtems_ka9q_execute_command ("ifconfig rtems"); } static void @@ -106,37 +103,10 @@ testFread (void) } static int -makeFullname (rtems_unsigned32 host, const char *file) +makeFullname (const char *hostname, const char *file) { - const char *hostname; -#if !defined(USE_BOOTP) - static char name[16]; -#endif - -#if 0 - printf( "makeFullname(0x08%x, %s)\n", host, file); -#endif - -#if (defined (USE_BOOTP)) - if (host) { - hostname = rtems_hostname_for_address (BootpHost.s_addr, 0); - if (hostname == NULL) { - printf ("No host to read from!\n"); - return 0; - } - } else { - hostname = ""; - } -#else - if (host) { - sprintf( name, "%d.%d.%d.%d", host >> 24, (host >> 16) & 0xff, - (host >> 8) & 0xff, host & 0xff - ); - hostname = name; - } else { + if (hostname == NULL) hostname = ""; - } -#endif fullname = realloc (fullname, 8 + strlen (file) + strlen (hostname)); sprintf (fullname, "/TFTP/%s/%s", hostname, file); printf ("Read `%s'.\n", fullname); @@ -144,12 +114,12 @@ makeFullname (rtems_unsigned32 host, const char *file) } void -testTFTP (void) +testTFTP (const char *hostname, const char *filename) { /* * Check that invalid file names are reported as such */ - if (makeFullname (0, "")) { + if (makeFullname (hostname, "")) { testRawRead (); testFread (); } @@ -157,24 +127,15 @@ testTFTP (void) /* * Check that non-existent files are reported as such */ - if (makeFullname (0, "BAD-FILE-NAME")) { + if (makeFullname (hostname, "BAD-FILE-NAME")) { testRawRead (); testFread (); } /* - * Check read speed + * Check that read works */ -#if (defined (USE_BOOTP)) - if (BootpFileName == NULL) { - printf ("Nothing to read!\n"); - return; - } - if (makeFullname (BootpHost.s_addr, BootpFileName)) { -#else - if (makeFullname (aton (DATA_SOURCE_HOST), DATA_SOURCE_FILE)) { -#endif - + if (makeFullname (hostname, filename)) { testRawRead (); testFread (); } |