svn commit: r195128 - in projects/mips/sys/mips: include mips
Oleksandr Tymoshenko
gonzo at FreeBSD.org
Sat Jun 27 23:27:44 UTC 2009
Author: gonzo
Date: Sat Jun 27 23:27:41 2009
New Revision: 195128
URL: http://svn.freebsd.org/changeset/base/195128
Log:
- Add support for handling TLS area address in kernel space.
From the userland point of view get/set operations are
performed using sysarch(2) call.
Added:
projects/mips/sys/mips/mips/sys_machdep.c
Modified:
projects/mips/sys/mips/include/proc.h
projects/mips/sys/mips/include/sysarch.h
projects/mips/sys/mips/include/ucontext.h
projects/mips/sys/mips/mips/genassym.c
projects/mips/sys/mips/mips/machdep.c
projects/mips/sys/mips/mips/pm_machdep.c
projects/mips/sys/mips/mips/vm_machdep.c
Modified: projects/mips/sys/mips/include/proc.h
==============================================================================
--- projects/mips/sys/mips/include/proc.h Sat Jun 27 23:01:35 2009 (r195127)
+++ projects/mips/sys/mips/include/proc.h Sat Jun 27 23:27:41 2009 (r195128)
@@ -54,6 +54,7 @@ struct mdthread {
int md_pc_count; /* performance counter */
int md_pc_spill; /* performance counter spill */
vm_offset_t md_realstack;
+ void *md_tls;
};
/* md_flags */
Modified: projects/mips/sys/mips/include/sysarch.h
==============================================================================
--- projects/mips/sys/mips/include/sysarch.h Sat Jun 27 23:01:35 2009 (r195127)
+++ projects/mips/sys/mips/include/sysarch.h Sat Jun 27 23:27:41 2009 (r195128)
@@ -35,16 +35,12 @@
#ifndef _MACHINE_SYSARCH_H_
#define _MACHINE_SYSARCH_H_
+#define MIPS_SET_TLS 1
+#define MIPS_GET_TLS 2
+
#ifndef _KERNEL
#include <sys/cdefs.h>
-#if 0
-/* Something useful for each MIPS platform. */
-#else
-#define mips_tcb_set(tcb) do {} while (0)
-#define mips_tcb_get() NULL
-#endif /* _MIPS_ARCH_XLR */
-
__BEGIN_DECLS
int sysarch(int, void *);
__END_DECLS
Modified: projects/mips/sys/mips/include/ucontext.h
==============================================================================
--- projects/mips/sys/mips/include/ucontext.h Sat Jun 27 23:01:35 2009 (r195127)
+++ projects/mips/sys/mips/include/ucontext.h Sat Jun 27 23:27:41 2009 (r195128)
@@ -53,6 +53,7 @@ typedef struct __mcontext {
int mc_fpused; /* fp has been used */
f_register_t mc_fpregs[33]; /* fp regs 0 to 31 and csr */
register_t mc_fpc_eir; /* fp exception instruction reg */
+ void *mc_tls; /* pointer to TLS area */
int __spare__[8]; /* XXX reserved */
} mcontext_t;
#endif
Modified: projects/mips/sys/mips/mips/genassym.c
==============================================================================
--- projects/mips/sys/mips/mips/genassym.c Sat Jun 27 23:01:35 2009 (r195127)
+++ projects/mips/sys/mips/mips/genassym.c Sat Jun 27 23:27:41 2009 (r195128)
@@ -69,6 +69,7 @@ ASSYM(TD_REALKSTACK, offsetof(struct thr
ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
ASSYM(TD_LOCK, offsetof(struct thread, td_lock));
ASSYM(TD_FRAME, offsetof(struct thread, td_frame));
+ASSYM(TD_TLS, offsetof(struct thread, td_md.md_tls));
ASSYM(TF_REG_SR, offsetof(struct trapframe, sr));
Modified: projects/mips/sys/mips/mips/machdep.c
==============================================================================
--- projects/mips/sys/mips/mips/machdep.c Sat Jun 27 23:01:35 2009 (r195127)
+++ projects/mips/sys/mips/mips/machdep.c Sat Jun 27 23:27:41 2009 (r195128)
@@ -350,12 +350,6 @@ cpu_pcpu_init(struct pcpu *pcpu, int cpu
}
int
-sysarch(struct thread *td, register struct sysarch_args *uap)
-{
- return (ENOSYS);
-}
-
-int
fill_dbregs(struct thread *td, struct dbreg *dbregs)
{
Modified: projects/mips/sys/mips/mips/pm_machdep.c
==============================================================================
--- projects/mips/sys/mips/mips/pm_machdep.c Sat Jun 27 23:01:35 2009 (r195127)
+++ projects/mips/sys/mips/mips/pm_machdep.c Sat Jun 27 23:27:41 2009 (r195128)
@@ -413,9 +413,16 @@ get_mcontext(struct thread *td, mcontext
bcopy((void *)&td->td_frame->f0, (void *)&mcp->mc_fpregs,
sizeof(mcp->mc_fpregs));
}
+ if (flags & GET_MC_CLEAR_RET) {
+ mcp->mc_regs[V0] = 0;
+ mcp->mc_regs[V1] = 0;
+ mcp->mc_regs[A3] = 0;
+ }
+
mcp->mc_pc = td->td_frame->pc;
mcp->mullo = td->td_frame->mullo;
mcp->mulhi = td->td_frame->mulhi;
+ mcp->mc_tls = td->td_md.md_tls;
return (0);
}
@@ -436,6 +443,7 @@ set_mcontext(struct thread *td, const mc
td->td_frame->pc = mcp->mc_pc;
td->td_frame->mullo = mcp->mullo;
td->td_frame->mulhi = mcp->mulhi;
+ td->td_md.md_tls = mcp->mc_tls;
/* Dont let user to set any bits in Status and casue registers */
return (0);
Added: projects/mips/sys/mips/mips/sys_machdep.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/mips/sys/mips/mips/sys_machdep.c Sat Jun 27 23:27:41 2009 (r195128)
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/sysproto.h>
+#include <sys/syscall.h>
+#include <sys/sysent.h>
+
+#include <machine/sysarch.h>
+
+#ifndef _SYS_SYSPROTO_H_
+struct sysarch_args {
+ int op;
+ char *parms;
+};
+#endif
+
+int
+sysarch(td, uap)
+ struct thread *td;
+ register struct sysarch_args *uap;
+{
+ int error;
+ void *tlsbase;
+
+ switch (uap->op) {
+ case MIPS_SET_TLS :
+ td->td_md.md_tls = (void*)uap->parms;
+ error = 0;
+ break;
+
+ case MIPS_GET_TLS :
+ tlsbase = td->td_md.md_tls;
+ error = copyout(&tlsbase, uap->parms, sizeof(tlsbase));
+ break;
+ default:
+ error = EINVAL;
+ }
+ return (error);
+}
Modified: projects/mips/sys/mips/mips/vm_machdep.c
==============================================================================
--- projects/mips/sys/mips/mips/vm_machdep.c Sat Jun 27 23:01:35 2009 (r195127)
+++ projects/mips/sys/mips/mips/vm_machdep.c Sat Jun 27 23:27:41 2009 (r195128)
@@ -156,6 +156,7 @@ cpu_fork(register struct thread *td1,reg
* that are needed.
*/
+ td2->td_md.md_tls = td1->td_md.md_tls;
td2->td_md.md_saved_intr = MIPS_SR_INT_IE;
td2->td_md.md_spinlock_count = 1;
#ifdef TARGET_OCTEON
@@ -535,7 +536,7 @@ int
cpu_set_user_tls(struct thread *td, void *tls_base)
{
- /* TBD */
+ td->td_md.md_tls = tls_base;
return (0);
}
More information about the svn-src-projects
mailing list