rem: dprintf("team_create_team2: entry thread %ld\n", t->id);
add: TRACE(("team_create_team2: entry thread %ld\n", t->id));
context: team_create_team2(void *args){	int err;	struct thread *t;	struct team *team;	struct team_arg *teamArgs = args;	char *path;	addr entry;	char ustack_name[128];	uint32 totalSize;	char **uargs;	char **uenv;	char *udest;	struct uspace_program_args *uspa;	unsigned int arg_cnt;	unsigned int env_cnt;	t = thread_get_current_thread();	team = t->team;	dprintf("team_create_team2: entry thread %ld\n", t->id);	// create an initial primary stack region	// ToDo: make ENV_SIZE variable?	// ToDo: when B_BASE_ADDRESS is implemented, we could just allocate the stack from	//		the bottom of the USER_STACK_REGION.	totalSize = PAGE_ALIGN(MAIN_THREAD_STACK_SIZE + TLS_SIZE + ENV_SIZE +		get_arguments_data_size(teamArgs->args, teamArgs->argc));	t->user_stack_base = USER_STACK_REGION + USER_STACK_REGION_SIZE - totalSize;		// the exact location at the end of the user stack region	sprintf(ustack_name, "%s_primary_stack", team->name);	t->user_stack_region_id = create_area_etc(team, ustack_name, (void **)&t->user_stack_base,		B_EXACT_ADDRESS, totalSize, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);	if (t->user_stack_region_id < 0) {		panic("team_create_team2: could not create default user stack region\n");		return t->user_stack_region_id;	}	// now that the TLS area is allocated, initialize TLS	arch_thread_init_tls(t);	uspa = (struct uspace_program_args *)(t->user_stack_base + STACK_SIZE + TLS_SIZE + ENV_SIZE);	uargs = (char **)(uspa + 1);	udest = (char  *)(uargs + teamArgs->argc + 1);//	dprintf("addr: stack base=0x%x uargs = 0x%x  udest=0x%x tot_top_size=%d \n\n",t->user_stack_base,uargs,udest,tot_top_size);	for (arg_cnt = 0; arg_cnt < teamArgs->argc; arg_cnt++) {		uargs[arg_cnt] = udest;		udest += user_strlcpy(udest, teamArgs->args[arg_cnt], totalSize) + 1;	}	uargs[arg_cnt] = NULL;	team->user_env_base = t->user_stack_base + STACK_SIZE + TLS_SIZE;	uenv  = (char **)team->user_env_base;	udest = (char *)team->user_env_base + ENV_SIZE - 1;//	dprintf("team_create_team2: envc: %d, envp: 0x%p\n", teamArgs->envc, (void *)teamArgs->envp);	for (env_cnt = 0; env_cnt < teamArgs->envc; env_cnt++) {		size_t length = strlen(teamArgs->envp[env_cnt]) + 1;		udest -= length;		uenv[env_cnt] = udest;		user_memcpy(udest, teamArgs->envp[env_cnt], length);	}	uenv[env_cnt] = NULL;	user_memcpy(uspa->program_name, team->name, sizeof(uspa->program_name));	user_memcpy(uspa->program_path, teamArgs->path, sizeof(uspa->program_path));	uspa->argc = arg_cnt;	uspa->argv = uargs;	uspa->envc = env_cnt;	uspa->envp = uenv;	if (teamArgs->args != NULL)		kfree_strings_array(teamArgs->args, teamArgs->argc);	if (teamArgs->envp != NULL)		kfree_strings_array(teamArgs->envp, teamArgs->envc);	path = teamArgs->path;	dprintf("team_create_team2: loading elf binary '%s'\n", path);	err = elf_load_uspace("/boot/libexec/rld.so", team, 0, &entry);	if (err < 0){		// XXX clean up team		return err;	}	// free the args	free(teamArgs->path);	free(teamArgs);	dprintf("team_create_team2: loaded elf. entry = 0x%lx\n", entry);	team->state = TEAM_STATE_NORMAL;	// jump to the entry point in user space	arch_thread_enter_uspace(t, entry, uspa, NULL);	// never gets here	return 0;}