config: Specify OS type and release on command line

This patch enables users to speficy --os-type on the command
line. This option is used to take specific actions for an OS type,
such as changing the kernel command line. This patch is part of the
Android KitKat enablement.
This commit is contained in:
Chris Emmons 2015-03-19 04:06:14 -04:00
parent 9b4d8030e6
commit 142ab40c4b
4 changed files with 57 additions and 12 deletions

View file

@ -31,11 +31,13 @@ from os import environ as env
from m5.defines import buildEnv from m5.defines import buildEnv
class SysConfig: class SysConfig:
def __init__(self, script=None, mem=None, disk=None, rootdev=None): def __init__(self, script=None, mem=None, disk=None, rootdev=None,
os_type='linux'):
self.scriptname = script self.scriptname = script
self.diskname = disk self.diskname = disk
self.memsize = mem self.memsize = mem
self.root = rootdev self.root = rootdev
self.ostype = os_type
def script(self): def script(self):
if self.scriptname: if self.scriptname:
@ -69,6 +71,9 @@ class SysConfig:
else: else:
return '/dev/sda1' return '/dev/sda1'
def os_type(self):
return self.ostype
# Benchmarks are defined as a key in a dict which is a list of SysConfigs # Benchmarks are defined as a key in a dict which is a list of SysConfigs
# The first defined machine is the test system, the others are driving systems # The first defined machine is the test system, the others are driving systems
@ -119,13 +124,17 @@ Benchmarks = {
'MutexTest': [SysConfig('mutex-test.rcS', '128MB')], 'MutexTest': [SysConfig('mutex-test.rcS', '128MB')],
'ArmAndroid-GB': [SysConfig('null.rcS', '256MB', 'ArmAndroid-GB': [SysConfig('null.rcS', '256MB',
'ARMv7a-Gingerbread-Android.SMP.mouse.nolock.clean.img')], 'ARMv7a-Gingerbread-Android.SMP.mouse.nolock.clean.img',
None, 'android-gingerbread')],
'bbench-gb': [SysConfig('bbench-gb.rcS', '256MB', 'bbench-gb': [SysConfig('bbench-gb.rcS', '256MB',
'ARMv7a-Gingerbread-Android.SMP.mouse.nolock.img')], 'ARMv7a-Gingerbread-Android.SMP.mouse.nolock.img',
None, 'android-gingerbread')],
'ArmAndroid-ICS': [SysConfig('null.rcS', '256MB', 'ArmAndroid-ICS': [SysConfig('null.rcS', '256MB',
'ARMv7a-ICS-Android.SMP.nolock.clean.img')], 'ARMv7a-ICS-Android.SMP.nolock.clean.img',
None, 'android-ics')],
'bbench-ics': [SysConfig('bbench-ics.rcS', '256MB', 'bbench-ics': [SysConfig('bbench-ics.rcS', '256MB',
'ARMv7a-ICS-Android.SMP.nolock.img')] 'ARMv7a-ICS-Android.SMP.nolock.img',
None, 'android-ics')]
} }
benchs = Benchmarks.keys() benchs = Benchmarks.keys()

View file

