source: network-demos/netdemo/init.c @ 497f13d

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 497f13d was 497f13d, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 30, 1998 at 10:35:45 PM

Switched to using "../user.cfg"

  • Property mode set to 100644
File size: 4.0 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 (defined (USE_BOOTP))
89        if (rtems_ka9q_execute_command ("attach rtems broadcast y"
90                                        " ether " MY_ETHERNET_ADDRESS))
91#else
92        if (rtems_ka9q_execute_command ("attach rtems broadcast y"
93                                        " ip " MY_IP_ADDRESS
94                                        " ether " MY_ETHERNET_ADDRESS))
95#endif
96                rtems_panic ("Can't attach Ethernet driver.\n");
97
98#if (defined (TRACE_NETWORK_DRIVER))
99        /*
100         * Turn on debugging
101         */
102        puts( "Enabling debug mode of KA9Q" );
103        if (rtems_ka9q_execute_command ("trace rtems input <stdout>")
104         || rtems_ka9q_execute_command ("trace rtems output <stdout>")
105         || rtems_ka9q_execute_command ("trace rtems ascii <stdout>"))
106                rtems_panic ("Can't set tracing for Ethernet driver.\n");
107#endif
108
109        /*
110         * Configure the driver
111         */
112        if (rtems_ka9q_execute_command ("ifconfig rtems broadcast 255.255.255.255"))
113                rtems_panic ("Can't configure Ethernet driver.\n");
114
115        /*
116         * Add the ethernet broadcast address to the ARP table.
117         */
118        if (rtems_ka9q_execute_command ("arp add 255.255.255.255 ether FF:FF:FF:FF:FF:FF"))
119                rtems_panic ("Can't add broadcast entry to ARP table.\n");
120
121#if (defined (USE_BOOTP))
122        {
123        int i;
124        /*
125         * Get BOOTP information
126         */
127        for (i = 0 ; ; ) {
128                if (rtems_ka9q_execute_command ("bootp") == 0)
129                        break;
130                if (++i == 10)
131                        rtems_panic ("Can't get information from BOOTP server.\n");
132                delay_task (i);
133        }
134        if (BootpFileName)
135                printf ("BOOTP filename: `%s'\n", BootpFileName);
136        else
137                printf ("BOOTP -- No filename!\n");
138        }
139#else
140        if (rtems_ka9q_execute_command ("ifconfig rtems netmask 255.255.255.0"))
141                rtems_panic ("Can't set netmask.\n");
142        if (rtems_ka9q_execute_command ("route add default rtems"))
143                rtems_panic ("Can't add default route.\n");
144        printf ("Routing table after adding default route\n");
145        rtems_ka9q_execute_command ("route");
146#endif
147
148        /*
149         * Issue a gratuitous ARP request to update tables in
150         * other hosts on this network.
151         */
152        if (rtems_ka9q_execute_command ("arp gratuitous rtems"))
153                rtems_panic ("Can't send gratuitous ARP.\n");
154       
155        /*
156         * Everything is now running
157         */
158        printf ("NETWORK INITIALIZED!\n");
159
160        /*
161         * See if sockets work properly
162         */
163        doSocket ();
164
165        /*
166         * Wind things up
167         */
168        delay_task (2);
169        rtems_ka9q_execute_command ("detach rtems");
170        exit (0);
171}
Note: See TracBrowser for help on using the repository browser.