source: network-demos/ttcp/init.c @ c87143a

4.11ERIC-NORUMnetdemos-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 Demos-30May1998
Last change on this file since c87143a was c87143a, checked in by Joel Sherrill <joel.sherrill@…>, on 07/30/98 at 14:42:29

base from Eric Norum -- Demos.30May1998.tar.gz

  • 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
16/*#define TRACE_SCC1 1 */
17#include <bsp.h>
18
19#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
20#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
21#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
22
23#define CONFIGURE_EXECUTIVE_RAM_SIZE    (512*1024)
24#define CONFIGURE_MAXIMUM_SEMAPHORES    20
25#define CONFIGURE_MAXIMUM_TASKS         20
26#define CONFIGURE_MAXIMUM_TIMERS        10
27#define CONFIGURE_MAXIMUM_PERIODS       1
28#define CONFIGURE_MICROSECONDS_PER_TICK 10486
29
30#define CONFIGURE_INIT
31rtems_task Init (rtems_task_argument argument);
32
33#include <confdefs.h>
34
35#include <stdio.h>
36#include <rtems_ka9q.h>
37
38/*
39 * Board ethernet address
40 * REPLACE THIS WITH YOUR OWN VALUE BEFORE TRYING TO USE THIS PROGRAM!
41 */
42#define MY_ETHERNET_ADDRESS "3B:1D:3E:21:E2:D5"
43#define MY_ETHERNET_ADDRESS "prom"
44
45/*
46 * Use BOOTP to get information about me?
47 */
48#define USE_BOOTP       1
49
50#if (defined (USE_BOOTP))
51#include <bootp.h>
52#else
53/*
54 * Information about me if BOOTP isn't used
55 * CHOOSE A VALUE APPROPRIATE TO YOUR NETWORK!
56 */
57#define MY_IP_ADDRESS   "128.233.14.68"
58#endif
59
60/*
61 * Suspend execution for the specified number of seconds
62 */
63static void
64delay_task (int seconds)
65{
66        rtems_task_wake_after ((seconds * 1000000) / BSP_Configuration.microseconds_per_tick);
67}
68
69/*
70 * RTEMS Startup Task
71 */
72rtems_task
73Init (rtems_task_argument ignored)
74{
75        rtems_task_priority oldPri;
76        rtems_mode old_mode;
77
78#if (defined (m68040))
79        /*
80         * Hook up FPSP
81         */
82        M68kFPSPInstallExceptionHandlers ();
83
84        /*
85         * Turn on instruction cache
86         */
87        asm volatile ("cinva bc");
88        asm volatile ("movec %0,itt0" : : "d" (0x00ffc004));
89        asm volatile ("movec %0,dtt0" : : "d" (0x00ffc040));
90        asm volatile ("cinva bc\n\t"
91                        "movec %0,cacr" : : "d" (0x80008000));
92#endif
93
94        /*
95         * Start KA9Q
96         */
97        rtems_task_set_priority (RTEMS_SELF, 30, &oldPri);
98        rtems_ka9q_start (30);
99
100        /*
101         * Hook up drivers
102         */
103#if (defined (USE_BOOTP))
104        if (rtems_ka9q_execute_command ("attach rtems"
105                                        " rbuf 24 tbuf 5"
106                                        " ether " MY_ETHERNET_ADDRESS))
107#else
108        if (rtems_ka9q_execute_command ("attach rtems"
109                                        " rbuf 24 tbuf 5"
110                                        " ip " MY_IP_ADDRESS
111                                        " ether " MY_ETHERNET_ADDRESS))
112#endif
113                rtems_panic ("Can't attach Ethernet driver.\n");
114
115        /*
116         * Configure the driver
117         */
118        if (rtems_ka9q_execute_command ("ifconfig rtems broadcast 255.255.255.255"))
119                rtems_panic ("Can't configure Ethernet driver.\n");
120
121        /*
122         * Add the ethernet broadcast address to the ARP table.
123         */
124        if (rtems_ka9q_execute_command ("arp add 255.255.255.255 ether FF:FF:FF:FF:FF:FF"))
125                rtems_panic ("Can't add broadcast entry to ARP table.\n");
126
127#if (defined (USE_BOOTP))
128        {
129        int i;
130        /*
131         * Get BOOTP information
132         */
133        for (i = 0 ; ; ) {
134                if (rtems_ka9q_execute_command ("bootp") == 0)
135                        break;
136                if (++i == 10)
137                        rtems_panic ("Can't get information from BOOTP server.\n");
138                delay_task (i);
139        }
140        if (BootpFileName)
141                printf ("BOOTP filename: `%s'\n", BootpFileName);
142        else
143                printf ("BOOTP -- No filename!\n");
144        }
145#else
146        if (rtems_ka9q_execute_command ("ifconfig rtems netmask 255.255.255.0"))
147                rtems_panic ("Can't set netmask.\n");
148        if (rtems_ka9q_execute_command ("route add default rtems"))
149                rtems_panic ("Can't add default route.\n");
150        printf ("Routing table after adding default route\n");
151        rtems_ka9q_execute_command ("route");
152#endif
153
154        rtems_ka9q_execute_command ("tcp window");
155        rtems_ka9q_execute_command ("tcp window 4096");
156        rtems_ka9q_execute_command ("tcp window");
157
158        /*
159         * Whew!
160         */
161        printf ("NETWORK INITIALIZED!\n");
162
163        /*
164         * Let other tasks preempt this one
165         */
166        rtems_task_mode (RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode);
167
168        /*
169         * See if sockets work properly
170         */
171        test_network ();
172        exit (0);
173}
Note: See TracBrowser for help on using the repository browser.