@ -43,6 +43,18 @@ from m5.objects import *
from Benchmarks import * from Benchmarks import *
from m5.util import * from m5.util import *
# Populate to reflect supported os types per target ISA
os_types = { 'alpha' : [ 'linux' ],
'mips' : [ 'linux' ],
'sparc' : [ 'linux' ],
'x86' : [ 'linux' ],
'arm' : [ 'linux',
'android-gingerbread',
'android-ics',
'android-jellybean',
'android-kitkat' ],
}
class CowIdeDisk(IdeDisk): class CowIdeDisk(IdeDisk):
image = CowDiskImage(child=RawDiskImage(read_only=True), image = CowDiskImage(child=RawDiskImage(read_only=True),
read_only=False) read_only=False)
@ -54,7 +66,6 @@ class MemBus(SystemXBar):
badaddr_responder = BadAddr() badaddr_responder = BadAddr()
default = Self.badaddr_responder.pio default = Self.badaddr_responder.pio
def fillInCmdline(mdesc, template, **kwargs): def fillInCmdline(mdesc, template, **kwargs):
kwargs.setdefault('disk', mdesc.disk()) kwargs.setdefault('disk', mdesc.disk())
kwargs.setdefault('rootdev', mdesc.rootdev()) kwargs.setdefault('rootdev', mdesc.rootdev())
@ -286,11 +297,31 @@ def makeArmSystem(mem_mode, machine_type, num_cpus=1, mdesc=None,
self.gic_cpu_addr = self.realview.gic.cpu_addr self.gic_cpu_addr = self.realview.gic.cpu_addr
self.flags_addr = self.realview.realview_io.pio_addr + 0x30 self.flags_addr = self.realview.realview_io.pio_addr + 0x30
# Android disk images must have 'android' keyword in the disk name # This check is for users who have previously put 'android' in
# Look for 'android' in disk name and append /init to boot_osflags # the disk image filename to tell the config scripts to
# prepare the kernel with android-specific boot options. That
# behavior has been replaced with a more explicit option per
# the error message below. The disk can have any name now and
# doesn't need to include 'android' substring.
if (os.path.split(mdesc.disk())[-1]).lower().count('android'): if (os.path.split(mdesc.disk())[-1]).lower().count('android'):
cmdline += " init=/init " if 'android' not in mdesc.os_type():
fatal("It looks like you are trying to boot an Android " \
"platform. To boot Android, you must specify " \
"--os-type with an appropriate Android release on " \
"the command line.")
# android-specific tweaks
if 'android' in mdesc.os_type():
# generic tweaks
cmdline += " init=/init"
# release-specific tweaks
if 'kitkat' in mdesc.os_type():
cmdline += " androidboot.hardware=gem5 qemu=1 qemu.gles=0 " + \
"android.bootanim=0"
self.boot_osflags = fillInCmdline(mdesc, cmdline) self.boot_osflags = fillInCmdline(mdesc, cmdline)
self.realview.attachOnChipIO(self.membus, self.bridge) self.realview.attachOnChipIO(self.membus, self.bridge)
self.realview.attachIO(self.iobus) self.realview.attachIO(self.iobus)
self.intrctrl = IntrControl() self.intrctrl = IntrControl()

View file

@ -46,6 +46,8 @@ from Benchmarks import *
import CpuConfig import CpuConfig
import MemConfig import MemConfig
from FSConfig import os_types
def _listCpuTypes(option, opt, value, parser): def _listCpuTypes(option, opt, value, parser):
CpuConfig.print_cpu_list() CpuConfig.print_cpu_list()
sys.exit(0) sys.exit(0)
@ -241,6 +243,9 @@ def addFSOptions(parser):
# System options # System options
parser.add_option("--kernel", action="store", type="string") parser.add_option("--kernel", action="store", type="string")
parser.add_option("--os-type", action="store", type="choice",
choices=os_types[buildEnv['TARGET_ISA']], default="linux",
help="Specifies type of OS to boot")
parser.add_option("--script", action="store", type="string") parser.add_option("--script", action="store", type="string")
parser.add_option("--frame-capture", action="store_true", parser.add_option("--frame-capture", action="store_true",
help="Stores changed frame buffers from the VNC server to compressed "\ help="Stores changed frame buffers from the VNC server to compressed "\

View file

@ -314,12 +314,12 @@ if options.benchmark:
else: else:
if options.dual: if options.dual:
bm = [SysConfig(disk=options.disk_image, rootdev=options.root_device, bm = [SysConfig(disk=options.disk_image, rootdev=options.root_device,
mem=options.mem_size), mem=options.mem_size, os_type=options.os_type),
SysConfig(disk=options.disk_image, rootdev=options.root_device, SysConfig(disk=options.disk_image, rootdev=options.root_device,
mem=options.mem_size)] mem=options.mem_size, os_type=options.os_type)]
else: else:
bm = [SysConfig(disk=options.disk_image, rootdev=options.root_device, bm = [SysConfig(disk=options.disk_image, rootdev=options.root_device,
mem=options.mem_size)] mem=options.mem_size, os_type=options.os_type)]
np = options.num_cpus np = options.num_cpus