source: network-demos/tftpTest/init.c @ 4cfe89f

4.11netdemos-4-5-branchnetwork-demos-4-10-branchnetwork-demos-4-6-branchnetwork-demos-4-7-branchnetwork-demos-4-8-branchnetwork-demos-4-9-branchrtems-4-5-branch
Last change on this file since 4cfe89f was 3b67d88, checked in by Joel Sherrill <joel.sherrill@…>, on 08/12/98 at 23:15:45

Added gratuitous arp and commented out a confusing printf.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 * Test RTEMS/KA9Q TFTP device driver
3 *
4 * This program may be distributed and used for any purpose.
5 * I ask only that you:
6 *      1. Leave this author information intact.
7 *      2. Document any changes you make.
8 *
9 * W. Eric Norum
10 * Saskatchewan Accelerator Laboratory
11 * University of Saskatchewan
12 * Saskatoon, Saskatchewan, CANADA
13 * eric@skatter.usask.ca
14 */
15
16#include "../usercfg.h"
17
18#include <bsp.h>
19#include <rtems/error.h>
20#include <tftp.h>
21#include <rtems_ka9q.h>
22#include <stdio.h>
23
24#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
25
26#define CONFIGURE_EXECUTIVE_RAM_SIZE    (128*1024)
27#define CONFIGURE_MAXIMUM_SEMAPHORES    10
28#define CONFIGURE_MAXIMUM_TIMERS        5
29#define CONFIGURE_MAXIMUM_PERIODS       1
30
31#define CONFIGURE_MICROSECONDS_PER_TICK 10486
32
33#define CONFIGURE_INIT
34rtems_task Init (rtems_task_argument argument);
35
36#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
37rtems_driver_address_table Device_drivers[] = {
38  CONSOLE_DRIVER_TABLE_ENTRY,
39  CLOCK_DRIVER_TABLE_ENTRY,
40  TFTP_DRIVER_TABLE_ENTRY,
41};
42
43#include <confdefs.h>
44
45#if (defined (USE_BOOTP))
46#include <bootp.h>
47#endif
48extern void testTFTP (void);
49
50/*
51 * RTEMS Startup Task
52 */
53rtems_task
54Init (rtems_task_argument ignored)
55{
56        int i;
57        rtems_task_priority oldPri;
58        rtems_interval ticksPerSecond;
59
60        /*
61         * Get some timing information
62         */
63        rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
64
65        /*
66         * Start KA9Q
67         */
68        rtems_task_set_priority (RTEMS_SELF, 30, &oldPri);
69        rtems_ka9q_start (20);
70
71        /*
72         * Hook up drivers
73         */
74#if (defined (USE_BOOTP))
75        if (rtems_ka9q_execute_command ("attach rtems broadcast y"
76                                        " ether " MY_ETHERNET_ADDRESS))
77#else
78        if (rtems_ka9q_execute_command ("attach rtems broadcast y"
79                                        " ip " MY_IP_ADDRESS
80                                        " ether " MY_ETHERNET_ADDRESS))
81#endif
82                rtems_panic ("Can't attach Ethernet driver.\n");
83
84        /*
85         * Configure the driver
86         */
87        if (rtems_ka9q_execute_command ("ifconfig rtems broadcast 255.255.255.255"))
88                rtems_panic ("Can't configure Ethernet driver.\n");
89
90        /*
91         * Add the ethernet broadcast address to the ARP table.
92         */
93        if (rtems_ka9q_execute_command ("arp add 255.255.255.255 ether FF:FF:FF:FF:FF:FF"))
94                rtems_panic ("Can't add broadcast entry to ARP table.\n");
95
96#if (defined (USE_BOOTP))
97        {
98        int i;
99        /*
100         * Get BOOTP information
101         */
102        for (i = 0 ; ; ) {
103                if (rtems_ka9q_execute_command ("bootp") == 0)
104                        break;
105                if (++i == 10)
106                        rtems_panic ("Can't get information from BOOTP server.\n");
107                delay_task (i);
108        }
109        if (BootpFileName)
110                printf ("BOOTP filename: `%s'\n", BootpFileName);
111        else
112                printf ("BOOTP -- No filename!\n");
113        }
114#else
115        if (rtems_ka9q_execute_command ("ifconfig rtems netmask 255.255.255.0"))
116                rtems_panic ("Can't set netmask.\n");
117        if (rtems_ka9q_execute_command ("route add default rtems"))
118                rtems_panic ("Can't add default route.\n");
119        printf ("Routing table after adding default route\n");
120        rtems_ka9q_execute_command ("route");
121#endif
122
123        /*
124         * Issue a gratuitous ARP request to update tables in
125         * other hosts on this network.
126         */
127
128        if (rtems_ka9q_execute_command ("arp gratuitous rtems"))
129                rtems_panic ("Can't send gratuitous ARP.\n");
130
131
132        /*
133         * Test TFTP driver
134         */
135        testTFTP ();
136
137        /*
138         * Wind things up
139         */
140        rtems_task_wake_after (2 * ticksPerSecond);
141        rtems_ka9q_execute_command ("detach rtems");
142        exit (0);
143}
Note: See TracBrowser for help on using the repository browser.