11.1Smartin/* $NetBSD: _lwp.c,v 1.1 2015/04/17 12:51:05 martin Exp $ */ 21.1Smartin 31.1Smartin/*- 41.1Smartin * Copyright (c) 2001 The NetBSD Foundation, Inc. 51.1Smartin * All rights reserved. 61.1Smartin * 71.1Smartin * This code is derived from software contributed to The NetBSD Foundation 81.1Smartin * by Nathan J. Williams. 91.1Smartin * 101.1Smartin * Redistribution and use in source and binary forms, with or without 111.1Smartin * modification, are permitted provided that the following conditions 121.1Smartin * are met: 131.1Smartin * 1. Redistributions of source code must retain the above copyright 141.1Smartin * notice, this list of conditions and the following disclaimer. 151.1Smartin * 2. Redistributions in binary form must reproduce the above copyright 161.1Smartin * notice, this list of conditions and the following disclaimer in the 171.1Smartin * documentation and/or other materials provided with the distribution. 181.1Smartin * 191.1Smartin * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Smartin * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Smartin * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Smartin * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Smartin * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Smartin * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Smartin * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Smartin * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Smartin * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Smartin * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Smartin * POSSIBILITY OF SUCH DAMAGE. 301.1Smartin */ 311.1Smartin 321.1Smartin#include <sys/cdefs.h> 331.1Smartin#if defined(LIBC_SCCS) && !defined(lint) 341.1Smartin__RCSID("$NetBSD: _lwp.c,v 1.1 2015/04/17 12:51:05 martin Exp $"); 351.1Smartin#endif /* LIBC_SCCS and not lint */ 361.1Smartin 371.1Smartin#include "namespace.h" 381.1Smartin#include <sys/types.h> 391.1Smartin#include <ucontext.h> 401.1Smartin#include <lwp.h> 411.1Smartin#include <stdlib.h> 421.1Smartin 431.1Smartinvoid 441.1Smartin_lwp_makecontext(ucontext_t *u, void (*start)(void *), 451.1Smartin void *arg, void *private, caddr_t stack_base, size_t stack_size) 461.1Smartin{ 471.1Smartin#if 0 481.1Smartin __greg_t *gr; 491.1Smartin 501.1Smartin getcontext(u); 511.1Smartin gr = u->uc_mcontext.__gregs; 521.1Smartin 531.1Smartin u->uc_link = NULL; 541.1Smartin 551.1Smartin u->uc_stack.ss_sp = stack_base; 561.1Smartin u->uc_stack.ss_size = stack_size; 571.1Smartin 581.1Smartin gr[_REG_PC] = (unsigned long)start; 591.1Smartin gr[_REG_T12] = (unsigned long) start; 601.1Smartin gr[_REG_RA] = (unsigned long) _lwp_exit; 611.1Smartin gr[_REG_A0] = (unsigned long) arg; 621.1Smartin gr[_REG_SP] = ((unsigned long) (stack_base + stack_size)) & ~0x7; 631.1Smartin gr[_REG_S6] = 0; 641.1Smartin gr[_REG_UNIQUE] = (unsigned long)private; 651.1Smartin 661.1Smartin u->uc_flags |= _UC_TLSBASE; 671.1Smartin#endif 681.1Smartin} 69