source: rtems/c/src/lib/libbsp/powerpc/psim/tools/psim-shared @ b094233

4.104.11
Last change on this file since b094233 was b094233, checked in by Till Straumann <strauman@…>, on Sep 11, 2009 at 5:13:42 PM

2009-09-11 Till Straumann <strauman@…>

  • Makefile.am, preinstall.am, irq/no_pic.c (REMOVED), irq/irq.h, irq/irq_init.c: use openpic from 'shared' area instead of no_pic.
  • inlude/psim.h: use openpic from 'shared' area instead of no_pic. Added 'extern' declaration for (linker-script defined) RamBase? and RamSize? symbols. Let CPP macros expand to these symbols instead of static constants. Added register definitions for OpenPIC in the register area. Added register definitions for ethernet controller in the register area.
  • startup/linkcmds: Increased RamSize? to 16M. Increased 'RAM' memory region to 32M (there is really no disadvantage in making this large). Added comment explaining the inter-relation between RamSize?, the size of the memory region, the device-tree property "oea-memory-size" and the DBAT setting.
  • tools/psim-shared: Try to determine RamSize? from executable and set 'oea-memory-size' accordingly. May be overridden if 'RAM_SIZE' envvar is set. Added openpic to device-tree. Added ethernet controller to device-tree (commented because a PSIM patch is currently required to use this device).
  • startup/bspstart: Increase DBAT0 mapping to size of 32M.
  • Property mode set to 100755
File size: 5.1 KB
Line 
1
2TREE_FILE=psim_tree.${LOGNAME}
3
4case $0 in
5  *4.8*)  rtemsTarget=powerpc-rtems4.8 ;;
6  *4.9*)  rtemsTarget=powerpc-rtems4.9 ;;
7  *4.10*) rtemsTarget=powerpc-rtems4.10 ;;
8  *) ;;
9esac
10
11### Generate the PSIM device tree based upon the type of application being run
12gen_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
47cat <<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
79##### ETHTAP @ 0x0c100020 for 0x40
80##
81## NOTE 'ethtap' currently (200902) requires psim to
82##      be patched -- also, it is only supported on
83##      a linux host.
84##      the 'ethtap' device transfers data from/to the
85##      simulated network interface to/from a 'ethertap'
86##      interface on the linux host (consult tun/tap
87##      device documentation).
88##      A very useful tool is 'tunctl' which allows for
89##      configuring user-accessible, persistent 'tap'
90##      devices so that psim may be executed w/o special
91##      (root) privileges.
92#
93#/ethtap@0x0c100020/reg           0x0c100020 0x40
94## route interrupt to open-pic
95#/ethtap@0x0c100020               > 0 irq0 /opic@0x0c130000
96## 'tun' device on host
97#/ethtap@0x0c100020/tun-device    "/dev/net/tun"
98## name of 'tap' device to use
99#/ethtap@0x0c100020/tap-ifname    "tap0"
100## ethernet address of simulated IF
101#/ethtap@0x0c100020/hw-address    "00:00:00:22:11:00"
102## generate CRC and append to received packet before
103## handing over to the simulation. This is mostly for
104## debugging the rtems device driver. If unsure, leave 'false'.
105#/ethtap@0x0c100020/enable-crc    false
106EOF
107
108  if [ ${enable_sysv_devices} = yes ] ; then
109    echo "##### System V IPC (Semaphore) 0x0c100010 for 12"
110    echo "/sem@0x0c100010/reg 0x0c100010 12"
111    echo "/sem@0x0c100010/key ${RTEMS_SHM_SEMAPHORE_KEY}"
112    echo "/sem@0x0c100010/value ${value}"
113    echo
114    echo "##### System V IPC (Shared Memory) 0x0c110000 for 128K"
115    echo "/shm@0x0c110000/reg 0x0c110000 0x20000"
116    echo "/shm@0x0c110000/key ${RTEMS_SHM_KEY}"
117  fi
118}
119
120### run the specified test with the time limit
121runone()
122{
123  testname=${1}
124  max_run_time=${2}
125  if [ $# -eq 3 ] ; then
126    treefile=${3}
127  else
128    treefile=${TREE_FILE}
129  fi
130  if [ ${max_run_time} -eq 0 ] ; then
131    #echo run ${testname} forever
132    ${RUN} -f ${treefile} ${RUN_DEBUG} ${testname}
133  else
134    log=`echo ${testname} | sed -e 's/.exe$/.log/' -e 's/.ralf$/.log/'`
135    #echo run ${testname} for maximum ${max_run_time} seconds
136    ${RUN} -f ${treefile} ${RUN_DEBUG} ${testname} >${log} 2>&1 &
137    pid=$!
138
139    # Make sure it won't run forever...
140    time_run=0
141    while [ $time_run -lt $max_run_time ]
142    do
143      # sleep 1s at a time waiting for job to finish or timer to expire
144      # if job has exited, then we exit, too.
145      sleep 1
146      kill -0 $pid 2> /dev/null
147      running=$?
148      if [ $running -eq 0 ] ; then
149        time_run=$((time_run + 5))
150        if [ $time_run -ge $max_run_time ]; then
151          kill -9 $pid 2> /dev/null
152          ran_too_long="yes"
153          echo "${testname} killed after running ${max_run_time} seconds"
154        fi
155        grep "Suspending faulting task" ${log} >/dev/null 2>&1
156        Fault=$?
157        grep "assertion failed" ${log} >/dev/null 2>&1
158        Assert=$?
159        if [ $Fault -eq 0 -o $Assert -eq 0 ] ; then
160          kill -9 $pid 2> /dev/null
161          echo "${testname} failed after ${max_run_time} seconds"
162          ran_too_long="no"
163          break
164        fi
165      else
166        ran_too_long="no"
167        break
168      fi
169    done
170    cat ${log}
171    rm -f ${log}
172  fi
173
174}
175
Note: See TracBrowser for help on using the repository browser.