Ejemplo n.º 1
0
def process(yaml_all):
    # This will return all the enums when we're done
    root = {}
    # Loop for every chip
    for chip in chip_list.getChips():
        # Get the YAML corresponding to this chip
        file = chip_list.getYamlFile(chip)
        # Loop through all blocks
        yaml_root = yaml_all[file]
        for block in yaml_root:
            # Trickbox doesn't exist in the chip as in only useful to Asim
            if block == "TRICKBOX":
                continue
            yaml_block = yaml_root[block]
            # Skip proprietary_for blocks
            attributes = getChild(yaml_block, "attributes", True)
            if attributes:
                p = getChild(attributes, "proprietary_for", True)
                if p and (not p in chip_list.ALLOWED_PROPRIETARY):
                    continue
            # Find the yaml enums section
            yaml_enums = getChild(yaml_block, "enums", True)
            if not yaml_enums:
                continue
            # Process each enum for this chip
            for enum in yaml_enums:
                _parseEnum(root, enum, chip, block)
    for e in root:
        _validateEnum(root, e)
    return root
Ejemplo n.º 2
0
def process(yaml_all, enums):
    # This will return all the registers when we're done
    root = {}
    # Loop through all chips
    for chip in chip_list.getChips():
        # Get the YAML corresponding to this chip
        file = chip_list.getYamlFile(chip)
        yaml_root = yaml_all[file]
        # Loop through all blocks
        for block in yaml_root:
            # Trickbox doesn't exist in the chip as in only useful to Asim
            if block == "TRICKBOX":
                continue
            yaml_block = yaml_root[block]
            # Skip proprietary_for blocks
            attributes = getChild(yaml_block, "attributes", True)
            if attributes:
                p = getChild(attributes, "proprietary_for", True)
                if p and (not p in chip_list.ALLOWED_PROPRIETARY):
                    continue
            # Find the yaml registers section
            yaml_regs = getChild(yaml_block, "registers", True)
            if not yaml_regs:
                continue
            # Process each register for this chip
            for reg in yaml_regs:
                _parseReg(root, reg, chip, yaml_root, block)
    for r in root.keys():
        _validateReg(root, r)
        _fixAddressRVU(root, r, enums)
    for r in root.keys():
        _buildBarOffsets(root, r, enums)
    return root
Ejemplo n.º 3
0
def writeMainIndex(enums, structs, regs):
    diff_list = []
    out = open("html/index.html", "w")
    writePageHeader(out, "Cavium Chip Information")
    out.write("<table class=\"layout_table\">\n")
    out.write("<tr><td>\n")
    out.write("<font size=-1>Updated: %s</font><br><br>\n" % time.asctime())
    out.write("<font size=+2>Chips</font><br>\n")
    out.write("<table class=\"chips_table\">\n")
    out.write("<tr>")
    out.write(TH("Chip"))
    out.write(TH("Pass", colspan=4))
    out.write("</tr>")
    by_model = {}
    for chip in chip_list.getChips():
        family, model, pass_num = chip_list.getChipNameParts(chip)
        if not model in by_model:
            by_model[model] = []
        by_model[model].append((chip, pass_num))
    models = by_model.keys()
    models.sort()
    for model in models:
        out.write("<tr>")
        out.write(TD(model))
        last_chip = None
        for chip, p in by_model[model]:
            link = "<a href=%s.html target=\"frame\">%.1f</a>" % (chip.lower(),
                                                                  p)
            out.write(TD(link))
            if last_chip:
                diff_list.append(
                    diffChip(last_chip, chip, enums, structs, regs))
            last_chip = chip
        out.write("</tr>\n")
    out.write("</table>\n")
    out.write("<font size=+2>Differences</font><br>\n")
    for diff in chip_list.DIFFS:
        diff_list.append(diffChip(diff[0], diff[1], enums, structs, regs))
    out.write("<table class=\"chips_table\">\n")
    out.write("<tr>")
    out.write(TH("Chip1"))
    out.write(TH("Chip2"))
    out.write(TH("Diff"))
    out.write("</tr>\n")
    for diff in diff_list:
        out.write("<tr>")
        out.write(TD(diff[0].replace("P", "&nbsp;").replace("_", ".")))
        out.write(TD(diff[1].replace("P", "&nbsp;").replace("_", ".")))
        link = "<a href=%s target=\"frame\">diff</a>" % diff[2]
        out.write(TD(link))
        out.write("</tr>\n")
    out.write("</table>\n")
    out.write("</td>\n")
    out.write("<td width=100%>")
    out.write("<iframe name=\"frame\" width=100%></iframe>\n")
    out.write("</td></tr>\n")
    out.write("</table>\n")
    writePageFooter(out)
    out.close()
Ejemplo n.º 4
0
 def __setitem__(self, name, value):
     if not name in ["s", "CN7", "CN8", "CN9"]:
         assert name in chip_list.getChips()
     if not isinstance(value, self.allowedType):
         if not self.allowedType2 or not isinstance(value,
                                                    self.allowedType2):
             assert False, "%s: %s not %s or %s" % (
                 name, value, self.allowedType, self.allowedType2)
     types.DictType.__setitem__(self, name, value)
