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.
This commit is contained in:
Bahadir Balban
2009-09-13 01:12:20 +03:00
parent 35097b1492
commit f7acdc116d
3 changed files with 63 additions and 3 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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: