source: network-demos/tftpTest/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 Jul 30, 1998 at 2:42:29 PM

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

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 * Test RTEMS/KA9Q TFTP device driver
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 <bsp.h>
17#include <rtems/error.h>
18#include <tftp.h>
19#include <rtems_ka9q.h>
20#include <stdio.h>
21
22#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
23
24#define CONFIGURE_EXECUTIVE_RAM_SIZE    (128*1024)
25#define CONFIGURE_MAXIMUM_SEMAPHORES    10
26#define CONFIGURE_MAXIMUM_TIMERS        5
27#define CONFIGURE_MAXIMUM_PERIODS       1
28
29#define CONFIGURE_MICROSECONDS_PER_TICK 10486
30
31#define CONFIGURE_INIT
32rtems_task Init (rtems_task_argument argument);
33
34#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
35rtems_driver_address_table Device_drivers[] = {
36  CONSOLE_DRIVER_TABLE_ENTRY,
37  CLOCK_DRIVER_TABLE_ENTRY,
38  TFTP_DRIVER_TABLE_ENTRY,
39};
40
41#include <confdefs.h>
42
43/*
44 * Board ethernet address
45 * REPLACE THIS WITH YOUR OWN VALUE BEFORE TRYING TO USE THIS PROGRAM!
46 */
47#define MY_ETHERNET_ADDRESS "48:3E:3E:21:2E:D5"
48#define MY_ETHERNET_ADDRESS "prom"
49
50#include <bootp.h>
51extern void testTFTP (void);
52
53/*
54 * RTEMS Startup Task
55 */
56rtems_task
57Init (rtems_task_argument ignored)
58{
59        int i;
60        rtems_task_priority oldPri;
61        rtems_interval ticksPerSecond;
62
63        /*
64         * Get some timing information
65         */
66        rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
67
68        /*
69         * Start KA9Q
70         */
71        rtems_task_set_priority (RTEMS_SELF, 30, &oldPri);
72        rtems_ka9q_start (20);
73
74        /*
75         * Hook up drivers
76         */
77        if (rtems_ka9q_execute_command ("attach rtems broadcast n ether " MY_ETHERNET_ADDRESS))
78                rtems_panic ("Can't attach Ethernet driver.\n");
79
80        /*
81         * Configure the driver
82         */
83        if (rtems_ka9q_execute_command ("ifconfig rtems broadcast 255.255.255.255"))
84                rtems_panic ("Can't configure Ethernet driver.\n");
85
86        /*
87         * Add the ethernet broadcast address to the ARP table.
88         */
89        if (rtems_ka9q_execute_command ("arp add 255.255.255.255 ether FF:FF:FF:FF:FF:FF"))
90                rtems_panic ("Can't add broadcast entry to ARP table.\n");
91
92        /*
93         * Get BOOTP information
94         */
95        for (i = 0 ; ; ) {
96                if (rtems_ka9q_execute_command ("bootp") == 0)
97                        break;
98                if (++i == 10)
99                        rtems_panic ("Can't get information from BOOTP server.\n");
100                rtems_task_wake_after (i * ticksPerSecond);
101        }
102
103        /*
104         * Test TFTP driver
105         */
106        testTFTP ();
107
108        /*
109         * Wind things up
110         */
111        rtems_task_wake_after (2 * ticksPerSecond);
112        rtems_ka9q_execute_command ("detach rtems");
113        exit (0);
114}
Note: See TracBrowser for help on using the repository browser.