Ejemplo n.º 5
0
def consolidateChips(by_chip, useArch=None):
    # Worker function to check that all "keys" are in "dict" and the same. If
    # they are, remove the keys and replace them with a single item "new_key".
    def check_all_same(keys, dict, new_key):
        ref = None
        ref_str = None
        for key in keys:
            if not key in by_chip:
                return False
            s = str(dict[key])
            if ref_str == None:
                ref = dict[key]
                ref_str = s
            elif s != ref_str:
                return False
        for key in keys:
            del dict[key]
        dict[new_key] = ref
        return True

    # If an architecture was supplied, all chips for said architecture must be
    # present for consolidation. Otherwise we just require the ones passed.
    if useArch:
        chips = []
        for chip in chip_list.getChips():
            if csr_utils.isChipArch(useArch, chip):
                chips.append(chip)
    else:
        chips = by_chip.keys()
    # Create a multi-level dictionary describing all the families, models,
    # major passes, and minor passes in use
    used_chips = {}
    for chip in chips:
        family, model, chip_pass = chip_list.getChipNameParts(chip)
        major = "%s_P%d" % (model, int(chip_pass))
        if not family in used_chips:
            used_chips[family] = {}
        if not model in used_chips[family]:
            used_chips[family][model] = {}
        if not major in used_chips[family][model]:
            used_chips[family][model][major] = []
        used_chips[family][model][major].append(chip)
    # Search for and consolidate duplicates
    family_all_same = True
    for family in used_chips:
        model_all_same = True
        for model in used_chips[family]:
            major_all_same = True
            for major in used_chips[family][model]:
                minor_all_same = check_all_same(
                    used_chips[family][model][major], by_chip, major)
                major_all_same &= minor_all_same
            if major_all_same:
                major_all_same = check_all_same(
                    used_chips[family][model].keys(), by_chip, model)
                model_all_same &= major_all_same
        if model_all_same:
            model_all_same = check_all_same(used_chips[family].keys(), by_chip,
                                            family)
            family_all_same &= model_all_same
    if family_all_same:
        check_all_same(used_chips.keys(), by_chip, "CN")
Ejemplo n.º 6
0
import output_c_header_uboot
import output_c_database

#
# Misc constants
#
PICKLE_FILE = "yaml.pickle"
pp = pprint.PrettyPrinter(indent=4, width=132)

#
# Main code start
#

# Create a list of all possible chips
print "Processing Chips:"
all_chips = chip_list.getChips()
for chip in all_chips:
    print "\t%s" % chip

# Load all the yaml
try:
    inf = open(PICKLE_FILE, "r")
    print "Loading %s" % PICKLE_FILE
    yaml_all = cPickle.load(inf)
    inf.close()
except:
    print "Reading YAML files"
    # Read YAML for all chips
    yaml_all = yaml_loader.read_files(chip_list.getYamlFiles())
    # Pickle it to disk for faster repeats
    print "Saving %s" % PICKLE_FILE
Ejemplo n.º 7
0
def process(enums, structs, regs):
    for chip in chip_list.getChips():
        writeChip(chip, enums, structs, regs)
    writeMainIndex(enums, structs, regs)
