source: network-demos/netdemo/init.c @ 481950e

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 481950e was 481950e, checked in by Joel Sherrill <joel.sherrill@…>, on 07/30/98 at 21:46:06

Added notes from Eric to README.

Added CVS $Id$ to all files.

  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*
2 * RTEMS configuration/initialization
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 * $Id$
16 */
17
18/*#define TRACE_NETWORK_DRIVER 1 */
19#include <bsp.h>
20
21#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
22#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
23#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
24
25#define CONFIGURE_EXECUTIVE_RAM_SIZE    (512*1024)
26#define CONFIGURE_MAXIMUM_SEMAPHORES    20
27#define CONFIGURE_MAXIMUM_TASKS         20
28#define CONFIGURE_MAXIMUM_TIMERS        10
29#define CONFIGURE_MAXIMUM_PERIODS       1
30
31#define CONFIGURE_MICROSECONDS_PER_TICK 10486
32
33#define CONFIGURE_INIT_TASK_STACK_SIZE  (10*1024)
34#define CONFIGURE_INIT_TASK_PRIORITY    100
35#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
36                                           RTEMS_NO_TIMESLICE | \
37                                           RTEMS_NO_ASR | \
38                                           RTEMS_INTERRUPT_LEVEL(0))
39
40#define CONFIGURE_INIT
41rtems_task Init (rtems_task_argument argument);
42
43#include <confdefs.h>
44
45#include <stdio.h>
46#include <rtems_ka9q.h>
47
48/*
49 * Board ethernet address
50 * REPLACE THIS WITH YOUR OWN VALUE BEFORE TRYING TO USE THIS PROGRAM!
51 */
52#define MY_ETHERNET_ADDRESS "37:1D:3E:21:2B:A5"
53
54/*
55 * Some board support packages let the network driver
56 * get the Ethernet address from the bootstrap PROM.
57 */
58#define MY_ETHERNET_ADDRESS "prom"
59
60/*
61 * Use BOOTP to get information about me?
62 */
63#define USE_BOOTP       1
64
65#if (defined (USE_BOOTP))
66#include <bootp.h>
67#else
68/*
69 * Information about me if BOOTP isn't used
70 * CHOOSE A VALUE APPROPRIATE TO YOUR NETWORK!
71 */
72#define MY_IP_ADDRESS   "128.233.14.68"
73#endif
74
75/*
76 * Suspend execution for the specified number of seconds
77 */
78static void
79delay_task (int seconds)
80{
81        rtems_interval ticksPerSecond;
82
83        rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
84        rtems_task_wake_after (seconds * ticksPerSecond);
85}
86
87/*
88 * RTEMS Startup Task
89 */
90rtems_task
91Init (rtems_task_argument ignored)
92{
93        printf( "\n\n*** HELLO WORLD TEST ***\n" );
94        printf( "Hello World\n" );
95        printf( "*** END OF HELLO WORLD TEST ***\n" );
96
97        /*
98         * Start KA9Q
99         */
100        rtems_ka9q_start (50);
101
102        /*
103         * Hook up drivers
104         */
105#if (defined (USE_BOOTP))
106        if (rtems_ka9q_execute_command ("attach rtems broadcast y"
107                                        " ether " MY_ETHERNET_ADDRESS))
108#else
109        if (rtems_ka9q_execute_command ("attach rtems broadcast y"
110                                        " ip " MY_IP_ADDRESS
111                                        " ether " MY_ETHERNET_ADDRESS))
112#endif
113                rtems_panic ("Can't attach Ethernet driver.\n");
114
115#if (defined (TRACE_NETWORK_DRIVER))
116        /*
117         * Turn on debugging
118         */
119        if (rtems_ka9q_execute_command ("trace rtems input <stdout>")
120         || rtems_ka9q_execute_command ("trace rtems output <stdout>")
121         || rtems_ka9q_execute_command ("trace rtems ascii <stdout>"))
122                rtems_panic ("Can't set tracing for Ethernet driver.\n");
123#endif
124
125        /*
126         * Configure the driver
127         */
128        if (rtems_ka9q_execute_command ("ifconfig rtems broadcast 255.255.255.255"))
129                rtems_panic ("Can't configure Ethernet driver.\n");
130
131        /*
132         * Add the ethernet broadcast address to the ARP table.
133         */
134        if (rtems_ka9q_execute_command ("arp add 255.255.255.255 ether FF:FF:FF:FF:FF:FF"))
135                rtems_panic ("Can't add broadcast entry to ARP table.\n");
136
137#if (defined (USE_BOOTP))
138        {
139        int i;
140        /*
141         * Get BOOTP information
142         */
143        for (i = 0 ; ; ) {
144                if (rtems_ka9q_execute_command ("bootp") == 0)
145                        break;
146                if (++i == 10)
147                        rtems_panic ("Can't get information from BOOTP server.\n");
148                delay_task (i);
149        }
150        if (BootpFileName)
151                printf ("BOOTP filename: `%s'\n", BootpFileName);
152        else
153                printf ("BOOTP -- No filename!\n");
154        }
155#else
156        if (rtems_ka9q_execute_command ("ifconfig rtems netmask 255.255.255.0"))
157                rtems_panic ("Can't set netmask.\n");
158        if (rtems_ka9q_execute_command ("route add default rtems"))
159                rtems_panic ("Can't add default route.\n");
160        printf ("Routing table after adding default route\n");
161        rtems_ka9q_execute_command ("route");
162#endif
163
164        /*
165         * Issue a gratuitous ARP request to update tables in
166         * other hosts on this network.
167         */
168        if (rtems_ka9q_execute_command ("arp gratuitous rtems"))
169                rtems_panic ("Can't send gratuitous ARP.\n");
170       
171        /*
172         * Everything is now running
173         */
174        printf ("NETWORK INITIALIZED!\n");
175
176        /*
177         * See if sockets work properly
178         */
179        doSocket ();
180
181        /*
182         * Wind things up
183         */
184        delay_task (2);
185        rtems_ka9q_execute_command ("detach rtems");
186        exit (0);
187}
Note: See TracBrowser for help on using the repository browser.