[1] | 1 | #! /bin/bash |
---|
| 2 | |
---|
| 3 | #-------------------------------------------------------------------- |
---|
| 4 | # File : arch_info_gen.sh |
---|
| 5 | # Author : Ghassan Almaless |
---|
| 6 | # Contact : ghassan.almaless@lip6.fr |
---|
| 7 | # Copyright : UPMC/LIP6 |
---|
| 8 | # Version : 1.2 |
---|
| 9 | # Date : 2010/11/06 (YYYY/MM/DD) |
---|
| 10 | #-------------------------------------------------------------------- |
---|
| 11 | # This script is released under the GNU public license version 2 |
---|
| 12 | #-------------------------------------------------------------------- |
---|
| 13 | # Description : |
---|
| 14 | # - This script will generate TSAR hardware description |
---|
| 15 | # in the Boot Information Block (BIB) format defined by |
---|
| 16 | # the Advanced Locality Management Operating System (ALMOS). |
---|
| 17 | # |
---|
| 18 | # - The output of this script is ready to be transformed to BIB |
---|
| 19 | # binary layout with info2bib utility. |
---|
| 20 | # |
---|
| 21 | # - 5 arguments can be passed to this script (order is relevant) |
---|
| 22 | # MEMSZ: per cluster memory size (given in decimal bytes) |
---|
| 23 | # XMAX: number of clusters in a row |
---|
| 24 | # YMAX: number of clusters in a column |
---|
| 25 | # NPROCS: number of CPUs per Cluster |
---|
| 26 | # BSCPU: bootstrap cpu id (global one) declared as operationnal |
---|
| 27 | # Default values are (in order) 0xC00000 2 2 4 (io-cid) |
---|
| 28 | #-------------------------------------------------------------------- |
---|
| 29 | |
---|
| 30 | # XICU Segment Base |
---|
| 31 | XICU_BASE=0xF00000 |
---|
| 32 | |
---|
| 33 | # MEMC Segment Base |
---|
| 34 | MEMC_BASE=0xF40000 |
---|
| 35 | |
---|
| 36 | # FrameBuffer size |
---|
| 37 | FB_SIZE=0x200000 |
---|
| 38 | |
---|
| 39 | # Physical address width |
---|
| 40 | ADDR_WIDTH=32 |
---|
| 41 | |
---|
| 42 | # Default values |
---|
| 43 | DEFAULT_X_MAX=2 |
---|
| 44 | DEFAULT_Y_MAX=2 |
---|
| 45 | DEFAULT_CPU_PER_CLUSTER=4 |
---|
| 46 | DEFAULT_MEMSZ=0xC00000 |
---|
| 47 | #------------------------ |
---|
| 48 | MEMSZ=${1-$DEFAULT_MEMSZ} |
---|
| 49 | X_MAX=${2-$DEFAULT_X_MAX} |
---|
| 50 | Y_MAX=${3-$DEFAULT_Y_MAX} |
---|
| 51 | NPROCS=${4-$DEFAULT_CPU_PER_CLUSTER} |
---|
| 52 | #------------------------ |
---|
| 53 | |
---|
| 54 | print_comments() |
---|
| 55 | { |
---|
| 56 | date=$(date "+%c") |
---|
| 57 | echo "# TSAR hardware description in BIB (Boot Information Block) format" |
---|
| 58 | echo "# This file is autogenerated by the command: $0 $X_MAX $Y_MAX $NPROCS $BSCPU" |
---|
| 59 | echo "# It is ready to be passed to info2bib utility so the binary format can be generated" |
---|
| 60 | echo " " |
---|
| 61 | echo "# $USER on $HOSTNAME $date" |
---|
| 62 | echo " " |
---|
| 63 | echo " " |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | print_header() |
---|
| 67 | { |
---|
| 68 | echo "[HEADER]" |
---|
| 69 | echo " REVISION=1" |
---|
| 70 | echo " ARCH=SOCLIB-TSAR" |
---|
| 71 | echo " XMAX="$X_MAX |
---|
| 72 | echo " YMAX="$Y_MAX |
---|
| 73 | echo " CPU_NR="$NPROCS |
---|
| 74 | echo " BSCPU="$BSCPU |
---|
| 75 | echo " BSTTY=0xBFF20000" |
---|
| 76 | echo " BSDMA=0xBFF30000" |
---|
| 77 | echo " " |
---|
| 78 | echo " " |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | print_cluster() |
---|
| 82 | { |
---|
| 83 | offset=$1 |
---|
| 84 | cid=$2 |
---|
| 85 | ram_base=$(printf "0x%x" $offset) |
---|
| 86 | ram_size=$(printf "0x%x" $MEMSZ) |
---|
| 87 | xicu_base=$(printf "0x%x" $((offset + $XICU_BASE))) |
---|
| 88 | memc_base=$(printf "0x%x" $((offset + $MEMC_BASE))) |
---|
| 89 | |
---|
| 90 | echo "[CLUSTER]" |
---|
| 91 | echo " CID="$cid |
---|
| 92 | echo " CPU_NR="$NPROCS |
---|
| 93 | echo " DEV_NR=3" |
---|
| 94 | echo " DEVID=RAM BASE=$ram_base SIZE=$ram_size IRQ=-1" |
---|
| 95 | echo " DEVID=XICU BASE=$xicu_base SIZE=0x1000 IRQ=-1" |
---|
| 96 | echo " DEVID=MEMC BASE=$memc_base SIZE=0x1000 IRQ=-1" |
---|
| 97 | echo " " |
---|
| 98 | echo " " |
---|
| 99 | |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | print_io_cluster() |
---|
| 103 | { |
---|
| 104 | offset=$1 |
---|
| 105 | cid=$2 |
---|
| 106 | ram_base=$(printf "0x%x" $offset) |
---|
| 107 | ram_size=$(printf "0x%x" $MEMSZ) |
---|
| 108 | xicu_base=$(printf "0x%x" $((offset + $XICU_BASE))) |
---|
| 109 | memc_base=$(printf "0x%x" $((offset + $MEMC_BASE))) |
---|
| 110 | |
---|
| 111 | echo "[CLUSTER]" |
---|
| 112 | echo " CID="$cid |
---|
| 113 | echo " CPU_NR="$NPROCS |
---|
| 114 | echo " DEV_NR=10" |
---|
| 115 | echo " DEVID=RAM BASE=$ram_base SIZE=$ram_size IRQ=-1" |
---|
| 116 | echo " DEVID=XICU BASE=$xicu_base SIZE=0x1000 IRQ=-1" |
---|
| 117 | echo " DEVID=FB BASE=0xBFD00000 SIZE=$FB_SIZE IRQ=-1" |
---|
| 118 | echo " DEVID=MEMC BASE=$memc_base SIZE=0x1000 IRQ=-1" |
---|
| 119 | echo " DEVID=BLKDEV BASE=0xBFF10000 SIZE=0x20 IRQ=0" |
---|
| 120 | echo " DEVID=TTY BASE=0xBFF20000 SIZE=0x10 IRQ=2" |
---|
| 121 | echo " DEVID=TTY BASE=0xBFF20010 SIZE=0x10 IRQ=3" |
---|
| 122 | echo " DEVID=TTY BASE=0xBFF20020 SIZE=0x10 IRQ=4" |
---|
| 123 | echo " DEVID=TTY BASE=0xBFF20030 SIZE=0x10 IRQ=5" |
---|
| 124 | echo " DEVID=DMA BASE=0xBFF30000 SIZE=0x14 IRQ=1" |
---|
| 125 | echo " " |
---|
| 126 | echo " " |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | # Derive X_WIDTH form X_MAX |
---|
| 130 | case $X_MAX in |
---|
| 131 | 2) X_WIDTH=1 |
---|
| 132 | ;; |
---|
| 133 | |
---|
| 134 | [3-4]) X_WIDTH=2 |
---|
| 135 | ;; |
---|
| 136 | |
---|
| 137 | [5-8]) X_WIDTH=3 |
---|
| 138 | ;; |
---|
| 139 | |
---|
| 140 | *) X_WIDTH=4 |
---|
| 141 | ;; |
---|
| 142 | esac |
---|
| 143 | |
---|
| 144 | # Derive Y_WIDTH form Y_MAX |
---|
| 145 | case $Y_MAX in |
---|
| 146 | 2) Y_WIDTH=1 |
---|
| 147 | ;; |
---|
| 148 | |
---|
| 149 | [3-4]) Y_WIDTH=2 |
---|
| 150 | ;; |
---|
| 151 | |
---|
| 152 | [5-8]) Y_WIDTH=3 |
---|
| 153 | ;; |
---|
| 154 | |
---|
| 155 | *) Y_WIDTH=4 |
---|
| 156 | ;; |
---|
| 157 | esac |
---|
| 158 | |
---|
| 159 | x=0; y=0 |
---|
| 160 | io_cid=$((0xbf >> (8 - X_WIDTH - Y_WIDTH))) |
---|
| 161 | BSCPU=${5-$(($io_cid * $NPROCS))} |
---|
| 162 | |
---|
| 163 | # Generate the description |
---|
| 164 | print_comments "$0" |
---|
| 165 | print_header |
---|
| 166 | |
---|
| 167 | while test $x -lt $X_MAX |
---|
| 168 | do |
---|
| 169 | while test $y -lt $Y_MAX |
---|
| 170 | do |
---|
| 171 | cid=$((x * Y_MAX + y)) |
---|
| 172 | offset=$(( cid << (ADDR_WIDTH - X_WIDTH - Y_WIDTH))) |
---|
| 173 | |
---|
| 174 | if [ $cid -eq $io_cid ] |
---|
| 175 | then |
---|
| 176 | print_io_cluster $offset $cid |
---|
| 177 | else |
---|
| 178 | print_cluster $offset $cid |
---|
| 179 | fi |
---|
| 180 | |
---|
| 181 | y=$((y + 1)) |
---|
| 182 | done |
---|
| 183 | |
---|
| 184 | y=0; x=$((x + 1)) |
---|
| 185 | done |
---|
| 186 | |
---|
| 187 | #-------------------------------------------------------------------------# |
---|
| 188 | # End of script # |
---|
| 189 | #-------------------------------------------------------------------------# |
---|