Ejemplo n.º 8
0
def writeDB(arch, regs):
    global globalStringTable
    global globalStringTableLookup
    global globalStringTableLen
    global globalNumberTable
    global globalNumberTableLen
    global globalFieldTable
    global globalFieldTableLen
    global globalFieldListTable
    global globalFieldListTableLen
    global globalRangeTable
    global globalRangeTableLen
    global globalParamIndexTable
    global globalParamIndexTableLen
    global globalCsrTable
    global globalCsrTableLen
    globalStringTable = {}
    globalStringTableLookup = {}
    globalStringTableLen = 0
    globalNumberTable = {}
    globalNumberTableLen = 0
    globalFieldTable = {}
    globalFieldTableLen = 0
    globalFieldListTable = {}
    globalFieldListTableLen = 0
    globalRangeTable = {}
    globalRangeTableLen = 0
    globalParamIndexTable = {}
    globalParamIndexTableLen = 0
    globalCsrTable = {}
    globalCsrTableLen = 0

    filename = "output/%s/%s.c" % (arch, FILE_PREFIX)
    out = open(filename, "w")
    writeCopyrightBanner(out)
    out.write('#include <bdk.h>\n')
    out.write("\n")
    empty_range = getRangeTable([(-1,-1)])

    #
    # Write the per chip CSR tables
    #

    null_csr_ranges = getParamIndexTable([0 for x in range(chip_list.MAX_CSR_PARAMS)])
    null_csr = getCsrTable("{0, 0, 0, BDK_CSR_TYPE_NCB, 0, 0, %d, %d}" % (null_csr_ranges, null_csr_ranges))
    for chip in chip_list.getChips():
        if not csr_utils.isChipArch(arch, chip):
            continue
        # Skip minor passes as they are basically the same as the major pass
        if not chip.endswith("_0"):
            continue
        out.write("static const int16_t __bdk_csr_db_%s[] = {\n" % chip)
        names = regs.keys()
        names.sort()
        for name in names:
            reg = regs[name]
            if not chip in reg["description"]:
                continue
            # Don't insert CSRs that we couldn't simplify the equation
            if isinstance(reg["address"][chip], StringType):
                continue
            # Skip dv_uvm_no_create registers
            if (("attributes" in reg) and (chip in reg["attributes"]) and
                ("dv_uvm_no_create" in reg["attributes"][chip])):
                    if reg["attributes"][chip]["dv_uvm_no_create"]:
                        assert reg["attributes"][chip]["dv_uvm_no_create"] == "True", "dv_uvm_no_create is expected to be True"
                        continue
            range_len = len(reg["ranges"][chip])
            assert range_len <= chip_list.MAX_CSR_PARAMS, "Only support %d params for now" % chip_list.MAX_CSR_PARAMS
            range_list = [empty_range for x in range(chip_list.MAX_CSR_PARAMS)]
            param_inc = [0 for x in range(chip_list.MAX_CSR_PARAMS)]
            for i in range(range_len):
                range_list[i] = getRangeTable(reg["ranges"][chip][i])
                param_inc[i] = getNumberTable(reg["address"][chip][i+1])
            range_index = getParamIndexTable(range_list)
            param_index = getParamIndexTable(param_inc)
            csr_str = "{%5d, %4d, %d, BDK_CSR_TYPE_%s, %d, %d, %d, %d}" % (
                        getStringTable(name.replace("#", "X")), # Name index
                        getNumberTable(reg["address"][chip][0]), # Base index
                        0, # Unused
                        reg["bus"][chip], # Bus Type
                        csr_utils.getSizeBits(reg, 32) / 8, # Width in bytes
                        getFieldListTable(reg, chip), # Field index
                        range_index,
                        param_index)
            csr_index = getCsrTable(csr_str)
            out.write("    %d, /* %s */\n" % (csr_index, name))

        out.write("    %s\n" % null_csr)
        out.write("};\n\n")
    #
    # Write the global CSR table
    #
    out.write("const __bdk_csr_db_type_t __bdk_csr_db_csr[] = {\n")
    keys = getKeysSorted(globalCsrTable)
    for key in keys:
        out.write("    %s, /* %d */\n" % (key, globalCsrTable[key]))
    out.write("};\n\n")
    #
    # Write the CSR fieldList table
    #
    out.write("const uint16_t __bdk_csr_db_fieldList[] = {\n")
    keys = getKeysSorted(globalFieldListTable)
    for key in keys:
        out.write("    %s, /* %d */\n" % (key, globalFieldListTable[key]))
    out.write("};\n\n")
    #
    # Write the CSR field table
    #
    out.write("const __bdk_csr_db_field_t __bdk_csr_db_field[] = {\n")
    keys = getKeysSorted(globalFieldTable)
    for key in keys:
        out.write("    %s, /* %d */\n" % (key, globalFieldTable[key]))
    out.write("};\n\n")
    #
    # Write the CSR range table
    #
    out.write("const int __bdk_csr_db_range[] = {\n")
    keys = getKeysSorted(globalRangeTable)
    for key in keys:
        out.write("    %s, /* %d */\n" % (key, globalRangeTable[key]))
    out.write("};\n\n")
    #
    # Write the CSR string table
    #
    out.write("const char __bdk_csr_db_string[] = ")
    keys = getKeysSorted(globalStringTable)
    for key in keys:
        if len(key) &1 == 0:
            out.write("\n    \"%s\\0\\0\" /* %s/2 */" % (key, globalStringTable[key]))
        else:
            out.write("\n    \"%s\\0\" /* %s/2 */" % (key, globalStringTable[key]))
    out.write("\n    \"\";\n\n")
    #
    # Write the CSR number table
    #
    out.write("const uint64_t __bdk_csr_db_number[] = {\n")
    keys = getKeysSorted(globalNumberTable)
    for key in keys:
        out.write("    0x%016xull, /* %s */\n" % (key, globalNumberTable[key]))
    out.write("};\n\n")
    #
    # Write the param index table
    #
    out.write("const uint16_t __bdk_csr_db_param_index[][BDK_CSR_DB_MAX_PARAM] = {\n")
    keys = getKeysSorted(globalParamIndexTable)
    for key in keys:
        out.write("    %s, /* %d */\n" % (key, globalParamIndexTable[key]))
    out.write("};\n\n")
    #
    # Write the chip id to CSR table map
    #
    out.write("const __bdk_csr_db_map_t __bdk_csr_db[] = {\n")
    for chip in chip_list.getChips():
        if not csr_utils.isChipArch(arch, chip):
            continue
        # Skip minor passes as they are basically the same as the major pass
        if not chip.endswith("_0"):
            continue
        model_check = chip_list.chipToModelDefine(chip)
        assert model_check.endswith("_0"), model_check
        model_check = model_check[0:-2] + "_X"
        out.write("    {%s, __bdk_csr_db_%s},\n" % (model_check, chip))
    out.write("    {0, NULL}\n")
    out.write("};\n\n")
    out.close()