1# * Copyright 2015, NICTA
2# *
3# * This software may be distributed and modified according to the terms of
4# * the BSD 2-Clause license. Note that NO WARRANTY is provided.
5# * See "LICENSE_BSD2.txt" for details.
6# *
7# * @TAG(NICTA_BSD)
8
9from target_objects import target_dir, structs, functions
10from target_objects import symbols, sections, rodata, pairings
11import target_objects
12
13import syntax
14import pseudo_compile
15import objdump
16import logic
17import re
18
19f = open ('%s/kernel.elf.symtab' % target_dir)
20objdump.install_syms (f)
21f.close ()
22
23f = open ('%s/CFunctions.txt' % target_dir)
24syntax.parse_and_install_all (f, 'C')
25f.close ()
26
27f = open ('%s/ASMFunctions.txt' % target_dir)
28(astructs, afunctions, aconst_globals) = syntax.parse_and_install_all (f, 'ASM',skip_functions= ['fastpath_call', 'fastpath_reply_recv','c_handle_syscall'])
29f.close ()
30assert not astructs
31assert not aconst_globals
32
33assert logic.aligned_address_sanity (afunctions, symbols, 4)
34
35f = open ('%s/kernel.elf.rodata' % target_dir)
36objdump.install_rodata (f, [('Section', '.rodata'), ('Symbol', 'kernel_devices'),
37	('Symbol', 'avail_p_regs'), ('Symbol', 'dev_p_regs')])
38f.close ()
39
40print 'Pseudo-Compiling.'
41pseudo_compile.compile_funcs (functions)
42
43print 'Doing stack/inst logic.'
44
45def make_pairings ():
46	pairs = [(s, 'Kernel_C.' + s) for s in functions
47		if ('Kernel_C.' + s) in functions]
48	target_objects.use_hooks.add ('stack_logic')
49	import stack_logic
50	stack_bounds = '%s/StackBounds.txt' % target_dir
51	new_pairings = stack_logic.mk_stack_pairings (pairs, stack_bounds)
52	pairings.update (new_pairings)
53
54make_pairings ()
55
56import inst_logic
57inst_logic.add_inst_specs ()
58
59print 'Checking.'
60syntax.check_funs (functions)
61
62
63