[1012] | 1 | #-------------------------------------------------------------------- |
---|
| 2 | # File : gen_arch_info_large.sh |
---|
| 3 | #-------------------------------------------------------------------- |
---|
| 4 | |
---|
| 5 | import getpass |
---|
| 6 | import socket |
---|
| 7 | import time |
---|
| 8 | import sys |
---|
| 9 | |
---|
| 10 | X_MAX = 0 |
---|
| 11 | Y_MAX = 0 |
---|
| 12 | CPU_PER_CLUSTER = 0 |
---|
| 13 | BSCPU = 0 |
---|
| 14 | BSTTY = 0 |
---|
| 15 | BSDMA = 0 |
---|
| 16 | MEMC_SIZE = 0 |
---|
| 17 | P_WDITH = 4 |
---|
| 18 | NB_TTY = 4 |
---|
| 19 | TTY_CHANNEL_SIZE = 0X00000010 |
---|
| 20 | TTY_SIZE = 0X00001000 |
---|
| 21 | OUTPUT_IRQ_PER_PROC = 4 |
---|
| 22 | DMA_SIZE = 0X00001000 |
---|
| 23 | XCU_SIZE = 0X00001000 |
---|
| 24 | BDV_SIZE = 0X00001000 |
---|
| 25 | FBF_SIZE = 0X00200000 |
---|
| 26 | |
---|
| 27 | MEMC_TGTID = 0 |
---|
| 28 | XICU_TGTID = 1 |
---|
| 29 | MDMA_TGTID = 2 |
---|
| 30 | MTTY_TGTID = 3 |
---|
| 31 | BDEV_TGTID = 4 |
---|
| 32 | MNIC_TGTID = 5 |
---|
| 33 | BROM_TGTID = 6 |
---|
| 34 | CDMA_TGTID = 7 |
---|
| 35 | SIMH_TGTID = 8 |
---|
| 36 | FBUF_TGTID = 9 |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | # PHYSICAL ADDRESS WIDTH |
---|
| 40 | ADDR_WIDTH = 32 |
---|
| 41 | |
---|
| 42 | # DEFAULT VALUES |
---|
| 43 | DEFAULT_X_MAX = 8 |
---|
| 44 | DEFAULT_Y_MAX = 8 |
---|
| 45 | DEFAULT_CPU_PER_CLUSTER = 4 |
---|
| 46 | CLUSTER_INC = 0 |
---|
| 47 | |
---|
| 48 | def print_comments(cmd): |
---|
| 49 | print "# TSAR hardware description in BIB (Boot Information Block) format" |
---|
| 50 | print "# This file is autogenerated by the command: " + cmd + " %d %d %d %d" % (X_MAX, Y_MAX, CPU_PER_CLUSTER, BSCPU) |
---|
| 51 | print "# It is ready to be passed to info2bib utility so the binary format can be generated" |
---|
| 52 | print " " |
---|
| 53 | print "# " + getpass.getuser() + " on " + socket.gethostname() + " " + time.strftime("%H:%M:%S") |
---|
| 54 | print " " |
---|
| 55 | print " " |
---|
| 56 | |
---|
| 57 | def print_header(): |
---|
| 58 | print "[HEADER]" |
---|
| 59 | print " REVISION=1" |
---|
| 60 | print " ARCH=SOCLIB-TSAR" |
---|
| 61 | print " XMAX=%d" % X_MAX |
---|
| 62 | print " YMAX=%d" % Y_MAX |
---|
| 63 | print " BSCPU=%d" % BSCPU |
---|
| 64 | print " BSTTY=0x%x" % BSTTY |
---|
| 65 | print " BSDMA=0x%x" % BSDMA |
---|
| 66 | print " " |
---|
| 67 | print " " |
---|
| 68 | |
---|
| 69 | def print_cluster(offset, cid): |
---|
| 70 | mem_base = offset |
---|
| 71 | mem_size = MEMC_SIZE |
---|
| 72 | xcu_base = (offset + (CLUSTER_INC / 2) + (XICU_TGTID << 19)) |
---|
| 73 | dma_base = (offset + (CLUSTER_INC / 2) + (MDMA_TGTID << 19)) |
---|
| 74 | print "[CLUSTER]" |
---|
| 75 | cpu_num=0; |
---|
| 76 | while (cpu_num != CPU_PER_CLUSTER): |
---|
| 77 | gid = (cid << CPU_PER_CLUSTER) + cpu_num |
---|
| 78 | print " [CPU] ID=%d OUTIRQ=%d" % (gid, (cpu_num * OUTPUT_IRQ_PER_PROC)) |
---|
| 79 | cpu_num = cpu_num + 1 |
---|
| 80 | |
---|
| 81 | print " [DEV] ID=RAM BASE=%#.8x SIZE=%#.8x IRQ=-1 IRQTYPE=NONE" % (mem_base, mem_size) |
---|
| 82 | print " [DEV] ID=XICU BASE=%#.8x SIZE=%#.8x IRQ=-1 IRQTYPE=NONE" % (xcu_base, DMA_SIZE) |
---|
| 83 | print " [DEV] ID=DMA BASE=%#.8x SIZE=%#.8x IRQ=8 IRQTYPE=HWI" % (dma_base, XCU_SIZE) |
---|
| 84 | print " " |
---|
| 85 | print " " |
---|
| 86 | |
---|
| 87 | def print_io_cluster(offset, cid): |
---|
| 88 | mem_base = offset |
---|
| 89 | mem_size = MEMC_SIZE |
---|
| 90 | xcu_base = (offset + (CLUSTER_INC / 2) + (XICU_TGTID << 19)) |
---|
| 91 | dma_base = (offset + (CLUSTER_INC / 2) + (MDMA_TGTID << 19)) |
---|
| 92 | bdv_base = (offset + (CLUSTER_INC / 2) + (BDEV_TGTID << 19)) |
---|
| 93 | tty_base = (offset + (CLUSTER_INC / 2) + (MTTY_TGTID << 19)) |
---|
| 94 | fbf_base = (offset + (CLUSTER_INC / 2) + (FBUF_TGTID << 19)) |
---|
| 95 | |
---|
| 96 | print "[CLUSTER]" |
---|
| 97 | cpu_num = 0 |
---|
| 98 | while (cpu_num != CPU_PER_CLUSTER): |
---|
| 99 | gid = (cid << CPU_PER_CLUSTER) + cpu_num |
---|
| 100 | print " [CPU] ID=%d OUTIRQ=%d" % (gid, (cpu_num * OUTPUT_IRQ_PER_PROC)) |
---|
| 101 | cpu_num = cpu_num + 1 |
---|
| 102 | |
---|
| 103 | print " [DEV] ID=RAM BASE=%#.8x SIZE=%#.8x IRQ=-1 IRQTYPE=NONE" % (mem_base, mem_size) |
---|
| 104 | print " [DEV] ID=XICU BASE=%#.8x SIZE=%#.8x IRQ=-1 IRQTYPE=NONE" % (xcu_base, XCU_SIZE) |
---|
| 105 | print " [DEV] ID=DMA BASE=%#.8x SIZE=%#.8x IRQ=8 IRQTYPE=HWI" % (dma_base, DMA_SIZE) |
---|
| 106 | print " [DEV] ID=BLKDEV BASE=%#.8x SIZE=%#.8x IRQ=31 IRQTYPE=HWI" % (bdv_base, BDV_SIZE) |
---|
| 107 | ntty = 0 |
---|
| 108 | irq = 16 |
---|
| 109 | while (ntty < NB_TTY): |
---|
| 110 | tty_base_i = tty_base + ntty * TTY_CHANNEL_SIZE |
---|
| 111 | print " [DEV] ID=TTY BASE=%#.8x SIZE=%#.8x IRQ=%d IRQTYPE=HWI" % (tty_base_i, TTY_CHANNEL_SIZE, irq) |
---|
| 112 | irq = irq + 1 |
---|
| 113 | ntty = ntty + 1 |
---|
| 114 | print " [DEV] ID=FB BASE=%#.8x SIZE=%#.8x IRQ=-1 IRQTYPE=NONE" % (fbf_base, FBF_SIZE) |
---|
| 115 | print " " |
---|
| 116 | print " " |
---|
| 117 | |
---|
| 118 | def gen_arch_info(x, y, x_width, y_width, bscpu, arch_info_name): |
---|
| 119 | fp = open(arch_info_name, 'w') |
---|
| 120 | stdout = sys.stdout |
---|
| 121 | sys.stdout = fp |
---|
| 122 | global X_MAX |
---|
| 123 | global Y_MAX |
---|
| 124 | global CPU_PER_CLUSTER |
---|
| 125 | global CLUSTER_INC |
---|
| 126 | global MEMC_SIZE |
---|
| 127 | global BSCPU |
---|
| 128 | global BSDMA |
---|
| 129 | global BSTTY |
---|
| 130 | |
---|
| 131 | #------------------------ |
---|
| 132 | |
---|
| 133 | X_MAX = x |
---|
| 134 | Y_MAX = y |
---|
| 135 | cpu_per_cluster = DEFAULT_CPU_PER_CLUSTER |
---|
| 136 | CPU_PER_CLUSTER = cpu_per_cluster |
---|
| 137 | |
---|
| 138 | #------------------------ |
---|
| 139 | CLUSTER_INC = (0x80000000 >> (x_width + y_width)) * 2 |
---|
| 140 | max_memc_size = 0x40000000 / (X_MAX * Y_MAX) |
---|
| 141 | size = min(max_memc_size, 0x10000000) |
---|
| 142 | MEMC_SIZE = size |
---|
| 143 | |
---|
| 144 | ########################################################################################## |
---|
| 145 | #we force io_cid to 0 because this is the only cluster we know which will be present |
---|
| 146 | #in all platform where the number of clusters is independant of x_width and y_width values |
---|
| 147 | io_cid = 0 |
---|
| 148 | ########################################################################################## |
---|
| 149 | |
---|
| 150 | BSCPU = bscpu |
---|
| 151 | |
---|
| 152 | break_loop = 0 |
---|
| 153 | xi = 0 |
---|
| 154 | yi = 0 |
---|
| 155 | while (xi < X_MAX): |
---|
| 156 | while (yi < Y_MAX): |
---|
| 157 | cid = xi * (1 << y_width) + yi |
---|
| 158 | offset = cid << (ADDR_WIDTH - x_width - y_width) |
---|
| 159 | if cid == io_cid: |
---|
| 160 | BSDMA = offset + (CLUSTER_INC / 2) + (MDMA_TGTID << 19) |
---|
| 161 | BSTTY = offset + (CLUSTER_INC / 2) + (MTTY_TGTID << 19) |
---|
| 162 | break_loop = 1 |
---|
| 163 | break |
---|
| 164 | else: |
---|
| 165 | bsdma="error" |
---|
| 166 | yi = yi + 1 |
---|
| 167 | |
---|
| 168 | if break_loop == 1: |
---|
| 169 | break |
---|
| 170 | yi = 0 |
---|
| 171 | xi = xi + 1 |
---|
| 172 | |
---|
| 173 | # Generate the description |
---|
| 174 | print_comments(sys.argv[0]) |
---|
| 175 | print_header() |
---|
| 176 | |
---|
| 177 | xi = 0 |
---|
| 178 | yi = 0 |
---|
| 179 | while (xi < X_MAX): |
---|
| 180 | while (yi < Y_MAX): |
---|
| 181 | cid = xi * (1 << y_width) + yi |
---|
| 182 | offset = cid << (ADDR_WIDTH - (x_width + y_width)) |
---|
| 183 | if cid == io_cid: |
---|
| 184 | print_io_cluster(offset, cid) |
---|
| 185 | else: |
---|
| 186 | print_cluster(offset, cid) |
---|
| 187 | yi = yi + 1 |
---|
| 188 | yi = 0 |
---|
| 189 | xi = xi + 1 |
---|
| 190 | sys.stdout = stdout |
---|
| 191 | fp.close() |
---|
| 192 | |
---|