1 | |
---|
2 | TREE_FILE=psim_tree.${LOGNAME} |
---|
3 | |
---|
4 | case $0 in |
---|
5 | *4.8*) rtemsTarget=powerpc-rtems4.8 ;; |
---|
6 | *4.9*) rtemsTarget=powerpc-rtems4.9 ;; |
---|
7 | *4.10*) rtemsTarget=powerpc-rtems4.10 ;; |
---|
8 | *) ;; |
---|
9 | esac |
---|
10 | |
---|
11 | ### Generate the PSIM device tree based upon the type of application being run |
---|
12 | gen_device_tree() |
---|
13 | { |
---|
14 | enable_sysv_ipc="yes" |
---|
15 | |
---|
16 | if [ ${use_sysv_ipc} = "yes" ] ; then |
---|
17 | enable_sysv_ipc="yes" |
---|
18 | value=-1 # for now assume we are slave in this mode |
---|
19 | else |
---|
20 | case ${1} in |
---|
21 | *node*) |
---|
22 | enable_sysv_devices="yes" |
---|
23 | case ${1} in |
---|
24 | *node1*) value=1 ;; |
---|
25 | *) value=-1 ;; |
---|
26 | esac |
---|
27 | ;; |
---|
28 | *) |
---|
29 | enable_sysv_devices="no" |
---|
30 | ;; |
---|
31 | esac |
---|
32 | fi |
---|
33 | |
---|
34 | if [ ${enable_sysv_devices} = "yes" ] ; then |
---|
35 | if [ X${RTEMS_SHM_SEMAPHORE_KEY} = X -o X${RTEMS_SHM_KEY} = X ] ; then |
---|
36 | fatal RTEMS_SHM_SEMAPHORE_KEY and/or RTEMS_SHM_KEY not set |
---|
37 | fi |
---|
38 | fi |
---|
39 | |
---|
40 | if [ X${RAM_SIZE} = X ] ; then |
---|
41 | if [ X${NM} = X ] ; then |
---|
42 | NM=${rtemsTarget}-nm |
---|
43 | fi |
---|
44 | RAM_SIZE=`$NM ${1} | awk '/\<RamSize\>/{print "0x"$1}'` |
---|
45 | fi |
---|
46 | |
---|
47 | cat <<EOF |
---|
48 | # |
---|
49 | # Device Tree for PSIM |
---|
50 | # |
---|
51 | # Automatically Generated -- DO NOT EDIT!! |
---|
52 | # |
---|
53 | /#address-cells 1 |
---|
54 | /openprom/init/register/pvr 0xfffe0000 |
---|
55 | # This must be >= than linkcmds defined RamSize! |
---|
56 | /openprom/options/oea-memory-size $RAM_SIZE |
---|
57 | ##### EEPROM @ 0x0c000000 for 512K |
---|
58 | /eeprom@0x0c000000/reg 0x0c000000 0x80000 |
---|
59 | /eeprom@0x0c000000/nr-sectors 8 |
---|
60 | /eeprom@0x0c000000/sector-size 0x10000 |
---|
61 | /eeprom@0x0c000000/byte-write-delay 1000 |
---|
62 | /eeprom@0x0c000000/sector-start-delay 100 |
---|
63 | /eeprom@0x0c000000/erase-delay 1000 |
---|
64 | /eeprom@0x0c000000/manufacture-code 0x01 |
---|
65 | /eeprom@0x0c000000/device-code 0xa4 |
---|
66 | |
---|
67 | ##### NVRAM/RTC NVRAM Portion is 0x0c080000 for 512K |
---|
68 | ##### NVRAM/RTC RTC Portion is 0x0c100000 for 12 |
---|
69 | /nvram@0x0c080000/reg 0x0c080000 524300 |
---|
70 | /nvram@0x0c080000/timezone -3600 |
---|
71 | |
---|
72 | ##### OPENPIC @ 0x0c130000 - 0x0c170000 (512K) |
---|
73 | /opic@0x0c130000/reg 0x0c130000 0 0x0c130000 0x40000 |
---|
74 | /opic@0x0c130000/interrupt-ranges 0 0 0 16 |
---|
75 | /opic@0x0c130000/device_type open-pic |
---|
76 | # interupt out -> CPU's interrupt pin |
---|
77 | /opic@0x0c130000 > intr0 int /cpus/cpu@0 |
---|
78 | EOF |
---|
79 | |
---|
80 | if [ X${enable_if_sim} = Xyes ] ; then |
---|
81 | cat <<EOF |
---|
82 | |
---|
83 | #### ETHTAP @ 0x0c100020 for 0x40 |
---|
84 | # |
---|
85 | # NOTE 'ethtap' currently (200902) requires psim to |
---|
86 | # be patched -- also, it is only supported on |
---|
87 | # a linux host. |
---|
88 | # the 'ethtap' device transfers data from/to the |
---|
89 | # simulated network interface to/from a 'ethertap' |
---|
90 | # interface on the linux host (consult tun/tap |
---|
91 | # device documentation). |
---|
92 | # A very useful tool is 'tunctl' which allows for |
---|
93 | # configuring user-accessible, persistent 'tap' |
---|
94 | # devices so that psim may be executed w/o special |
---|
95 | # (root) privileges. |
---|
96 | |
---|
97 | /ethtap@0x0c100020/reg 0x0c100020 0x40 |
---|
98 | # route interrupt to open-pic |
---|
99 | /ethtap@0x0c100020 > 0 irq0 /opic@0x0c130000 |
---|
100 | # 'tun' device on host |
---|
101 | /ethtap@0x0c100020/tun-device "/dev/net/tun" |
---|
102 | # name of 'tap' device to use |
---|
103 | /ethtap@0x0c100020/tap-ifname "tap0" |
---|
104 | # ethernet address of simulated IF |
---|
105 | /ethtap@0x0c100020/hw-address "00:00:00:22:11:00" |
---|
106 | # generate CRC and append to received packet before |
---|
107 | # handing over to the simulation. This is mostly for |
---|
108 | # debugging the rtems device driver. If unsure, leave 'false'. |
---|
109 | /ethtap@0x0c100020/enable-crc false |
---|
110 | EOF |
---|
111 | fi |
---|
112 | |
---|
113 | if [ ${enable_sysv_devices} = yes ] ; then |
---|
114 | echo "##### System V IPC (Semaphore) 0x0c100010 for 12" |
---|
115 | echo "/sem@0x0c100010/reg 0x0c100010 12" |
---|
116 | echo "/sem@0x0c100010/key ${RTEMS_SHM_SEMAPHORE_KEY}" |
---|
117 | echo "/sem@0x0c100010/value ${value}" |
---|
118 | echo |
---|
119 | echo "##### System V IPC (Shared Memory) 0x0c110000 for 128K" |
---|
120 | echo "/shm@0x0c110000/reg 0x0c110000 0x20000" |
---|
121 | echo "/shm@0x0c110000/key ${RTEMS_SHM_KEY}" |
---|
122 | fi |
---|
123 | } |
---|
124 | |
---|
125 | ### run the specified test with the time limit |
---|
126 | runone() |
---|
127 | { |
---|
128 | testname=${1} |
---|
129 | max_run_time=${2} |
---|
130 | if [ $# -eq 3 ] ; then |
---|
131 | treefile=${3} |
---|
132 | else |
---|
133 | treefile=${TREE_FILE} |
---|
134 | fi |
---|
135 | if [ ${max_run_time} -eq 0 ] ; then |
---|
136 | #echo run ${testname} forever |
---|
137 | ${RUN} -f ${treefile} ${RUN_DEBUG} ${testname} |
---|
138 | else |
---|
139 | log=`echo ${testname} | sed -e 's/.exe$/.log/' -e 's/.ralf$/.log/'` |
---|
140 | #echo run ${testname} for maximum ${max_run_time} seconds |
---|
141 | ${RUN} -f ${treefile} ${RUN_DEBUG} ${testname} >${log} 2>&1 & |
---|
142 | pid=$! |
---|
143 | |
---|
144 | # Make sure it won't run forever... |
---|
145 | time_run=0 |
---|
146 | while [ $time_run -lt $max_run_time ] |
---|
147 | do |
---|
148 | # sleep 1s at a time waiting for job to finish or timer to expire |
---|
149 | # if job has exited, then we exit, too. |
---|
150 | sleep 1 |
---|
151 | kill -0 $pid 2> /dev/null |
---|
152 | running=$? |
---|
153 | if [ $running -eq 0 ] ; then |
---|
154 | time_run=$((time_run + 5)) |
---|
155 | if [ $time_run -ge $max_run_time ]; then |
---|
156 | kill -9 $pid 2> /dev/null |
---|
157 | ran_too_long="yes" |
---|
158 | echo "${testname} killed after running ${max_run_time} seconds" |
---|
159 | fi |
---|
160 | grep "Suspending faulting task" ${log} >/dev/null 2>&1 |
---|
161 | Fault=$? |
---|
162 | grep "assertion failed" ${log} >/dev/null 2>&1 |
---|
163 | Assert=$? |
---|
164 | if [ $Fault -eq 0 -o $Assert -eq 0 ] ; then |
---|
165 | kill -9 $pid 2> /dev/null |
---|
166 | echo "${testname} failed after ${max_run_time} seconds" |
---|
167 | ran_too_long="no" |
---|
168 | break |
---|
169 | fi |
---|
170 | else |
---|
171 | ran_too_long="no" |
---|
172 | break |
---|
173 | fi |
---|
174 | done |
---|
175 | cat ${log} |
---|
176 | rm -f ${log} |
---|
177 | fi |
---|
178 | |
---|
179 | } |
---|
180 | |
---|