OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [scripts/] [qemu/] [qemu_cmdline.py] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
#! /usr/bin/env python2.6
2
# -*- mode: python; coding: utf-8; -*-
3
#
4
#  Codezero -- Virtualization microkernel for embedded systems.
5
#
6
#  Copyright © 2009  B Labs Ltd
7
#
8
import os, sys
9
from os.path import join
10
 
11
PROJRELROOT = "../.."
12
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT)))
13
 
14
from config.projpaths import *
15
from config.configuration import *
16
 
17
#config = configuration_retrieve()
18
#cpu = config.cpu
19
#platform = config.platform
20
 
21
# Mapping between system configuration and qemu flags
22
#           Platform         CPU           qemu "-M" flag          qemu "-cpu" flag
23
map_list = (['EB',          'ARM1136',      'realview-eb',          'arm1136'],
24
            ['EB',          'ARM11MPCORE',  'realview-eb-mpcore',   'arm11mpcore'],
25
            ['EB',          'CORTEXA8',     'realview-eb',          'cortex-a8'],
26
            ['EB',          'CORTEXA9',     'realview-pbx-a9',      'cortex-a9'],
27
            ['PB926',       'ARM926',       'versatilepb',          'arm926'],
28
            ['BEAGLE',      'CORTEXA8',     'beagle',               'cortex-a8'],
29
            ['PBA9',        'CORTEXA9',     'realview-pbx-a9',      'cortex-a9'],
30
            ['PBA8',        'CORTEXA8',     'realview-pb-a8',       'cortex-a8'])
31
 
32
data_up = \
33
'''
34
cd build
35
qemu-system-arm -s -S -kernel final.elf -nographic -M %s -cpu %s &
36
arm-none-insight ; pkill qemu-system-arm
37
cd ..
38
'''
39
 
40
data_smp = \
41
'''
42
cd build
43
qemu-system-arm -s -S -kernel final.elf -smp %d -nographic -M %s -cpu %s &
44
arm-none-insight ; pkill qemu-system-arm
45
cd ..
46
'''
47
 
48
def build_qemu_cmdline_script():
49
    build_tools_folder = 'tools'
50
    qemu_cmd_file = join(build_tools_folder, 'run-qemu-insight')
51
 
52
    # Get system selected platform and cpu
53
    config = configuration_retrieve()
54
    cpu = config.cpu.upper()
55
    platform = config.platform.upper()
56
    smp = config.smp
57
    ncpu = config.ncpu
58
 
59
    # Find appropriate flags
60
    for platform_type, cpu_type, m_flag, cpu_flag in map_list:
61
        if platform_type == platform and cpu_type == cpu:
62
            mflag = m_flag
63
            cpuflag = cpu_flag
64
            break
65
 
66
    if not mflag or not cpuflag:
67
        print 'Qemu flags not found'
68
        sys.exit(1)
69
 
70
    if os.path.exists(build_tools_folder) is False:
71
        os.system("mkdir " + build_tools_folder)
72
 
73
    # Special case for EB+A9(non-smp)
74
    if platform == 'EB' and cpu == 'CORTEXA9' and smp == False:
75
        mflag = 'realview-eb'
76
 
77
    # Write run-qemu-insight file
78
    with open(qemu_cmd_file, 'w+') as f:
79
        if smp == False:
80
            f.write(data_up % (mflag, cpuflag))
81
        else:
82
            f.write(data_smp % (ncpu, mflag, cpuflag))
83
 
84
    os.system("chmod +x " + qemu_cmd_file)
85
 
86
if __name__ == "__main__":
87
    build_qemu_cmdline_script()

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.