Exemple #1
0
def final_spec(cspaces, obj_space, addr_spaces, elf_files, architecture):
    """
    Generates a final CapDL spec file that can be given to a capdl loader application
    """
    arch = lookup_architecture(architecture)

    for e in [item for sublist in elf_files for item in sublist]:
        name = os.path.basename(e)
        elf = ELF(e, name, architecture)
        cspace = cspaces[name]

        # Avoid inferring a TCB as we've already created our own.
        elf_spec = elf.get_spec(infer_tcb=False,
                                infer_asid=False,
                                pd=addr_spaces[name].vspace_root,
                                addr_space=addr_spaces[name])
        obj_space.merge(elf_spec)
        cspace.cnode.finalise_size(arch)

        # Fill in TCB object information.
        # TODO: This should be generalised with what is in the Camkes filters
        tcb = obj_space["tcb_%s" % name]
        progsymbol = elf.get_symbol_vaddr("progname")
        vsyscall = elf.get_symbol_vaddr("sel4_vsyscall")
        tcb.init = [0, 0, 0, 0, 2, progsymbol, 1, 0, 0, 32, vsyscall, 0, 0]
        tcb.addr = elf.get_symbol_vaddr("mainIpcBuffer")
        tcb.sp = elf.get_symbol_vaddr("stack") + elf.get_symbol_size("stack")
        tcb.ip = elf.get_entry_point()

    return obj_space
Exemple #2
0
def final_spec(cspaces, obj_space, addr_spaces, elf_files, architecture, so_files):
    """
    Generates a final CapDL spec file that can be given to a capdl loader application
    """

    # cspaces : dict containes all the CSpaceAllocator for this app
    # obj_space : ObjectAllocator for all the objs in the spec
    # addr_spaces : dict containers all the AddressSpaceAllocator for this app
    print("In final_spec function")
    arch = lookup_architecture(architecture)

    # NOTE: handle shared lib so files here
    for e in [item for sublist in so_files for item in sublist]:
        name = os.path.basename(e)
        name = name[3:-3]
        print(name)

        elf = ELF(e, name, architecture)
        cspace = cspaces[name]

        print('the vspace root is ' + str(addr_spaces[name].vspace_root))
        print('The addr space allocator is ' + str(addr_spaces[name]))

        # Avoid inferring a TCB as we've already created our own.
        elf_spec = elf.get_spec(
            infer_tcb=False,
            infer_asid=False,
            pd=addr_spaces[name].vspace_root,
            addr_space=addr_spaces[name]
            )

        obj_space.merge(elf_spec)
        cspace.cnode.finalise_size(arch)

        # Fill in TCB object information.
        # NOTE: There will be a tcb for a shared lib file but handled in root task of capdl
        # loader
        # TODO: This should be generalised with what is in the Camkes filters
        tcb = obj_space["tcb_%s" % name]
        progsymbol = 0
        vsyscall = 0
        tcb.init = [0,0,0,0,2,progsymbol,1,0,0,32,vsyscall,0,0]
        tcb.addr = 0
        tcb.sp = 0
        tcb.ip = 0


    for e in [item for sublist in elf_files for item in sublist]:
        name = os.path.basename(e)
        print(name)

        # path, name, arch
        elf = ELF(e, name, architecture)

        # find the cspace for current elf
        cspace = cspaces[name]

        print('the vspace root is ' + str(addr_spaces[name].vspace_root))
        print('The addr space allocator is ' + str(addr_spaces[name]))

        # Avoid inferring a TCB as we've already created our own.
        elf_spec = elf.get_spec(
            infer_tcb=False,
            infer_asid=False,
            pd=addr_spaces[name].vspace_root,
            addr_space=addr_spaces[name]
            )
        obj_space.merge(elf_spec)
        cspace.cnode.finalise_size(arch)

        # Fill in TCB object information.
        # TODO: This should be generalised with what is in the Camkes filters
        tcb = obj_space["tcb_%s" % name]
        progsymbol = elf.get_symbol_vaddr("progname")
        vsyscall = elf.get_symbol_vaddr("sel4_vsyscall")
        tcb.init = [0,0,0,0,2,progsymbol,1,0,0,32,vsyscall,0,0]
        tcb.addr = elf.get_symbol_vaddr("mainIpcBuffer");
        tcb.sp = elf.get_symbol_vaddr("stack")+elf.get_symbol_size("stack");
        tcb.ip = elf.get_entry_point()

    return obj_space