From f7acdc116d651f9f0b2afac61ed91258a44a1fb7 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Sun, 13 Sep 2009 01:12:20 +0300 Subject: [PATCH] Configuration can now extract container attributes and store in container class. Configuration symbols are stored as container class attributes CML2 arm.cml has richer container parameters, lma, vma, type etc. --- config/cml/arm.cml | 2 +- config/configuration.py | 55 +++++++++++++++++++++++++++++++++++++++-- configure.py | 9 +++++++ 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/config/cml/arm.cml b/config/cml/arm.cml index be52ab3..89a3f49 100644 --- a/config/cml/arm.cml +++ b/config/cml/arm.cml @@ -145,7 +145,7 @@ CONFIG_CONT1_VIRT_START 'Container 1 virtual start address' CONFIG_CONT1_VIRT_END 'Container 1 virtual end address' -default CONFIG_CONTAINERS from 1 +default CONFIG_CONTAINERS from 2 default CONFIG_CONT0_PHYS_START from 0x40000 default CONFIG_CONT0_PHYS_END from 0x1000000 default CONFIG_CONT0_VIRT_START from 0x0 diff --git a/config/configuration.py b/config/configuration.py index 67b7d44..e199ad5 100644 --- a/config/configuration.py +++ b/config/configuration.py @@ -1,9 +1,9 @@ #! /usr/bin/env python2.6 # -*- mode: python; coding: utf-8; -*- -import os, sys, shelve, shutil +import os, sys, shelve, shutil, re from projpaths import * -class container: +class Container: name = None type = None id = None @@ -53,6 +53,57 @@ class configuration: if name[:len("CONFIG_CONTAINERS")] == "CONFIG_CONTAINERS": self.ncontainers = val + # TODO: Carry this over to Container() as static method??? + def get_container_parameter(self, id, param, val): + if param[:len("VIRT_START")] == "VIRT_START": + self.containers[id].vma_start = val + elif param[:len("VIRT_END")] == "VIRT_END": + self.containers[id].vma_end = val + elif param[:len("PHYS_START")] == "PHYS_START": + self.containers[id].lma_start = val + elif param[:len("PHYS_END")] == "PHYS_END": + self.containers[id].lma_end = val + else: + param1, param2 = param.split("_", 2) + if param1 == "TYPE": + if param2 == "LINUX": + self.containers[id].type = "linux" + elif param2 == "C0_POSIX": + self.containers[id].type = "cps" + elif param2 == "BARE": + self.containers[id].type = "bare" + + # Extract parameters for containers + def get_container_parameters(self, name, val): + matchobj = re.match(r"(CONFIG_CONT){1}([0-9]){1}(\w+)", name) + if not matchobj: + return None + + prefix, idstr, param = matchobj.groups() + id = int(idstr) + + # Create and add new container if this id was not seen + self.check_add_container(id) + + # Get rid of '_' in front + param = param[1:] + + # Check and store info on this parameter + self.get_container_parameter(id, param, val) + + def check_add_container(self, id): + for cont in self.containers: + if id == cont.id: + return + + # New container created. TODO: Pass id to constructor + container = Container() + container.id = id + self.containers.append(container) + + # Make sure elements in order for indexed accessing + self.containers.sort() + def configuration_retrieve(): # Get configuration information config_shelve = shelve.open(CONFIG_SHELVE) diff --git a/configure.py b/configure.py index a794419..33c9d2f 100755 --- a/configure.py +++ b/configure.py @@ -18,6 +18,15 @@ def cml2_header_to_symbols(cml2_header, symbols): symbols.get_subarch(name, value) symbols.get_platform(name, value) symbols.get_ncontainers(name, value) + symbols.get_container_parameters(name, value) + for cont in symbols.containers: + print "Container", cont.id + print "vma start:", cont.vma_start + print "vma end:", cont.vma_end + print "lma start:", cont.lma_start + print "lma end:", cont.lma_end + print "type:", cont.type + print "\n" def cml2_update_config_h(config_h_path, config): with open(config_h_path, "a") as config_h: