From 202e9cab94b4c3608dba342dbc5cf576180288ba Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Thu, 10 Sep 2009 22:45:39 +0300 Subject: [PATCH] Shorter names for symbols, class symbols to contain symbol information --- configs/arm.cml | 116 ++++++++++++++++++++++++------------------------ configure.py | 88 +++++++++++++++++++++--------------- 2 files changed, 111 insertions(+), 93 deletions(-) diff --git a/configs/arm.cml b/configs/arm.cml index 360faa7..a42b57c 100644 --- a/configs/arm.cml +++ b/configs/arm.cml @@ -5,30 +5,30 @@ start main_menu ############# symbols -ARCH_ARM 'ARM' +CONFIG_ARCH_ARM 'ARM' -arm_cpu_type 'ARM Processor Type' -ARM_CPU_ARM1136 'ARM1136 - To be added' -ARM_CPU_ARM11MPCORE 'ARM11 MPCore - To be added' -ARM_CPU_ARM926 'ARM926EJ-S' -ARM_CPU_CORTEXA8 'ARM Cortex-A8 - Not supported' +arm_cpu_type 'ARM Processor Type' +CONFIG_CPU_ARM1136 'ARM1136 - To be added' +CONFIG_CPU_ARM11MPCORE 'ARM11 MPCore - To be added' +CONFIG_CPU_ARM926 'ARM926EJ-S' +CONFIG_CPU_CORTEXA8 'ARM Cortex-A8 - Not supported' -arm_subarch_type 'ARM Architecture Family' -ARM_SUBARCH_V5 'ARM v5 Architecture' -ARM_SUBARCH_V6 'ARM v6 Architecture, To be added' -ARM_SUBARCH_V7 'ARM v7 Architecture, To be added' +arm_subarch_type 'ARM Architecture Family' +CONFIG_SUBARCH_V5 'ARM v5 Architecture' +CONFIG_SUBARCH_V6 'ARM v6 Architecture, To be added' +CONFIG_SUBARCH_V7 'ARM v7 Architecture, To be added' -arm_platform_type 'ARM Platform Type' -ARM_PLATFORM_EB 'Realview EB Platform, Unsupported yet' -ARM_PLATFORM_AB926 'Versatile AB926 Platform, Unsupported yet' -ARM_PLATFORM_PB926 'Versatile PB926 Platform' -ARM_PLATFORM_PB11MPCORE 'Realview PB11MPCore Platform' -ARM_PLATFORM_PBA8 'Realview PB-A8 Platform' +arm_platform_type 'ARM Platform Type' +CONFIG_PLATFORM_EB 'Realview EB Platform, Unsupported yet' +CONFIG_PLATFORM_AB926 'Versatile AB926 Platform, Unsupported yet' +CONFIG_PLATFORM_PB926 'Versatile PB926 Platform' +CONFIG_PLATFORM_PB11MPCORE 'Realview PB11MPCore Platform' +CONFIG_PLATFORM_PBA8 'Realview PB-A8 Platform' -DRIVER_UART_PL011 'ARM UART Primecell driver PL011' -DRIVER_TIMER_SP804 'ARM Dual Timer Primecell driver SP804' -DRIVER_IRQ_PL190 'ARM Vectored Interrupt Controller PL190' -DRIVER_IRQ_GIC 'ARM Generic Interrupt Controller GIC' +CONFIG_DRIVER_UART_PL011 'ARM UART Primecell driver PL011' +CONFIG_DRIVER_TIMER_SP804 'ARM Dual Timer Primecell driver SP804' +CONFIG_DRIVER_IRQ_PL190 'ARM Vectored Interrupt Controller PL190' +CONFIG_DRIVER_IRQ_GIC 'ARM Generic Interrupt Controller GIC' main_menu 'Codezero Microkernel Configurator' arm_menu 'ARM Architecture Configuration' @@ -79,29 +79,29 @@ Physical address that this container ends # CHOICES # ############# choices arch_type - ARCH_ARM - default ARCH_ARM + CONFIG_ARCH_ARM + default CONFIG_ARCH_ARM choices arm_subarch_type - ARM_SUBARCH_V5 - ARM_SUBARCH_V6 - ARM_SUBARCH_V7 - default ARM_SUBARCH_V5 + CONFIG_SUBARCH_V5 + CONFIG_SUBARCH_V6 + CONFIG_SUBARCH_V7 + default CONFIG_SUBARCH_V5 choices arm_cpu_type - ARM_CPU_ARM926 - ARM_CPU_ARM1136 - ARM_CPU_ARM11MPCORE - ARM_CPU_CORTEXA8 - default ARM_CPU_ARM926 + CONFIG_CPU_ARM926 + CONFIG_CPU_ARM1136 + CONFIG_CPU_ARM11MPCORE + CONFIG_CPU_CORTEXA8 + default CONFIG_CPU_ARM926 choices arm_platform_type - ARM_PLATFORM_EB - ARM_PLATFORM_AB926 - ARM_PLATFORM_PB926 - ARM_PLATFORM_PB11MPCORE - ARM_PLATFORM_PBA8 - default ARM_PLATFORM_PB926 + CONFIG_PLATFORM_EB + CONFIG_PLATFORM_AB926 + CONFIG_PLATFORM_PB926 + CONFIG_PLATFORM_PB11MPCORE + CONFIG_PLATFORM_PBA8 + default CONFIG_PLATFORM_PB926 ############# # MENUS # @@ -123,10 +123,10 @@ menu arm_platform_menu arm_platform_type menu drivers_menu - DRIVER_UART_PL011 - DRIVER_TIMER_SP804 - DRIVER_IRQ_PL190 - DRIVER_IRQ_GIC + CONFIG_DRIVER_UART_PL011 + CONFIG_DRIVER_TIMER_SP804 + CONFIG_DRIVER_IRQ_PL190 + CONFIG_DRIVER_IRQ_GIC menu arm_menu arm_subarch_type @@ -145,31 +145,31 @@ menu main_menu ############# #Platform rules: -unless ARM_SUBARCH_V5 suppress ARM_PLATFORM_PB926 -unless ARM_SUBARCH_V5 suppress ARM_PLATFORM_AB926 -unless ARM_SUBARCH_V6 suppress ARM_PLATFORM_PB11MPCORE -unless ARM_SUBARCH_V7 suppress ARM_PLATFORM_PBA8 +unless CONFIG_SUBARCH_V5 suppress CONFIG_PLATFORM_PB926 +unless CONFIG_SUBARCH_V5 suppress CONFIG_PLATFORM_AB926 +unless CONFIG_SUBARCH_V6 suppress CONFIG_PLATFORM_PB11MPCORE +unless CONFIG_SUBARCH_V7 suppress CONFIG_PLATFORM_PBA8 #CPU rules: -unless ARM_SUBARCH_V5 suppress ARM_CPU_ARM926 -unless ARM_SUBARCH_V6 suppress ARM_CPU_ARM1136 -unless ARM_SUBARCH_V6 suppress ARM_CPU_ARM11MPCORE -unless ARM_SUBARCH_V7 suppress ARM_CPU_CORTEXA8 +unless CONFIG_SUBARCH_V5 suppress CONFIG_CPU_ARM926 +unless CONFIG_SUBARCH_V6 suppress CONFIG_CPU_ARM1136 +unless CONFIG_SUBARCH_V6 suppress CONFIG_CPU_ARM11MPCORE +unless CONFIG_SUBARCH_V7 suppress CONFIG_CPU_CORTEXA8 # NOTE: Unlike menus, choices dont take { sym } model of visibility # dependencies. Instead, a choice symbol is declared in a menu, and # suppress statement is used to make sym visible, instead of a # { sym } model under the choices. (See manual for { sym } usage). -unless ARM_SUBARCH_V5 suppress ARM_PLATFORM_PB926 -unless ARCH_ARM suppress arm_menu -unless ARM_PLATFORM_PB926 or ARM_PLATFORM_AB926 suppress DRIVER_IRQ_PL190 -unless ARM_PLATFORM_EB suppress ARM_CPU_ARM1136 -unless ARM_PLATFORM_EB or ARM_PLATFORM_PBA8 or ARM_PLATFORM_PB11MPCORE suppress DRIVER_IRQ_GIC -default DRIVER_UART_PL011 from y -default DRIVER_TIMER_SP804 from y -default DRIVER_IRQ_PL190 from y -default DRIVER_IRQ_GIC from y +unless CONFIG_SUBARCH_V5 suppress CONFIG_PLATFORM_PB926 +unless CONFIG_ARCH_ARM suppress arm_menu +unless CONFIG_PLATFORM_PB926 or CONFIG_PLATFORM_AB926 suppress CONFIG_DRIVER_IRQ_PL190 +unless CONFIG_PLATFORM_EB suppress CONFIG_CPU_ARM1136 +unless CONFIG_PLATFORM_EB or CONFIG_PLATFORM_PBA8 or CONFIG_PLATFORM_PB11MPCORE suppress CONFIG_DRIVER_IRQ_GIC +default CONFIG_DRIVER_UART_PL011 from y +default CONFIG_DRIVER_TIMER_SP804 from y +default CONFIG_DRIVER_IRQ_PL190 from y +default CONFIG_DRIVER_IRQ_GIC from y # Container Rules default CONFIG_CONTAINERS from 1 diff --git a/configure.py b/configure.py index 284f8ba..e12e334 100755 --- a/configure.py +++ b/configure.py @@ -16,6 +16,7 @@ CONFIG_DATA_DIR = join(BUILDDIR, "configdata") CONFIG_DATA_FILENAME = "configuration" CONFIG_DATA = join(CONFIG_DATA_DIR, CONFIG_DATA_FILENAME) configuration = {} +config_data = {} def save_configuration(configuration): if not os.path.exists(CONFIG_DATA_DIR): @@ -25,14 +26,55 @@ def save_configuration(configuration): config_shelve["cml2_config"] = configuration config_shelve.close() -def cml2_process(cml2_conf_props): - config_items = {} - with file(cml2_conf_props) as config_file: - for line in config_file: - item = line.split('=') - if len(item) == 2: - config_items[item[0].strip()] = (item[1].strip() == 'y') - return config_items +''' +def cml2_parse_config_symbol(name, value): + sname, sval = line.split('=') + if len(config_sym_pair) == 2: # This means it is a valid symbol + cml2_parse_config_symbol(name, value) + config, rest = name.split("_", 1) + print symparts +''' + +class config_symbols: + arch = None + subarch = None + platform = None + kbuild = [] + all = [] + + # Get all name value symbols + def get_all(self, name, val): + self.all.append([name, val]) + + # Convert line to name value pair, if possible + def line_to_name_value(self, line): + parts = line.split() + if len(parts) > 0: + if parts[0] == "#define": + return parts[1], parts[2] + return None + + # Extract architecture from a name value pair + def get_arch(self, name, val): + if name[:len("CONFIG_ARCH_")] == "CONFIG_ARCH_": + parts = name.split("_", 3) + print parts + self.arch = parts[2].lower() + + +symbols = config_symbols() + +def cml2_header_to_symbols(cml2_header): + with file(cml2_header) as header_file: + for line in header_file: + pair = symbols.line_to_name_value(line) + if pair is not None: + print pair + name, value = pair + symbols.get_all(name,value) + symbols.get_arch(name,value) + print symbols.all + print symbols.arch def cml2_update_config_h(configuration): config_h_path = BUILDDIR + '/l4/config.h' @@ -41,26 +83,6 @@ def cml2_update_config_h(configuration): config_h.write("#define __PLATFORM__ " + configuration['PLATFORM'] + '\n') config_h.write("#define __SUBARCH__ " + configuration['SUBARCH'] + '\n') -def cml2_parse_configuration(configuration, config_data): - for key, value in config_data.items(): - if value: - items = key.split('_') - if items[0] == 'ARCH': - configuration['ARCH'] = items[1].lower() - for key, value in config_data.items(): - if value: - items = key.split('_') - if items[0] == 'ARCH': continue - if items[0] == configuration['ARCH'].upper(): - configuration[items[1]] = items[2].lower() - else: - path = items[1].lower() + '/' + items[2].lower() - try: - configuration[items[0]] - except KeyError: - configuration[items[0]] = [] - configuration[items[0]].append(path) - def cml2_configure(cml2_config_file): os.system(CML2TOOLSDIR + '/cmlcompile.py -o ' + CML2RULES + ' ' + cml2_config_file) os.system(CML2TOOLSDIR + '/cmlconfigure.py -c -o ' + CML2_CONFIG_PROPERTIES + ' ' + CML2RULES) @@ -74,13 +96,9 @@ def configure_kernel(cml_file): os.mkdir(BUILDDIR) cml2_configure(cml_file) - - config_data = cml2_process(CML2_CONFIG_PROPERTIES) - - cml2_parse_configuration(configuration, config_data) - - cml2_update_config_h(configuration) - + cml2_header_to_symbols(CML2_CONFIG_H) + #cml2_parse_config_data(configuration, config_data) + #cml2_update_config_h(configuration) save_configuration(configuration) return configuration