mirror of
https://github.com/drasko/codezero.git
synced 2026-07-27 01:25:24 +02:00
CPUID and ARCHID taking at runtime from config.h
This commit is contained in:
@@ -123,7 +123,7 @@ class configuration:
|
|||||||
self.containers[id].linux_phys_offset = int(val, 0)
|
self.containers[id].linux_phys_offset = int(val, 0)
|
||||||
self.containers[id].pager_lma += int(val, 0)
|
self.containers[id].pager_lma += int(val, 0)
|
||||||
elif param[:len("LINUX_ZRELADDR")] == "LINUX_ZRELADDR":
|
elif param[:len("LINUX_ZRELADDR")] == "LINUX_ZRELADDR":
|
||||||
self.containers[id].linux_zreladdr += int(val, 0)
|
self.containers[id].linux_zreladdr = int(val, 0)
|
||||||
elif param[:len("LINUX_ROOTFS_ADDRESS")] == "LINUX_ROOTFS_ADDRESS":
|
elif param[:len("LINUX_ROOTFS_ADDRESS")] == "LINUX_ROOTFS_ADDRESS":
|
||||||
self.containers[id].linux_rootfs_address += int(val, 0)
|
self.containers[id].linux_rootfs_address += int(val, 0)
|
||||||
elif re.match(r"(VIRT|PHYS){1}([0-9]){1}(_){1}(START|END){1}", param):
|
elif re.match(r"(VIRT|PHYS){1}([0-9]){1}(_){1}(START|END){1}", param):
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright © 2009 B Labs Ltd
|
# Copyright © 2009 B Labs Ltd
|
||||||
#
|
#
|
||||||
import os, sys, shelve
|
import os, sys, shelve, string
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
PROJRELROOT = '../../'
|
PROJRELROOT = '../../'
|
||||||
@@ -31,9 +31,15 @@ def source_to_builddir(srcdir, id):
|
|||||||
class LinuxUpdateKernel:
|
class LinuxUpdateKernel:
|
||||||
|
|
||||||
def __init__(self, container):
|
def __init__(self, container):
|
||||||
self.list = (['MAGIC_SYSRQ', 'SET'],['DEBUG_KERNEL', 'SET'])
|
# List for setting/unsetting .config params of linux
|
||||||
self.modify_kernel_config()
|
self.config_param_list = \
|
||||||
self.update_kernel_params(container)
|
(['MAGIC_SYSRQ', 'SET'],['DEBUG_KERNEL', 'SET'])
|
||||||
|
|
||||||
|
# List of CPUIDs, to be used by linux based on codezero config
|
||||||
|
self.cpuid_list = (['ARM926', '0x41069265'],)
|
||||||
|
# List of ARCHIDs, to be used by linux based on codezero config
|
||||||
|
self.archid_list = (['PB926', '0x183'],
|
||||||
|
['AB926', '0x25E'],)
|
||||||
|
|
||||||
# Replace line(having input_pattern) in filename with new_data
|
# Replace line(having input_pattern) in filename with new_data
|
||||||
def replace_line(self, filename, input_pattern, new_data, prev_line):
|
def replace_line(self, filename, input_pattern, new_data, prev_line):
|
||||||
@@ -102,16 +108,49 @@ class LinuxUpdateKernel:
|
|||||||
prev_line = ''
|
prev_line = ''
|
||||||
self.replace_line(file, data_to_replace, new_data, prev_line)
|
self.replace_line(file, data_to_replace, new_data, prev_line)
|
||||||
|
|
||||||
# Update ARCHID, CPUID and ATAGS ADDRESS
|
# Update ARCHID, CPUID and ATAGS ADDRESS
|
||||||
# Atags will be present at PHYS_OFFSET + 0x100
|
def modify_register_values(self, container):
|
||||||
|
# Patterns as defined in config.h
|
||||||
|
cpuid_pattern = '#define CONFIG_CPU_'
|
||||||
|
archid_pattern = '#define CONFIG_PLATFORM_'
|
||||||
|
|
||||||
|
# Need some better way to find relpath of config.h
|
||||||
|
config_h_relpath = join(PROJROOT, "include/l4")
|
||||||
|
config_h_relpath = os.path.relpath(config_h_relpath, os.getcwd())
|
||||||
|
config_h_relpath = join (config_h_relpath,'config.h')
|
||||||
|
|
||||||
|
for pattern in cpuid_pattern, archid_pattern:
|
||||||
|
with open(config_h_relpath, 'r') as f:
|
||||||
|
for line in f:
|
||||||
|
start = string.find(line, pattern)
|
||||||
|
if start == -1:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
end = start + len(pattern)
|
||||||
|
start = end
|
||||||
|
while line[end] != ' ':
|
||||||
|
end = end + 1
|
||||||
|
if pattern == cpuid_pattern:
|
||||||
|
cpu_type = line[start:end]
|
||||||
|
elif pattern == archid_pattern:
|
||||||
|
arch_type = line[start:end]
|
||||||
|
break
|
||||||
|
for i in self.cpuid_list:
|
||||||
|
if i[0] == cpu_type:
|
||||||
|
cpuid = i[1]
|
||||||
|
break
|
||||||
|
for i in self.archid_list:
|
||||||
|
if i[0] == arch_type:
|
||||||
|
archid = i[1]
|
||||||
|
break
|
||||||
|
|
||||||
file = join(LINUX_KERNELDIR, 'arch/arm/kernel/head.S')
|
file = join(LINUX_KERNELDIR, 'arch/arm/kernel/head.S')
|
||||||
prev_line = ''
|
prev_line = ''
|
||||||
# CPUID for versatile: 0x41069265
|
new_data = ('cpuid: .word ' + cpuid + '\n')
|
||||||
new_data = ('cpuid: .word ' + '0x41069265' + '\n')
|
|
||||||
data_to_replace = "(cpuid:)"
|
data_to_replace = "(cpuid:)"
|
||||||
self.replace_line(file, data_to_replace, new_data, prev_line)
|
self.replace_line(file, data_to_replace, new_data, prev_line)
|
||||||
# ARCHID for versatile: 0x183
|
|
||||||
new_data = ('archid: .word ' + '0x183' + '\n')
|
new_data = ('archid: .word ' + archid + '\n')
|
||||||
data_to_replace = "(archid:)"
|
data_to_replace = "(archid:)"
|
||||||
self.replace_line(file, data_to_replace, new_data, prev_line)
|
self.replace_line(file, data_to_replace, new_data, prev_line)
|
||||||
# Atags will be present at PHYS_OFFSET + 0x100(=256)
|
# Atags will be present at PHYS_OFFSET + 0x100(=256)
|
||||||
@@ -122,7 +161,7 @@ class LinuxUpdateKernel:
|
|||||||
|
|
||||||
def modify_kernel_config(self):
|
def modify_kernel_config(self):
|
||||||
file = join(LINUX_KERNELDIR, 'arch/arm/configs/versatile_defconfig')
|
file = join(LINUX_KERNELDIR, 'arch/arm/configs/versatile_defconfig')
|
||||||
for i in self.list:
|
for i in self.config_param_list:
|
||||||
param = 'CONFIG_' + i[0]
|
param = 'CONFIG_' + i[0]
|
||||||
prev_line = ''
|
prev_line = ''
|
||||||
if i[1] == 'SET':
|
if i[1] == 'SET':
|
||||||
@@ -134,7 +173,6 @@ class LinuxUpdateKernel:
|
|||||||
|
|
||||||
self.replace_line(file, data_to_replace, new_data, prev_line)
|
self.replace_line(file, data_to_replace, new_data, prev_line)
|
||||||
|
|
||||||
|
|
||||||
class LinuxBuilder:
|
class LinuxBuilder:
|
||||||
|
|
||||||
def __init__(self, pathdict, container):
|
def __init__(self, pathdict, container):
|
||||||
@@ -166,6 +204,11 @@ class LinuxBuilder:
|
|||||||
os.chdir(self.LINUX_KERNELDIR)
|
os.chdir(self.LINUX_KERNELDIR)
|
||||||
if not os.path.exists(self.LINUX_KERNEL_BUILDDIR):
|
if not os.path.exists(self.LINUX_KERNEL_BUILDDIR):
|
||||||
os.makedirs(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(self.container)
|
||||||
|
|
||||||
os.system("make defconfig ARCH=arm O=" + self.LINUX_KERNEL_BUILDDIR)
|
os.system("make defconfig ARCH=arm O=" + self.LINUX_KERNEL_BUILDDIR)
|
||||||
os.system("make ARCH=arm " + \
|
os.system("make ARCH=arm " + \
|
||||||
"CROSS_COMPILE=arm-none-linux-gnueabi- O=" + \
|
"CROSS_COMPILE=arm-none-linux-gnueabi- O=" + \
|
||||||
|
|||||||
Reference in New Issue
Block a user