1 |
2 |
drasko |
|
2 |
|
|
Import('config', 'env', 'contid')
|
3 |
|
|
|
4 |
|
|
import os, sys
|
5 |
|
|
|
6 |
|
|
arch = config.arch
|
7 |
|
|
subarch = config.subarch
|
8 |
|
|
|
9 |
|
|
sys.path.append('../../../../')
|
10 |
|
|
from config.lib import *
|
11 |
|
|
|
12 |
|
|
container = next((c for c in config.containers if int(c.id) == int(contid)), None)
|
13 |
|
|
|
14 |
|
|
def generate_container_h(target, source, env):
|
15 |
|
|
base_value_dict = {}
|
16 |
|
|
with open(source[0].path, 'r') as ch_in:
|
17 |
|
|
with open(target[0].path, 'w+') as ch_out:
|
18 |
|
|
container_h = ch_in.read()
|
19 |
|
|
assert container.pager_task_region_start != 0
|
20 |
|
|
assert container.pager_task_region_end != 0
|
21 |
|
|
assert container.pager_shm_region_start != 0
|
22 |
|
|
assert container.pager_shm_region_end != 0
|
23 |
|
|
assert container.pager_utcb_region_start != 0
|
24 |
|
|
assert container.pager_utcb_region_end != 0
|
25 |
|
|
|
26 |
|
|
base_value_dict = { 'task_start' : conv_hex(container.pager_task_region_start), \
|
27 |
|
|
'task_end' : conv_hex(container.pager_task_region_end), \
|
28 |
|
|
'shmem_start' : conv_hex(container.pager_shm_region_start), \
|
29 |
|
|
'shmem_end' : conv_hex(container.pager_shm_region_end), \
|
30 |
|
|
'utcb_start' : conv_hex(container.pager_utcb_region_start), \
|
31 |
|
|
'utcb_end' : conv_hex(container.pager_utcb_region_end) }
|
32 |
|
|
ch_out.write(container_h % base_value_dict)
|
33 |
|
|
|
34 |
|
|
def generate_vma_lma_lds(target, source, env):
|
35 |
|
|
with open(source[0].path, 'r') as lds_in:
|
36 |
|
|
with open(target[0].path, 'w+') as lds_out:
|
37 |
|
|
linker_script = lds_in.read()
|
38 |
|
|
assert container.pager_lma != 0
|
39 |
|
|
assert container.pager_vma != 0
|
40 |
|
|
lds_out.write(linker_script % (conv_hex(container.pager_vma), \
|
41 |
|
|
conv_hex(container.pager_lma)))
|
42 |
|
|
|
43 |
|
|
lma_lds = Command('include/linker.lds', 'include/linker.lds.in', generate_vma_lma_lds)
|
44 |
|
|
|
45 |
|
|
container_h = Command('include/container.h', 'include/container.h.in', generate_container_h)
|
46 |
|
|
src = [Glob('*.c') + Glob('mm/*.c') + Glob('lib/*.c') + Glob('fs/*.c') + \
|
47 |
|
|
Glob('fs/memfs/*.c') + Glob('lib/elf/*.c') + Glob('mm/arch/' + arch + '/*.[Sc]') +
|
48 |
|
|
Glob('mm/arch/' + arch + '/' + subarch + '/*.[Sc]')]
|
49 |
|
|
|
50 |
|
|
e = env.Clone()
|
51 |
|
|
|
52 |
|
|
e.Append(LINKFLAGS = ['-T' + lma_lds[0].path, '-u_start'])
|
53 |
|
|
e.Append(LIBS = 'posix')
|
54 |
|
|
e.Append(CPPFLAGS = ' -include ' + container_h[0].path + ' -include macros.h -include l4lib/macros.h ')
|
55 |
|
|
objs = e.Object(src)
|
56 |
|
|
mm0 = e.Program('mm0.elf', objs)
|
57 |
|
|
Depends(objs, container_h)
|
58 |
|
|
Depends(mm0, lma_lds)
|
59 |
|
|
Depends(mm0, container_h)
|
60 |
|
|
AlwaysBuild(container_h)
|
61 |
|
|
Return('mm0')
|
62 |
|
|
|