示例#1
0
int
__pthread_setup (struct __pthread *thread,
		 void (*entry_point)(void *(*)(void *), void *),
		 void *(*start_routine)(void *), void *arg)
{
  thread->mcontext.pc = (void *) &_pthread_entry_point;
  thread->mcontext.sp = (void *) stack_setup (thread, start_routine, arg,
					      entry_point);

  if (__pthread_num_threads == 1)
    return 0;

  assert (! ADDR_IS_VOID (thread->exception_area[0]));

  struct exception_page *exception_page = thread->exception_area_va;

  /* SP is set to the end of the exception area minus one word, which
     is the location of the exception page.  */
  exception_page->exception_handler_sp
    = (uintptr_t) thread->exception_area_va + EXCEPTION_AREA_SIZE;
  exception_page->exception_handler_sp -= sizeof (void *);
  * (void **) exception_page->exception_handler_sp = thread->exception_area_va;

  exception_page->exception_handler_ip = (uintptr_t) &exception_handler_entry;
  exception_page->exception_handler_end = (uintptr_t) &exception_handler_end;

  return 0;
}
示例#2
0
BLE::BLE(CordioHCIDriver& hci_driver) :
    initialization_status(NOT_INITIALIZED),
    instanceID(::BLE::DEFAULT_INSTANCE),
    _event_queue(),
    _last_update_us(0)
{
    _hci_driver = &hci_driver;
    stack_setup();
}
示例#3
0
void c_main(int ac, char **av, char **env)
{
	char *file_to_map = av[3];
	char *file_to_unmap = av[2];
	int how_to_map = 0;
	void *mapped;
	void *entry_point;
	unsigned long dummy;
	Elf64_Ehdr *elf_ehdr, *ldso_ehdr;
	struct saved_block *argvb, *envb, *elfauxvb;
	int trim_args;
	void *stack_bottom;
	unsigned long empty[32768];

	empty[0] = 1;

	if (NULL == strstr(av[1], "dyn_unmap_run"))
	{
		file_to_map = av[1];
		file_to_unmap = NULL;
		how_to_map = 1;
		trim_args = 1;
	} else {
		file_to_map = av[2];
		file_to_unmap = av[0];
		how_to_map = 0;
		trim_args = 2;
	}

	if (file_to_unmap)
		unmap(file_to_unmap);

	mapped = map_file(file_to_map, &dummy);
	elf_ehdr = (Elf64_Ehdr *)mapped;

	entry_point = load_elf(mapped, how_to_map, &elf_ehdr, &ldso_ehdr);

	linux_munmap(mapped, dummy);

	argvb = save_argv(ac - trim_args, &av[trim_args]);
	envb = save_argv(0, env);
	elfauxvb = save_elfauxv(env);

	stack_bottom = stack_setup(argvb, envb, elfauxvb, elf_ehdr, ldso_ehdr);

	SET_STACK(stack_bottom);
	JMP_ADDR(entry_point);
}