1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# RT-Thread building script for the unified RISC-V CPU port
import os
from building import *
Import('rtconfig')
cwd = GetCurrentDir()
bsp_path = Dir('#').abspath
CPPPATH = [cwd + '/include', cwd]
if GetDepend('ARCH_RISCV_VECTOR'):
CPPPATH += [os.path.join(cwd, '..', 'vector', 'rvv-1.0')]
bsp_startup_obj = []
builtin_fdt_obj = []
src = [
'backtrace.c',
'cpu.c',
'cpuport.c',
'isa_ext.c',
'riscv_timer.c',
'stack.c',
'trap.c',
]
if GetDepend('RT_USING_CACHE'):
src += ['cache.c']
if rtconfig.PLATFORM in ['gcc']:
src += [
'context_gcc.S',
'cpu_gcc.S',
'stack_gcc.S',
'startup.c',
'vector_gcc.S',
]
bsp_startup = os.path.join(bsp_path, 'startup_gcc.S')
if os.path.isfile(bsp_startup):
bsp_startup_obj = Env.Object('startup_gcc.o', '#startup_gcc.S')
else:
src += ['startup_gcc.S']
if GetDepend('RT_USING_BUILTIN_FDT'):
dtb_path = os.path.join(bsp_path, GetDepend('RT_BUILTIN_FDT_PATH').strip('"'))
builtin_fdt_obj = Env.Object('builtin_fdt_gcc.o', 'builtin_fdt_gcc.S')
Env.Depends(builtin_fdt_obj, dtb_path)
if GetDepend('ARCH_MM_MMU'):
src += ['mmu.c']
if GetDepend('RT_USING_HW_ATOMIC'):
src += ['atomic_riscv.c']
if GetDepend('RT_USING_LWP'):
src += ['syscall.c']
if not GetDepend('ARCH_RISCV_M_MODE'):
src += ['sbi.c']
if not GetDepend('RT_USING_DM'):
src += ['console.c']
if GetDepend('RT_USING_DM'):
src += ['setup.c']
if GetDepend('RT_USING_SMP'):
src += ['cpu_spinwait.c']
if not GetDepend('ARCH_RISCV_M_MODE'):
src += ['cpu_sbi.c']
if not GetDepend('RT_USING_DM'):
src += ['interrupt.c']
if GetDepend('ARCH_RISCV_USING_IRQ_STACK'):
src += ['irq_stack.c']
group = DefineGroup('libcpu', src, depend = [''], CPPPATH = CPPPATH)
group += bsp_startup_obj
group += builtin_fdt_obj
# build for sub-directory
list = os.listdir(cwd)
objs = []
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))
group = group + objs
Return('group')
|