1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | from mapping import * |
---|
4 | |
---|
5 | ###################################################################################### |
---|
6 | # file : shell.py |
---|
7 | # date : july 2015 |
---|
8 | # author : Alain Greiner |
---|
9 | ####################################################################################### |
---|
10 | # This file describes the mapping of the single thread "shell" application. |
---|
11 | # It is mapped on processor[xmap][ymap][pmap] of the target |
---|
12 | # multi-clusters, multi-processors architecture. |
---|
13 | #################################################################################### |
---|
14 | |
---|
15 | ###################### |
---|
16 | def extend( mapping ): |
---|
17 | |
---|
18 | # define mapping |
---|
19 | xmap = mapping.x_size - 1 |
---|
20 | ymap = mapping.y_size - 1 |
---|
21 | pmap = mapping.nprocs - 1 |
---|
22 | |
---|
23 | # define vsegs base & size |
---|
24 | code_base = 0x10000000 |
---|
25 | code_size = 0x00010000 # 64 Kbytes |
---|
26 | |
---|
27 | data_base = 0x20000000 |
---|
28 | data_size = 0x00080000 # 512 Kbytes |
---|
29 | |
---|
30 | stack_base = 0x40000000 |
---|
31 | stack_size = 0x00200000 # 2 Mbytes |
---|
32 | |
---|
33 | heap_base = 0x60000000 |
---|
34 | heap_size = 0x00040000 # 256 Kbytes |
---|
35 | |
---|
36 | mmap_base = 0x70000000 |
---|
37 | mmap_size = 0x10000000 # 256 Mbytes (unmapped) |
---|
38 | |
---|
39 | # create vspace |
---|
40 | vspace = mapping.addVspace( name = 'shell', startname = 'shell_data' , active = True ) |
---|
41 | |
---|
42 | # data vseg |
---|
43 | mapping.addVseg( vspace, 'shell_data', data_base , data_size, |
---|
44 | 'C_WU', vtype = 'ELF', x = xmap, y = ymap, pseg = 'RAM', |
---|
45 | binpath = 'bin/shell/appli.elf', |
---|
46 | local = False ) |
---|
47 | |
---|
48 | # code vseg |
---|
49 | mapping.addVseg( vspace, 'shell_code', code_base , code_size, |
---|
50 | 'CXWU', vtype = 'ELF', x = xmap, y = ymap, pseg = 'RAM', |
---|
51 | binpath = 'bin/shell/appli.elf', |
---|
52 | local = False ) |
---|
53 | |
---|
54 | # stack vseg |
---|
55 | mapping.addVseg( vspace, 'shell_stack', stack_base, stack_size, |
---|
56 | 'C_WU', vtype = 'BUFFER', x = xmap , y = ymap , pseg = 'RAM', |
---|
57 | local = False, big = True ) |
---|
58 | |
---|
59 | # heap vseg |
---|
60 | mapping.addVseg( vspace, 'shell_heap', heap_base, heap_size, |
---|
61 | 'C_WU', vtype = 'HEAP', x = xmap , y = ymap , pseg = 'RAM', |
---|
62 | local = False ) |
---|
63 | |
---|
64 | # mmap vseg |
---|
65 | mapping.addVseg( vspace, 'shell_mmap', mmap_base, mmap_size, |
---|
66 | 'C_WU', vtype = 'MMAP', x = xmap , y = ymap , pseg = 'RAM', |
---|
67 | local = False ) |
---|
68 | |
---|
69 | # task |
---|
70 | mapping.addThread( vspace, |
---|
71 | 'shell', |
---|
72 | True, # is_main |
---|
73 | xmap, ymap, pmap, |
---|
74 | 'shell_stack', |
---|
75 | 'shell_heap', |
---|
76 | 0 ) # startid |
---|
77 | |
---|
78 | # extend mapping name |
---|
79 | mapping.name += '_shell' |
---|
80 | |
---|
81 | return vspace # useful for test |
---|
82 | |
---|
83 | ################################ test ###################################################### |
---|
84 | |
---|
85 | if __name__ == '__main__': |
---|
86 | |
---|
87 | vspace = extend( Mapping( 'test', 2, 2, 4 ) ) |
---|
88 | print vspace.xml() |
---|
89 | |
---|
90 | |
---|
91 | # Local Variables: |
---|
92 | # tab-width: 4; |
---|
93 | # c-basic-offset: 4; |
---|
94 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
95 | # indent-tabs-mode: nil; |
---|
96 | # End: |
---|
97 | # |
---|
98 | # vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
99 | |
---|