mirror of
https://github.com/drasko/codezero.git
synced 2026-01-13 19:33:15 +01:00
Added autogeneration of cinfo.c with memory capabilities
Also fixed a bug with configurator in that the containers were not sorted properly and consequently an already filled in container was getting overwritten by the new one. modified: config/configuration.py modified: configure.py new file: generate_kernel_cinfo.py deleted: src/generic/cinfo.c
This commit is contained in:
135
generate_kernel_cinfo.py
Executable file
135
generate_kernel_cinfo.py
Executable file
@@ -0,0 +1,135 @@
|
||||
#! /usr/bin/env python2.6
|
||||
# -*- mode: python; coding: utf-8; -*-
|
||||
#
|
||||
# Codezero -- a microkernel for embedded systems.
|
||||
#
|
||||
# Copyright © 2009 B Labs Ltd
|
||||
#
|
||||
import os, sys, shelve, glob
|
||||
from os.path import join
|
||||
|
||||
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 *
|
||||
|
||||
|
||||
cinfo_file_start = \
|
||||
'''/*
|
||||
* Autogenerated container descriptions
|
||||
* defined for the current build.
|
||||
*
|
||||
* Copyright (C) 2009 Bahadir Balban
|
||||
*/
|
||||
#include <l4/generic/container.h>
|
||||
#include <l4/generic/resource.h>
|
||||
#include <l4/generic/capability.h>
|
||||
#include <l4/generic/cap-types.h>
|
||||
|
||||
/*
|
||||
* FIXME:
|
||||
* Add irqs, exceptions
|
||||
*/
|
||||
|
||||
struct container_info cinfo[] = {
|
||||
'''
|
||||
cinfo_file_end = \
|
||||
'''
|
||||
};
|
||||
'''
|
||||
|
||||
cinfo_start = \
|
||||
'''
|
||||
\t[%d] = {
|
||||
\t.name = "%s",
|
||||
\t.npagers = 1,
|
||||
\t.pager = {
|
||||
'''
|
||||
|
||||
cinfo_end = \
|
||||
'''
|
||||
\t\t},
|
||||
\t},
|
||||
'''
|
||||
|
||||
pager_start = \
|
||||
'''
|
||||
\t\t[0] = {
|
||||
\t\t\t.pager_lma = __pfn(CONFIG_CONT%d_PAGER_LMA),
|
||||
\t\t\t.pager_vma = __pfn(CONFIG_CONT%d_PAGER_VMA),
|
||||
\t\t\t.pager_size = __pfn(CONFIG_CONT%d_PAGER_SIZE),
|
||||
\t\t\t.ncaps = %d,
|
||||
\t\t\t.caps = {
|
||||
'''
|
||||
pager_end = \
|
||||
'''
|
||||
\t\t\t},
|
||||
\t\t},
|
||||
'''
|
||||
|
||||
cap_virtmem = \
|
||||
'''
|
||||
\t\t\t[%d] = {
|
||||
\t\t\t\t.type = CAP_TYPE_MAP | CAP_RTYPE_VIRTMEM,
|
||||
\t\t\t\t.access = CAP_MAP_READ | CAP_MAP_WRITE
|
||||
\t\t\t\t | CAP_MAP_EXEC | CAP_MAP_UNMAP,
|
||||
\t\t\t\t.start = __pfn(CONFIG_CONT%d_VIRT%d_START),
|
||||
\t\t\t\t.end = __pfn(CONFIG_CONT%d_VIRT%d_END),
|
||||
\t\t\t\t.size = __pfn(CONFIG_CONT%d_VIRT%d_END - CONFIG_CONT%d_VIRT%d_START),
|
||||
\t\t\t},
|
||||
'''
|
||||
|
||||
cap_physmem = \
|
||||
'''
|
||||
\t\t\t[%d] = {
|
||||
\t\t\t\t.type = CAP_TYPE_MAP | CAP_RTYPE_PHYSMEM,
|
||||
\t\t\t\t.access = CAP_MAP_READ | CAP_MAP_WRITE
|
||||
\t\t\t\t | CAP_MAP_EXEC | CAP_MAP_UNMAP,
|
||||
\t\t\t\t.start = __pfn(CONFIG_CONT%d_PHYS%d_START),
|
||||
\t\t\t\t.end = __pfn(CONFIG_CONT%d_PHYS%d_END),
|
||||
\t\t\t\t.size = __pfn(CONFIG_CONT%d_PHYS%d_END - CONFIG_CONT%d_PHYS%d_START),
|
||||
\t\t\t},
|
||||
'''
|
||||
|
||||
def generate_kernel_cinfo(containers, cinfo_path):
|
||||
with open(cinfo_path, 'w+') as cinfo_file:
|
||||
fbody = cinfo_file_start
|
||||
for c in containers:
|
||||
print "Container %s: %s" % (c.id, c.name)
|
||||
# Currently only these are considered as capabilities
|
||||
total_caps = c.virt_regions + c.phys_regions
|
||||
fbody += cinfo_start % (c.id, c.name)
|
||||
fbody += pager_start % (c.id, c.id, c.id, total_caps)
|
||||
cap_index = 0
|
||||
for mem_index in range(c.virt_regions):
|
||||
fbody += cap_virtmem % \
|
||||
(cap_index, c.id, \
|
||||
mem_index, c.id, \
|
||||
mem_index, c.id, \
|
||||
mem_index, c.id, mem_index)
|
||||
cap_index += 1
|
||||
for mem_index in range(c.phys_regions):
|
||||
fbody += cap_physmem % \
|
||||
(cap_index, c.id, \
|
||||
mem_index, c.id, \
|
||||
mem_index, c.id, \
|
||||
mem_index, c.id, mem_index)
|
||||
cap_index += 1
|
||||
fbody += pager_end
|
||||
fbody += cinfo_end
|
||||
fbody += cinfo_file_end
|
||||
cinfo_file.write(fbody)
|
||||
|
||||
if __name__ == "__main__":
|
||||
config = configuration_retrieve()
|
||||
config.config_print()
|
||||
containers = config.containers
|
||||
containers.sort()
|
||||
if len(sys.argv) > 1:
|
||||
generate_kernel_cinfo(containers, join(PROJROOT, sys.argv[1]))
|
||||
else:
|
||||
generate_kernel_cinfo(containers, join(PROJROOT, 'src/generic/cinfo.c'))
|
||||
|
||||
Reference in New Issue
Block a user