source: network-demos/netdemo/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 7c81a8b, checked in by Joel Sherrill <joel.sherrill@…>, on 08/12/98 at 23:06:16

Cleaned up USE_BOOTP conditional for initialization.

Get info from usercfg.h now.

Added message indicating test is exitting.

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