Kernel updates since December 2009

This commit is contained in:
Bahadir Balban
2010-03-25 01:12:40 +02:00
parent 16818191b3
commit 74b5963fcb
487 changed files with 22477 additions and 3857 deletions

View File

@@ -21,6 +21,12 @@ containers_menu = \
'''
menu containers_menu
CAPABILITIES
CONTAINERS%
'''
default_number_of_containers = \
'''
default CONTAINERS from 1
'''
containers_constraint = \
@@ -87,6 +93,8 @@ def generate_container_cml(arch, ncont):
for cont in range(ncont):
fbody += '\tcont%d_menu\n' % cont
fbody += default_number_of_containers
# Generate inter-container suppression rules for as many rules as containers
fbody += generate_container_suppress_rules(ncont)

View File

@@ -33,7 +33,7 @@ def build_linux_container(config, projpaths, container):
# Calculate and store size of pager
pager_binary = \
"cont" + str(container.id) + "/linux/linux-2.6.28.10/linux.elf"
"cont" + str(container.id) + "/linux/linux-2.6.33/linux.elf"
config.containers[container.id].pager_size = \
conv_hex(elf_binary_size(join(BUILDDIR, pager_binary)))

View File

@@ -96,7 +96,7 @@ class LinuxContainerPacker:
self.atags_elf_in])
self.generate_container_assembler([self.kernel_image_in, self.rootfs_elf_in, \
self.atags_elf_in])
os.system(config.user_toolchain + "gcc " + "-nostdlib -o %s -T%s %s" \
os.system(config.toolchain + "gcc " + "-nostdlib -o %s -T%s %s" \
% (self.container_elf_out, self.container_lds_out, \
self.container_S_out))
# Final file is returned so that the final packer needn't
@@ -155,7 +155,7 @@ class DefaultContainerPacker:
def pack_container(self, config):
self.generate_container_lds(self.images_in)
self.generate_container_assembler(self.images_in)
os.system(config.user_toolchain + "gcc " + "-nostdlib -o %s -T%s %s" \
os.system(config.toolchain + "gcc " + "-nostdlib -o %s -T%s %s" \
% (self.container_elf_out, self.container_lds_out, \
self.container_S_out))
# Final file is returned so that the final packer needn't

View File

@@ -79,7 +79,7 @@ class AllContainerPacker:
def pack_all(self, config):
self.generate_container_lds(self.containers_lds_out)
self.generate_container_S(self.containers_S_out)
os.system(config.user_toolchain + "gcc " + "-nostdlib -o %s -T%s %s" \
os.system(config.toolchain + "gcc " + "-nostdlib -o %s -T%s %s" \
% (self.containers_elf_out, self.containers_lds_out, \
self.containers_S_out))

View File

@@ -82,7 +82,8 @@ cap_virtmem = \
\t\t\t\t.target = %(cn)d,
\t\t\t\t.type = CAP_TYPE_MAP_VIRTMEM | CAP_RTYPE_CONTAINER,
\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\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),

View File

@@ -64,7 +64,7 @@ class AtagsBuilder:
with open(self.atags_h_in, 'r') as input:
output.write(input.read() % {'cn' : self.cont_id})
os.system(config.user_toolchain + "cpp -I%s -P %s > %s" % \
os.system(config.toolchain + "cpp -I%s -P %s > %s" % \
(self.LINUX_ATAGS_BUILDDIR, self.atags_lds_in, \
self.atags_lds_out))
@@ -72,7 +72,7 @@ class AtagsBuilder:
with open(self.atags_c_in, 'r') as input:
output.write(input.read() % {'cn' : self.cont_id})
os.system(config.user_toolchain + "gcc " + \
os.system(config.toolchain + "gcc " + \
"-g -ffreestanding -std=gnu99 -Wall -Werror " + \
"-nostdlib -o %s -T%s %s" % \
(self.atags_elf_out, self.atags_lds_out, self.atags_c_out))

View File

@@ -40,12 +40,31 @@ class LinuxUpdateKernel:
['USB_SUPPORT', 'UNSET'],['SOUND', 'UNSET'],)
# List of CPUIDs, to be used by linux based on codezero config
self.cpuid_list = (['ARM926', '0x41069265'],)
self.cpuid_list = (['ARM926', '0x41069265'],
['CORTEXA8', '0x410fc080'],
['ARM11MPCORE', '0x410fb022'],
['CORTEXA9', '0x410fc090'])
# List of ARCHIDs, to be used by linux based on codezero config
self.archid_list = (['PB926', '0x183'],
['PB1176', '0x5E0'],
['EB', '0x33B'],
['PB11MPCORE', '0x3D4'],)
['PB11MPCORE', '0x3D4'],
['BEAGLE', '0x60A'],
['PBA9', '0x76D'],
['PBA8', '0x769'])
# Path of system_macros header file
self.system_macros_h_out = \
join(LINUX_KERNELDIR,
'arch/codezero/include/virtualization/system_macros.h')
self.system_macros_h_in = \
join(LINUX_KERNELDIR,
'arch/codezero/include/virtualization/system_macros.h.in')
#Path for kernel_param file
self.kernel_param_out = \
join(LINUX_KERNELDIR, 'arch/codezero/include/virtualization/kernel_param')
self.kernel_param_in = \
join(LINUX_KERNELDIR, 'arch/codezero/include/virtualization/kernel_param.in')
# Replace line(having input_pattern) in filename with new_data
def replace_line(self, filename, input_pattern, new_data, prev_line):
@@ -81,41 +100,20 @@ class LinuxUpdateKernel:
# Write back to file
f.write(l.replace(line, new_data))
def update_kernel_params(self, container):
# Update TEXT_START
file = join(LINUX_KERNELDIR, 'arch/arm/boot/compressed/Makefile')
param = str(conv_hex(container.linux_phys_offset))
new_data = ('ZTEXTADDR' + '\t' + ':= ' + param + '\n')
data_to_replace = "(ZTEXTADDR)(\t)(:= 0)"
prev_line = ''
self.replace_line(file, data_to_replace, new_data, prev_line)
# Update PHYS_OFFSET
file = join(LINUX_KERNELDIR, 'arch/arm/mach-versatile/include/mach/memory.h')
param = str(conv_hex(container.linux_phys_offset))
new_data = ('#define PHYS_OFFSET UL(' + param + ')\n')
data_to_replace = "(#define PHYS_OFFSET)"
prev_line = ''
self.replace_line(file, data_to_replace, new_data, prev_line)
# Update kernel parameters
def update_kernel_params(self, config, container):
# Update PAGE_OFFSET
file = join(LINUX_KERNELDIR, 'arch/arm/Kconfig')
# FIXME: Find a way to add this in system_macros.h or kernel_param
# issue is we have to update this in KCONFIG file which cannot
# have dependency on other files.
file = join(LINUX_KERNELDIR, 'arch/codezero/Kconfig')
param = str(conv_hex(container.linux_page_offset))
new_data = ('\t' + 'default ' + param + '\n')
data_to_replace = "(\t)(default )"
prev_line = ('\t'+'default 0x80000000 if VMSPLIT_2G' + '\n')
self.replace_line(file, data_to_replace, new_data, prev_line)
# Update ZRELADDR
file = join(LINUX_KERNELDIR, 'arch/arm/mach-versatile/Makefile.boot')
param = str(conv_hex(container.linux_zreladdr))
new_data = (' zreladdr-y' + '\t' + ':= ' + param + '\n')
data_to_replace = "(\s){3}(zreladdr-y)(\t)(:= )"
prev_line = ''
self.replace_line(file, data_to_replace, new_data, prev_line)
# Update ARCHID, CPUID and ATAGS ADDRESS
def modify_register_values(self, config, container):
for cpu_type, cpu_id in self.cpuid_list:
if cpu_type == config.cpu.upper():
cpuid = cpu_id
@@ -125,23 +123,28 @@ class LinuxUpdateKernel:
archid = arch_id
break
file = join(LINUX_KERNELDIR, 'arch/arm/kernel/head.S')
prev_line = ''
new_data = ('cpuid: .word ' + cpuid + '\n')
data_to_replace = "(cpuid:)"
self.replace_line(file, data_to_replace, new_data, prev_line)
# Create system_macros header
with open(self.system_macros_h_out, 'w+') as output:
with open(self.system_macros_h_in, 'r') as input:
output.write(input.read() % \
{'cpuid' : cpuid, \
'archid' : archid, \
'atags' : str(conv_hex(container.linux_page_offset + 0x100)), \
'ztextaddr' : str(conv_hex(container.linux_phys_offset)), \
'phys_offset' : str(conv_hex(container.linux_phys_offset)), \
'page_offset' : str(conv_hex(container.linux_page_offset)), \
'zreladdr' : str(conv_hex(container.linux_zreladdr))})
new_data = ('archid: .word ' + archid + '\n')
data_to_replace = "(archid:)"
self.replace_line(file, data_to_replace, new_data, prev_line)
# Atags will be present at PHYS_OFFSET + 0x100(=256)
new_data = ('atags: .word ' + \
str(conv_hex(container.linux_phys_offset + 0x100)) + '\n')
data_to_replace = "(atags:)"
self.replace_line(file, data_to_replace, new_data, prev_line)
with open(self.kernel_param_out, 'w+') as output:
with open(self.kernel_param_in, 'r') as input:
output.write(input.read() % \
{'ztextaddr' : str(conv_hex(container.linux_phys_offset)), \
'phys_offset' : str(conv_hex(container.linux_phys_offset)), \
'page_offset' : str(conv_hex(container.linux_page_offset)), \
'zreladdr' : str(conv_hex(container.linux_zreladdr))})
def modify_kernel_config(self):
file = join(LINUX_KERNELDIR, 'arch/arm/configs/versatile_defconfig')
def modify_kernel_config(self, linux_builddir):
file = join(linux_builddir, '.config')
for param_name, param_value in self.config_param_list:
param = 'CONFIG_' + param_name
prev_line = ''
@@ -152,7 +155,7 @@ class LinuxUpdateKernel:
data_to_replace = param
new_data = ('# ' + param + ' is not set' + '\n')
self.replace_line(file, data_to_replace, new_data, prev_line)
self.replace_line(file, data_to_replace, new_data, prev_line)
class LinuxBuilder:
@@ -170,23 +173,36 @@ class LinuxBuilder:
self.kernel_image = join(self.LINUX_KERNEL_BUILDDIR, "linux.elf")
self.kernel_updater = LinuxUpdateKernel(self.container)
# Default configuration file to use based on selected platform
self.platform_config_file = (['PB926', 'versatile_defconfig'],
['BEAGLE', 'omap3_beagle_defconfig'],
['PBA8', 'realview_defconfig'],
['PBA9', 'realview-smp_defconfig'],
['PB11MPCORE', 'realview-smp_defconfig'],)
def build_linux(self, config):
print '\nBuilding the linux kernel...'
os.chdir(self.LINUX_KERNELDIR)
if not os.path.exists(self.LINUX_KERNEL_BUILDDIR):
os.makedirs(self.LINUX_KERNEL_BUILDDIR)
self.kernel_updater.modify_kernel_config()
self.kernel_updater.update_kernel_params(self.container)
self.kernel_updater.modify_register_values(config, self.container)
for platform, config_file in self.platform_config_file:
if platform == config.platform.upper():
configuration_file = config_file
os.system("make ARCH=codezero CROSS_COMPILE=" + config.toolchain + \
" O=" + self.LINUX_KERNEL_BUILDDIR + " " + configuration_file)
os.system("make defconfig ARCH=arm O=" + self.LINUX_KERNEL_BUILDDIR)
os.system("make ARCH=arm " + \
"CROSS_COMPILE=" + config.user_toolchain + " O=" + \
self.kernel_updater.modify_kernel_config(self.LINUX_KERNEL_BUILDDIR)
self.kernel_updater.update_kernel_params(config, self.container)
os.system("make ARCH=codezero CROSS_COMPILE=" + config.toolchain + \
" O=" + self.LINUX_KERNEL_BUILDDIR + " menuconfig")
os.system("make ARCH=codezero " + \
"CROSS_COMPILE=" + config.toolchain + " O=" + \
self.LINUX_KERNEL_BUILDDIR)
# Generate kernel_image, elf to be used by codezero
linux_elf_gen_cmd = ("arm-none-linux-gnueabi-objcopy -R .note \
linux_elf_gen_cmd = (config.toolchain + "objcopy -R .note \
-R .note.gnu.build-id -R .comment -S --change-addresses " + \
str(conv_hex(-self.container.linux_page_offset + self.container.linux_phys_offset)) + \
" " + self.kernel_binary_image + " " + self.kernel_image)

View File

@@ -51,10 +51,10 @@ class RootfsBuilder:
with open(self.rootfs_h_in, 'r') as input:
output.write(input.read() % {'cn' : self.cont_id})
os.system(config.user_toolchain + "cpp -I%s -P %s > %s" % \
os.system(config.toolchain + "cpp -I%s -P %s > %s" % \
(self.LINUX_ROOTFS_BUILDDIR, self.rootfs_lds_in, \
self.rootfs_lds_out))
os.system(config.user_toolchain + "gcc " + \
os.system(config.toolchain + "gcc " + \
"-nostdlib -o %s -T%s rootfs.S" % (self.rootfs_elf_out, \
self.rootfs_lds_out))
print "Done..."

View File

@@ -53,7 +53,7 @@ def generate_ksym_to_loader(target_path, source_path):
asm_file.write(ksym_header % (target_path, source_path, sys.argv[0]))
for symbol in symbols:
process = \
subprocess.Popen(config.kernel_toolchain + 'objdump -d ' + \
subprocess.Popen(config.toolchain + 'objdump -d ' + \
source_path + ' | grep "<' + \
symbol + '>"', shell=True, \
stdout=subprocess.PIPE)

0
scripts/qemu/__init__.py Normal file
View File

View File

@@ -0,0 +1,67 @@
#! /usr/bin/env python2.6
# -*- mode: python; coding: utf-8; -*-
#
# Codezero -- Virtualization microkernel for embedded systems.
#
# Copyright © 2009 B Labs Ltd
#
import os, sys
from os.path import join
PROJRELROOT = "../.."
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT)))
from config.projpaths import *
from config.configuration import *
#config = configuration_retrieve()
#cpu = config.cpu
#platform = config.platform
# Mapping between system configuration and qemu flags
# Platform CPU qemu "-M" flag qemu "-cpu" flag
map_list = (['EB', 'ARM1136', 'realview-eb', 'arm1136'],
['EB', 'ARM11MPCORE', 'realview-eb-mpcore', 'arm11mpcore'],
['EB', 'CORTEXA8', 'realview-eb', 'cortex-a8'],
['PB926', 'ARM926', 'versatilepb', 'arm926'],
['BEAGLE', 'CORTEXA8', 'beagle', 'cortex-a8'],
['PBA9', 'CORTEXA9', 'realview-pbx-a9', 'cortex-a9'],
['PBA8', 'CORTEXA8', 'realview-pb-a8', 'cortex-a8'])
data = \
'''
cd build
qemu-system-arm -s -S -kernel final.elf -nographic -M %s -cpu %s &
arm-none-insight ; pkill qemu-system-arm
cd ..
'''
def build_qemu_cmdline_script():
build_tools_folder = 'tools'
qemu_cmd_file = join(build_tools_folder, 'run-qemu-insight')
# Get system selected platform and cpu
config = configuration_retrieve()
cpu = config.cpu.upper()
platform = config.platform.upper()
# Find appropriate flags
for platform_type, cpu_type, mflag, cpuflag in map_list:
if platform_type == platform and cpu_type == cpu:
break
if not mflag or not cpuflag:
print 'Qemu flags not found'
sys.exit(1)
if os.path.exists(build_tools_folder) is False:
os.system("mkdir " + build_tools_folder)
# Write run-qemu-insight file
with open(qemu_cmd_file, 'w+') as f:
f.write(data % (mflag, cpuflag))
os.system("chmod +x " + qemu_cmd_file)
if __name__ == "__main__":
build_qemu_cmdline_script()