From c8c35f76abc9044a26c94c7d41c88f2f95d81aad Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Mon, 9 Dec 2019 08:46:20 -0600 Subject: [PATCH] scripts: dts: Remove deprecated extract_dts_includes.py script We now use EDTS and gen_defines.py to generate DTS defines. We deprecated the old script and defines several releases ago, so lets now remove them. Signed-off-by: Kumar Gala --- cmake/dts.cmake | 25 +- include/generated_dts_board.h | 2 - scripts/dts/devicetree.py | 309 --------------- scripts/dts/extract/__init__.py | 7 - scripts/dts/extract/clocks.py | 224 ----------- scripts/dts/extract/compatible.py | 73 ---- scripts/dts/extract/default.py | 107 ----- scripts/dts/extract/directive.py | 40 -- scripts/dts/extract/flash.py | 224 ----------- scripts/dts/extract/globals.py | 591 ---------------------------- scripts/dts/extract/interrupts.py | 122 ------ scripts/dts/extract/reg.py | 128 ------ scripts/dts/extract_dts_includes.py | 572 --------------------------- 13 files changed, 1 insertion(+), 2423 deletions(-) delete mode 100755 scripts/dts/devicetree.py delete mode 100644 scripts/dts/extract/__init__.py delete mode 100644 scripts/dts/extract/clocks.py delete mode 100644 scripts/dts/extract/compatible.py delete mode 100644 scripts/dts/extract/default.py delete mode 100644 scripts/dts/extract/directive.py delete mode 100644 scripts/dts/extract/flash.py delete mode 100644 scripts/dts/extract/globals.py delete mode 100644 scripts/dts/extract/interrupts.py delete mode 100644 scripts/dts/extract/reg.py delete mode 100755 scripts/dts/extract_dts_includes.py diff --git a/cmake/dts.cmake b/cmake/dts.cmake index 29487096e93..493ccb997ce 100644 --- a/cmake/dts.cmake +++ b/cmake/dts.cmake @@ -8,7 +8,7 @@ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/generated) # encoded in DTS. # # Here we call on dtc, the gcc preprocessor, and -# scripts/dts/extract_dts_includes.py to generate this header file at +# scripts/dts/gen_defines.py to generate this header file at # CMake configure-time. # # See ~/zephyr/doc/dts @@ -198,29 +198,6 @@ if(SUPPORTS_DTS) message(FATAL_ERROR "new extractor failed with return code: ${ret}") endif() - # - # Run extract_dts_includes.py (the older DT/binding parser) to generate some - # legacy identifiers (via --deprecated-only). This will go away later. - # - - set(CMD_EXTRACT_DTS_INCLUDES ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/dts/extract_dts_includes.py - --deprecated-only - --dts ${BOARD}.dts_compiled - --yaml ${DTS_ROOT_BINDINGS} - --include ${GENERATED_DTS_BOARD_UNFIXED_H}.deprecated - --old-alias-names - ) - - execute_process( - COMMAND ${CMD_EXTRACT_DTS_INCLUDES} - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - RESULT_VARIABLE ret - ) - if(NOT "${ret}" STREQUAL "0") - message(FATAL_ERROR "command failed with return code: ${ret}") - endif() - else() file(WRITE ${GENERATED_DTS_BOARD_UNFIXED_H} "/* WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY! */") - file(WRITE ${GENERATED_DTS_BOARD_UNFIXED_H}.deprecated "/* WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY! */") endif(SUPPORTS_DTS) diff --git a/include/generated_dts_board.h b/include/generated_dts_board.h index a48f3f858da..ea0615c872f 100644 --- a/include/generated_dts_board.h +++ b/include/generated_dts_board.h @@ -13,8 +13,6 @@ #include -#include - /* The following definitions fixup the generated include */ #include diff --git a/scripts/dts/devicetree.py b/scripts/dts/devicetree.py deleted file mode 100755 index 83e3e98bd93..00000000000 --- a/scripts/dts/devicetree.py +++ /dev/null @@ -1,309 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (c) 2017 Intel Corporation -# -# SPDX-License-Identifier: Apache-2.0 -# - -# NOTE: This file is part of the old device tree scripts, which will be removed -# later. They are kept to generate some legacy #defines via the -# --deprecated-only flag. -# -# The new scripts are gen_defines.py, edtlib.py, and dtlib.py. - -# vim: ai:ts=4:sw=4 - -import sys -import pprint -import re - -def read_until(line, fd, end): - out = [line] - while True: - idx = line.find(end) - if idx < 0: - line = clean_line(fd.readline(), fd) - out.append(line) - else: - out.append(line[idx + len(end):]) - return out - -def remove_comment(line, fd): - out = [] - while True: - idx = line.find('/*') - if idx < 0: - idx = line.find('//') - if idx < 0: - out.append(line) - else: - out.append(line[:idx]) - return ' '.join(out) - - out.append(line[:idx]) - line = read_until(line[idx:], fd, '*/')[-1] - -def clean_line(line, fd): - return remove_comment(line, fd).strip() - -def parse_node_name(line): - line = line[:-1] - - if '@' in line: - line, addr = line.split('@') - else: - addr = None - - if ':' in line: - if len(line.split(':')) == 3: - alt_label, label, name = line.split(':') - else: - label, name = line.split(':') - alt_label = None - else: - name = line - label = None - alt_label = None - - if addr is None: - return label, name.strip(), None, None, None - - if alt_label is None: - return label, name.strip(), addr, int(addr, 16), None - - return label, name.strip(), addr, int(addr, 16), alt_label - -def parse_values_internal(value, start, end, separator): - out = [] - - inside = False - accum = [] - for ch in value: - if not inside: - if ch == start: - inside = True - accum = [] - else: - if ch == end: - inside = False - out.append(''.join(accum)) - accum = [] - else: - accum.append(ch) - - if separator == ' ': - out = [v.split() for v in out] - - if len(out) == 1: - return parse_value(out[0]) - - return [parse_value(v) for v in out] - -def parse_values(value, start, end, separator): - out = parse_values_internal(value, start, end, separator) - if isinstance(out, list) and \ - all(isinstance(v, str) and len(v) == 1 and not v.isalpha() for v in out): - return bytearray(out) - - return out - -def parse_value(value): - if value == '': - return value - - if isinstance(value, list): - out = [parse_value(v) for v in value] - return out[0] if len(out) == 1 else out - - if value[0] == '<': - return parse_values(value, '<', '>', ' ') - if value[0] == '"': - return parse_values(value, '"', '"', ',') - if value[0] == '[': - return list(bytes.fromhex(value[1:value.find(']')])) - - if value[0] == '&': - return {'ref': value[1:]} - - if value[0].isdigit(): - if value.startswith("0x"): - return int(value, 16) - if value[0] == '0': - return int(value, 8) - # Match alpha numeric values - if re.match(r"\w", value): - return value - return int(value, 10) - - return value - -def parse_property(property, fd): - if '=' in property: - key, value = property.split('=', 1) - value = ' '.join(read_until(value, fd, ';')).strip() - if not value.endswith(';'): - raise SyntaxError("parse_property: missing semicolon: %s" % value) - return key.strip(), parse_value(value[:-1]) - - property = property.strip() - if not property.endswith(';'): - raise SyntaxError("parse_property: missing semicolon: %s" % property) - - return property[:-1].strip(), True - -def build_node_name(name, addr): - if addr is None: - return name - elif isinstance(addr, int): - return '%s@%x' % (name, addr) - - return '%s@%s' % (name, addr.strip()) - -def parse_node(line, fd): - label, name, addr, numeric_addr, alt_label = parse_node_name(line) - - node = { - 'label': label, - 'type': type, - 'addr': numeric_addr, - 'children': {}, - 'props': {}, - 'name': build_node_name(name, addr) - } - if alt_label: - node['alt_name'] = alt_label - - while True: - line = fd.readline() - if not line: - raise SyntaxError("parse_node: Missing } while parsing node") - - line = clean_line(line, fd) - if not line: - continue - - if line == "};": - break - - if line.endswith('{'): - new_node = parse_node(line, fd) - node['children'][new_node['name']] = new_node - else: - key, value = parse_property(line, fd) - node['props'][key] = value - - return node - -def parse_file(fd, ignore_dts_version=False): - nodes = {} - has_v1_tag = False - while True: - line = fd.readline() - if not line: - break - - line = clean_line(line, fd) - if not line: - continue - - if line.startswith('/include/ '): - _, filename = line.split() - with open(filename.strip()[1:-1], encoding="utf-8") as new_fd: - nodes.update(parse_file(new_fd, True)) - elif line == '/dts-v1/;': - has_v1_tag = True - elif line.startswith('/memreserve/ ') and line.endswith(';'): - _, start, end = line.split() - start = int(start, 16) - end = int(end[:-1], 16) - label = "reserved_memory_0x%x_0x%x" % (start, end) - nodes[label] = { - 'type': 'memory', - 'reg': [start, end], - 'label': label, - 'addr': start, - 'name': '' - } - elif line.endswith('{'): - if not has_v1_tag and not ignore_dts_version: - raise SyntaxError("parse_file: Missing /dts-v1/ tag") - - new_node = parse_node(line, fd) - nodes[new_node['name']] = new_node - else: - raise SyntaxError("parse_file: Couldn't understand the line: %s" % line) - return nodes - -def dump_refs(name, value, indent=0): - spaces = ' ' * indent - - out = [] - if isinstance(value, dict) and 'ref' in value: - out.append('%s\"%s\" -> \"%s\";' % (spaces, name, value['ref'])) - elif isinstance(value, list): - for elem in value: - out.extend(dump_refs(name, elem, indent)) - - return out - -def dump_all_refs(name, props, indent=0): - out = [] - for value in props.values(): - out.extend(dump_refs(name, value, indent)) - return out - -def next_subgraph(count=[0]): - count[0] += 1 - return 'subgraph cluster_%d' % count[0] - -def get_dot_node_name(node): - name = node['name'] - return name[1:] if name[0] == '&' else name - -def dump_to_dot(nodes, indent=0, start_string='digraph devicetree', name=None): - spaces = ' ' * indent - - print("%s%s {" % (spaces, start_string)) - - if name is not None: - print("%slabel = \"%s\";" % (spaces, name)) - print("%s\"%s\";" % (spaces, name)) - - ref_list = [] - for node in nodes.values(): - if node['children']: - refs = dump_to_dot(node['children'], indent + 1, next_subgraph(), - get_dot_node_name(node)) - ref_list.extend(refs) - else: - print("%s\"%s\";" % (spaces, get_dot_node_name(node))) - - for node in nodes.values(): - refs = dump_all_refs(get_dot_node_name(node), node['props'], indent) - ref_list.extend(refs) - - if start_string.startswith("digraph"): - print("%s%s" % (spaces, '\n'.join(ref_list))) - - print("%s}" % spaces) - - return ref_list - -def main(args): - if len(args) == 1: - print('Usage: %s filename.dts' % args[0]) - return 1 - - if '--dot' in args: - formatter = dump_to_dot - args.remove('--dot') - else: - formatter = lambda nodes: pprint.pprint(nodes, indent=2) - - with open(args[1], encoding="utf-8") as fd: - formatter(parse_file(fd)) - - return 0 - -if __name__ == '__main__': - sys.exit(main(sys.argv)) diff --git a/scripts/dts/extract/__init__.py b/scripts/dts/extract/__init__.py deleted file mode 100644 index 55a39fab19e..00000000000 --- a/scripts/dts/extract/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -# -# Copyright (c) 2017 Bobby Noelte -# -# SPDX-License-Identifier: Apache-2.0 -# - -# Empty to allow all modules to be imported diff --git a/scripts/dts/extract/clocks.py b/scripts/dts/extract/clocks.py deleted file mode 100644 index 85a55ed0f72..00000000000 --- a/scripts/dts/extract/clocks.py +++ /dev/null @@ -1,224 +0,0 @@ -# -# Copyright (c) 2018 Bobby Noelte -# -# SPDX-License-Identifier: Apache-2.0 -# - -# NOTE: This file is part of the old device tree scripts, which will be removed -# later. They are kept to generate some legacy #defines via the -# --deprecated-only flag. -# -# The new scripts are gen_defines.py, edtlib.py, and dtlib.py. - -from extract.globals import * -from extract.directive import DTDirective - -## -# @brief Manage clocks related directives. -# -# Handles: -# - clocks -# directives. -# -class DTClocks(DTDirective): - def _extract_consumer(self, node_path, clocks, def_label): - clock_consumer_label = 'DT_' + node_label(node_path) - - clock_index = 0 - clock_cell_index = 0 - nr_clock_cells = 0 - clock_provider_node_path = '' - clock_provider = {} - for cell in clocks: - if clock_cell_index == 0: - if cell not in phandles: - raise Exception( - ("Could not find the clock provider node {} for clocks" - " = {} in clock consumer node {}. Did you activate" - " the clock node?. Last clock provider: {}.") - .format(str(cell), str(clocks), node_path, - str(clock_provider))) - clock_provider_node_path = phandles[cell] - clock_provider = reduced[clock_provider_node_path] - clock_provider_bindings = get_binding( - clock_provider_node_path) - nr_clock_cells = int(clock_provider['props'].get( - '#clock-cells', 0)) - clock_cells_string = clock_provider_bindings.get( - 'cell_string', 'CLOCK') - - if "clock-cells" in clock_provider_bindings: - clock_cells_names = clock_provider_bindings["clock-cells"] - elif "#cells" in clock_provider_bindings: - clock_cells_names = clock_provider_bindings["#cells"] - else: - clock_cells_names = ["ID", "CELL1", "CELL2", "CELL3"] - - clock_cells = [] - else: - clock_cells.append(cell) - clock_cell_index += 1 - if clock_cell_index > nr_clock_cells or nr_clock_cells == 0: - # clock consumer device - clocks info - ##################################### - prop_def = {} - prop_alias = {} - - # Legacy clocks definitions by extract_cells - for i, cell in enumerate(clock_cells): - if i >= len(clock_cells_names): - clock_cell_name = 'CELL{}'.format(i) - else: - clock_cell_name = clock_cells_names[i] - if clock_cells_string == clock_cell_name: - clock_label = self.get_label_string([ - clock_consumer_label, clock_cells_string, - str(clock_index)]) - add_compat_alias(node_path, - self.get_label_string(["", - clock_cells_string, str(clock_index)]), - clock_label, prop_alias) - else: - clock_label = self.get_label_string([ - clock_consumer_label, clock_cells_string, - clock_cell_name, str(clock_index)]) - add_compat_alias(node_path, - self.get_label_string(["", - clock_cells_string, clock_cell_name, - str(clock_index)]), - clock_label, prop_alias) - prop_def[clock_label] = str(cell) - if clock_index == 0 and \ - len(clocks) == (len(clock_cells) + 1): - index = '' - else: - index = str(clock_index) - if node_path in aliases: - if clock_cells_string == clock_cell_name: - add_prop_aliases( - node_path, - lambda alias: - self.get_label_string([ - alias, - clock_cells_string, - index]), - clock_label, - prop_alias) - else: - add_prop_aliases( - node_path, - lambda alias: - self.get_label_string([ - alias, - clock_cells_string, - clock_cell_name, - index]), - clock_label, - prop_alias) - # alias - if i < nr_clock_cells: - # clocks info for first clock - clock_alias_label = self.get_label_string([ - clock_consumer_label, clock_cells_string, - clock_cell_name]) - prop_alias[clock_alias_label] = clock_label - add_compat_alias(node_path, - self.get_label_string(["", - clock_cells_string, clock_cell_name]), - clock_label, prop_alias) - - - # Legacy clocks definitions by extract_controller - clock_provider_label_str = clock_provider['props'].get('label', - None) - if clock_provider_label_str is not None: - clock_cell_name = 'CLOCK_CONTROLLER' - if clock_index == 0 and \ - len(clocks) == (len(clock_cells) + 1): - index = '' - else: - index = str(clock_index) - clock_label = self.get_label_string([clock_consumer_label, - clock_cell_name, - index]) - add_compat_alias(node_path, - self.get_label_string(["", clock_cell_name, index]), - clock_label, prop_alias) - prop_def[clock_label] = '"' + clock_provider_label_str + '"' - if node_path in aliases: - add_prop_aliases( - node_path, - lambda alias: - self.get_label_string([ - alias, - clock_cell_name, - index]), - clock_label, - prop_alias) - - # If the provided clock has a fixed rate, extract its frequency - # as a macro generated for the clock consumer. - if clock_provider['props']['compatible'] == 'fixed-clock': - clock_prop_name = 'clock-frequency' - clock_prop_label = 'CLOCKS_CLOCK_FREQUENCY' - if clock_index == 0 and \ - len(clocks) == (len(clock_cells) + 1): - index = '' - else: - index = str(clock_index) - clock_frequency_label = \ - self.get_label_string([clock_consumer_label, - clock_prop_label, - index]) - - prop_def[clock_frequency_label] = \ - clock_provider['props'][clock_prop_name] - add_compat_alias( - node_path, - self.get_label_string([clock_prop_label, index]), - clock_frequency_label, - prop_alias) - if node_path in aliases: - add_prop_aliases( - node_path, - lambda alias: - self.get_label_string([ - alias, - clock_prop_label, - index]), - clock_frequency_label, - prop_alias) - - insert_defs(node_path, prop_def, prop_alias) - - clock_cell_index = 0 - clock_index += 1 - - ## - # @brief Extract clocks related directives - # - # @param node_path Path to node owning the clockxxx definition. - # @param prop clockxxx property name - # @param def_label Define label string of node owning the directive. - # - def extract(self, node_path, prop, def_label): - - properties = reduced[node_path]['props'][prop] - - prop_list = [] - if not isinstance(properties, list): - prop_list.append(properties) - else: - prop_list = list(properties) - - if prop == 'clocks': - # indicator for clock consumers - self._extract_consumer(node_path, prop_list, def_label) - else: - raise Exception( - "DTClocks.extract called with unexpected directive ({})." - .format(prop)) - -## -# @brief Management information for clocks. -clocks = DTClocks() diff --git a/scripts/dts/extract/compatible.py b/scripts/dts/extract/compatible.py deleted file mode 100644 index 67a2e234d6c..00000000000 --- a/scripts/dts/extract/compatible.py +++ /dev/null @@ -1,73 +0,0 @@ -# -# Copyright (c) 2018 Bobby Noelte -# -# SPDX-License-Identifier: Apache-2.0 -# - -# NOTE: This file is part of the old device tree scripts, which will be removed -# later. They are kept to generate some legacy #defines via the -# --deprecated-only flag. -# -# The new scripts are gen_defines.py, edtlib.py, and dtlib.py. - -from extract.globals import * -from extract.directive import DTDirective - -## -# @brief Manage compatible directives. -# -# Handles: -# - compatible -# -class DTCompatible(DTDirective): - ## - # @brief Extract compatible - # - # @param node_path Path to node owning the - # compatible definition. - # @param prop compatible property name - # @param def_label Define label string of node owning the - # compatible definition. - # - def extract(self, node_path, prop, def_label): - - # compatible definition - binding = get_binding(node_path) - compatible = reduced[node_path]['props'][prop] - if not isinstance(compatible, list): - compatible = [compatible, ] - - for comp in compatible: - # Generate #define - insert_defs(node_path, - {'DT_COMPAT_' + str_to_label(comp): '1'}, - {}) - - # Generate #define for BUS a "sensor" might be on, for example - # #define DT_ST_LPS22HB_PRESS_BUS_SPI 1 - if 'parent' in binding: - compat_def = 'DT_' + str_to_label(comp) + '_BUS_' + \ - binding['parent']['bus'].upper() - insert_defs(node_path, {compat_def: '1'}, {}) - - # Generate defines of the form: - # #define DT__ 1 - for compat, instance_id in reduced[node_path]['instance_id'].items(): - compat_instance = 'DT_' + str_to_label(compat) + '_' + str(instance_id) - - insert_defs(node_path, {compat_instance: '1'}, {}) - deprecated_main.append(compat_instance) - - # Generate defines of the form: - # #define DT___BUS_ 1 - if 'parent' in binding: - bus = binding['parent']['bus'] - insert_defs(node_path, - {compat_instance + '_BUS_' + bus.upper(): '1'}, - {}) - deprecated_main.append(compat_instance + '_BUS_' + bus.upper()) - - -## -# @brief Management information for compatible. -compatible = DTCompatible() diff --git a/scripts/dts/extract/default.py b/scripts/dts/extract/default.py deleted file mode 100644 index 9975447de56..00000000000 --- a/scripts/dts/extract/default.py +++ /dev/null @@ -1,107 +0,0 @@ -# -# Copyright (c) 2018 Bobby Noelte -# -# SPDX-License-Identifier: Apache-2.0 -# - -# NOTE: This file is part of the old device tree scripts, which will be removed -# later. They are kept to generate some legacy #defines via the -# --deprecated-only flag. -# -# The new scripts are gen_defines.py, edtlib.py, and dtlib.py. - -from extract.globals import * -from extract.directive import DTDirective - -## -# @brief Manage directives in a default way. -# -class DTDefault(DTDirective): - - @staticmethod - def _extract_enum(node_path, prop, prop_values, label): - cell_yaml = get_binding(node_path)['properties'][prop] - if 'enum' in cell_yaml: - if prop_values in cell_yaml['enum']: - if isinstance(cell_yaml['enum'], list): - value = cell_yaml['enum'].index(prop_values) - if isinstance(cell_yaml['enum'], dict): - value = cell_yaml['enum'][prop_values] - label = label + "_ENUM" - return {label:value} - else: - print("ERROR") - return {} - - - ## - # @brief Extract directives in a default way - # - # @param node_path Path to node owning the clockxxx definition. - # @param prop property name - # @param prop type (string, boolean, etc) - # @param def_label Define label string of node owning the directive. - # - def extract(self, node_path, prop, prop_type, def_label): - prop_def = {} - prop_alias = {} - - if prop_type == 'boolean': - if prop in reduced[node_path]['props']: - prop_values = 1 - else: - prop_values = 0 - else: - prop_values = reduced[node_path]['props'][prop] - - if prop_type in {"string-array", "array", "uint8-array"}: - if not isinstance(prop_values, list): - prop_values = [prop_values] - - if prop_type == "uint8-array": - prop_name = str_to_label(prop) - label = def_label + '_' + prop_name - prop_value = ''.join(['{ ', - ', '.join(["0x%02x" % b for b in prop_values]), - ' }']) - prop_def[label] = prop_value - add_compat_alias(node_path, prop_name, label, prop_alias) - elif isinstance(prop_values, list): - for i, prop_value in enumerate(prop_values): - prop_name = str_to_label(prop) - label = def_label + '_' + prop_name - if isinstance(prop_value, str): - prop_value = "\"" + prop_value + "\"" - prop_def[label + '_' + str(i)] = prop_value - add_compat_alias(node_path, - prop_name + '_' + str(i), - label + '_' + str(i), - prop_alias) - else: - prop_name = str_to_label(prop) - label = def_label + '_' + prop_name - - if prop_values == 'parent-label': - prop_values = find_parent_prop(node_path, 'label') - - prop_def = self._extract_enum(node_path, prop, prop_values, label) - if prop_def: - add_compat_alias(node_path, prop_name + "_ENUM" , label + "_ENUM", prop_alias) - if isinstance(prop_values, str): - prop_values = "\"" + prop_values + "\"" - prop_def[label] = prop_values - add_compat_alias(node_path, prop_name, label, prop_alias) - - # generate defs for node aliases - if node_path in aliases: - add_prop_aliases( - node_path, - lambda alias: str_to_label(alias) + '_' + prop_name, - label, - prop_alias) - - insert_defs(node_path, prop_def, prop_alias) - -## -# @brief Management information for directives handled by default. -default = DTDefault() diff --git a/scripts/dts/extract/directive.py b/scripts/dts/extract/directive.py deleted file mode 100644 index 3b676ff83d3..00000000000 --- a/scripts/dts/extract/directive.py +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright (c) 2018 Bobby Noelte -# -# SPDX-License-Identifier: Apache-2.0 -# - -# NOTE: This file is part of the old device tree scripts, which will be removed -# later. They are kept to generate some legacy #defines via the -# --deprecated-only flag. -# -# The new scripts are gen_defines.py, edtlib.py, and dtlib.py. - -from .globals import * - -## -# @brief Base class for device tree directives -# -class DTDirective(object): - - ## - # @brief Get a label string for a list of label sub-strings. - # - # Label sub-strings are concatenated by '_'. - # - # @param label List of label sub-strings - # @return label string - # - @staticmethod - def get_label_string(label): - return str_to_label('_'.join(x.strip() for x in label if x.strip())) - - ## - # @brief Extract directive information. - # - # @param node_path Path to node issuing the directive. - # @param prop Directive property name - # @param def_label Define label string of node owning the directive. - # - def extract(self, node_path, prop, def_label): - pass diff --git a/scripts/dts/extract/flash.py b/scripts/dts/extract/flash.py deleted file mode 100644 index b69ccdcfaa0..00000000000 --- a/scripts/dts/extract/flash.py +++ /dev/null @@ -1,224 +0,0 @@ -# -# Copyright (c) 2018 Bobby Noelte -# -# SPDX-License-Identifier: Apache-2.0 -# - -# NOTE: This file is part of the old device tree scripts, which will be removed -# later. They are kept to generate some legacy #defines via the -# --deprecated-only flag. -# -# The new scripts are gen_defines.py, edtlib.py, and dtlib.py. - -from extract.globals import * -from extract.directive import DTDirective - -from extract.default import default - -## -# @brief Manage flash directives. -# -class DTFlash(DTDirective): - def __init__(self): - self._area_id = 0 - - def extract_partition(self, node_path): - self._add_partition_index_entries(node_path) - self._add_partition_label_entries(node_path) - - def _add_partition_index_entries(self, node_path): - # Adds DT_FLASH_AREA__... entries, to the '# DT_FLASH_AREA' - # section - - prop_def = {} - prop_alias = {} - node = reduced[node_path] - - # Index-based partition ID - area_id = self._area_id - self._area_id += 1 - - # Extract a per partition dev name. Something like - # - # #define DT_FLASH_AREA_1_DEV "FLASH_CTRL" - prop_def["DT_FLASH_AREA_{}_DEV".format(area_id)] = \ - '"' + reduced[controller_path(node_path)]['props']['label'] + '"' - - partition_label = str_to_label(node['props']['label']) - prop_def["DT_FLASH_AREA_{}_LABEL".format(area_id)] = partition_label - deprecated_main.append("DT_FLASH_AREA_{}_LABEL".format(area_id)) - prop_def["DT_FLASH_AREA_{}_ID".format(partition_label)] = area_id - - reg = node['props']['reg'] - for i in range(len(reg)//2): - prop_def["DT_FLASH_AREA_{}_OFFSET_{}".format(area_id, i)] = reg[2*i] - prop_def["DT_FLASH_AREA_{}_SIZE_{}".format(area_id, i)] = reg[2*i + 1] - - # Number of flash areas defined - prop_def["DT_FLASH_AREA_NUM"] = self._area_id - - # Alias sector 0 - prop_alias[ - "DT_FLASH_AREA_{}_OFFSET".format(area_id) - ] = "DT_FLASH_AREA_{}_OFFSET_0".format(area_id) - prop_alias[ - "DT_FLASH_AREA_{}_SIZE".format(area_id) - ] = "DT_FLASH_AREA_{}_SIZE_0".format(area_id) - - insert_defs("DT_FLASH_AREA", prop_def, prop_alias) - - @staticmethod - def _add_partition_label_entries(node_path): - # Adds DT_FLASH_AREA_