From d4fdccadbab5043c442b00dbf54555873c6bee7b Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 23 Jan 2019 14:55:56 +0800 Subject: minikconfig: add parser skeleton This implements a scanner and recursive descent parser for Kconfig-like configuration files. The only "action" of the parser is for now to detect undefined variables and process include files. The main differences between Kconfig and this are: * only the "bool" type is supported * variables can only be defined once * choices are not supported (but they could be added as syntactic sugar for multiple Boolean values) * menus and other graphical concepts (prompts, help text) are not supported * assignments ("CONFIG_FOO=y", "CONFIG_FOO=n") are parsed as part of the Kconfig language, not as a separate file. The idea was originally by Ákos Kovács, but I could not find his implementation so I had to redo it. Signed-off-by: Paolo Bonzini Message-Id: <20190123065618.3520-23-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- scripts/minikconf.py | 441 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 441 insertions(+) create mode 100644 scripts/minikconf.py (limited to 'scripts') diff --git a/scripts/minikconf.py b/scripts/minikconf.py new file mode 100644 index 0000000000..fd75d96c6a --- /dev/null +++ b/scripts/minikconf.py @@ -0,0 +1,441 @@ +# +# Mini-Kconfig parser +# +# Copyright (c) 2015 Red Hat Inc. +# +# Authors: +# Paolo Bonzini +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or, at your option, any later version. See the COPYING file in +# the top-level directory. + +from __future__ import print_function +import os +import sys + +__all__ = [ 'KconfigParserError', 'KconfigData', 'KconfigParser' ] + +def debug_print(*args): + #print('# ' + (' '.join(str(x) for x in args))) + pass + +# ------------------------------------------- +# KconfigData implements the Kconfig semantics. For now it can only +# detect undefined symbols, i.e. symbols that were referenced in +# assignments or dependencies but were not declared with "config FOO". +# +# Semantic actions are represented by methods called do_*. The do_var +# method return the semantic value of a variable (which right now is +# just its name). +# ------------------------------------------- + +class KconfigData: + def __init__(self): + self.previously_included = [] + self.incl_info = None + self.defined_vars = set() + self.referenced_vars = set() + + # semantic analysis ------------- + + def check_undefined(self): + undef = False + for i in self.referenced_vars: + if not (i in self.defined_vars): + print("undefined symbol %s" % (i), file=sys.stderr) + undef = True + return undef + + # semantic actions ------------- + + def do_declaration(self, var): + if (var in self.defined_vars): + raise Exception('variable "' + var + '" defined twice') + + self.defined_vars.add(var) + + # var is a string with the variable's name. + # + # For now this just returns the variable's name itself. + def do_var(self, var): + self.referenced_vars.add(var) + return var + + def do_assignment(self, var, val): + pass + + def do_default(self, var, val, cond=None): + pass + + def do_depends_on(self, var, expr): + pass + + def do_select(self, var, symbol, cond=None): + pass + + def do_imply(self, var, symbol, cond=None): + pass + +# ------------------------------------------- +# KconfigParser implements a recursive descent parser for (simplified) +# Kconfig syntax. +# ------------------------------------------- + +# tokens table +TOKENS = {} +TOK_NONE = -1 +TOK_LPAREN = 0; TOKENS[TOK_LPAREN] = '"("'; +TOK_RPAREN = 1; TOKENS[TOK_RPAREN] = '")"'; +TOK_EQUAL = 2; TOKENS[TOK_EQUAL] = '"="'; +TOK_AND = 3; TOKENS[TOK_AND] = '"&&"'; +TOK_OR = 4; TOKENS[TOK_OR] = '"||"'; +TOK_NOT = 5; TOKENS[TOK_NOT] = '"!"'; +TOK_DEPENDS = 6; TOKENS[TOK_DEPENDS] = '"depends"'; +TOK_ON = 7; TOKENS[TOK_ON] = '"on"'; +TOK_SELECT = 8; TOKENS[TOK_SELECT] = '"select"'; +TOK_IMPLY = 9; TOKENS[TOK_IMPLY] = '"imply"'; +TOK_CONFIG = 10; TOKENS[TOK_CONFIG] = '"config"'; +TOK_DEFAULT = 11; TOKENS[TOK_DEFAULT] = '"default"'; +TOK_Y = 12; TOKENS[TOK_Y] = '"y"'; +TOK_N = 13; TOKENS[TOK_N] = '"n"'; +TOK_SOURCE = 14; TOKENS[TOK_SOURCE] = '"source"'; +TOK_BOOL = 15; TOKENS[TOK_BOOL] = '"bool"'; +TOK_IF = 16; TOKENS[TOK_IF] = '"if"'; +TOK_ID = 17; TOKENS[TOK_ID] = 'identifier'; +TOK_EOF = 18; TOKENS[TOK_EOF] = 'end of file'; + +class KconfigParserError(Exception): + def __init__(self, parser, msg, tok=None): + self.loc = parser.location() + tok = tok or parser.tok + if tok != TOK_NONE: + location = TOKENS.get(tok, None) or ('"%s"' % tok) + msg = '%s before %s' % (msg, location) + self.msg = msg + + def __str__(self): + return "%s: %s" % (self.loc, self.msg) + +class KconfigParser: + @classmethod + def parse(self, fp): + data = KconfigData() + parser = KconfigParser(data) + parser.parse_file(fp) + if data.check_undefined(): + raise KconfigParserError(parser, "there were undefined symbols") + + return data + + def __init__(self, data): + self.data = data + + def parse_file(self, fp): + self.abs_fname = os.path.abspath(fp.name) + self.fname = fp.name + self.data.previously_included.append(self.abs_fname) + self.src = fp.read() + if self.src == '' or self.src[-1] != '\n': + self.src += '\n' + self.cursor = 0 + self.line = 1 + self.line_pos = 0 + self.get_token() + self.parse_config() + + # file management ----- + + def error_path(self): + inf = self.data.incl_info + res = "" + while inf: + res = ("In file included from %s:%d:\n" % (inf['file'], + inf['line'])) + res + inf = inf['parent'] + return res + + def location(self): + col = 1 + for ch in self.src[self.line_pos:self.pos]: + if ch == '\t': + col += 8 - ((col - 1) % 8) + else: + col += 1 + return '%s%s:%d:%d' %(self.error_path(), self.fname, self.line, col) + + def do_include(self, include): + incl_abs_fname = os.path.join(os.path.dirname(self.abs_fname), + include) + # catch inclusion cycle + inf = self.data.incl_info + while inf: + if incl_abs_fname == os.path.abspath(inf['file']): + raise KconfigParserError(self, "Inclusion loop for %s" + % include) + inf = inf['parent'] + + # skip multiple include of the same file + if incl_abs_fname in self.data.previously_included: + return + try: + fp = open(incl_abs_fname, 'r') + except IOError as e: + raise KconfigParserError(self, + '%s: %s' % (e.strerror, include)) + + inf = self.data.incl_info + self.data.incl_info = { 'file': self.fname, 'line': self.line, + 'parent': inf } + KconfigParser(self.data).parse_file(fp) + self.data.incl_info = inf + + # recursive descent parser ----- + + # y_or_n: Y | N + def parse_y_or_n(self): + if self.tok == TOK_Y: + self.get_token() + return True + if self.tok == TOK_N: + self.get_token() + return False + raise KconfigParserError(self, 'Expected "y" or "n"') + + # var: ID + def parse_var(self): + if self.tok == TOK_ID: + val = self.val + self.get_token() + return self.data.do_var(val) + else: + raise KconfigParserError(self, 'Expected identifier') + + # assignment_var: ID (starting with "CONFIG_") + def parse_assignment_var(self): + if self.tok == TOK_ID: + val = self.val + if not val.startswith("CONFIG_"): + raise KconfigParserError(self, + 'Expected identifier starting with "CONFIG_"', TOK_NONE) + self.get_token() + return self.data.do_var(val[7:]) + else: + raise KconfigParserError(self, 'Expected identifier') + + # assignment: var EQUAL y_or_n + def parse_assignment(self): + var = self.parse_assignment_var() + if self.tok != TOK_EQUAL: + raise KconfigParserError(self, 'Expected "="') + self.get_token() + self.data.do_assignment(var, self.parse_y_or_n()) + + # primary: NOT primary + # | LPAREN expr RPAREN + # | var + def parse_primary(self): + if self.tok == TOK_NOT: + self.get_token() + self.parse_primary() + elif self.tok == TOK_LPAREN: + self.get_token() + self.parse_expr() + if self.tok != TOK_RPAREN: + raise KconfigParserError(self, 'Expected ")"') + self.get_token() + elif self.tok == TOK_ID: + self.parse_var() + else: + raise KconfigParserError(self, 'Expected "!" or "(" or identifier') + + # disj: primary (OR primary)* + def parse_disj(self): + self.parse_primary() + while self.tok == TOK_OR: + self.get_token() + self.parse_primary() + + # expr: disj (AND disj)* + def parse_expr(self): + self.parse_disj() + while self.tok == TOK_AND: + self.get_token() + self.parse_disj() + + # condition: IF expr + # | empty + def parse_condition(self): + if self.tok == TOK_IF: + self.get_token() + return self.parse_expr() + else: + return None + + # property: DEFAULT y_or_n condition + # | DEPENDS ON expr + # | SELECT var condition + # | BOOL + def parse_property(self, var): + if self.tok == TOK_DEFAULT: + self.get_token() + val = self.parse_y_or_n() + cond = self.parse_condition() + self.data.do_default(var, val, cond) + elif self.tok == TOK_DEPENDS: + self.get_token() + if self.tok != TOK_ON: + raise KconfigParserError(self, 'Expected "on"') + self.get_token() + self.data.do_depends_on(var, self.parse_expr()) + elif self.tok == TOK_SELECT: + self.get_token() + symbol = self.parse_var() + cond = self.parse_condition() + self.data.do_select(var, symbol, cond) + elif self.tok == TOK_IMPLY: + self.get_token() + symbol = self.parse_var() + cond = self.parse_condition() + self.data.do_imply(var, symbol, cond) + elif self.tok == TOK_BOOL: + self.get_token() + else: + raise KconfigParserError(self, 'Error in recursive descent?') + + # properties: properties property + # | /* empty */ + def parse_properties(self, var): + had_default = False + while self.tok == TOK_DEFAULT or self.tok == TOK_DEPENDS or \ + self.tok == TOK_SELECT or self.tok == TOK_BOOL or \ + self.tok == TOK_IMPLY: + self.parse_property(var) + self.data.do_default(var, False) + + # for nicer error message + if self.tok != TOK_SOURCE and self.tok != TOK_CONFIG and \ + self.tok != TOK_ID and self.tok != TOK_EOF: + raise KconfigParserError(self, 'expected "source", "config", identifier, ' + + '"default", "depends on", "imply" or "select"') + + # declaration: config var properties + def parse_declaration(self): + if self.tok == TOK_CONFIG: + self.get_token() + var = self.parse_var() + self.data.do_declaration(var) + self.parse_properties(var) + else: + raise KconfigParserError(self, 'Error in recursive descent?') + + # clause: SOURCE + # | declaration + # | assignment + def parse_clause(self): + if self.tok == TOK_SOURCE: + val = self.val + self.get_token() + self.do_include(val) + elif self.tok == TOK_CONFIG: + self.parse_declaration() + elif self.tok == TOK_ID: + self.parse_assignment() + else: + raise KconfigParserError(self, 'expected "source", "config" or identifier') + + # config: clause+ EOF + def parse_config(self): + while self.tok != TOK_EOF: + self.parse_clause() + return self.data + + # scanner ----- + + def get_token(self): + while True: + self.tok = self.src[self.cursor] + self.pos = self.cursor + self.cursor += 1 + + self.val = None + self.tok = self.scan_token() + if self.tok is not None: + return + + def check_keyword(self, rest): + if not self.src.startswith(rest, self.cursor): + return False + length = len(rest) + if self.src[self.cursor + length].isalnum() or self.src[self.cursor + length] == '|': + return False + self.cursor += length + return True + + def scan_token(self): + if self.tok == '#': + self.cursor = self.src.find('\n', self.cursor) + return None + elif self.tok == '=': + return TOK_EQUAL + elif self.tok == '(': + return TOK_LPAREN + elif self.tok == ')': + return TOK_RPAREN + elif self.tok == '&' and self.src[self.pos+1] == '&': + self.cursor += 1 + return TOK_AND + elif self.tok == '|' and self.src[self.pos+1] == '|': + self.cursor += 1 + return TOK_OR + elif self.tok == '!': + return TOK_NOT + elif self.tok == 'd' and self.check_keyword("epends"): + return TOK_DEPENDS + elif self.tok == 'o' and self.check_keyword("n"): + return TOK_ON + elif self.tok == 's' and self.check_keyword("elect"): + return TOK_SELECT + elif self.tok == 'i' and self.check_keyword("mply"): + return TOK_IMPLY + elif self.tok == 'c' and self.check_keyword("onfig"): + return TOK_CONFIG + elif self.tok == 'd' and self.check_keyword("efault"): + return TOK_DEFAULT + elif self.tok == 'b' and self.check_keyword("ool"): + return TOK_BOOL + elif self.tok == 'i' and self.check_keyword("f"): + return TOK_IF + elif self.tok == 'y' and self.check_keyword(""): + return TOK_Y + elif self.tok == 'n' and self.check_keyword(""): + return TOK_N + elif (self.tok == 's' and self.check_keyword("ource")) or \ + self.tok == 'i' and self.check_keyword("nclude"): + # source FILENAME + # include FILENAME + while self.src[self.cursor].isspace(): + self.cursor += 1 + start = self.cursor + self.cursor = self.src.find('\n', self.cursor) + self.val = self.src[start:self.cursor] + return TOK_SOURCE + elif self.tok.isalpha(): + # identifier + while self.src[self.cursor].isalnum() or self.src[self.cursor] == '_': + self.cursor += 1 + self.val = self.src[self.pos:self.cursor] + return TOK_ID + elif self.tok == '\n': + if self.cursor == len(self.src): + return TOK_EOF + self.line += 1 + self.line_pos = self.cursor + elif not self.tok.isspace(): + raise KconfigParserError(self, 'invalid input') + + return None + +if __name__ == '__main__': + fname = len(sys.argv) > 1 and sys.argv[1] or 'Kconfig.test' + KconfigParser.parse(open(fname, 'r')) -- cgit v1.2.3-55-g7522 From 53167f562693981dbc18fb0071df4667dabdf7b6 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 23 Jan 2019 14:55:57 +0800 Subject: minikconfig: add AST Add Python classes that represent the Kconfig abstract syntax tree. The abstract syntax tree is stored as a list of clauses. For example: config FOO depends on BAR select BAZ is represented as three clauses: FOO depends on BAR FOO default n select BAZ if FOO Signed-off-by: Paolo Bonzini Message-Id: <20190123065618.3520-24-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- scripts/minikconf.py | 121 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 19 deletions(-) (limited to 'scripts') diff --git a/scripts/minikconf.py b/scripts/minikconf.py index fd75d96c6a..f0cc3b9fb9 100644 --- a/scripts/minikconf.py +++ b/scripts/minikconf.py @@ -31,11 +31,84 @@ def debug_print(*args): # ------------------------------------------- class KconfigData: + class Expr: + def __and__(self, rhs): + return KconfigData.AND(self, rhs) + def __or__(self, rhs): + return KconfigData.OR(self, rhs) + def __invert__(self): + return KconfigData.NOT(self) + + class AND(Expr): + def __init__(self, lhs, rhs): + self.lhs = lhs + self.rhs = rhs + def __str__(self): + return "(%s && %s)" % (self.lhs, self.rhs) + + class OR(Expr): + def __init__(self, lhs, rhs): + self.lhs = lhs + self.rhs = rhs + def __str__(self): + return "(%s || %s)" % (self.lhs, self.rhs) + + class NOT(Expr): + def __init__(self, lhs): + self.lhs = lhs + def __str__(self): + return "!%s" % (self.lhs) + + class Var(Expr): + def __init__(self, name): + self.name = name + self.value = None + def __str__(self): + return self.name + + class Clause: + def __init__(self, dest): + self.dest = dest + + class AssignmentClause(Clause): + def __init__(self, dest, value): + KconfigData.Clause.__init__(self, dest) + self.value = value + def __str__(self): + return "%s=%s" % (self.dest, 'y' if self.value else 'n') + + class DefaultClause(Clause): + def __init__(self, dest, value, cond=None): + KconfigData.Clause.__init__(self, dest) + self.value = value + self.cond = cond + def __str__(self): + value = 'y' if self.value else 'n' + if self.cond is None: + return "config %s default %s" % (self.dest, value) + else: + return "config %s default %s if %s" % (self.dest, value, self.cond) + + class DependsOnClause(Clause): + def __init__(self, dest, expr): + KconfigData.Clause.__init__(self, dest) + self.expr = expr + def __str__(self): + return "config %s depends on %s" % (self.dest, self.expr) + + class SelectClause(Clause): + def __init__(self, dest, cond): + KconfigData.Clause.__init__(self, dest) + self.cond = cond + def __str__(self): + return "select %s if %s" % (self.dest, self.cond) + def __init__(self): self.previously_included = [] self.incl_info = None self.defined_vars = set() - self.referenced_vars = set() + self.referenced_vars = dict() + self.clauses = list() # semantic analysis ------------- @@ -53,29 +126,34 @@ class KconfigData: if (var in self.defined_vars): raise Exception('variable "' + var + '" defined twice') - self.defined_vars.add(var) + self.defined_vars.add(var.name) # var is a string with the variable's name. - # - # For now this just returns the variable's name itself. def do_var(self, var): - self.referenced_vars.add(var) - return var + if (var in self.referenced_vars): + return self.referenced_vars[var] + + var_obj = self.referenced_vars[var] = KconfigData.Var(var) + return var_obj def do_assignment(self, var, val): - pass + self.clauses.append(KconfigData.AssignmentClause(var, val)) def do_default(self, var, val, cond=None): - pass + self.clauses.append(KconfigData.DefaultClause(var, val, cond)) def do_depends_on(self, var, expr): - pass + self.clauses.append(KconfigData.DependsOnClause(var, expr)) def do_select(self, var, symbol, cond=None): - pass + cond = (cond & var) if cond is not None else var + self.clauses.append(KconfigData.SelectClause(symbol, cond)) def do_imply(self, var, symbol, cond=None): - pass + # "config X imply Y [if COND]" is the same as + # "config Y default y if X [&& COND]" + cond = (cond & var) if cond is not None else var + self.do_default(symbol, True, cond) # ------------------------------------------- # KconfigParser implements a recursive descent parser for (simplified) @@ -237,31 +315,34 @@ class KconfigParser: def parse_primary(self): if self.tok == TOK_NOT: self.get_token() - self.parse_primary() + val = ~self.parse_primary() elif self.tok == TOK_LPAREN: self.get_token() - self.parse_expr() + val = self.parse_expr() if self.tok != TOK_RPAREN: raise KconfigParserError(self, 'Expected ")"') self.get_token() elif self.tok == TOK_ID: - self.parse_var() + val = self.parse_var() else: raise KconfigParserError(self, 'Expected "!" or "(" or identifier') + return val # disj: primary (OR primary)* def parse_disj(self): - self.parse_primary() + lhs = self.parse_primary() while self.tok == TOK_OR: self.get_token() - self.parse_primary() + lhs = lhs | self.parse_primary() + return lhs # expr: disj (AND disj)* def parse_expr(self): - self.parse_disj() + lhs = self.parse_disj() while self.tok == TOK_AND: self.get_token() - self.parse_disj() + lhs = lhs & self.parse_disj() + return lhs # condition: IF expr # | empty @@ -438,4 +519,6 @@ class KconfigParser: if __name__ == '__main__': fname = len(sys.argv) > 1 and sys.argv[1] or 'Kconfig.test' - KconfigParser.parse(open(fname, 'r')) + data = KconfigParser.parse(open(fname, 'r')) + for i in data.clauses: + print i -- cgit v1.2.3-55-g7522 From f7082a9a7cb26bd6531d6cd25914e4fcc30ab0c3 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 23 Jan 2019 14:55:58 +0800 Subject: minikconfig: add semantic analysis There are three parts in the semantic analysis: 1) evaluating expressions. This is done as a simple visit of the Expr nodes. 2) ordering clauses. This is done by constructing a graph of variables. There is an edge from X to Y if Y depends on X, if X selects Y, or if X appears in a conditional selection of Y; in other words, if the value of X can affect the value of Y. Each clause has a "destination" variable whose value can be affected by the clause, and clauses will be processed according to a topological sorting of their destination variables. Defaults are processed after all other clauses with the same destination. 3) deriving the value of the variables. This is done by processing the clauses in the topological order provided by the previous step. A "depends on" clause will force a variable to False, a "select" clause will force a variable to True, an assignment will force a variable to its RHS. A default will set a variable to its RHS if it has not been set before. Because all variables have a default, after visiting all clauses all variables will have been set. Signed-off-by: Paolo Bonzini Message-Id: <20190123065618.3520-25-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- scripts/minikconf.py | 144 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 135 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/scripts/minikconf.py b/scripts/minikconf.py index f0cc3b9fb9..d89fb09271 100644 --- a/scripts/minikconf.py +++ b/scripts/minikconf.py @@ -14,7 +14,8 @@ from __future__ import print_function import os import sys -__all__ = [ 'KconfigParserError', 'KconfigData', 'KconfigParser' ] +__all__ = [ 'KconfigDataError', 'KconfigParserError', + 'KconfigData', 'KconfigParser' ] def debug_print(*args): #print('# ' + (' '.join(str(x) for x in args))) @@ -30,6 +31,13 @@ def debug_print(*args): # just its name). # ------------------------------------------- +class KconfigDataError(Exception): + def __init__(self, msg): + self.msg = msg + + def __str__(self): + return self.msg + class KconfigData: class Expr: def __and__(self, rhs): @@ -39,6 +47,12 @@ class KconfigData: def __invert__(self): return KconfigData.NOT(self) + # Abstract methods + def add_edges_to(self, var): + pass + def evaluate(self): + assert False + class AND(Expr): def __init__(self, lhs, rhs): self.lhs = lhs @@ -46,6 +60,12 @@ class KconfigData: def __str__(self): return "(%s && %s)" % (self.lhs, self.rhs) + def add_edges_to(self, var): + self.lhs.add_edges_to(var) + self.rhs.add_edges_to(var) + def evaluate(self): + return self.lhs.evaluate() and self.rhs.evaluate() + class OR(Expr): def __init__(self, lhs, rhs): self.lhs = lhs @@ -53,35 +73,85 @@ class KconfigData: def __str__(self): return "(%s || %s)" % (self.lhs, self.rhs) + def add_edges_to(self, var): + self.lhs.add_edges_to(var) + self.rhs.add_edges_to(var) + def evaluate(self): + return self.lhs.evaluate() or self.rhs.evaluate() + class NOT(Expr): def __init__(self, lhs): self.lhs = lhs def __str__(self): return "!%s" % (self.lhs) + def add_edges_to(self, var): + self.lhs.add_edges_to(var) + def evaluate(self): + return not self.lhs.evaluate() + class Var(Expr): def __init__(self, name): self.name = name self.value = None + self.outgoing = set() + self.clauses_for_var = list() def __str__(self): return self.name + def has_value(self): + return not (self.value is None) + def set_value(self, val, clause): + self.clauses_for_var.append(clause) + if self.has_value() and self.value != val: + print("The following clauses were found for " + self.name) + for i in self.clauses_for_var: + print(" " + str(i), file=sys.stderr) + raise KconfigDataError('contradiction between clauses when setting %s' % self) + debug_print("=> %s is now %s" % (self.name, val)) + self.value = val + + # depth first search of the dependency graph + def dfs(self, visited, f): + if self in visited: + return + visited.add(self) + for v in self.outgoing: + v.dfs(visited, f) + f(self) + + def add_edges_to(self, var): + self.outgoing.add(var) + def evaluate(self): + if not self.has_value(): + raise KconfigDataError('cycle found including %s' % self) + return self.value + class Clause: def __init__(self, dest): self.dest = dest + def priority(self): + return 0 + def process(self): + pass class AssignmentClause(Clause): def __init__(self, dest, value): KconfigData.Clause.__init__(self, dest) self.value = value def __str__(self): - return "%s=%s" % (self.dest, 'y' if self.value else 'n') + return "CONFIG_%s=%s" % (self.dest, 'y' if self.value else 'n') + + def process(self): + self.dest.set_value(self.value, self) class DefaultClause(Clause): def __init__(self, dest, value, cond=None): KconfigData.Clause.__init__(self, dest) self.value = value self.cond = cond + if not (self.cond is None): + self.cond.add_edges_to(self.dest) def __str__(self): value = 'y' if self.value else 'n' if self.cond is None: @@ -89,20 +159,38 @@ class KconfigData: else: return "config %s default %s if %s" % (self.dest, value, self.cond) + def priority(self): + # Defaults are processed just before leaving the variable + return -1 + def process(self): + if not self.dest.has_value() and \ + (self.cond is None or self.cond.evaluate()): + self.dest.set_value(self.value, self) + class DependsOnClause(Clause): def __init__(self, dest, expr): KconfigData.Clause.__init__(self, dest) self.expr = expr + self.expr.add_edges_to(self.dest) def __str__(self): return "config %s depends on %s" % (self.dest, self.expr) + def process(self): + if not self.expr.evaluate(): + self.dest.set_value(False, self) + class SelectClause(Clause): def __init__(self, dest, cond): KconfigData.Clause.__init__(self, dest) self.cond = cond + self.cond.add_edges_to(self.dest) def __str__(self): return "select %s if %s" % (self.dest, self.cond) + def process(self): + if self.cond.evaluate(): + self.dest.set_value(True, self) + def __init__(self): self.previously_included = [] self.incl_info = None @@ -120,11 +208,54 @@ class KconfigData: undef = True return undef + def compute_config(self): + if self.check_undefined(): + raise KconfigDataError("there were undefined symbols") + return None + + debug_print("Input:") + for clause in self.clauses: + debug_print(clause) + + debug_print("\nDependency graph:") + for i in self.referenced_vars: + debug_print(i, "->", [str(x) for x in self.referenced_vars[i].outgoing]) + + # The reverse of the depth-first order is the topological sort + dfo = dict() + visited = set() + debug_print("\n") + def visit_fn(var): + debug_print(var, "has DFS number", len(dfo)) + dfo[var] = len(dfo) + + for name, v in self.referenced_vars.items(): + self.do_default(v, False) + v.dfs(visited, visit_fn) + + # Put higher DFS numbers and higher priorities first. This + # places the clauses in topological order and places defaults + # after assignments and dependencies. + self.clauses.sort(key=lambda x: (-dfo[x.dest], -x.priority())) + + debug_print("\nSorted clauses:") + for clause in self.clauses: + debug_print(clause) + clause.process() + + debug_print("") + values = dict() + for name, v in self.referenced_vars.items(): + debug_print("Evaluating", name) + values[name] = v.evaluate() + + return values + # semantic actions ------------- def do_declaration(self, var): if (var in self.defined_vars): - raise Exception('variable "' + var + '" defined twice') + raise KconfigDataError('variable "' + var + '" defined twice') self.defined_vars.add(var.name) @@ -201,9 +332,6 @@ class KconfigParser: data = KconfigData() parser = KconfigParser(data) parser.parse_file(fp) - if data.check_undefined(): - raise KconfigParserError(parser, "there were undefined symbols") - return data def __init__(self, data): @@ -392,7 +520,6 @@ class KconfigParser: self.tok == TOK_SELECT or self.tok == TOK_BOOL or \ self.tok == TOK_IMPLY: self.parse_property(var) - self.data.do_default(var, False) # for nicer error message if self.tok != TOK_SOURCE and self.tok != TOK_CONFIG and \ @@ -520,5 +647,4 @@ class KconfigParser: if __name__ == '__main__': fname = len(sys.argv) > 1 and sys.argv[1] or 'Kconfig.test' data = KconfigParser.parse(open(fname, 'r')) - for i in data.clauses: - print i + print data.compute_config() -- cgit v1.2.3-55-g7522 From 82f5181777ebe04b550fd94a1d04c49dd3f012dc Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 23 Jan 2019 14:56:00 +0800 Subject: kconfig: introduce kconfig files The Kconfig files were generated mostly with this script: for i in `grep -ho CONFIG_[A-Z0-9_]* default-configs/* | sort -u`; do set fnord `git grep -lw $i -- 'hw/*/Makefile.objs' ` shift if test $# = 1; then cat >> $(dirname $1)/Kconfig << EOF config ${i#CONFIG_} bool EOF git add $(dirname $1)/Kconfig else echo $i $* fi done sed -i '$d' hw/*/Kconfig for i in hw/*; do if test -d $i && ! test -f $i/Kconfig; then touch $i/Kconfig git add $i/Kconfig fi done Whenever a symbol is referenced from multiple subdirectories, the script prints the list of directories that reference the symbol. These symbols have to be added manually to the Kconfig files. Kconfig.host and hw/Kconfig were created manually. Signed-off-by: Paolo Bonzini Signed-off-by: Yang Zhong Message-Id: <20190123065618.3520-27-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- Kconfig.host | 26 +++++++++++ hw/9pfs/Kconfig | 2 + hw/Kconfig | 68 +++++++++++++++++++++++++++++ hw/acpi/Kconfig | 20 +++++++++ hw/adc/Kconfig | 2 + hw/alpha/Kconfig | 2 + hw/arm/Kconfig | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++ hw/audio/Kconfig | 35 +++++++++++++++ hw/block/Kconfig | 29 ++++++++++++ hw/bt/Kconfig | 2 + hw/char/Kconfig | 32 ++++++++++++++ hw/core/Kconfig | 11 +++++ hw/cpu/Kconfig | 8 ++++ hw/cris/Kconfig | 5 +++ hw/display/Kconfig | 77 ++++++++++++++++++++++++++++++++ hw/dma/Kconfig | 20 +++++++++ hw/gpio/Kconfig | 8 ++++ hw/hppa/Kconfig | 2 + hw/hyperv/Kconfig | 5 +++ hw/i2c/Kconfig | 20 +++++++++ hw/i386/Kconfig | 23 ++++++++++ hw/ide/Kconfig | 35 +++++++++++++++ hw/input/Kconfig | 23 ++++++++++ hw/intc/Kconfig | 47 ++++++++++++++++++++ hw/ipack/Kconfig | 2 + hw/ipmi/Kconfig | 14 ++++++ hw/isa/Kconfig | 23 ++++++++++ hw/lm32/Kconfig | 5 +++ hw/m68k/Kconfig | 8 ++++ hw/mem/Kconfig | 8 ++++ hw/microblaze/Kconfig | 8 ++++ hw/mips/Kconfig | 20 +++++++++ hw/misc/Kconfig | 94 +++++++++++++++++++++++++++++++++++++++ hw/misc/macio/Kconfig | 11 +++++ hw/moxie/Kconfig | 2 + hw/net/Kconfig | 92 ++++++++++++++++++++++++++++++++++++++ hw/nios2/Kconfig | 5 +++ hw/nvram/Kconfig | 8 ++++ hw/openrisc/Kconfig | 2 + hw/pci-bridge/Kconfig | 20 +++++++++ hw/pci-host/Kconfig | 35 +++++++++++++++ hw/pci/Kconfig | 2 + hw/pcmcia/Kconfig | 2 + hw/ppc/Kconfig | 44 +++++++++++++++++++ hw/riscv/Kconfig | 20 +++++++++ hw/s390x/Kconfig | 2 + hw/scsi/Kconfig | 26 +++++++++++ hw/sd/Kconfig | 11 +++++ hw/sh4/Kconfig | 11 +++++ hw/smbios/Kconfig | 2 + hw/sparc/Kconfig | 11 +++++ hw/sparc64/Kconfig | 5 +++ hw/ssi/Kconfig | 14 ++++++ hw/timer/Kconfig | 53 ++++++++++++++++++++++ hw/tpm/Kconfig | 14 ++++++ hw/tricore/Kconfig | 2 + hw/unicore32/Kconfig | 2 + hw/usb/Kconfig | 53 ++++++++++++++++++++++ hw/vfio/Kconfig | 20 +++++++++ hw/virtio/Kconfig | 17 ++++++++ hw/watchdog/Kconfig | 11 +++++ hw/xtensa/Kconfig | 5 +++ scripts/minikconf.py | 35 +++++++++++++-- 63 files changed, 1337 insertions(+), 3 deletions(-) create mode 100644 Kconfig.host create mode 100644 hw/9pfs/Kconfig create mode 100644 hw/Kconfig create mode 100644 hw/acpi/Kconfig create mode 100644 hw/adc/Kconfig create mode 100644 hw/alpha/Kconfig create mode 100644 hw/arm/Kconfig create mode 100644 hw/audio/Kconfig create mode 100644 hw/block/Kconfig create mode 100644 hw/bt/Kconfig create mode 100644 hw/char/Kconfig create mode 100644 hw/core/Kconfig create mode 100644 hw/cpu/Kconfig create mode 100644 hw/cris/Kconfig create mode 100644 hw/display/Kconfig create mode 100644 hw/dma/Kconfig create mode 100644 hw/gpio/Kconfig create mode 100644 hw/hppa/Kconfig create mode 100644 hw/hyperv/Kconfig create mode 100644 hw/i2c/Kconfig create mode 100644 hw/i386/Kconfig create mode 100644 hw/ide/Kconfig create mode 100644 hw/input/Kconfig create mode 100644 hw/intc/Kconfig create mode 100644 hw/ipack/Kconfig create mode 100644 hw/ipmi/Kconfig create mode 100644 hw/isa/Kconfig create mode 100644 hw/lm32/Kconfig create mode 100644 hw/m68k/Kconfig create mode 100644 hw/mem/Kconfig create mode 100644 hw/microblaze/Kconfig create mode 100644 hw/mips/Kconfig create mode 100644 hw/misc/Kconfig create mode 100644 hw/misc/macio/Kconfig create mode 100644 hw/moxie/Kconfig create mode 100644 hw/net/Kconfig create mode 100644 hw/nios2/Kconfig create mode 100644 hw/nvram/Kconfig create mode 100644 hw/openrisc/Kconfig create mode 100644 hw/pci-bridge/Kconfig create mode 100644 hw/pci-host/Kconfig create mode 100644 hw/pci/Kconfig create mode 100644 hw/pcmcia/Kconfig create mode 100644 hw/ppc/Kconfig create mode 100644 hw/riscv/Kconfig create mode 100644 hw/s390x/Kconfig create mode 100644 hw/scsi/Kconfig create mode 100644 hw/sd/Kconfig create mode 100644 hw/sh4/Kconfig create mode 100644 hw/smbios/Kconfig create mode 100644 hw/sparc/Kconfig create mode 100644 hw/sparc64/Kconfig create mode 100644 hw/ssi/Kconfig create mode 100644 hw/timer/Kconfig create mode 100644 hw/tpm/Kconfig create mode 100644 hw/tricore/Kconfig create mode 100644 hw/unicore32/Kconfig create mode 100644 hw/usb/Kconfig create mode 100644 hw/vfio/Kconfig create mode 100644 hw/virtio/Kconfig create mode 100644 hw/watchdog/Kconfig create mode 100644 hw/xtensa/Kconfig (limited to 'scripts') diff --git a/Kconfig.host b/Kconfig.host new file mode 100644 index 0000000000..11fefa4813 --- /dev/null +++ b/Kconfig.host @@ -0,0 +1,26 @@ +# These are "proxy" symbols used to pass config-host.mak values +# down to Kconfig. + +config KVM + bool + +config LINUX + bool + +config OPENGL + bool + +config SPICE + bool + +config TPM + bool + +config VHOST_USER + bool + +config XEN + bool + +config VIRTFS + bool diff --git a/hw/9pfs/Kconfig b/hw/9pfs/Kconfig new file mode 100644 index 0000000000..a4750999d9 --- /dev/null +++ b/hw/9pfs/Kconfig @@ -0,0 +1,2 @@ +config VIRTIO_9P + bool diff --git a/hw/Kconfig b/hw/Kconfig new file mode 100644 index 0000000000..c4f1547546 --- /dev/null +++ b/hw/Kconfig @@ -0,0 +1,68 @@ +# devices Kconfig +source 9pfs/Kconfig +source acpi/Kconfig +source adc/Kconfig +source audio/Kconfig +source block/Kconfig +source bt/Kconfig +source char/Kconfig +source core/Kconfig +source display/Kconfig +source dma/Kconfig +source gpio/Kconfig +source hyperv/Kconfig +source i2c/Kconfig +source ide/Kconfig +source input/Kconfig +source intc/Kconfig +source ipack/Kconfig +source ipmi/Kconfig +source isa/Kconfig +source mem/Kconfig +source misc/Kconfig +source net/Kconfig +source nvram/Kconfig +source pci-bridge/Kconfig +source pci-host/Kconfig +source pcmcia/Kconfig +source pci/Kconfig +source scsi/Kconfig +source sd/Kconfig +source smbios/Kconfig +source ssi/Kconfig +source timer/Kconfig +source tpm/Kconfig +source usb/Kconfig +source virtio/Kconfig +source vfio/Kconfig +source watchdog/Kconfig + +# arch Kconfig +source arm/Kconfig +source alpha/Kconfig +source cris/Kconfig +source hppa/Kconfig +source i386/Kconfig +source lm32/Kconfig +source m68k/Kconfig +source microblaze/Kconfig +source mips/Kconfig +source moxie/Kconfig +source nios2/Kconfig +source openrisc/Kconfig +source ppc/Kconfig +source riscv/Kconfig +source s390x/Kconfig +source sh4/Kconfig +source sparc/Kconfig +source sparc64/Kconfig +source tricore/Kconfig +source unicore32/Kconfig +source xtensa/Kconfig + +# Symbols used by multiple targets +config XILINX + bool + +config XILINX_AXI + bool diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig new file mode 100644 index 0000000000..c485a3448f --- /dev/null +++ b/hw/acpi/Kconfig @@ -0,0 +1,20 @@ +config ACPI + bool + +config ACPI_X86 + bool + +config ACPI_X86_ICH + bool + +config ACPI_CPU_HOTPLUG + bool + +config ACPI_MEMORY_HOTPLUG + bool + +config ACPI_NVDIMM + bool + +config ACPI_VMGENID + bool diff --git a/hw/adc/Kconfig b/hw/adc/Kconfig new file mode 100644 index 0000000000..25d2229fb8 --- /dev/null +++ b/hw/adc/Kconfig @@ -0,0 +1,2 @@ +config STM32F2XX_ADC + bool diff --git a/hw/alpha/Kconfig b/hw/alpha/Kconfig new file mode 100644 index 0000000000..c5d0438a11 --- /dev/null +++ b/hw/alpha/Kconfig @@ -0,0 +1,2 @@ +config DP264 + bool diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig new file mode 100644 index 0000000000..e4386ce78f --- /dev/null +++ b/hw/arm/Kconfig @@ -0,0 +1,119 @@ +config ARM_VIRT + bool + +config DIGIC + bool + +config EXYNOS4 + bool + +config HIGHBANK + bool + +config INTEGRATOR + bool + +config MAINSTONE + bool + +config MUSICPAL + bool + +config NETDUINO2 + bool + +config NSERIES + bool + +config OMAP + bool + +config PXA2XX + bool + +config REALVIEW + bool + +config STELLARIS + bool + +config STRONGARM + bool + +config VERSATILE + bool + +config ZYNQ + bool + +config ARM_V7M + bool + +config ALLWINNER_A10 + bool + +config RASPI + bool + +config STM32F205_SOC + bool + +config XLNX_ZYNQMP_ARM + bool + +config XLNX_VERSAL + bool + +config FSL_IMX25 + bool + +config FSL_IMX31 + bool + +config FSL_IMX6 + bool + +config ASPEED_SOC + bool + +config MPS2 + bool + +config FSL_IMX7 + bool + +config ARM_SMMUV3 + bool + +config FSL_IMX6UL + bool + +config NRF51_SOC + bool + +config MSF2 + bool + +config ZAURUS + bool + +config A9MPCORE + bool + +config A15MPCORE + bool + +config ARM11MPCORE + bool + +config ARMSSE + bool + +config ARMSSE_CPUID + bool + +config ARMSSE_MHU + bool + +config MUSCA + bool diff --git a/hw/audio/Kconfig b/hw/audio/Kconfig new file mode 100644 index 0000000000..207baee6e1 --- /dev/null +++ b/hw/audio/Kconfig @@ -0,0 +1,35 @@ +config SB16 + bool + +config ES1370 + bool + +config AC97 + bool + +config ADLIB + bool + +config GUS + bool + +config CS4231A + bool + +config HDA + bool + +config PCSPK + bool + +config WM8750 + bool + +config PL041 + bool + +config CS4231 + bool + +config MARVELL_88W8618 + bool diff --git a/hw/block/Kconfig b/hw/block/Kconfig new file mode 100644 index 0000000000..9d418bce4d --- /dev/null +++ b/hw/block/Kconfig @@ -0,0 +1,29 @@ +config FDC + bool + +config SSI_M25P80 + bool + +config NAND + bool + +config PFLASH_CFI01 + bool + +config PFLASH_CFI02 + bool + +config ECC + bool + +config ONENAND + bool + +config NVME_PCI + bool + +config VIRTIO_BLK + bool + +config VHOST_USER_BLK + bool diff --git a/hw/bt/Kconfig b/hw/bt/Kconfig new file mode 100644 index 0000000000..554a9ee75e --- /dev/null +++ b/hw/bt/Kconfig @@ -0,0 +1,2 @@ +config BLUETOOTH + bool diff --git a/hw/char/Kconfig b/hw/char/Kconfig new file mode 100644 index 0000000000..26c13243cf --- /dev/null +++ b/hw/char/Kconfig @@ -0,0 +1,32 @@ +config ESCC + bool + +config PARALLEL + bool + +config PL011 + bool + +config SERIAL + bool + +config SERIAL_ISA + bool + +config SERIAL_PCI + bool + +config VIRTIO_SERIAL + bool + +config STM32F2XX_USART + bool + +config CMSDK_APB_UART + bool + +config SCLPCONSOLE + bool + +config TERMINAL3270 + bool diff --git a/hw/core/Kconfig b/hw/core/Kconfig new file mode 100644 index 0000000000..c2a1ae8122 --- /dev/null +++ b/hw/core/Kconfig @@ -0,0 +1,11 @@ +config EMPTY_SLOT + bool + +config PTIMER + bool + +config FITLOADER + bool + +config PLATFORM_BUS + bool diff --git a/hw/cpu/Kconfig b/hw/cpu/Kconfig new file mode 100644 index 0000000000..1767d028ac --- /dev/null +++ b/hw/cpu/Kconfig @@ -0,0 +1,8 @@ +config ARM11MPCORE + bool + +config A9MPCORE + bool + +config A15MPCORE + bool diff --git a/hw/cris/Kconfig b/hw/cris/Kconfig new file mode 100644 index 0000000000..86954ab0b7 --- /dev/null +++ b/hw/cris/Kconfig @@ -0,0 +1,5 @@ +config AXIS + bool + +config ETRAXFS + bool diff --git a/hw/display/Kconfig b/hw/display/Kconfig new file mode 100644 index 0000000000..d5c022c886 --- /dev/null +++ b/hw/display/Kconfig @@ -0,0 +1,77 @@ +config EDID + bool + +config FW_CFG_DMA + bool + +config ADS7846 + bool + +config VGA_CIRRUS + bool + +config G364FB + bool + +config JAZZ_LED + bool + +config PL110 + bool + +config SII9022 + bool + +config SSD0303 + bool + +config SSD0323 + bool + +config VGA_PCI + bool + +config VGA_ISA + bool + +config VGA_ISA_MM + bool + +config VMWARE_VGA + bool + +config BOCHS_DISPLAY + bool + +config BLIZZARD + bool + +config FRAMEBUFFER + bool + +config MILKYMIST_TMU2 + bool + +config SM501 + bool + +config TCX + bool + +config CG3 + bool + +config VGA + bool + +config QXL + bool + +config VIRTIO_GPU + bool + +config VIRTIO_VGA + bool + +config DPCD + bool diff --git a/hw/dma/Kconfig b/hw/dma/Kconfig new file mode 100644 index 0000000000..b9ce1c58c4 --- /dev/null +++ b/hw/dma/Kconfig @@ -0,0 +1,20 @@ +config RC4030 + bool + +config PL080 + bool + +config PL330 + bool + +config I82374 + bool + +config I8257 + bool + +config ZYNQ_DEVCFG + bool + +config STP2000 + bool diff --git a/hw/gpio/Kconfig b/hw/gpio/Kconfig new file mode 100644 index 0000000000..d0a4abf93f --- /dev/null +++ b/hw/gpio/Kconfig @@ -0,0 +1,8 @@ +config MAX7310 + bool + +config PL061 + bool + +config GPIO_KEY + bool diff --git a/hw/hppa/Kconfig b/hw/hppa/Kconfig new file mode 100644 index 0000000000..5ce48ef940 --- /dev/null +++ b/hw/hppa/Kconfig @@ -0,0 +1,2 @@ +config DINO + bool diff --git a/hw/hyperv/Kconfig b/hw/hyperv/Kconfig new file mode 100644 index 0000000000..be724b7f8b --- /dev/null +++ b/hw/hyperv/Kconfig @@ -0,0 +1,5 @@ +config HYPERV + bool + +config HYPERV_TESTDEV + bool diff --git a/hw/i2c/Kconfig b/hw/i2c/Kconfig new file mode 100644 index 0000000000..d6d4402608 --- /dev/null +++ b/hw/i2c/Kconfig @@ -0,0 +1,20 @@ +config I2C + bool + +config SMBUS_EEPROM + bool + +config DDC + bool + +config VERSATILE_I2C + bool + +config ACPI_SMBUS + bool + +config BITBANG_I2C + bool + +config IMX_I2C + bool diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig new file mode 100644 index 0000000000..c851e2b5ab --- /dev/null +++ b/hw/i386/Kconfig @@ -0,0 +1,23 @@ +config SEV + bool + +config I440FX + bool + +config ISAPC + bool + +config Q35 + bool + +config VTD + bool + +config AMD_IOMMU + bool + +config VMPORT + bool + +config VMMOUSE + bool diff --git a/hw/ide/Kconfig b/hw/ide/Kconfig new file mode 100644 index 0000000000..5ec449525f --- /dev/null +++ b/hw/ide/Kconfig @@ -0,0 +1,35 @@ +config IDE_CORE + bool + +config IDE_QDEV + bool + +config IDE_PCI + bool + +config IDE_ISA + bool + +config IDE_PIIX + bool + +config IDE_CMD646 + bool + +config IDE_MACIO + bool + +config IDE_MMIO + bool + +config IDE_VIA + bool + +config MICRODRIVE + bool + +config AHCI + bool + +config IDE_SII3112 + bool diff --git a/hw/input/Kconfig b/hw/input/Kconfig new file mode 100644 index 0000000000..91bae47498 --- /dev/null +++ b/hw/input/Kconfig @@ -0,0 +1,23 @@ +config ADB + bool + +config LM832X + bool + +config PCKBD + bool + +config PL050 + bool + +config STELLARIS_INPUT + bool + +config TSC2005 + bool + +config VIRTIO_INPUT + bool + +config TSC210X + bool diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig new file mode 100644 index 0000000000..69adbd135f --- /dev/null +++ b/hw/intc/Kconfig @@ -0,0 +1,47 @@ +config HEATHROW_PIC + bool + +config I8259 + bool + +config PL190 + bool + +config IOAPIC + bool + +config ARM_GIC + bool + +config OPENPIC + bool + +config APIC + bool + +config ARM_GIC_KVM + bool + +config OPENPIC_KVM + bool + +config XICS + bool + +config XICS_SPAPR + bool + +config XICS_KVM + bool + +config ALLWINNER_A10_PIC + bool + +config S390_FLIC + bool + +config S390_FLIC_KVM + bool + +config OMPIC + bool diff --git a/hw/ipack/Kconfig b/hw/ipack/Kconfig new file mode 100644 index 0000000000..481e0d2e64 --- /dev/null +++ b/hw/ipack/Kconfig @@ -0,0 +1,2 @@ +config IPACK + bool diff --git a/hw/ipmi/Kconfig b/hw/ipmi/Kconfig new file mode 100644 index 0000000000..68f8ba1a54 --- /dev/null +++ b/hw/ipmi/Kconfig @@ -0,0 +1,14 @@ +config IPMI + bool + +config IPMI_LOCAL + bool + +config IPMI_EXTERN + bool + +config ISA_IPMI_KCS + bool + +config ISA_IPMI_BT + bool diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig new file mode 100644 index 0000000000..b59d074453 --- /dev/null +++ b/hw/isa/Kconfig @@ -0,0 +1,23 @@ +config ISA_BUS + bool + +config APM + bool + +config I82378 + bool + +config PC87312 + bool + +config PIIX4 + bool + +config VT82C686 + bool + +config SMC37C669 + bool + +config LPC_ICH9 + bool diff --git a/hw/lm32/Kconfig b/hw/lm32/Kconfig new file mode 100644 index 0000000000..84c530e991 --- /dev/null +++ b/hw/lm32/Kconfig @@ -0,0 +1,5 @@ +config LM32 + bool + +config MILKYMIST + bool diff --git a/hw/m68k/Kconfig b/hw/m68k/Kconfig new file mode 100644 index 0000000000..cd66ada909 --- /dev/null +++ b/hw/m68k/Kconfig @@ -0,0 +1,8 @@ +config AN5206 + bool + +config MCF5206 + bool + +config MCF5208 + bool diff --git a/hw/mem/Kconfig b/hw/mem/Kconfig new file mode 100644 index 0000000000..a3a4372fa7 --- /dev/null +++ b/hw/mem/Kconfig @@ -0,0 +1,8 @@ +config DIMM + bool + +config MEM_DEVICE + bool + +config NVDIMM + bool diff --git a/hw/microblaze/Kconfig b/hw/microblaze/Kconfig new file mode 100644 index 0000000000..44683b2737 --- /dev/null +++ b/hw/microblaze/Kconfig @@ -0,0 +1,8 @@ +config PETALOGIX_S3ADSP1800 + bool + +config PETALOGIX_ML605 + bool + +config XLNX_ZYNQMP_PMU + bool diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig new file mode 100644 index 0000000000..348c9bf6d3 --- /dev/null +++ b/hw/mips/Kconfig @@ -0,0 +1,20 @@ +config R4K + bool + +config MALTA + bool + +config MIPSSIM + bool + +config JAZZ + bool + +config FULONG + bool + +config MIPS_CPS + bool + +config MIPS_BOSTON + bool diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig new file mode 100644 index 0000000000..d5126349d9 --- /dev/null +++ b/hw/misc/Kconfig @@ -0,0 +1,94 @@ +config APPLESMC + bool + +config MAX111X + bool + +config TMP105 + bool + +config TMP421 + bool + +config ISA_DEBUG + bool + +config SGA + bool + +config ISA_TESTDEV + bool + +config PCI_TESTDEV + bool + +config EDU + bool + +config PCA9552 + bool + +config PL310 + bool + +config INTEGRATOR_DEBUG + bool + +config A9SCU + bool + +config ARM11SCU + bool + +config MOS6522 + bool + +config MACIO + bool + +config IVSHMEM_DEVICE + bool + +config ECCMEMCTL + bool + +config IMX + bool + +config STM32F2XX_SYSCFG + bool + +config MIPS_ITU + bool + +config MPS2_FPGAIO + bool + +config MPS2_SCC + bool + +config TZ_MPC + bool + +config TZ_MSC + bool + +config TZ_PPC + bool + +config IOTKIT_SECCTL + bool + +config IOTKIT_SYSCTL + bool + +config IOTKIT_SYSINFO + bool + +config PVPANIC + bool + +config AUX + bool + +source macio/Kconfig diff --git a/hw/misc/macio/Kconfig b/hw/misc/macio/Kconfig new file mode 100644 index 0000000000..c6caeb672f --- /dev/null +++ b/hw/misc/macio/Kconfig @@ -0,0 +1,11 @@ +config CUDA + bool + +config MAC_PMU + bool + +config MAC_DBDMA + bool + +config MACIO_GPIO + bool diff --git a/hw/moxie/Kconfig b/hw/moxie/Kconfig new file mode 100644 index 0000000000..03f62e3361 --- /dev/null +++ b/hw/moxie/Kconfig @@ -0,0 +1,2 @@ +config MOXIESIM + bool diff --git a/hw/net/Kconfig b/hw/net/Kconfig new file mode 100644 index 0000000000..ad56fc0d7b --- /dev/null +++ b/hw/net/Kconfig @@ -0,0 +1,92 @@ +config DP8393X + bool + +config NE2000_PCI + bool + +config EEPRO100_PCI + bool + +config PCNET_PCI + bool + +config PCNET_COMMON + bool + +config E1000_PCI + bool + +config E1000E_PCI_EXPRESS + bool + +config RTL8139_PCI + bool + +config VMXNET3_PCI + bool + +config SMC91C111 + bool + +config LAN9118 + bool + +config NE2000_ISA + bool + +config OPENCORES_ETH + bool + +config XGMAC + bool + +config MIPSNET + bool + +config ALLWINNER_EMAC + bool + +config IMX_FEC + bool + +config CADENCE + bool + +config STELLARIS_ENET + bool + +config LANCE + bool + +config SUNHME + bool + +config FTGMAC100 + bool + +config SUNGEM + bool + +config COLDFIRE + bool + +config XILINX_ETHLITE + bool + +config VIRTIO_NET + bool + +config ETSEC + bool + +config ROCKER + bool + +config CAN_BUS + bool + +config CAN_PCI + bool + +config CAN_SJA1000 + bool diff --git a/hw/nios2/Kconfig b/hw/nios2/Kconfig new file mode 100644 index 0000000000..22817e45fe --- /dev/null +++ b/hw/nios2/Kconfig @@ -0,0 +1,5 @@ +config NIOS2_10M50 + bool + +config NIOS2 + bool diff --git a/hw/nvram/Kconfig b/hw/nvram/Kconfig new file mode 100644 index 0000000000..1f5ec95d8b --- /dev/null +++ b/hw/nvram/Kconfig @@ -0,0 +1,8 @@ +config DS1225Y + bool + +config AT24C + bool + +config MAC_NVRAM + bool diff --git a/hw/openrisc/Kconfig b/hw/openrisc/Kconfig new file mode 100644 index 0000000000..7aef98dc85 --- /dev/null +++ b/hw/openrisc/Kconfig @@ -0,0 +1,2 @@ +config OR1K_SIM + bool diff --git a/hw/pci-bridge/Kconfig b/hw/pci-bridge/Kconfig new file mode 100644 index 0000000000..bb19b7aac1 --- /dev/null +++ b/hw/pci-bridge/Kconfig @@ -0,0 +1,20 @@ +config PCIE_PORT + bool + +config PXB + bool + +config XIO3130 + bool + +config IOH3420 + bool + +config I82801B11 + bool + +config DEC_PCI + bool + +config SIMBA + bool diff --git a/hw/pci-host/Kconfig b/hw/pci-host/Kconfig new file mode 100644 index 0000000000..2edc5bbc9a --- /dev/null +++ b/hw/pci-host/Kconfig @@ -0,0 +1,35 @@ +config PAM + bool + +config PREP_PCI + bool + +config GRACKLE_PCI + bool + +config UNIN_PCI + bool + +config PPCE500_PCI + bool + +config VERSATILE_PCI + bool + +config PCI_SABRE + bool + +config PCI_PIIX + bool + +config PCI_EXPRESS_Q35 + bool + +config PCI_EXPRESS_GENERIC_BRIDGE + bool + +config PCI_EXPRESS_XILINX + bool + +config PCI_EXPRESS_DESIGNWARE + bool diff --git a/hw/pci/Kconfig b/hw/pci/Kconfig new file mode 100644 index 0000000000..d3d2205577 --- /dev/null +++ b/hw/pci/Kconfig @@ -0,0 +1,2 @@ +config PCI + bool diff --git a/hw/pcmcia/Kconfig b/hw/pcmcia/Kconfig new file mode 100644 index 0000000000..41f2df9136 --- /dev/null +++ b/hw/pcmcia/Kconfig @@ -0,0 +1,2 @@ +config PCMCIA + bool diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig new file mode 100644 index 0000000000..608745488a --- /dev/null +++ b/hw/ppc/Kconfig @@ -0,0 +1,44 @@ +config PSERIES + bool + +config SPAPR_RNG + bool + +config POWERNV + bool + +config PPC405 + bool + +config PPC440 + bool + +config PPC4XX + bool + +config SAM460EX + bool + +config PREP + bool + +config RS6000_MC + bool + +config MAC_OLDWORLD + bool + +config MAC_NEWWORLD + bool + +config E500 + bool + +config VIRTEX + bool + +config XIVE + bool + +config XIVE_SPAPR + bool diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig new file mode 100644 index 0000000000..4989589308 --- /dev/null +++ b/hw/riscv/Kconfig @@ -0,0 +1,20 @@ +config HTIF + bool + +config HART + bool + +config SIFIVE + bool + +config SIFIVE_E + bool + +config SIFIVE_U + bool + +config SPIKE + bool + +config RISCV_VIRT + bool diff --git a/hw/s390x/Kconfig b/hw/s390x/Kconfig new file mode 100644 index 0000000000..303db7f552 --- /dev/null +++ b/hw/s390x/Kconfig @@ -0,0 +1,2 @@ +config S390_CCW_VIRTIO + bool diff --git a/hw/scsi/Kconfig b/hw/scsi/Kconfig new file mode 100644 index 0000000000..eb78478ef0 --- /dev/null +++ b/hw/scsi/Kconfig @@ -0,0 +1,26 @@ +config SCSI + bool + +config LSI_SCSI_PCI + bool + +config MPTSAS_SCSI_PCI + bool + +config MEGASAS_SCSI_PCI + bool + +config VMW_PVSCSI_SCSI_PCI + bool + +config ESP + bool + +config ESP_PCI + bool + +config VIRTIO_SCSI + bool + +config VHOST_USER_SCSI + bool diff --git a/hw/sd/Kconfig b/hw/sd/Kconfig new file mode 100644 index 0000000000..4f43bbb352 --- /dev/null +++ b/hw/sd/Kconfig @@ -0,0 +1,11 @@ +config PL181 + bool + +config SSI_SD + bool + +config SD + bool + +config SDHCI + bool diff --git a/hw/sh4/Kconfig b/hw/sh4/Kconfig new file mode 100644 index 0000000000..417a72fd5d --- /dev/null +++ b/hw/sh4/Kconfig @@ -0,0 +1,11 @@ +config R2D + bool + +config SHIX + bool + +config SH7750 + bool + +config SH4 + bool diff --git a/hw/smbios/Kconfig b/hw/smbios/Kconfig new file mode 100644 index 0000000000..553adf4bfc --- /dev/null +++ b/hw/smbios/Kconfig @@ -0,0 +1,2 @@ +config SMBIOS + bool diff --git a/hw/sparc/Kconfig b/hw/sparc/Kconfig new file mode 100644 index 0000000000..3795754eb6 --- /dev/null +++ b/hw/sparc/Kconfig @@ -0,0 +1,11 @@ +config SUN4M + bool + +config LEON3 + bool + +config GRLIB + bool + +config SLAVIO + bool diff --git a/hw/sparc64/Kconfig b/hw/sparc64/Kconfig new file mode 100644 index 0000000000..8c13345f01 --- /dev/null +++ b/hw/sparc64/Kconfig @@ -0,0 +1,5 @@ +config SUN4U + bool + +config NIAGARA + bool diff --git a/hw/ssi/Kconfig b/hw/ssi/Kconfig new file mode 100644 index 0000000000..5a03110a8d --- /dev/null +++ b/hw/ssi/Kconfig @@ -0,0 +1,14 @@ +config PL022 + bool + +config SSI + bool + +config XILINX_SPI + bool + +config XILINX_SPIPS + bool + +config STM32F2XX_SPI + bool diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig new file mode 100644 index 0000000000..7dbc1211ab --- /dev/null +++ b/hw/timer/Kconfig @@ -0,0 +1,53 @@ +config ARM_TIMER + bool + +config ARM_MPTIMER + bool + +config A9_GTIMER + bool + +config DS1338 + bool + +config HPET + bool + +config I8254 + bool + +config M41T80 + bool + +config M48T59 + bool + +config PL031 + bool + +config TWL92230 + bool + +config XLNX_ZYNQMP + bool + +config ALTERA_TIMER + bool + +config MC146818RTC + bool + +config ALLWINNER_A10_PIT + bool + +config STM32F2XX_TIMER + bool + +config SUN4V_RTC + bool + +config CMSDK_APB_TIMER + bool + +config CMSDK_APB_DUALTIMER + bool diff --git a/hw/tpm/Kconfig b/hw/tpm/Kconfig new file mode 100644 index 0000000000..2eee8eb865 --- /dev/null +++ b/hw/tpm/Kconfig @@ -0,0 +1,14 @@ +config TPM + bool + +config TPM_TIS + bool + +config TPM_CRB + bool + +config TPM_PASSTHROUGH + bool + +config TPM_EMULATOR + bool diff --git a/hw/tricore/Kconfig b/hw/tricore/Kconfig new file mode 100644 index 0000000000..9313409309 --- /dev/null +++ b/hw/tricore/Kconfig @@ -0,0 +1,2 @@ +config TRICORE + bool diff --git a/hw/unicore32/Kconfig b/hw/unicore32/Kconfig new file mode 100644 index 0000000000..b3cf294c04 --- /dev/null +++ b/hw/unicore32/Kconfig @@ -0,0 +1,2 @@ +config PUV3 + bool diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig new file mode 100644 index 0000000000..cbf5c5d761 --- /dev/null +++ b/hw/usb/Kconfig @@ -0,0 +1,53 @@ +config USB + bool + +config USB_UHCI + bool + +config USB_OHCI + bool + +config USB_EHCI + bool + +config USB_EHCI_SYSBUS + bool + +config USB_XHCI + bool + +config USB_XHCI_NEC + bool + +config USB_MUSB + bool + +config TUSB6010 + bool + +config USB_TABLET_WACOM + bool + +config USB_STORAGE_BOT + bool + +config USB_STORAGE_UAS + bool + +config USB_AUDIO + bool + +config USB_SERIAL + bool + +config USB_NETWORK + bool + +config USB_BLUETOOTH + bool + +config USB_SMARTCARD + bool + +config USB_STORAGE_MTP + bool diff --git a/hw/vfio/Kconfig b/hw/vfio/Kconfig new file mode 100644 index 0000000000..36069674cb --- /dev/null +++ b/hw/vfio/Kconfig @@ -0,0 +1,20 @@ +config VFIO + bool + +config VFIO_PCI + bool + +config VFIO_CCW + bool + +config VFIO_PLATFORM + bool + +config VFIO_XGMAC + bool + +config VFIO_AMD_XGBE + bool + +config VFIO_AP + bool diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig new file mode 100644 index 0000000000..ebf18124fb --- /dev/null +++ b/hw/virtio/Kconfig @@ -0,0 +1,17 @@ +config VIRTIO + bool + +config VIRTIO_RNG + bool + +config VIRTIO_PCI + bool + +config VIRTIO_MMIO + bool + +config VIRTIO_BALLOON + bool + +config VIRTIO_CRYPTO + bool diff --git a/hw/watchdog/Kconfig b/hw/watchdog/Kconfig new file mode 100644 index 0000000000..cd0244f4e1 --- /dev/null +++ b/hw/watchdog/Kconfig @@ -0,0 +1,11 @@ +config CMSDK_APB_WATCHDOG + bool + +config WDT_IB6300ESB + bool + +config WDT_IB700 + bool + +config WDT_DIAG288 + bool diff --git a/hw/xtensa/Kconfig b/hw/xtensa/Kconfig new file mode 100644 index 0000000000..97543a9263 --- /dev/null +++ b/hw/xtensa/Kconfig @@ -0,0 +1,5 @@ +config XTENSA_SIM + bool + +config XTENSA_FPGA + bool diff --git a/scripts/minikconf.py b/scripts/minikconf.py index d89fb09271..6bedc5736e 100644 --- a/scripts/minikconf.py +++ b/scripts/minikconf.py @@ -13,6 +13,7 @@ from __future__ import print_function import os import sys +import re __all__ = [ 'KconfigDataError', 'KconfigParserError', 'KconfigData', 'KconfigParser' ] @@ -350,6 +351,12 @@ class KconfigParser: self.get_token() self.parse_config() + def do_assignment(self, var, val): + if not var.startswith("CONFIG_"): + raise Error('assigned variable should start with CONFIG_') + var = self.data.do_var(var[7:]) + self.data.do_assignment(var, val) + # file management ----- def error_path(self): @@ -645,6 +652,28 @@ class KconfigParser: return None if __name__ == '__main__': - fname = len(sys.argv) > 1 and sys.argv[1] or 'Kconfig.test' - data = KconfigParser.parse(open(fname, 'r')) - print data.compute_config() + argv = sys.argv + if len(argv) == 1: + print ("%s: at least one argument is required" % argv[0], file=sys.stderr) + sys.exit(1) + + data = KconfigData() + parser = KconfigParser(data) + for arg in argv[3:]: + m = re.match(r'^(CONFIG_[A-Z0-9_]+)=([yn]?)$', arg) + if m is not None: + name, value = m.groups() + parser.do_assignment(name, value == 'y') + else: + fp = open(arg, 'r') + parser.parse_file(fp) + fp.close() + + config = data.compute_config() + for key in sorted(config.keys()): + print ('CONFIG_%s=%s' % (key, ('y' if config[key] else 'n'))) + + deps = open(argv[2], 'w') + for fname in data.previously_included: + print ('%s: %s' % (argv[1], fname), file=deps) + deps.close() -- cgit v1.2.3-55-g7522 From e0e312f3525ad6ac18ba6633af29190dd9620cbc Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 23 Jan 2019 14:56:01 +0800 Subject: build: switch to Kconfig The make_device_config.sh script is replaced by minikconf, which is modified to support the same command line as its predecessor. The roots of the parsing are default-configs/*.mak, Kconfig.host and hw/Kconfig. One difference with make_device_config.sh is that all symbols have to be defined in a Kconfig file, including those coming from the configure script. This is the reason for the Kconfig.host file introduced in the previous patch. Whenever a file in default-configs/*.mak used $(...) to refer to a config-host.mak symbol, this is replaced by a Kconfig dependency; this part must be done already in this patch for bisectability. Signed-off-by: Paolo Bonzini Signed-off-by: Yang Zhong Acked-by: Thomas Huth Message-Id: <20190123065618.3520-28-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- Kconfig.host | 9 ++++++++- Makefile | 26 +++++++++++++++++++++----- Makefile.target | 7 ++++++- configure | 6 ++++++ default-configs/arm-softmmu.mak | 3 --- default-configs/i386-softmmu.mak | 5 +---- default-configs/lm32-softmmu.mak | 1 - default-configs/pci.mak | 1 - default-configs/ppc-softmmu.mak | 1 - default-configs/ppc64-softmmu.mak | 5 ----- default-configs/s390x-softmmu.mak | 4 +--- default-configs/virtio.mak | 3 --- hw/9pfs/Kconfig | 2 ++ hw/arm/Kconfig | 1 + hw/block/Kconfig | 2 ++ hw/display/Kconfig | 3 +++ hw/i386/Kconfig | 8 ++++++++ hw/input/Kconfig | 5 +++++ hw/intc/Kconfig | 12 ++++++++++++ hw/misc/Kconfig | 2 ++ hw/ppc/Kconfig | 4 ++++ hw/scsi/Kconfig | 7 +++++++ hw/tpm/Kconfig | 2 ++ hw/vfio/Kconfig | 9 +++++++++ hw/xtensa/Kconfig | 2 +- rules.mak | 2 +- scripts/make_device_config.sh | 30 ------------------------------ 27 files changed, 102 insertions(+), 60 deletions(-) delete mode 100644 scripts/make_device_config.sh (limited to 'scripts') diff --git a/Kconfig.host b/Kconfig.host index 11fefa4813..add5b179f7 100644 --- a/Kconfig.host +++ b/Kconfig.host @@ -1,5 +1,6 @@ # These are "proxy" symbols used to pass config-host.mak values -# down to Kconfig. +# down to Kconfig. See also MINIKCONF_ARGS in the Makefile: +# these two need to be kept in sync. config KVM bool @@ -10,9 +11,15 @@ config LINUX config OPENGL bool +config X11 + bool + config SPICE bool +config IVSHMEM + bool + config TPM bool diff --git a/Makefile b/Makefile index cad585b4d6..2b251c39d9 100644 --- a/Makefile +++ b/Makefile @@ -327,8 +327,8 @@ DOCS= endif SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) BUILD_DIR=$(BUILD_DIR) -SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(TARGET_DIRS)) -SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %-config-devices.mak.d, $(TARGET_DIRS)) +SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(filter %-softmmu, $(TARGET_DIRS))) +SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %.d, $(SUBDIR_DEVICES_MAK)) ifeq ($(SUBDIR_DEVICES_MAK),) config-all-devices.mak: @@ -343,9 +343,25 @@ endif -include $(SUBDIR_DEVICES_MAK_DEP) -%/config-devices.mak: default-configs/%.mak $(SRC_PATH)/scripts/make_device_config.sh - $(call quiet-command, \ - $(SHELL) $(SRC_PATH)/scripts/make_device_config.sh $< $*-config-devices.mak.d $@ > $@.tmp,"GEN","$@.tmp") +# This has to be kept in sync with Kconfig.host. +MINIKCONF_ARGS = \ + $@ $*-config.devices.mak.d $< $(MINIKCONF_INPUTS) \ + CONFIG_KVM=$(CONFIG_KVM) \ + CONFIG_SPICE=$(CONFIG_SPICE) \ + CONFIG_IVSHMEM=$(CONFIG_IVSHMEM) \ + CONFIG_TPM=$(CONFIG_TPM) \ + CONFIG_XEN=$(CONFIG_XEN) \ + CONFIG_OPENGL=$(CONFIG_OPENGL) \ + CONFIG_X11=$(CONFIG_X11) \ + CONFIG_VHOST_USER=$(CONFIG_VHOST_USER) \ + CONFIG_VIRTFS=$(CONFIG_VIRTFS) \ + CONFIG_LINUX=$(CONFIG_LINUX) + +MINIKCONF_INPUTS = $(SRC_PATH)/Kconfig.host $(SRC_PATH)/hw/Kconfig +MINIKCONF = $(PYTHON) $(SRC_PATH)/scripts/minikconf.py \ + +$(SUBDIR_DEVICES_MAK): %/config-devices.mak: default-configs/%.mak $(MINIKCONF_INPUTS) $(BUILD_DIR)/config-host.mak + $(call quiet-command, $(MINIKCONF) $(MINIKCONF_ARGS) > $@.tmp, "GEN", "$@.tmp") $(call quiet-command, if test -f $@; then \ if cmp -s $@.old $@; then \ mv $@.tmp $@; \ diff --git a/Makefile.target b/Makefile.target index 3b79e7074c..ec72733ace 100644 --- a/Makefile.target +++ b/Makefile.target @@ -4,9 +4,12 @@ BUILD_DIR?=$(CURDIR)/.. include ../config-host.mak include config-target.mak -include config-devices.mak include $(SRC_PATH)/rules.mak +ifdef CONFIG_SOFTMMU +include config-devices.mak +endif + $(call set-vpath, $(SRC_PATH):$(BUILD_DIR)) ifdef CONFIG_LINUX QEMU_CFLAGS += -I../linux-headers @@ -201,7 +204,9 @@ all-obj-$(CONFIG_SOFTMMU) += $(crypto-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(io-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(slirp-obj-y) +ifdef CONFIG_SOFTMMU $(QEMU_PROG_BUILD): config-devices.mak +endif COMMON_LDADDS = ../libqemuutil.a diff --git a/configure b/configure index 5921d08cb3..89e4a23f6c 100755 --- a/configure +++ b/configure @@ -7438,12 +7438,18 @@ fi if supported_xen_target $target; then echo "CONFIG_XEN=y" >> $config_target_mak + echo "$target/config-devices.mak: CONFIG_XEN=y" >> $config_host_mak if test "$xen_pci_passthrough" = yes; then echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" fi +else + echo "$target/config-devices.mak: CONFIG_XEN=n" >> $config_host_mak fi if supported_kvm_target $target; then echo "CONFIG_KVM=y" >> $config_target_mak + echo "$target/config-devices.mak: CONFIG_KVM=y" >> $config_host_mak +else + echo "$target/config-devices.mak: CONFIG_KVM=n" >> $config_host_mak fi if supported_hax_target $target; then echo "CONFIG_HAX=y" >> $config_target_mak diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak index bd6943b691..797bfa52fe 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -51,7 +51,6 @@ CONFIG_ARM_V7M=y CONFIG_NETDUINO2=y CONFIG_ARM_GIC=y -CONFIG_ARM_GIC_KVM=$(CONFIG_KVM) CONFIG_ARM_TIMER=y CONFIG_ARM_MPTIMER=y CONFIG_A9_GTIMER=y @@ -126,8 +125,6 @@ CONFIG_VERSATILE_PCI=y CONFIG_VERSATILE_I2C=y CONFIG_PCI_EXPRESS_GENERIC_BRIDGE=y -CONFIG_VFIO=$(CONFIG_LINUX) -CONFIG_VFIO_PLATFORM=y CONFIG_VFIO_XGMAC=y CONFIG_VFIO_AMD_XGBE=y diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak index 15b628757b..412c8c5b4f 100644 --- a/default-configs/i386-softmmu.mak +++ b/default-configs/i386-softmmu.mak @@ -4,7 +4,6 @@ include pci.mak include sound.mak include usb.mak include hyperv.mak -CONFIG_QXL=$(CONFIG_SPICE) CONFIG_VGA_ISA=y CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y @@ -37,8 +36,6 @@ CONFIG_HPET=y CONFIG_APPLESMC=y CONFIG_I8259=y CONFIG_PFLASH_CFI01=y -CONFIG_TPM_TIS=$(CONFIG_TPM) -CONFIG_TPM_CRB=$(CONFIG_TPM) CONFIG_MC146818RTC=y CONFIG_PCI_PIIX=y CONFIG_WDT_IB700=y @@ -66,9 +63,9 @@ CONFIG_ACPI_SMBUS=y CONFIG_SMBUS_EEPROM=y CONFIG_FW_CFG_DMA=y CONFIG_I2C=y -CONFIG_SEV=$(CONFIG_KVM) CONFIG_VTD=y CONFIG_AMD_IOMMU=y CONFIG_PAM=y +CONFIG_PC=y CONFIG_I440FX=y CONFIG_Q35=y diff --git a/default-configs/lm32-softmmu.mak b/default-configs/lm32-softmmu.mak index 4049b23562..ef0f4bae72 100644 --- a/default-configs/lm32-softmmu.mak +++ b/default-configs/lm32-softmmu.mak @@ -2,7 +2,6 @@ CONFIG_LM32=y CONFIG_MILKYMIST=y -CONFIG_MILKYMIST_TMU2=$(call land,$(CONFIG_X11),$(CONFIG_OPENGL)) CONFIG_FRAMEBUFFER=y CONFIG_PTIMER=y CONFIG_PFLASH_CFI01=y diff --git a/default-configs/pci.mak b/default-configs/pci.mak index 055219030a..3d4c71d2af 100644 --- a/default-configs/pci.mak +++ b/default-configs/pci.mak @@ -47,6 +47,5 @@ CONFIG_VGA_PCI=y CONFIG_BOCHS_DISPLAY=y CONFIG_IVSHMEM_DEVICE=$(CONFIG_IVSHMEM) CONFIG_ROCKER=y -CONFIG_VFIO=$(CONFIG_LINUX) CONFIG_VFIO_PCI=y CONFIG_EDID=y diff --git a/default-configs/ppc-softmmu.mak b/default-configs/ppc-softmmu.mak index 52acb7cf39..90118cb767 100644 --- a/default-configs/ppc-softmmu.mak +++ b/default-configs/ppc-softmmu.mak @@ -18,7 +18,6 @@ CONFIG_I8259=y CONFIG_XILINX=y CONFIG_XILINX_ETHLITE=y CONFIG_E500=y -CONFIG_OPENPIC_KVM=$(call land,$(CONFIG_E500),$(CONFIG_KVM)) CONFIG_PLATFORM_BUS=y CONFIG_ETSEC=y CONFIG_PPC405=y diff --git a/default-configs/ppc64-softmmu.mak b/default-configs/ppc64-softmmu.mak index 7f34ad0528..a0a9151328 100644 --- a/default-configs/ppc64-softmmu.mak +++ b/default-configs/ppc64-softmmu.mak @@ -13,11 +13,6 @@ CONFIG_ISA_IPMI_BT=y # For pSeries CONFIG_PSERIES=y CONFIG_VIRTIO_VGA=y -CONFIG_XICS=$(CONFIG_PSERIES) -CONFIG_XICS_SPAPR=$(CONFIG_PSERIES) -CONFIG_XICS_KVM=$(call land,$(CONFIG_PSERIES),$(CONFIG_KVM)) -CONFIG_XIVE=$(CONFIG_PSERIES) -CONFIG_XIVE_SPAPR=$(CONFIG_PSERIES) CONFIG_MEM_DEVICE=y CONFIG_DIMM=y CONFIG_SPAPR_RNG=y diff --git a/default-configs/s390x-softmmu.mak b/default-configs/s390x-softmmu.mak index 6f2c6cec18..2794ffb8bd 100644 --- a/default-configs/s390x-softmmu.mak +++ b/default-configs/s390x-softmmu.mak @@ -1,12 +1,10 @@ CONFIG_PCI=y -CONFIG_VIRTIO_PCI=$(CONFIG_PCI) +CONFIG_VIRTIO_PCI=y include virtio.mak CONFIG_SCLPCONSOLE=y CONFIG_TERMINAL3270=y CONFIG_S390_FLIC=y -CONFIG_S390_FLIC_KVM=$(CONFIG_KVM) CONFIG_WDT_DIAG288=y CONFIG_S390_CCW_VIRTIO=y -CONFIG_VFIO=$(CONFIG_LINUX) CONFIG_VFIO_CCW=y CONFIG_VFIO_AP=y diff --git a/default-configs/virtio.mak b/default-configs/virtio.mak index b653aa06b1..51599ed276 100644 --- a/default-configs/virtio.mak +++ b/default-configs/virtio.mak @@ -1,5 +1,3 @@ -CONFIG_VHOST_USER_SCSI=$(CONFIG_VHOST_USER) -CONFIG_VHOST_USER_BLK=$(CONFIG_VHOST_USER) CONFIG_VIRTIO=y CONFIG_VIRTIO_9P=$(CONFIG_VIRTFS) CONFIG_VIRTIO_BALLOON=y @@ -12,4 +10,3 @@ CONFIG_VIRTIO_RNG=y CONFIG_SCSI=y CONFIG_VIRTIO_SCSI=y CONFIG_VIRTIO_SERIAL=y -CONFIG_VIRTIO_INPUT_HOST=$(CONFIG_LINUX) diff --git a/hw/9pfs/Kconfig b/hw/9pfs/Kconfig index a4750999d9..c9e244fdff 100644 --- a/hw/9pfs/Kconfig +++ b/hw/9pfs/Kconfig @@ -1,2 +1,4 @@ config VIRTIO_9P bool + default y + depends on VIRTFS diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index e4386ce78f..9eab67bddd 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -1,5 +1,6 @@ config ARM_VIRT bool + imply VFIO_PLATFORM config DIGIC bool diff --git a/hw/block/Kconfig b/hw/block/Kconfig index 9d418bce4d..65431c47f2 100644 --- a/hw/block/Kconfig +++ b/hw/block/Kconfig @@ -27,3 +27,5 @@ config VIRTIO_BLK config VHOST_USER_BLK bool + default y + depends on VHOST_USER && LINUX diff --git a/hw/display/Kconfig b/hw/display/Kconfig index d5c022c886..1149ea2bcd 100644 --- a/hw/display/Kconfig +++ b/hw/display/Kconfig @@ -51,6 +51,8 @@ config FRAMEBUFFER config MILKYMIST_TMU2 bool + default y + depends on OPENGL && X11 config SM501 bool @@ -66,6 +68,7 @@ config VGA config QXL bool + depends on SPICE && PCI config VIRTIO_GPU bool diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index c851e2b5ab..307a804349 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -1,5 +1,13 @@ config SEV bool + depends on KVM + +config PC + bool + imply QXL + imply SEV + imply TPM_CRB + imply TPM_TIS config I440FX bool diff --git a/hw/input/Kconfig b/hw/input/Kconfig index 91bae47498..c729dcd0b2 100644 --- a/hw/input/Kconfig +++ b/hw/input/Kconfig @@ -19,5 +19,10 @@ config TSC2005 config VIRTIO_INPUT bool +config VIRTIO_INPUT_HOST + bool + default y + depends on LINUX + config TSC210X bool diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig index 69adbd135f..6eea14e804 100644 --- a/hw/intc/Kconfig +++ b/hw/intc/Kconfig @@ -21,18 +21,28 @@ config APIC config ARM_GIC_KVM bool + default y + depends on ARM_GIC && KVM config OPENPIC_KVM bool + default y + depends on OPENPIC && KVM config XICS bool + default y + depends on PSERIES config XICS_SPAPR bool + default y + depends on PSERIES config XICS_KVM bool + default y + depends on XICS && KVM config ALLWINNER_A10_PIC bool @@ -42,6 +52,8 @@ config S390_FLIC config S390_FLIC_KVM bool + default y + depends on S390_FLIC && KVM config OMPIC bool diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index d5126349d9..fc068efdfd 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -48,6 +48,8 @@ config MACIO config IVSHMEM_DEVICE bool + default y + depends on PCI && LINUX && IVSHMEM config ECCMEMCTL bool diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig index 608745488a..fb085d76fd 100644 --- a/hw/ppc/Kconfig +++ b/hw/ppc/Kconfig @@ -39,6 +39,10 @@ config VIRTEX config XIVE bool + default y + depends on PSERIES config XIVE_SPAPR bool + default y + depends on PSERIES diff --git a/hw/scsi/Kconfig b/hw/scsi/Kconfig index eb78478ef0..a3518a3754 100644 --- a/hw/scsi/Kconfig +++ b/hw/scsi/Kconfig @@ -19,8 +19,15 @@ config ESP config ESP_PCI bool +config SPAPR_VSCSI + bool + default y + depends on PSERIES + config VIRTIO_SCSI bool config VHOST_USER_SCSI bool + default y + depends on VHOST_USER && LINUX diff --git a/hw/tpm/Kconfig b/hw/tpm/Kconfig index 2eee8eb865..b5d1724f8c 100644 --- a/hw/tpm/Kconfig +++ b/hw/tpm/Kconfig @@ -3,9 +3,11 @@ config TPM config TPM_TIS bool + depends on TPM config TPM_CRB bool + depends on TPM config TPM_PASSTHROUGH bool diff --git a/hw/vfio/Kconfig b/hw/vfio/Kconfig index 36069674cb..0fdff10c13 100644 --- a/hw/vfio/Kconfig +++ b/hw/vfio/Kconfig @@ -1,14 +1,21 @@ config VFIO bool + depends on LINUX config VFIO_PCI bool + select VFIO + depends on LINUX config VFIO_CCW bool + select VFIO + depends on LINUX config VFIO_PLATFORM bool + select VFIO + depends on LINUX config VFIO_XGMAC bool @@ -18,3 +25,5 @@ config VFIO_AMD_XGBE config VFIO_AP bool + select VFIO + depends on LINUX diff --git a/hw/xtensa/Kconfig b/hw/xtensa/Kconfig index 97543a9263..dc8eaf6080 100644 --- a/hw/xtensa/Kconfig +++ b/hw/xtensa/Kconfig @@ -1,5 +1,5 @@ config XTENSA_SIM bool -config XTENSA_FPGA +config XTENSA_XTFPGA bool diff --git a/rules.mak b/rules.mak index 19f3d2c126..df45bcffb4 100644 --- a/rules.mak +++ b/rules.mak @@ -144,7 +144,7 @@ cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \ cc-c-option = $(if $(shell $(CC) $1 $2 -c -o /dev/null -xc /dev/null \ >/dev/null 2>&1 && echo OK), $2, $3) -VPATH_SUFFIXES = %.c %.h %.S %.cc %.cpp %.m %.mak %.texi %.sh %.rc +VPATH_SUFFIXES = %.c %.h %.S %.cc %.cpp %.m %.mak %.texi %.sh %.rc Kconfig% set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) # install-prog list, dir diff --git a/scripts/make_device_config.sh b/scripts/make_device_config.sh deleted file mode 100644 index 354af317b3..0000000000 --- a/scripts/make_device_config.sh +++ /dev/null @@ -1,30 +0,0 @@ -#! /bin/sh -# Writes a target device config file to stdout, from a default and from -# include directives therein. Also emits Makefile dependencies. -# -# Usage: make_device_config.sh SRC DEPFILE-NAME DEPFILE-TARGET > DEST - -src=$1 -dep=$2 -target=$3 -src_dir=$(dirname $src) -all_includes= - -process_includes () { - cat $1 | grep '^include' | \ - while read include file ; do - all_includes="$all_includes $src_dir/$file" - process_includes $src_dir/$file - done -} - -f=$src -while [ -n "$f" ] ; do - f=$(cat $f | tr -d '\r' | awk '/^include / {printf "'$src_dir'/%s ", $2}') - [ $? = 0 ] || exit 1 - all_includes="$all_includes $f" -done -process_includes $src - -cat $src $all_includes | grep -v '^include' -echo "$target: $all_includes" > $dep -- cgit v1.2.3-55-g7522 From f349474920d80838ecea3d421531fdb0660b8740 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 23 Jan 2019 14:56:17 +0800 Subject: minikconfig: implement allnoconfig and defconfig modes Apart from defconfig (which is a no-op), allyesconfig/allnoconfig/randcondfig can be implemented simply by ignoring the RHS of assignments and "default" statements. The RHS is replaced respectively by "true", "false" or a random value. However, allyesconfig and randconfig do not quite work, because all the files for hw/ARCH/Kconfig are sourced and therefore you could end up enabling some ARM boards in x86 or things like that. This is left for future work, but I am leaving it in to help debugging minikconf itself. allnoconfig mode is tied to a new configure option, --without-default-devices. Signed-off-by: Paolo Bonzini --- Makefile | 1 + configure | 12 +++++++++++- scripts/minikconf.py | 39 ++++++++++++++++++++++++++++++++++----- 3 files changed, 46 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index 2b251c39d9..ba32d810ea 100644 --- a/Makefile +++ b/Makefile @@ -345,6 +345,7 @@ endif # This has to be kept in sync with Kconfig.host. MINIKCONF_ARGS = \ + $(CONFIG_MINIKCONF_MODE) \ $@ $*-config.devices.mak.d $< $(MINIKCONF_INPUTS) \ CONFIG_KVM=$(CONFIG_KVM) \ CONFIG_SPICE=$(CONFIG_SPICE) \ diff --git a/configure b/configure index 89e4a23f6c..6942b7bad4 100755 --- a/configure +++ b/configure @@ -487,7 +487,7 @@ libxml2="" docker="no" debug_mutex="no" libpmem="" -libudev="no" +default_devices="yes" # cross compilers defaults, can be overridden with --cross-cc-ARCH cross_cc_aarch64="aarch64-linux-gnu-gcc" @@ -996,6 +996,10 @@ for opt do ;; --with-trace-file=*) trace_file="$optarg" ;; + --with-default-devices) default_devices="yes" + ;; + --without-default-devices) default_devices="no" + ;; --enable-gprof) gprof="yes" ;; --enable-gcov) gcov="yes" @@ -6261,6 +6265,7 @@ echo "capstone $capstone" echo "docker $docker" echo "libpmem support $libpmem" echo "libudev $libudev" +echo "default devices $default_devices" if test "$supported_cpu" = "no"; then echo @@ -6322,6 +6327,11 @@ echo "GIT_UPDATE=$git_update" >> $config_host_mak echo "ARCH=$ARCH" >> $config_host_mak +if test "$default_devices" = "yes" ; then + echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak +else + echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak +fi if test "$debug_tcg" = "yes" ; then echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak fi diff --git a/scripts/minikconf.py b/scripts/minikconf.py index 6bedc5736e..5421db0ed0 100644 --- a/scripts/minikconf.py +++ b/scripts/minikconf.py @@ -14,9 +14,11 @@ from __future__ import print_function import os import sys import re +import random __all__ = [ 'KconfigDataError', 'KconfigParserError', - 'KconfigData', 'KconfigParser' ] + 'KconfigData', 'KconfigParser' , + 'defconfig', 'allyesconfig', 'allnoconfig', 'randconfig' ] def debug_print(*args): #print('# ' + (' '.join(str(x) for x in args))) @@ -39,6 +41,11 @@ class KconfigDataError(Exception): def __str__(self): return self.msg +allyesconfig = lambda x: True +allnoconfig = lambda x: False +defconfig = lambda x: x +randconfig = lambda x: random.randint(0, 1) == 1 + class KconfigData: class Expr: def __and__(self, rhs): @@ -192,7 +199,8 @@ class KconfigData: if self.cond.evaluate(): self.dest.set_value(True, self) - def __init__(self): + def __init__(self, value_mangler=defconfig): + self.value_mangler = value_mangler self.previously_included = [] self.incl_info = None self.defined_vars = set() @@ -272,6 +280,7 @@ class KconfigData: self.clauses.append(KconfigData.AssignmentClause(var, val)) def do_default(self, var, val, cond=None): + val = self.value_mangler(val) self.clauses.append(KconfigData.DefaultClause(var, val, cond)) def do_depends_on(self, var, expr): @@ -328,9 +337,10 @@ class KconfigParserError(Exception): return "%s: %s" % (self.loc, self.msg) class KconfigParser: + @classmethod - def parse(self, fp): - data = KconfigData() + def parse(self, fp, mode=None): + data = KconfigData(mode or KconfigParser.defconfig) parser = KconfigParser(data) parser.parse_file(fp) return data @@ -653,11 +663,30 @@ class KconfigParser: if __name__ == '__main__': argv = sys.argv + mode = defconfig + if len(sys.argv) > 1: + if argv[1] == '--defconfig': + del argv[1] + elif argv[1] == '--randconfig': + random.seed() + mode = randconfig + del argv[1] + elif argv[1] == '--allyesconfig': + mode = allyesconfig + del argv[1] + elif argv[1] == '--allnoconfig': + mode = allnoconfig + del argv[1] + if len(argv) == 1: print ("%s: at least one argument is required" % argv[0], file=sys.stderr) sys.exit(1) - data = KconfigData() + if argv[1].startswith('-'): + print ("%s: invalid option %s" % (argv[0], argv[1]), file=sys.stderr) + sys.exit(1) + + data = KconfigData(mode) parser = KconfigParser(data) for arg in argv[3:]: m = re.match(r'^(CONFIG_[A-Z0-9_]+)=([yn]?)$', arg) -- cgit v1.2.3-55-g7522