Changes since April

Clean up of build directories.
Simplifications to capability model.
This commit is contained in:
Bahadir Balban
2010-06-01 15:08:13 +03:00
parent aef14b55ec
commit 6fa4884a5a
450 changed files with 10449 additions and 7383 deletions

View File

@@ -0,0 +1,40 @@
#! /usr/bin/env python2.6
# -*- mode: python; coding: utf-8; -*-
#
# Codezero -- a microkernel for embedded systems.
#
# Copyright © 2009 B Labs Ltd
#
import os, sys
from tools.pyelf.elfsize import *
from scripts.config.projpaths import *
from scripts.config.configuration import *
def get_kernel_end_address(img):
kernel_size = elf_binary_size(img)
kernel_start = get_elf_load_address(img)
return (int(kernel_start.get()) + kernel_size)
def get_container_start():
start = 0xffffffff
with open(join(PROJROOT, CONFIG_H), 'r')as file:
for line in file:
begin = line.rfind(" ")
end = len(line)
if re.search("(PHYS)([0-9]){1,4}(_START)", line) and \
start > int(line[begin : end], 16):
start = int(line[begin : end], 16)
return start
def check_kernel_container_overlap():
kernel_end = get_kernel_end_address(KERNEL_ELF)
cont_start = get_container_start()
if kernel_end > cont_start:
print '\nKernel end address = ' + str(hex(kernel_end))
print 'Container start address = ' + str(hex(cont_start)) + '\n'
return 1
return 0
if __name__ == "__main__":
check_kernel_container_overlap()

View File

