1 | #! /bin/bash |
---|
2 | |
---|
3 | #-------------------------------------------------------------------- |
---|
4 | # File : gen_arch_info_large.sh |
---|
5 | #-------------------------------------------------------------------- |
---|
6 | |
---|
7 | NB_TTY=4 |
---|
8 | TTY_CHANNEL_SIZE=0x10 |
---|
9 | TTY_SIZE=0x1000 |
---|
10 | |
---|
11 | DMA_SIZE=0x1000 |
---|
12 | XICU_SIZE=0x1000 |
---|
13 | BDEV_SIZE=0x1000 |
---|
14 | # FrameBuffer size |
---|
15 | #FB_SIZE=0x80000 |
---|
16 | FB_SIZE=0x200000 |
---|
17 | |
---|
18 | MEMC_TGTID=0 |
---|
19 | XICU_TGTID=1 |
---|
20 | MDMA_TGTID=2 |
---|
21 | MTTY_TGTID=3 |
---|
22 | BDEV_TGTID=4 |
---|
23 | MNIC_TGTID=5 |
---|
24 | BROM_TGTID=6 |
---|
25 | CDMA_TGTID=7 |
---|
26 | SIMH_TGTID=8 |
---|
27 | FBUF_TGTID=9 |
---|
28 | |
---|
29 | |
---|
30 | # Physical address width |
---|
31 | ADDR_WIDTH=32 |
---|
32 | |
---|
33 | # Default values |
---|
34 | DEFAULT_X_MAX=8 |
---|
35 | DEFAULT_Y_MAX=8 |
---|
36 | DEFAULT_CPU_PER_CLUSTER=4 |
---|
37 | |
---|
38 | function mymin() |
---|
39 | { |
---|
40 | if test $1 -lt $2 ; then |
---|
41 | echo "$1" |
---|
42 | else |
---|
43 | echo "$2" |
---|
44 | fi |
---|
45 | } |
---|
46 | |
---|
47 | #------------------------ |
---|
48 | |
---|
49 | X_MAX=${1-$DEFAULT_X_MAX} |
---|
50 | Y_MAX=${2-$DEFAULT_Y_MAX} |
---|
51 | NPROCS=$DEFAULT_CPU_PER_CLUSTER |
---|
52 | |
---|
53 | #------------------------ |
---|
54 | CLUSTER_INC=$((0x80000000 / (X_MAX * Y_MAX) * 2)) |
---|
55 | MAX_MEMC_SIZE=$((0x40000000 / (X_MAX * Y_MAX))) |
---|
56 | size=$(mymin $MAX_MEMC_SIZE $((0x04000000))) |
---|
57 | MEMC_SIZE=$(printf "0x%X" $size) |
---|
58 | |
---|
59 | |
---|
60 | print_comments() |
---|
61 | { |
---|
62 | date=$(date "+%c") |
---|
63 | echo "# TSAR hardware description in BIB (Boot Information Block) format" |
---|
64 | echo "# This file is autogenerated by the command: $0 $X_MAX $Y_MAX $NPROCS $BSCPU" |
---|
65 | echo "# It is ready to be passed to info2bib utility so the binary format can be generated" |
---|
66 | echo " " |
---|
67 | echo "# $USER on $HOSTNAME $date" |
---|
68 | echo " " |
---|
69 | echo " " |
---|
70 | } |
---|
71 | |
---|
72 | print_header() |
---|
73 | { |
---|
74 | echo "[HEADER]" |
---|
75 | echo " REVISION=1" |
---|
76 | echo " ARCH=SOCLIB-TSAR" |
---|
77 | echo " XMAX=$X_MAX" |
---|
78 | echo " YMAX=$Y_MAX" |
---|
79 | echo " CPU_NR=$NPROCS" |
---|
80 | echo " BSCPU=$BSCPU" |
---|
81 | echo " BSTTY=$BSTTY" |
---|
82 | echo " BSDMA=$BSDMA" |
---|
83 | echo " " |
---|
84 | echo " " |
---|
85 | } |
---|
86 | |
---|
87 | print_cluster() |
---|
88 | { |
---|
89 | offset=$1 |
---|
90 | cid=$2 |
---|
91 | memc_base=$(printf "0x%X" $offset) |
---|
92 | memc_size=$(printf "0x%X" $MEMC_SIZE) |
---|
93 | xicu_base=$(printf "0x%X" $((offset + (CLUSTER_INC / 2) + (XICU_TGTID << 19)))) |
---|
94 | dma_base=$(printf "0x%X" $((offset + (CLUSTER_INC / 2) + (MDMA_TGTID << 19)))) |
---|
95 | |
---|
96 | echo "[CLUSTER]" |
---|
97 | echo " CID="$cid |
---|
98 | echo " CPU_NR="$NPROCS |
---|
99 | echo " DEV_NR=3" |
---|
100 | echo " DEVID=RAM BASE=$memc_base SIZE=$memc_size IRQ=-1" |
---|
101 | echo " DEVID=XICU BASE=$xicu_base SIZE=$DMA_SIZE IRQ=-1" |
---|
102 | echo " DEVID=DMA BASE=$dma_base SIZE=$XICU_SIZE IRQ=8" |
---|
103 | echo " " |
---|
104 | echo " " |
---|
105 | } |
---|
106 | |
---|
107 | print_io_cluster() |
---|
108 | { |
---|
109 | offset=$1 |
---|
110 | cid=$2 |
---|
111 | memc_base=$(printf "0x%X" $offset) |
---|
112 | memc_size=$(printf "0x%X" $MEMC_SIZE) |
---|
113 | xicu_base=$(printf "0x%X" $((offset + (CLUSTER_INC / 2) + (XICU_TGTID << 19)))) |
---|
114 | dma_base=$(printf "0x%X" $((offset + (CLUSTER_INC / 2) + (MDMA_TGTID << 19)))) |
---|
115 | bdev_base=$(printf "0x%X" $((offset + (CLUSTER_INC / 2) + (BDEV_TGTID << 19)))) |
---|
116 | tty_base=$(printf "0x%X" $((offset + (CLUSTER_INC / 2) + (MTTY_TGTID << 19)))) |
---|
117 | fbf_base=$(printf "0x%X" $((offset + (CLUSTER_INC / 2) + (FBUF_TGTID << 19)))) |
---|
118 | |
---|
119 | echo "[CLUSTER]" |
---|
120 | echo " CID="$cid |
---|
121 | echo " CPU_NR="$NPROCS |
---|
122 | echo " DEV_NR=9" |
---|
123 | echo " DEVID=RAM BASE=$memc_base SIZE=$memc_size IRQ=-1" |
---|
124 | echo " DEVID=XICU BASE=$xicu_base SIZE=$XICU_SIZE IRQ=-1" |
---|
125 | echo " DEVID=DMA BASE=$dma_base SIZE=$DMA_SIZE IRQ=8" |
---|
126 | echo " DEVID=BLKDEV BASE=$bdev_base SIZE=$BDEV_SIZE IRQ=31" |
---|
127 | ntty=0 |
---|
128 | irq=16 |
---|
129 | while test $ntty -lt $NB_TTY |
---|
130 | do |
---|
131 | tty_base_i=$(printf "0x%X" $((tty_base + ntty * TTY_CHANNEL_SIZE))) |
---|
132 | echo " DEVID=TTY BASE=$tty_base_i SIZE=$TTY_CHANNEL_SIZE IRQ=$irq" |
---|
133 | irq=$((irq + 1)) |
---|
134 | ntty=$((ntty + 1)) |
---|
135 | done |
---|
136 | echo " DEVID=FB BASE=$fbf_base SIZE=$FB_SIZE IRQ=-1" |
---|
137 | echo " " |
---|
138 | echo " " |
---|
139 | } |
---|
140 | |
---|
141 | # Derive X_WIDTH form X_MAX |
---|
142 | case $X_MAX in |
---|
143 | 1) X_WIDTH=0 |
---|
144 | ;; |
---|
145 | |
---|
146 | 2) X_WIDTH=1 |
---|
147 | ;; |
---|
148 | |
---|
149 | [3-4]) X_WIDTH=2 |
---|
150 | ;; |
---|
151 | |
---|
152 | [5-8]) X_WIDTH=3 |
---|
153 | ;; |
---|
154 | |
---|
155 | *) X_WIDTH=4 |
---|
156 | ;; |
---|
157 | esac |
---|
158 | |
---|
159 | # Derive Y_WIDTH form Y_MAX |
---|
160 | case $Y_MAX in |
---|
161 | 1) Y_WIDTH=0 |
---|
162 | ;; |
---|
163 | |
---|
164 | |
---|
165 | 2) Y_WIDTH=1 |
---|
166 | ;; |
---|
167 | |
---|
168 | [3-4]) Y_WIDTH=2 |
---|
169 | ;; |
---|
170 | |
---|
171 | [5-8]) Y_WIDTH=3 |
---|
172 | ;; |
---|
173 | |
---|
174 | *) Y_WIDTH=4 |
---|
175 | ;; |
---|
176 | esac |
---|
177 | |
---|
178 | x=0; y=0 |
---|
179 | io_cid=$((0xbf >> (8 - X_WIDTH - Y_WIDTH))) |
---|
180 | BSCPU=$(($io_cid * $NPROCS)) |
---|
181 | |
---|
182 | break_loop=0 |
---|
183 | while test $x -lt $X_MAX |
---|
184 | do |
---|
185 | while test $y -lt $Y_MAX |
---|
186 | do |
---|
187 | cid=$((x * Y_MAX + y)) |
---|
188 | offset=$((cid << (ADDR_WIDTH - X_WIDTH - Y_WIDTH))) |
---|
189 | |
---|
190 | if [ $cid -eq $io_cid ] |
---|
191 | then |
---|
192 | BSDMA=$(printf "0x%X" $((offset + (CLUSTER_INC / 2) + (MDMA_TGTID << 19)))) |
---|
193 | BSTTY=$(printf "0x%X" $((offset + (CLUSTER_INC / 2) + (MTTY_TGTID << 19)))) |
---|
194 | break_loop=1 |
---|
195 | break |
---|
196 | else |
---|
197 | BSDMA="error" |
---|
198 | fi |
---|
199 | |
---|
200 | y=$((y + 1)) |
---|
201 | done |
---|
202 | if test $break_loop -eq 1 ; then |
---|
203 | break |
---|
204 | fi |
---|
205 | y=0 |
---|
206 | x=$((x + 1)) |
---|
207 | done |
---|
208 | |
---|
209 | # Generate the description |
---|
210 | print_comments "$0" |
---|
211 | print_header |
---|
212 | |
---|
213 | x=0; y=0 |
---|
214 | while test $x -lt $X_MAX |
---|
215 | do |
---|
216 | while test $y -lt $Y_MAX |
---|
217 | do |
---|
218 | cid=$((x * Y_MAX + y)) |
---|
219 | offset=$((cid << (ADDR_WIDTH - X_WIDTH - Y_WIDTH))) |
---|
220 | |
---|
221 | if [ $cid -eq $io_cid ] |
---|
222 | then |
---|
223 | print_io_cluster $offset $cid |
---|
224 | else |
---|
225 | print_cluster $offset $cid |
---|
226 | fi |
---|
227 | |
---|
228 | y=$((y + 1)) |
---|
229 | done |
---|
230 | y=0 |
---|
231 | x=$((x + 1)) |
---|
232 | done |
---|
233 | |
---|
234 | #-------------------------------------------------------------------------# |
---|
235 | # End of script # |
---|
236 | #-------------------------------------------------------------------------# |
---|