summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/psim/tools/psim-shared
blob: c90fb526669e9726d917f992cbd68758a4600a82 (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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

TREE_FILE=psim_tree.${LOGNAME}

case $0 in
  *4.8*)  rtemsTarget=powerpc-rtems4.8 ;;
  *4.9*)  rtemsTarget=powerpc-rtems4.9 ;;
  *4.10*) rtemsTarget=powerpc-rtems4.10 ;;
  *) ;;
esac

### Generate the PSIM device tree based upon the type of application being run
gen_device_tree()
{
  enable_sysv_ipc="yes"

  if [ ${use_sysv_ipc} = "yes" ] ; then
    enable_sysv_ipc="yes"
    value=-1               # for now assume we are slave in this mode
  else
    case ${1} in 
      *node*)
        enable_sysv_devices="yes"
        case ${1} in
          *node1*) value=1 ;;
          *)       value=-1 ;;
        esac
        ;;
      *)
        enable_sysv_devices="no"
        ;;
    esac
  fi

  if [ ${enable_sysv_devices} = "yes" ] ; then
    if [ X${RTEMS_SHM_SEMAPHORE_KEY} = X -o X${RTEMS_SHM_KEY} = X ] ; then
      fatal  RTEMS_SHM_SEMAPHORE_KEY and/or RTEMS_SHM_KEY not set
    fi
  fi

cat <<EOF
#
#  Device Tree for PSIM
#
#  Automatically Generated -- DO NOT EDIT!!
#
/#address-cells 1
/openprom/init/register/pvr 0xfffe0000
/openprom/options/oea-memory-size 8388608
##### EEPROM @ 0x0c000000 for 512K
/eeprom@0x0c000000/reg 0x0c000000 0x80000
/eeprom@0x0c000000/nr-sectors 8
/eeprom@0x0c000000/sector-size 0x10000
/eeprom@0x0c000000/byte-write-delay 1000
/eeprom@0x0c000000/sector-start-delay 100
/eeprom@0x0c000000/erase-delay 1000
/eeprom@0x0c000000/manufacture-code 0x01
/eeprom@0x0c000000/device-code 0xa4

##### NVRAM/RTC NVRAM Portion is 0x0c080000 for 512K
##### NVRAM/RTC RTC   Portion is 0x0c100000 for 12
/nvram@0x0c080000/reg 0x0c080000 524300
/nvram@0x0c080000/timezone -3600
EOF

  if [ ${enable_sysv_devices} = yes ] ; then
    echo "##### System V IPC (Semaphore) 0x0c100010 for 12"
    echo "/sem@0x0c100010/reg 0x0c100010 12"
    echo "/sem@0x0c100010/key ${RTEMS_SHM_SEMAPHORE_KEY}"
    echo "/sem@0x0c100010/value ${value}"
    echo
    echo "##### System V IPC (Shared Memory) 0x0c110000 for 128K"
    echo "/shm@0x0c110000/reg 0x0c110000 0x20000"
    echo "/shm@0x0c110000/key ${RTEMS_SHM_KEY}"
  fi
}

### run the specified test with the time limit
runone()
{
  testname=${1}
  max_run_time=${2}
  if [ $# -eq 3 ] ; then
    treefile=${3}
  else
    treefile=${TREE_FILE}
  fi
  if [ ${max_run_time} -eq 0 ] ; then
    #echo run ${testname} forever
    ${RUN} -f ${treefile} ${RUN_DEBUG} ${testname}
  else
    log=`echo ${testname} | sed -e 's/.exe$/.log/' -e 's/.ralf$/.log/'`
    #echo run ${testname} for maximum ${max_run_time} seconds
    ${RUN} -f ${treefile} ${RUN_DEBUG} ${testname} >${log} 2>&1 &
    pid=$!

    # Make sure it won't run forever...
    time_run=0
    while [ $time_run -lt $max_run_time ]
    do
      # sleep 1s at a time waiting for job to finish or timer to expire
      # if job has exited, then we exit, too.
      sleep 1
      kill -0 $pid 2> /dev/null
      running=$?
      if [ $running -eq 0 ] ; then
        time_run=$((time_run + 5))
        if [ $time_run -ge $max_run_time ]; then
	  kill -9 $pid 2> /dev/null
	  ran_too_long="yes"
          echo "${testname} killed after running ${max_run_time} seconds"
        fi
        grep "Suspending faulting task" ${log} >/dev/null 2>&1
        Fault=$?
        grep "assertion failed" ${log} >/dev/null 2>&1
        Assert=$?
        if [ $Fault -eq 0 -o $Assert -eq 0 ] ; then
	  kill -9 $pid 2> /dev/null
          echo "${testname} failed after ${max_run_time} seconds"
          ran_too_long="no"
          break
        fi
      else
        ran_too_long="no"
        break
      fi
    done
    cat ${log}
    rm -f ${log}
  fi

}