diff --git a/build.py b/build.py index 23b8e16..0f39762 100755 --- a/build.py +++ b/build.py @@ -13,6 +13,8 @@ from config.projpaths import * from config.configuration import * from scripts.conts import containers from configure import * +from optparse import OptionParser +from scripts.cml.generate_container_cml import * # NOTE: # The scripts obtain all the configuration data (a set of class @@ -20,10 +22,43 @@ from configure import * # any arguments here. def main(): + autogen_true = 0 + usage = "usage: %prog [options] arg" + parser = OptionParser(usage) + + parser.add_option("-a", "--arch", type = "string", dest = "arch", + help = "Use configuration file for architecture") + parser.add_option("-c", "--num-containers", type = "int", dest = "ncont", + help = "Maximum number of containers available in configuration") + parser.add_option("-f", "--use-file", dest = "cml_file", + help = "Supply user-defined cml file" + "(Use only if you want to override default)") + parser.add_option("-w", "--wipeout-old-config", action = "store_true", + default = False, dest = "wipeout", + help = "Wipe out existing configuration file settings") + + (options, args) = parser.parse_args() + + autogen_true = len(sys.argv) > 1 or not os.path.exists(CML2_CML_FILE) + + if autogen_true and not options.arch: + print "No arch supplied (-a), using `arm' as default." + options.arch = "arm" + if autogen_true and not options.ncont: + options.ncont = 4 + print "Max container count not supplied (-c), using %d as default." % options.ncont + + # Regenerate cml file if options are supplied or the file doesn't exist. + if autogen_true: + generate_container_cml(options.arch, options.ncont) + if options.wipeout == 1 and os.path.exists(CML2_OLDCONFIG_FILE): + print "Deleting %s" % CML2_OLDCONFIG_FILE + os.remove(CML2_OLDCONFIG_FILE) + # # Configure # - configure_kernel(join(CML2_CONFIG_SRCDIR, 'arm.cml')) + configure_kernel(CML2_CML_FILE) # # Build the kernel diff --git a/config/cml/arm.cml b/config/cml/arm.cml index b172b10..2e0ec73 100644 --- a/config/cml/arm.cml +++ b/config/cml/arm.cml @@ -5,20 +5,20 @@ start main_menu ############# symbols -ARCH_ARM 'ARM' +ARCH_ARM 'ARM' -arm_cpu_type 'ARM Processor Type' +arm_cpu_type 'ARM Processor Type' CPU_ARM1136 'ARM1136 - To be added' CPU_ARM11MPCORE 'ARM11 MPCore - To be added' CPU_ARM926 'ARM926EJ-S' CPU_CORTEXA8 'ARM Cortex-A8 - Not supported' -arm_subarch_type 'ARM Architecture Family' +arm_subarch_type 'ARM Architecture Family' SUBARCH_V5 'ARM v5 Architecture' SUBARCH_V6 'ARM v6 Architecture, To be added' SUBARCH_V7 'ARM v7 Architecture, To be added' -arm_platform_type 'ARM Platform Type' +arm_platform_type 'ARM Platform Type' PLATFORM_EB 'Realview EB Platform, Unsupported yet' PLATFORM_AB926 'Versatile AB926 Platform, Unsupported yet' PLATFORM_PB926 'Versatile PB926 Platform' @@ -27,7 +27,7 @@ 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_PL190 'ARM Vectored Interrupt Controller PL190' DRIVER_IRQ_GIC 'ARM Generic Interrupt Controller GIC' main_menu 'Codezero Microkernel Configurator' @@ -35,8 +35,11 @@ arm_menu 'ARM Architecture Configuration' arm_cpu_menu 'ARM CPU type' arm_platform_menu 'ARM Platform Type' drivers_menu 'Platform Drivers' +containers_menu 'Container Setup' arch_type 'Main architecture' +CONTAINERS 'Number of containers' + ############# # CHOICES # ############# @@ -125,350 +128,6 @@ default DRIVER_TIMER_SP804 from y default DRIVER_IRQ_PL190 from y default DRIVER_IRQ_GIC from y -# Container Rules -symbols -CONTAINERS 'Number of containers' -CONT0_TYPE_LINUX 'Linux Container' -CONT0_TYPE_BARE 'Bare Container' -CONT0_TYPE_C0_POSIX 'Codezero POSIX Services Container (mm0, fs0 microkernel services)' -CONT0_OPT_DIRNAME 'Containers directory name under conts' - -CONT0_PHYSMEM_REGIONS 'Container 0 number of physical regions' -CONT0_PHYS0_START 'Container 0 physical start address' -CONT0_PHYS0_END 'Container 0 physical end address' -CONT0_PHYS1_START 'Container 0 physical start address' -CONT0_PHYS1_END 'Container 0 physical end address' -CONT0_PHYS2_START 'Container 0 physical start address' -CONT0_PHYS2_END 'Container 0 physical end address' -CONT0_PHYS3_START 'Container 0 physical start address' -CONT0_PHYS3_END 'Container 0 physical end address' - -CONT0_VIRTMEM_REGIONS 'Container 0 number of virtual regions' -CONT0_VIRT0_START 'Container 0 virtual start address' -CONT0_VIRT0_END 'Container 0 virtual end address' -CONT0_VIRT1_START 'Container 0 virtual start address' -CONT0_VIRT1_END 'Container 0 virtual end address' -CONT0_VIRT2_START 'Container 0 virtual start address' -CONT0_VIRT2_END 'Container 0 virtual end address' -CONT0_VIRT3_START 'Container 0 virtual start address' -CONT0_VIRT3_END 'Container 0 virtual end address' -CONT0_VIRT4_START 'Container 0 virtual start address' -CONT0_VIRT4_END 'Container 0 virtual end address' -CONT0_VIRT5_START 'Container 0 virtual start address' -CONT0_VIRT5_END 'Container 0 virtual end address' - - -CONT1_TYPE_LINUX 'Linux Container' -CONT1_TYPE_BARE 'Bare Container' -CONT1_TYPE_C0_POSIX 'Codezero POSIX Services Container (mm0, fs0 microkernel services)' -CONT1_OPT_DIRNAME 'Containers directory name under conts' - -CONT1_PHYSMEM_REGIONS 'Container 1 number of physical regions' -CONT1_PHYS0_START 'Container 1 physical start address' -CONT1_PHYS0_END 'Container 1 physical end address' -CONT1_PHYS1_START 'Container 1 physical start address' -CONT1_PHYS1_END 'Container 1 physical end address' -CONT1_PHYS2_START 'Container 1 physical start address' -CONT1_PHYS2_END 'Container 1 physical end address' -CONT1_PHYS3_START 'Container 1 physical start address' -CONT1_PHYS3_END 'Container 1 physical end address' - -CONT1_VIRTMEM_REGIONS 'Container 1 number of virtual regions' -CONT1_VIRT0_START 'Container 1 virtual start address' -CONT1_VIRT0_END 'Container 1 virtual end address' -CONT1_VIRT1_START 'Container 1 virtual start address' -CONT1_VIRT1_END 'Container 1 virtual end address' -CONT1_VIRT2_START 'Container 1 virtual start address' -CONT1_VIRT2_END 'Container 1 virtual end address' -CONT1_VIRT3_START 'Container 1 virtual start address' -CONT1_VIRT3_END 'Container 1 virtual end address' -CONT1_VIRT4_START 'Container 1 virtual start address' -CONT1_VIRT4_END 'Container 1 virtual end address' -CONT1_VIRT5_START 'Container 1 virtual start address' -CONT1_VIRT5_END 'Container 1 virtual end address' - -CONT0_PAGER_LMA 'Container 0 Pager LMA' -CONT0_PAGER_VMA 'Container 0 Pager VMA' -CONT0_PAGER_SIZE 'Container 0 Pager Initial map size (Optional)' -CONT0_LINUX_PAGE_OFFSET 'Container 0 Linux PAGE_OFFSET parameter' -CONT0_LINUX_TEXT_OFFSET 'Container 0 Linux TEXT_OFFSET parameter' -CONT0_LINUX_PHYS_OFFSET 'Container 0 Linux PHYS_OFFSET parameter' -CONT0_LINUX_MAPSIZE 'Container 0 Linux Initial kernel map size parameter' - -CONT1_PAGER_LMA 'Container 1 Pager LMA' -CONT1_PAGER_VMA 'Container 1 Pager VMA' -CONT1_PAGER_SIZE 'Container 1 Pager Initial map size (Optional)' -CONT1_LINUX_PAGE_OFFSET 'Container 1 Linux PAGE_OFFSET parameter' -CONT1_LINUX_TEXT_OFFSET 'Container 1 Linux TEXT_OFFSET parameter' -CONT1_LINUX_PHYS_OFFSET 'Container 1 Linux PHYS_OFFSET parameter' -CONT1_LINUX_MAPSIZE 'Container 1 Linux Initial kernel map size parameter' - - -default CONT0_PAGER_LMA from 0x0 -default CONT0_PAGER_VMA from 0x0 -default CONT0_PAGER_SIZE from 0x0 -default CONT0_LINUX_PAGE_OFFSET from 0x0 -default CONT0_LINUX_TEXT_OFFSET from 0x0 -default CONT0_LINUX_PHYS_OFFSET from 0x0 -default CONT0_LINUX_MAPSIZE from 0x0 - -default CONT1_PAGER_LMA from 0x0 -default CONT1_PAGER_VMA from 0x0 -default CONT1_PAGER_SIZE from 0x0 -default CONT1_LINUX_PAGE_OFFSET from 0x0 -default CONT1_LINUX_TEXT_OFFSET from 0x0 -default CONT1_LINUX_PHYS_OFFSET from 0x0 -default CONT1_LINUX_MAPSIZE from 0x0 - -default CONTAINERS from 2 - -default CONT0_VIRTMEM_REGIONS from 1 -default CONT0_PHYSMEM_REGIONS from 1 -default CONT1_VIRTMEM_REGIONS from 1 -default CONT1_PHYSMEM_REGIONS from 1 - -# Define limits on virtual and physical memory regions of a _single_ container 0. Too much code! -when CONT0_VIRTMEM_REGIONS < 2 suppress CONT0_VIRT1_START CONT0_VIRT1_END -when CONT0_VIRTMEM_REGIONS < 2 suppress CONT0_VIRT2_START CONT0_VIRT2_END -when CONT0_VIRTMEM_REGIONS < 2 suppress CONT0_VIRT3_START CONT0_VIRT3_END -when CONT0_VIRTMEM_REGIONS < 2 suppress CONT0_VIRT4_START CONT0_VIRT4_END -when CONT0_VIRTMEM_REGIONS < 2 suppress CONT0_VIRT5_START CONT0_VIRT5_END - -when CONT0_VIRTMEM_REGIONS < 3 suppress CONT0_VIRT2_START CONT0_VIRT2_END -when CONT0_VIRTMEM_REGIONS < 3 suppress CONT0_VIRT3_START CONT0_VIRT3_END -when CONT0_VIRTMEM_REGIONS < 3 suppress CONT0_VIRT4_START CONT0_VIRT4_END -when CONT0_VIRTMEM_REGIONS < 3 suppress CONT0_VIRT5_START CONT0_VIRT5_END - -when CONT0_VIRTMEM_REGIONS < 4 suppress CONT0_VIRT3_START CONT0_VIRT3_END -when CONT0_VIRTMEM_REGIONS < 4 suppress CONT0_VIRT4_START CONT0_VIRT4_END -when CONT0_VIRTMEM_REGIONS < 4 suppress CONT0_VIRT5_START CONT0_VIRT5_END - -when CONT0_VIRTMEM_REGIONS < 5 suppress CONT0_VIRT4_START CONT0_VIRT4_END -when CONT0_VIRTMEM_REGIONS < 5 suppress CONT0_VIRT5_START CONT0_VIRT5_END - -when CONT0_VIRTMEM_REGIONS < 6 suppress CONT0_VIRT5_START CONT0_VIRT5_END - -when CONT0_PHYSMEM_REGIONS < 2 suppress CONT0_PHYS1_START CONT0_PHYS1_END -when CONT0_PHYSMEM_REGIONS < 2 suppress CONT0_PHYS2_START CONT0_PHYS2_END -when CONT0_PHYSMEM_REGIONS < 2 suppress CONT0_PHYS3_START CONT0_PHYS3_END -when CONT0_PHYSMEM_REGIONS < 3 suppress CONT0_PHYS2_START CONT0_PHYS2_END -when CONT0_PHYSMEM_REGIONS < 3 suppress CONT0_PHYS3_START CONT0_PHYS3_END -when CONT0_PHYSMEM_REGIONS < 4 suppress CONT0_PHYS3_START CONT0_PHYS3_END - - -# Define limits on virtual and physical memory regions of a _single_ container 0. Too much code! -when CONT1_VIRTMEM_REGIONS < 2 suppress CONT1_VIRT1_START CONT1_VIRT1_END -when CONT1_VIRTMEM_REGIONS < 2 suppress CONT1_VIRT2_START CONT1_VIRT2_END -when CONT1_VIRTMEM_REGIONS < 2 suppress CONT1_VIRT3_START CONT1_VIRT3_END -when CONT1_VIRTMEM_REGIONS < 2 suppress CONT1_VIRT4_START CONT1_VIRT4_END -when CONT1_VIRTMEM_REGIONS < 2 suppress CONT1_VIRT5_START CONT1_VIRT5_END - -when CONT1_VIRTMEM_REGIONS < 3 suppress CONT1_VIRT2_START CONT1_VIRT2_END -when CONT1_VIRTMEM_REGIONS < 3 suppress CONT1_VIRT3_START CONT1_VIRT3_END -when CONT1_VIRTMEM_REGIONS < 3 suppress CONT1_VIRT4_START CONT1_VIRT4_END -when CONT1_VIRTMEM_REGIONS < 3 suppress CONT1_VIRT5_START CONT1_VIRT5_END - -when CONT1_VIRTMEM_REGIONS < 4 suppress CONT1_VIRT3_START CONT1_VIRT3_END -when CONT1_VIRTMEM_REGIONS < 4 suppress CONT1_VIRT4_START CONT1_VIRT4_END -when CONT1_VIRTMEM_REGIONS < 4 suppress CONT1_VIRT5_START CONT1_VIRT5_END - -when CONT1_VIRTMEM_REGIONS < 5 suppress CONT1_VIRT4_START CONT1_VIRT4_END -when CONT1_VIRTMEM_REGIONS < 5 suppress CONT1_VIRT5_START CONT1_VIRT5_END - -when CONT1_VIRTMEM_REGIONS < 6 suppress CONT1_VIRT5_START CONT1_VIRT5_END - -when CONT1_PHYSMEM_REGIONS < 2 suppress CONT1_PHYS1_START CONT1_PHYS1_END -when CONT1_PHYSMEM_REGIONS < 2 suppress CONT1_PHYS2_START CONT1_PHYS2_END -when CONT1_PHYSMEM_REGIONS < 2 suppress CONT1_PHYS3_START CONT1_PHYS3_END -when CONT1_PHYSMEM_REGIONS < 3 suppress CONT1_PHYS2_START CONT1_PHYS2_END -when CONT1_PHYSMEM_REGIONS < 3 suppress CONT1_PHYS3_START CONT1_PHYS3_END -when CONT1_PHYSMEM_REGIONS < 4 suppress CONT1_PHYS3_START CONT1_PHYS3_END - -default CONT0_PHYS0_START from 0x0 -default CONT0_PHYS0_END from 0x0 -default CONT0_PHYS1_START from 0x0 -default CONT0_PHYS1_END from 0x0 -default CONT0_PHYS2_START from 0x0 -default CONT0_PHYS2_END from 0x0 -default CONT0_PHYS3_START from 0x0 -default CONT0_PHYS3_END from 0x0 - -default CONT0_VIRT0_START from 0x0 -default CONT0_VIRT0_END from 0x0 -default CONT0_VIRT1_START from 0x0 -default CONT0_VIRT1_END from 0x0 -default CONT0_VIRT2_START from 0x0 -default CONT0_VIRT2_END from 0x0 -default CONT0_VIRT3_START from 0x0 -default CONT0_VIRT3_END from 0x0 -default CONT0_VIRT4_START from 0x0 -default CONT0_VIRT4_END from 0x0 -default CONT0_VIRT5_START from 0x0 -default CONT0_VIRT5_END from 0x0 - - -default CONT1_PHYS0_START from 0x0 -default CONT1_PHYS0_END from 0x0 -default CONT1_PHYS1_START from 0x0 -default CONT1_PHYS1_END from 0x0 -default CONT1_PHYS2_START from 0x0 -default CONT1_PHYS2_END from 0x0 -default CONT1_PHYS3_START from 0x0 -default CONT1_PHYS3_END from 0x0 - -default CONT1_VIRT0_START from 0x0 -default CONT1_VIRT0_END from 0x0 -default CONT1_VIRT1_START from 0x0 -default CONT1_VIRT1_END from 0x0 -default CONT1_VIRT2_START from 0x0 -default CONT1_VIRT2_END from 0x0 -default CONT1_VIRT3_START from 0x0 -default CONT1_VIRT3_END from 0x0 -default CONT1_VIRT4_START from 0x0 -default CONT1_VIRT4_END from 0x0 -default CONT1_VIRT5_START from 0x0 -default CONT1_VIRT5_END from 0x0 - -default CONT0_OPT_DIRNAME from (CONT0_TYPE_LINUX==y) ? "linux" : ((CONT0_TYPE_BARE==y) ? "bare" : "noname") -default CONT1_OPT_DIRNAME from (CONT1_TYPE_LINUX==y) ? "linux" : ((CONT1_TYPE_BARE==y) ? "bare" : "noname") - -unless CONTAINERS > 1 suppress cont1_menu -require CONTAINERS < 2 implies cont1_menu==n - -when CONT0_TYPE_LINUX==y suppress cont0_bare_pager_params -when CONT0_TYPE_BARE==y suppress cont0_linux_pager_params -when CONT1_TYPE_LINUX==y suppress cont1_bare_pager_params -when CONT1_TYPE_BARE==y suppress cont1_linux_pager_params - -symbols -containers_menu 'Configure Containers' -cont0_menu 'Container 0 Parameters' -cont1_menu 'Container 1 Parameters' -cont0_physmem_list 'Container 0 physical memory regions' -cont1_physmem_list 'Container 1 physical memory regions' -cont0_virtmem_list 'Container 0 Virtual memory regions' -cont1_virtmem_list 'Container 1 Virtual memory regions' -container0_type 'Container 0 Type' -container1_type 'Container 1 Type' -container0_options 'Container 0 Options' -container1_options 'Container 1 Options' - -cont0_linux_pager_params 'Container 0 Pager parameters' -cont0_bare_pager_params 'Container 0 Pager parameters' -cont1_linux_pager_params 'Container 1 Pager parameters' -cont1_bare_pager_params 'Container 1 Pager parameters' - -menu cont0_bare_pager_params - CONT0_PAGER_LMA@ - CONT0_PAGER_VMA@ - CONT0_PAGER_SIZE@ - -menu cont0_linux_pager_params - CONT0_LINUX_PAGE_OFFSET@ - CONT0_LINUX_TEXT_OFFSET@ - CONT0_LINUX_PHYS_OFFSET@ - CONT0_LINUX_MAPSIZE@ - -menu cont1_bare_pager_params - CONT1_PAGER_LMA@ - CONT1_PAGER_VMA@ - CONT1_PAGER_SIZE@ - -menu cont1_linux_pager_params - CONT1_LINUX_PAGE_OFFSET@ - CONT1_LINUX_TEXT_OFFSET@ - CONT1_LINUX_PHYS_OFFSET@ - CONT1_LINUX_MAPSIZE@ - -menu cont0_physmem_list - CONT0_PHYSMEM_REGIONS% - CONT0_PHYS0_START@ - CONT0_PHYS0_END@ - CONT0_PHYS1_START@ - CONT0_PHYS1_END@ - CONT0_PHYS2_START@ - CONT0_PHYS2_END@ - CONT0_PHYS3_START@ - CONT0_PHYS3_END@ - -menu cont1_physmem_list - CONT1_PHYSMEM_REGIONS% - CONT1_PHYS0_START@ - CONT1_PHYS0_END@ - CONT1_PHYS1_START@ - CONT1_PHYS1_END@ - CONT1_PHYS2_START@ - CONT1_PHYS2_END@ - CONT1_PHYS3_START@ - CONT1_PHYS3_END@ - -menu cont0_virtmem_list - CONT0_VIRTMEM_REGIONS% - CONT0_VIRT0_START@ - CONT0_VIRT0_END@ - CONT0_VIRT1_START@ - CONT0_VIRT1_END@ - CONT0_VIRT2_START@ - CONT0_VIRT2_END@ - CONT0_VIRT3_START@ - CONT0_VIRT3_END@ - CONT0_VIRT4_START@ - CONT0_VIRT4_END@ - CONT0_VIRT5_START@ - CONT0_VIRT5_END@ - -menu cont1_virtmem_list - CONT1_VIRTMEM_REGIONS% - CONT1_VIRT0_START@ - CONT1_VIRT0_END@ - CONT1_VIRT1_START@ - CONT1_VIRT1_END@ - CONT1_VIRT2_START@ - CONT1_VIRT2_END@ - CONT1_VIRT3_START@ - CONT1_VIRT3_END@ - CONT1_VIRT4_START@ - CONT1_VIRT4_END@ - CONT1_VIRT5_START@ - CONT1_VIRT5_END@ - -menu container0_options - CONT0_OPT_DIRNAME$ - cont0_linux_pager_params - cont0_bare_pager_params - cont0_physmem_list - cont0_virtmem_list - -menu container1_options - CONT1_OPT_DIRNAME$ - cont1_linux_pager_params - cont1_bare_pager_params - cont1_physmem_list - cont1_virtmem_list - -choices container0_type - CONT0_TYPE_LINUX - CONT0_TYPE_BARE - CONT0_TYPE_C0_POSIX - default CONT0_TYPE_LINUX - -choices container1_type - CONT1_TYPE_LINUX - CONT1_TYPE_BARE - CONT1_TYPE_C0_POSIX - default CONT1_TYPE_BARE - -menu cont0_menu - container0_type - container0_options - -menu cont1_menu - container1_type - container1_options - -menu containers_menu - cont0_menu - cont1_menu prefix CONFIG_ diff --git a/config/cml/container.template.cml b/config/cml/container.template.cml new file mode 100644 index 0000000..f0852f6 --- /dev/null +++ b/config/cml/container.template.cml @@ -0,0 +1,168 @@ +symbols +CONT%d_TYPE_LINUX 'Linux Container' +CONT%d_TYPE_BARE 'Bare Container' +CONT%d_TYPE_C0_POSIX 'Codezero POSIX Services Container (mm0, fs0 microkernel services)' +CONT%d_OPT_DIRNAME 'Containers directory name under conts' + +CONT%d_PHYSMEM_REGIONS 'Container %d number of physical regions' +CONT%d_PHYS0_START 'Container %d physical start address' +CONT%d_PHYS0_END 'Container %d physical end address' +CONT%d_PHYS1_START 'Container %d physical start address' +CONT%d_PHYS1_END 'Container %d physical end address' +CONT%d_PHYS2_START 'Container %d physical start address' +CONT%d_PHYS2_END 'Container %d physical end address' +CONT%d_PHYS3_START 'Container %d physical start address' +CONT%d_PHYS3_END 'Container %d physical end address' + +CONT%d_VIRTMEM_REGIONS 'Container %d number of virtual regions' +CONT%d_VIRT0_START 'Container %d virtual start address' +CONT%d_VIRT0_END 'Container %d virtual end address' +CONT%d_VIRT1_START 'Container %d virtual start address' +CONT%d_VIRT1_END 'Container %d virtual end address' +CONT%d_VIRT2_START 'Container %d virtual start address' +CONT%d_VIRT2_END 'Container %d virtual end address' +CONT%d_VIRT3_START 'Container %d virtual start address' +CONT%d_VIRT3_END 'Container %d virtual end address' +CONT%d_VIRT4_START 'Container %d virtual start address' +CONT%d_VIRT4_END 'Container %d virtual end address' +CONT%d_VIRT5_START 'Container %d virtual start address' +CONT%d_VIRT5_END 'Container %d virtual end address' + +CONT%d_PAGER_LMA 'Container %d Pager LMA' +CONT%d_PAGER_VMA 'Container %d Pager VMA' +CONT%d_PAGER_SIZE 'Container %d Pager Initial map size (Optional)' +CONT%d_LINUX_PAGE_OFFSET 'Container %d Linux PAGE_OFFSET parameter' +CONT%d_LINUX_TEXT_OFFSET 'Container %d Linux TEXT_OFFSET parameter' +CONT%d_LINUX_PHYS_OFFSET 'Container %d Linux PHYS_OFFSET parameter' +CONT%d_LINUX_MAPSIZE 'Container %d Linux Initial kernel map size parameter' + +default CONT%d_PAGER_LMA from 0x0 +default CONT%d_PAGER_VMA from 0x0 +default CONT%d_PAGER_SIZE from 0x0 +default CONT%d_LINUX_PAGE_OFFSET from 0x0 +default CONT%d_LINUX_TEXT_OFFSET from 0x0 +default CONT%d_LINUX_PHYS_OFFSET from 0x0 +default CONT%d_LINUX_MAPSIZE from 0x0 + +default CONT%d_VIRTMEM_REGIONS from 1 +default CONT%d_PHYSMEM_REGIONS from 1 + +# Define limits on virtual and physical memory regions of a _single_ container 0. Too much code! +when CONT%d_VIRTMEM_REGIONS < 2 suppress CONT%d_VIRT1_START CONT%d_VIRT1_END +when CONT%d_VIRTMEM_REGIONS < 2 suppress CONT%d_VIRT2_START CONT%d_VIRT2_END +when CONT%d_VIRTMEM_REGIONS < 2 suppress CONT%d_VIRT3_START CONT%d_VIRT3_END +when CONT%d_VIRTMEM_REGIONS < 2 suppress CONT%d_VIRT4_START CONT%d_VIRT4_END +when CONT%d_VIRTMEM_REGIONS < 2 suppress CONT%d_VIRT5_START CONT%d_VIRT5_END + +when CONT%d_VIRTMEM_REGIONS < 3 suppress CONT%d_VIRT2_START CONT%d_VIRT2_END +when CONT%d_VIRTMEM_REGIONS < 3 suppress CONT%d_VIRT3_START CONT%d_VIRT3_END +when CONT%d_VIRTMEM_REGIONS < 3 suppress CONT%d_VIRT4_START CONT%d_VIRT4_END +when CONT%d_VIRTMEM_REGIONS < 3 suppress CONT%d_VIRT5_START CONT%d_VIRT5_END + +when CONT%d_VIRTMEM_REGIONS < 4 suppress CONT%d_VIRT3_START CONT%d_VIRT3_END +when CONT%d_VIRTMEM_REGIONS < 4 suppress CONT%d_VIRT4_START CONT%d_VIRT4_END +when CONT%d_VIRTMEM_REGIONS < 4 suppress CONT%d_VIRT5_START CONT%d_VIRT5_END + +when CONT%d_VIRTMEM_REGIONS < 5 suppress CONT%d_VIRT4_START CONT%d_VIRT4_END +when CONT%d_VIRTMEM_REGIONS < 5 suppress CONT%d_VIRT5_START CONT%d_VIRT5_END + +when CONT%d_VIRTMEM_REGIONS < 6 suppress CONT%d_VIRT5_START CONT%d_VIRT5_END + +when CONT%d_PHYSMEM_REGIONS < 2 suppress CONT%d_PHYS1_START CONT%d_PHYS1_END +when CONT%d_PHYSMEM_REGIONS < 2 suppress CONT%d_PHYS2_START CONT%d_PHYS2_END +when CONT%d_PHYSMEM_REGIONS < 2 suppress CONT%d_PHYS3_START CONT%d_PHYS3_END +when CONT%d_PHYSMEM_REGIONS < 3 suppress CONT%d_PHYS2_START CONT%d_PHYS2_END +when CONT%d_PHYSMEM_REGIONS < 3 suppress CONT%d_PHYS3_START CONT%d_PHYS3_END +when CONT%d_PHYSMEM_REGIONS < 4 suppress CONT%d_PHYS3_START CONT%d_PHYS3_END + +default CONT%d_PHYS0_START from 0x0 +default CONT%d_PHYS0_END from 0x0 +default CONT%d_PHYS1_START from 0x0 +default CONT%d_PHYS1_END from 0x0 +default CONT%d_PHYS2_START from 0x0 +default CONT%d_PHYS2_END from 0x0 +default CONT%d_PHYS3_START from 0x0 +default CONT%d_PHYS3_END from 0x0 + +default CONT%d_VIRT0_START from 0x0 +default CONT%d_VIRT0_END from 0x0 +default CONT%d_VIRT1_START from 0x0 +default CONT%d_VIRT1_END from 0x0 +default CONT%d_VIRT2_START from 0x0 +default CONT%d_VIRT2_END from 0x0 +default CONT%d_VIRT3_START from 0x0 +default CONT%d_VIRT3_END from 0x0 +default CONT%d_VIRT4_START from 0x0 +default CONT%d_VIRT4_END from 0x0 +default CONT%d_VIRT5_START from 0x0 +default CONT%d_VIRT5_END from 0x0 + +default CONT%d_OPT_DIRNAME from (CONT%d_TYPE_LINUX==y) ? "linux" : ((CONT%d_TYPE_BARE==y) ? "bare%d" : "noname") + +when CONT%d_TYPE_LINUX==y suppress cont%d_bare_pager_params +when CONT%d_TYPE_BARE==y suppress cont%d_linux_pager_params + +symbols +cont%d_menu 'Container %d Parameters' +cont%d_physmem_list 'Container %d physical memory regions' +cont%d_virtmem_list 'Container %d Virtual memory regions' +container%d_type 'Container %d Type' +container%d_options 'Container %d Options' + +cont%d_linux_pager_params 'Container %d Pager parameters' +cont%d_bare_pager_params 'Container %d Pager parameters' + +menu cont%d_bare_pager_params + CONT%d_PAGER_LMA@ + CONT%d_PAGER_VMA@ + CONT%d_PAGER_SIZE@ + +menu cont%d_linux_pager_params + CONT%d_LINUX_PAGE_OFFSET@ + CONT%d_LINUX_TEXT_OFFSET@ + CONT%d_LINUX_PHYS_OFFSET@ + CONT%d_LINUX_MAPSIZE@ + +menu cont%d_virtmem_list + CONT%d_VIRTMEM_REGIONS% + CONT%d_VIRT0_START@ + CONT%d_VIRT0_END@ + CONT%d_VIRT1_START@ + CONT%d_VIRT1_END@ + CONT%d_VIRT2_START@ + CONT%d_VIRT2_END@ + CONT%d_VIRT3_START@ + CONT%d_VIRT3_END@ + CONT%d_VIRT4_START@ + CONT%d_VIRT4_END@ + CONT%d_VIRT5_START@ + CONT%d_VIRT5_END@ + +menu cont%d_physmem_list + CONT%d_PHYSMEM_REGIONS% + CONT%d_PHYS0_START@ + CONT%d_PHYS0_END@ + CONT%d_PHYS1_START@ + CONT%d_PHYS1_END@ + CONT%d_PHYS2_START@ + CONT%d_PHYS2_END@ + CONT%d_PHYS3_START@ + CONT%d_PHYS3_END@ + +menu container%d_options + CONT%d_OPT_DIRNAME$ + cont%d_linux_pager_params + cont%d_bare_pager_params + cont%d_physmem_list + cont%d_virtmem_list + +choices container%d_type + CONT%d_TYPE_LINUX + CONT%d_TYPE_BARE + CONT%d_TYPE_C0_POSIX + default CONT%d_TYPE_BARE + +menu cont%d_menu + container%d_type + container%d_options + diff --git a/config/projpaths.py b/config/projpaths.py index 66263c9..7e9192f 100644 --- a/config/projpaths.py +++ b/config/projpaths.py @@ -10,7 +10,7 @@ PROJROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) BUILDDIR = join(PROJROOT, "build") TOOLSDIR = join(PROJROOT, "tools") CML2_CONFIG_SRCDIR = join(PROJROOT, "config/cml") -CML2_RULES_FILE = join(CML2_CONFIG_SRCDIR, 'arm.cml') +CML2_CML_FILE = join(CML2_CONFIG_SRCDIR, 'out.cml') CML2_CONT_DEFFILE = join(PROJROOT, 'config/cml/container.template.cml') CML2TOOLSDIR = join(TOOLSDIR, "cml2-tools") CML2RULES = join(BUILDDIR, "cml2_rules.out") diff --git a/configure.py b/configure.py index 320d7df..090c623 100755 --- a/configure.py +++ b/configure.py @@ -64,5 +64,7 @@ def configure_kernel(cml_file): generate_kernel_cinfo(config.containers, KERNEL_CINFO_PATH) if __name__ == "__main__": - configure_kernel(join(CML2_CONFIG_SRCDIR, "arm.cml")) + if not os.path.exists(join(CML2_CONFIG_SRCDIR, 'out.cml')): + generate_container_cml(4) + configure_kernel(join(CML2_CONFIG_SRCDIR, "out.cml")) diff --git a/scripts/bare/bare_generator.py b/scripts/bare/bare_generator.py index 23e424d..4a4d467 100755 --- a/scripts/bare/bare_generator.py +++ b/scripts/bare/bare_generator.py @@ -103,11 +103,22 @@ class BareContGenerator: self.copy_bare_build_desc(config, cont) self.generate_linker_script(config, cont) + def update_configuration(self, config, cont): + self.build_readme_out = join(self.CONT_SRC_DIR, self.build_readme_name) + self.build_desc_out = join(self.CONT_SRC_DIR, self.build_desc_name) + self.linker_lds_out = join(join(self.CONT_SRC_DIR, 'include'), \ + self.linker_lds_name) + self.copy_bare_build_desc(config, cont) + self.generate_linker_script(config, cont) + def check_create_bare_sources(self, config): for cont in config.containers: if cont.type == "bare": if not os.path.exists(join(self.BARE_SRC_BASEDIR, cont.dirname)): self.create_bare_sources(config, cont) + # Don't create new sources but update configuration + else: + self.update_configuration(config, cont) def generate_linker_script(self, config, cont): with open(self.linker_lds_in) as fin: diff --git a/scripts/cml/__init__.py b/scripts/cml/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/cml/generate_container_cml.py b/scripts/cml/generate_container_cml.py new file mode 100755 index 0000000..cdc1dd6 --- /dev/null +++ b/scripts/cml/generate_container_cml.py @@ -0,0 +1,72 @@ +#! /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 * + +containers_menu = \ +''' +menu containers_menu +''' + +containers_constraint = \ +''' +unless CONTAINERS > %d suppress cont%d_menu +''' + +containers_default = \ +''' +default CONTAINERS from %d +''' + +def add_container_constraint(cid): + cml_string = "" + if cid == 0: + return "" + cml_string = containers_constraint % (cid, cid) + return cml_string + +def generate_container_cml(arch, ncont): + contid_occurence = 223 # Exact number of arguments + fbody = "" + with open(join(CML2_CONFIG_SRCDIR, arch + '.cml')) as in_cml: + fbody += in_cml.read() + + # Add container visibility constraint + for cont in range(ncont): + fbody += add_container_constraint(cont) + + # Add number of default containers + fbody += containers_default % ncont + + # Generate the containers menu with as many entries as containers + fbody += containers_menu + for cont in range(ncont): + fbody += '\tcont%d_menu\n' % cont + + # Write each container's rules + for cont in range(ncont): + with open(CML2_CONT_DEFFILE, "rU") as contdefs: + defbody = contdefs.read() + defbody = defbody.replace("%\n", "%%\n") + fbody += defbody % tuple(contid_occurence * [cont]) + + # Write the result to output rules file. + with open(join(CML2_CONFIG_SRCDIR, "out.cml"), "w+") as out_cml: + out_cml.write(fbody) + +if __name__ == "__main__": + generate_container_cml('arm', 4) +