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

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 f7b674f was 9399732, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 30, 1998 at 10:38:15 PM

Switched to using a single usercfg.h file.

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