blob: d4b6100c35a815b1bdeaecea0b30b1365e5800d0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/*
* Test RTEMS/KA9Q TFTP device driver
*
* This program may be distributed and used for any purpose.
* I ask only that you:
* 1. Leave this author information intact.
* 2. Document any changes you make.
*
* W. Eric Norum
* Saskatchewan Accelerator Laboratory
* University of Saskatchewan
* Saskatoon, Saskatchewan, CANADA
* eric@skatter.usask.ca
*/
#include <bsp.h>
#include <rtems/error.h>
#include <tftp.h>
#include <rtems_ka9q.h>
#include <stdio.h>
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_EXECUTIVE_RAM_SIZE (128*1024)
#define CONFIGURE_MAXIMUM_SEMAPHORES 10
#define CONFIGURE_MAXIMUM_TIMERS 5
#define CONFIGURE_MAXIMUM_PERIODS 1
#define CONFIGURE_MICROSECONDS_PER_TICK 10486
#define CONFIGURE_INIT
rtems_task Init (rtems_task_argument argument);
#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
rtems_driver_address_table Device_drivers[] = {
CONSOLE_DRIVER_TABLE_ENTRY,
CLOCK_DRIVER_TABLE_ENTRY,
TFTP_DRIVER_TABLE_ENTRY,
};
#include <confdefs.h>
/*
* Board ethernet address
* REPLACE THIS WITH YOUR OWN VALUE BEFORE TRYING TO USE THIS PROGRAM!
*/
#define MY_ETHERNET_ADDRESS "48:3E:3E:21:2E:D5"
#define MY_ETHERNET_ADDRESS "prom"
#include <bootp.h>
extern void testTFTP (void);
/*
* RTEMS Startup Task
*/
rtems_task
Init (rtems_task_argument ignored)
{
int i;
rtems_task_priority oldPri;
rtems_interval ticksPerSecond;
/*
* Get some timing information
*/
rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
/*
* Start KA9Q
*/
rtems_task_set_priority (RTEMS_SELF, 30, &oldPri);
rtems_ka9q_start (20);
/*
* Hook up drivers
*/
if (rtems_ka9q_execute_command ("attach rtems broadcast n ether " MY_ETHERNET_ADDRESS))
rtems_panic ("Can't attach Ethernet driver.\n");
/*
* Configure the driver
*/
if (rtems_ka9q_execute_command ("ifconfig rtems broadcast 255.255.255.255"))
rtems_panic ("Can't configure Ethernet driver.\n");
/*
* Add the ethernet broadcast address to the ARP table.
*/
if (rtems_ka9q_execute_command ("arp add 255.255.255.255 ether FF:FF:FF:FF:FF:FF"))
rtems_panic ("Can't add broadcast entry to ARP table.\n");
/*
* Get BOOTP information
*/
for (i = 0 ; ; ) {
if (rtems_ka9q_execute_command ("bootp") == 0)
break;
if (++i == 10)
rtems_panic ("Can't get information from BOOTP server.\n");
rtems_task_wake_after (i * ticksPerSecond);
}
/*
* Test TFTP driver
*/
testTFTP ();
/*
* Wind things up
*/
rtems_task_wake_after (2 * ticksPerSecond);
rtems_ka9q_execute_command ("detach rtems");
exit (0);
}
|