summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/psim/tools/psim-shared
blob: 0232f30f49415c46591ba6e01b993ebaea4955db (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

TREE_FILE=psim_tree.${LOGNAME}

### Generate the PSIM device tree based upon the type of application being run
gen_device_tree()
{
  case ${1} in 
    *mp*)
      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

      use_sysv_devices=yes
      case ${1} in
        *node1*) value=1 ;;
        *)       value=-1 ;;
      esac
      ;;
    *)
      use_sysv_devices=no
      ;;
  esac

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 [ ${use_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 "##### 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 [ ${max_run_time} -eq 0 ] ; then
    #echo run ${testname} forever
    ${RUN} -f ${TREE_FILE} ${RUN_DEBUG} ${testname}
  else
    #echo run ${testname} for maximum ${max_run_time} seconds
    ${RUN} -f ${TREE_FILE} ${RUN_DEBUG} ${testname} &
    pid=$!

    # Make sure it won't run forever...
    time_run=0
    while [ $time_run -lt $max_run_time ]
    do
      # sleep 5s 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
      else
        ran_too_long="no"
        break
      fi
    done
  fi
}