@@ -10,12 +10,11 @@ from os.path import join
from string import Template
PROJRELROOT = '../..'
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT)))
sys.path.append(os.path.abspath("../"))
from config.projpaths import *
from config.configuration import *
from scripts.config.projpaths import *
from scripts.config.configuration import *
cinfo_file_start = \
@@ -34,10 +33,6 @@ cinfo_file_start = \
%s
/*
* FIXME:
* Add irqs, exceptions
*/
__initdata struct container_info cinfo[] = {
'''
@@ -46,12 +41,17 @@ cinfo_file_end = \
};
'''
cinfo_start = \
cinfo_head_start = \
'''
\t[%d] = {
\t.name = "%s",
\t.npagers = 1,
\t.pager = {
\t.ncaps = %d,
\t.caps = {'''
cinfo_caps_end = \
'''
\t},
'''
cinfo_end = \
@@ -62,15 +62,16 @@ cinfo_end = \
pager_start = \
'''
\t.pager = {
\t\t[0] = {
\t\t\t.start_address = (CONFIG_CONT%(cn)d_START_PC_ADDR),
\t\t\t.pager_lma = __pfn(CONFIG_CONT%(cn)d_PAGER_LOAD_ADDR),
\t\t\t.pager_vma = __pfn(CONFIG_CONT%(cn)d_PAGER_VIRT_ADDR),
\t\t\t.pager_size = __pfn(page_align_up(CONT%(cn)d_PAGER_MAPSIZE)),
\t\t\t.rw_sections_start = %(rw_sec_start)s,
\t\t\t.rw_sections_end = %(rw_sec_end)s,
\t\t\t.rx_sections_start = %(rx_sec_start)s,
\t\t\t.rx_sections_end = %(rx_sec_end)s,
\t\t\t.rw_pheader_start = %(rw_pheader_start)s,
\t\t\t.rw_pheader_end = %(rw_pheader_end)s,
\t\t\t.rx_pheader_start = %(rx_pheader_start)s,
\t\t\t.rx_pheader_end = %(rx_pheader_end)s,
\t\t\t.ncaps = %(caps)d,
\t\t\t.caps = {
'''
@@ -80,6 +81,7 @@ pager_end = \
\t\t},
'''
# These are pager-only. If for container, remove the PAGER part, indent down some tabs.
cap_virtmem = \
'''
\t\t\t[%(capidx)d] = {
@@ -88,9 +90,9 @@ cap_virtmem = \
\t\t\t\t.access = CAP_MAP_READ | CAP_MAP_WRITE | CAP_MAP_EXEC
\t\t\t\t\t| CAP_MAP_CACHED | CAP_MAP_UNCACHED | CAP_MAP_UNMAP | CAP_MAP_UTCB |
\t\t\t\t\tCAP_CACHE_INVALIDATE | CAP_CACHE_CLEAN,
\t\t\t\t.start = __pfn(CONFIG_CONT%(cn)d_VIRT%(vn)d_START),
\t\t\t\t.end = __pfn(CONFIG_CONT%(cn)d_VIRT%(vn)d_END),
\t\t\t\t.size = __pfn(CONFIG_CONT%(cn)d_VIRT%(vn)d_END - CONFIG_CONT%(cn)d_VIRT%(vn)d_START),
\t\t\t\t.start = __pfn(CONFIG_CONT%(cn)d_PAGER_VIRT%(vn)d_START),
\t\t\t\t.end = __pfn(CONFIG_CONT%(cn)d_PAGER_VIRT%(vn)d_END),
\t\t\t\t.size = __pfn(CONFIG_CONT%(cn)d_PAGER_VIRT%(vn)d_END - CONFIG_CONT%(cn)d_PAGER_VIRT%(vn)d_START),
\t\t\t},
'''
@@ -101,9 +103,9 @@ cap_physmem = \
\t\t\t\t.type = CAP_TYPE_MAP_PHYSMEM | CAP_RTYPE_CONTAINER,
\t\t\t\t.access = CAP_MAP_READ | CAP_MAP_WRITE | CAP_MAP_EXEC |
\t\t\t\t\tCAP_MAP_CACHED | CAP_MAP_UNCACHED | CAP_MAP_UNMAP | CAP_MAP_UTCB,
\t\t\t\t.start = __pfn(CONFIG_CONT%(cn)d_PHYS%(pn)d_START),
\t\t\t\t.end = __pfn(CONFIG_CONT%(cn)d_PHYS%(pn)d_END),
\t\t\t\t.size = __pfn(CONFIG_CONT%(cn)d_PHYS%(pn)d_END - CONFIG_CONT%(cn)d_PHYS%(pn)d_START),
\t\t\t\t.start = __pfn(CONFIG_CONT%(cn)d_PAGER_PHYS%(pn)d_START),
\t\t\t\t.end = __pfn(CONFIG_CONT%(cn)d_PAGER_PHYS%(pn)d_END),
\t\t\t\t.size = __pfn(CONFIG_CONT%(cn)d_PAGER_PHYS%(pn)d_END - CONFIG_CONT%(cn)d_PAGER_PHYS%(pn)d_START),
\t\t\t},
'''
@@ -136,6 +138,7 @@ pager_ifdefs = \
#define CONT%(cn)d_PAGER_MAPSIZE (CONT%(cn)d_PAGER_SIZE)
#endif
'''
def generate_pager_memory_ifdefs(config, containers):
pager_ifdef_string = ""
linux = 0
@@ -149,7 +152,8 @@ def generate_pager_memory_ifdefs(config, containers):
pager_ifdef_string += pager_ifdefs % { 'cn' : c.id }
return pager_ifdef_string
def generate_kernel_cinfo(config, cinfo_path):
def generate_kernel_cinfo(cinfo_path):
config = configuration_retrieve()
containers = config.containers
containers.sort()
@@ -158,40 +162,44 @@ def generate_kernel_cinfo(config, cinfo_path):
pager_ifdefs = generate_pager_memory_ifdefs(config, containers)
with open(cinfo_path, 'w+') as cinfo_file:
with open(str(cinfo_path), 'w+') as cinfo_file:
fbody = cinfo_file_start % pager_ifdefs
for c in containers:
# Currently only these are considered as capabilities
total_caps = c.virt_regions + c.phys_regions + len(c.caps)
fbody += cinfo_start % (c.id, c.name)
fbody += pager_start % { 'cn' : c.id, 'caps' : total_caps,
'rw_sec_start' : hex(c.pager_rw_section_start),
'rw_sec_end' : hex(c.pager_rw_section_end),
'rx_sec_start' : hex(c.pager_rx_section_start),
'rx_sec_end' : hex(c.pager_rx_section_end),
}
cap_index = 0
for mem_index in range(c.virt_regions):
fbody += cap_virtmem % { 'capidx' : cap_index, 'cn' : c.id, 'vn' : mem_index }
cap_index += 1
for mem_index in range(c.phys_regions):
fbody += cap_physmem % { 'capidx' : cap_index, 'cn' : c.id, 'pn' : mem_index }
cap_index += 1
for caplist in [c.caplist["CONTAINER"], c.caplist["PAGER"]]:
total_caps = caplist.virt_regions + caplist.phys_regions + len(caplist.caps)
if caplist == c.caplist["CONTAINER"]:
fbody += cinfo_head_start % (c.id, c.name, total_caps)
else:
fbody += pager_start % { 'cn' : c.id, 'caps' : total_caps,
'rw_pheader_start' : hex(c.pager_rw_pheader_start),
'rw_pheader_end' : hex(c.pager_rw_pheader_end),
'rx_pheader_start' : hex(c.pager_rx_pheader_start),
'rx_pheader_end' : hex(c.pager_rx_pheader_end),
}
cap_index = 0
for mem_index in range(caplist.virt_regions):
fbody += cap_virtmem % { 'capidx' : cap_index, 'cn' : c.id, 'vn' : mem_index }
cap_index += 1
for mem_index in range(caplist.phys_regions):
fbody += cap_physmem % { 'capidx' : cap_index, 'cn' : c.id, 'pn' : mem_index }
cap_index += 1
for capkey, capstr in c.caps.items():
templ = Template(capstr)
fbody += templ.safe_substitute(idx = cap_index)
cap_index += 1
for capkey, capstr in caplist.caps.items():
templ = Template(capstr)
fbody += templ.safe_substitute(idx = cap_index)
cap_index += 1
fbody += pager_end
fbody += cinfo_end
if caplist == c.caplist["CONTAINER"]:
fbody += cinfo_caps_end
else:
fbody += pager_end
fbody += cinfo_end
fbody += cinfo_file_end
cinfo_file.write(fbody)
if __name__ == "__main__":
config = configuration_retrieve()
if len(sys.argv) > 1:
generate_kernel_cinfo(config, join(PROJROOT, sys.argv[1]))
generate_kernel_cinfo(join(PROJROOT, sys.argv[1]))
else:
generate_kernel_cinfo(config, join(PROJROOT, 'src/generic/cinfo.c'))
generate_kernel_cinfo(KERNEL_CINFO_PATH)