summaryrefslogtreecommitdiffstats
path: root/sys/mips/include
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2012-03-03 08:19:18 +0000
committerjmallett <jmallett@FreeBSD.org>2012-03-03 08:19:18 +0000
commit50c253779ff59b0d64f2cfbb7efedabe19a620d8 (patch)
tree84d0a513be42586ec703acf6b5a531bc9d48d09c /sys/mips/include
parent402a0f9de41a1a087445529e59d3183a11d266b9 (diff)
downloadFreeBSD-src-50c253779ff59b0d64f2cfbb7efedabe19a620d8.zip
FreeBSD-src-50c253779ff59b0d64f2cfbb7efedabe19a620d8.tar.gz
o) Add COMPAT_FREEBSD32 support for MIPS kernels using the n64 ABI with userlands
using the o32 ABI. This mostly follows nwhitehorn's lead in implementing COMPAT_FREEBSD32 on powerpc64. o) Add a new type to the freebsd32 compat layer, time32_t, which is time_t in the 32-bit ABI being used. Since the MIPS port is relatively-new, even the 32-bit ABIs use a 64-bit time_t. o) Because time{spec,val}32 has the same size and layout as time{spec,val} on MIPS with 32-bit compatibility, then, disable some code which assumes otherwise wrongly when built for MIPS. A more general macro to check in this case would seem like a good idea eventually. If someone adds support for using n32 userland with n64 kernels on MIPS, then they will have to add a variety of flags related to each piece of the ABI that can vary. That's probably the right time to generalize further. o) Add MIPS to the list of architectures which use PAD64_REQUIRED in the freebsd32 compat code. Probably this should be generalized at some point. Reviewed by: gonzo
Diffstat (limited to 'sys/mips/include')
-rw-r--r--sys/mips/include/elf.h3
-rw-r--r--sys/mips/include/md_var.h6
-rw-r--r--sys/mips/include/param.h6
-rw-r--r--sys/mips/include/proc.h1
-rw-r--r--sys/mips/include/reg.h31
-rw-r--r--sys/mips/include/sigframe.h18
-rw-r--r--sys/mips/include/ucontext.h30
-rw-r--r--sys/mips/include/vmparam.h5
8 files changed, 98 insertions, 2 deletions
diff --git a/sys/mips/include/elf.h b/sys/mips/include/elf.h
index 39efeee..1c3d44d 100644
--- a/sys/mips/include/elf.h
+++ b/sys/mips/include/elf.h
@@ -52,6 +52,9 @@
#include <sys/elf_generic.h>
#define ELF_ARCH EM_MIPS
+#if __ELF_WORD_SIZE == 32
+#define ELF_ARCH32 EM_MIPS
+#endif
#define ELF_MACHINE_OK(x) ((x) == EM_MIPS || (x) == EM_MIPS_RS4_BE)
/* Architecture dependent Segment types - p_type */
diff --git a/sys/mips/include/md_var.h b/sys/mips/include/md_var.h
index 6f65a0f..00ff95a 100644
--- a/sys/mips/include/md_var.h
+++ b/sys/mips/include/md_var.h
@@ -41,7 +41,11 @@
*/
extern long Maxmem;
extern char sigcode[];
-extern int szsigcode, szosigcode;
+extern int szsigcode;
+#if defined(__mips_n32) || defined(__mips_n64)
+extern char sigcode32[];
+extern int szsigcode32;
+#endif
extern uint32_t *vm_page_dump;
extern int vm_page_dump_size;
diff --git a/sys/mips/include/param.h b/sys/mips/include/param.h
index 608d802..bd6d800 100644
--- a/sys/mips/include/param.h
+++ b/sys/mips/include/param.h
@@ -60,6 +60,9 @@
#if _BYTE_ORDER == _BIG_ENDIAN
#ifdef __mips_n64
#define MACHINE_ARCH "mips64eb"
+#ifndef MACHINE_ARCH32
+#define MACHINE_ARCH32 "mipseb"
+#endif
#elif defined(__mips_n32)
#define MACHINE_ARCH "mipsn32eb"
#else
@@ -68,6 +71,9 @@
#else
#ifdef __mips_n64
#define MACHINE_ARCH "mips64el"
+#ifndef MACHINE_ARCH32
+#define MACHINE_ARCH32 "mipsel"
+#endif
#elif defined(__mips_n32)
#define MACHINE_ARCH "mipsn32el"
#else
diff --git a/sys/mips/include/proc.h b/sys/mips/include/proc.h
index beba9167..42d08d9 100644
--- a/sys/mips/include/proc.h
+++ b/sys/mips/include/proc.h
@@ -96,6 +96,7 @@ struct syscall_args {
#ifdef __mips_n64
#define KINFO_PROC_SIZE 1088
+#define KINFO_PROC32_SIZE 816
#else
#define KINFO_PROC_SIZE 816
#endif
diff --git a/sys/mips/include/reg.h b/sys/mips/include/reg.h
index 6510db6..c240506 100644
--- a/sys/mips/include/reg.h
+++ b/sys/mips/include/reg.h
@@ -42,6 +42,10 @@
#ifndef _MACHINE_REG_H_
#define _MACHINE_REG_H_
+#if defined(_KERNEL) && !defined(KLD_MODULE) && !defined(_STANDALONE)
+#include "opt_compat.h"
+#endif
+
/*
* Location of the users' stored registers relative to ZERO.
* must be visible to assembly code.
@@ -66,6 +70,21 @@ struct dbreg {
unsigned long junk;
};
+#ifdef COMPAT_FREEBSD32
+/* Must match struct trapframe */
+struct reg32 {
+ uint32_t r_regs[NUMSAVEREGS];
+};
+
+struct fpreg32 {
+ int32_t r_regs[NUMFPREGS];
+};
+
+struct dbreg32 {
+ uint32_t junk;
+};
+#endif
+
#ifdef _KERNEL
int fill_fpregs(struct thread *, struct fpreg *);
int fill_regs(struct thread *, struct reg *);
@@ -75,4 +94,16 @@ int fill_dbregs(struct thread *, struct dbreg *);
int set_dbregs(struct thread *, struct dbreg *);
#endif
+#ifdef COMPAT_FREEBSD32
+struct image_params;
+
+int fill_regs32(struct thread *, struct reg32 *);
+int set_regs32(struct thread *, struct reg32 *);
+int fill_fpregs32(struct thread *, struct fpreg32 *);
+int set_fpregs32(struct thread *, struct fpreg32 *);
+
+#define fill_dbregs32(td, reg) 0
+#define set_dbregs32(td, reg) 0
+#endif
+
#endif /* !_MACHINE_REG_H_ */
diff --git a/sys/mips/include/sigframe.h b/sys/mips/include/sigframe.h
index 6919882..69c7c02 100644
--- a/sys/mips/include/sigframe.h
+++ b/sys/mips/include/sigframe.h
@@ -32,6 +32,10 @@
#ifndef _MACHINE_SIGFRAME_H_
#define _MACHINE_SIGFRAME_H_
+#if defined(_KERNEL) && !defined(KLD_MODULE) && !defined(_STANDALONE)
+#include "opt_compat.h"
+#endif
+
/*
* WARNING: code in locore.s assumes the layout shown for sf_signum
* thru sf_addr so... don't alter them!
@@ -46,4 +50,18 @@ struct sigframe {
unsigned long __spare__[2];
};
+#if (defined(__mips_n32) || defined(__mips_n64)) && defined(COMPAT_FREEBSD32)
+#include <compat/freebsd32/freebsd32_signal.h>
+
+struct sigframe32 {
+ int32_t sf_signum;
+ int32_t sf_siginfo; /* code or pointer to sf_si */
+ int32_t sf_ucontext; /* points to sf_uc */
+ int32_t sf_addr; /* undocumented 4th arg */
+ ucontext32_t sf_uc; /* = *sf_ucontext */
+ struct siginfo32 sf_si; /* = *sf_siginfo (SA_SIGINFO case) */
+ uint32_t __spare__[2];
+};
+#endif
+
#endif /* !_MACHINE_SIGFRAME_H_ */
diff --git a/sys/mips/include/ucontext.h b/sys/mips/include/ucontext.h
index 72f07b4..aafd1dc 100644
--- a/sys/mips/include/ucontext.h
+++ b/sys/mips/include/ucontext.h
@@ -39,6 +39,10 @@
#ifndef _LOCORE
+#if defined(_KERNEL) && !defined(KLD_MODULE) && !defined(_STANDALONE)
+#include "opt_compat.h"
+#endif
+
typedef struct __mcontext {
/*
* These fields must match the corresponding fields in struct
@@ -56,6 +60,32 @@ typedef struct __mcontext {
void *mc_tls; /* pointer to TLS area */
int __spare__[8]; /* XXX reserved */
} mcontext_t;
+
+#if (defined(__mips_n32) || defined(__mips_n64)) && defined(COMPAT_FREEBSD32)
+#include <compat/freebsd32/freebsd32_signal.h>
+
+typedef struct __mcontext32 {
+ int mc_onstack;
+ int32_t mc_pc;
+ int32_t mc_regs[32];
+ int32_t sr;
+ int32_t mullo, mulhi;
+ int mc_fpused;
+ int32_t mc_fpregs[33];
+ int32_t mc_fpc_eir;
+ void *mc_tls;
+ int __spare__[8];
+} mcontext32_t;
+
+typedef struct __ucontext32 {
+ sigset_t uc_sigmask;
+ mcontext32_t uc_mcontext;
+ uint32_t uc_link;
+ struct sigaltstack32 uc_stack;
+ uint32_t uc_flags;
+ uint32_t __spare__[4];
+} ucontext32_t;
+#endif
#endif
#ifndef SZREG
diff --git a/sys/mips/include/vmparam.h b/sys/mips/include/vmparam.h
index 4a702f5..aa0a5d7 100644
--- a/sys/mips/include/vmparam.h
+++ b/sys/mips/include/vmparam.h
@@ -96,7 +96,10 @@
* offset is calculated.
*/
#define USRSTACK (VM_MAXUSER_ADDRESS - PAGE_SIZE)
-
+#ifdef __mips_n64
+#define FREEBSD32_USRSTACK (((vm_offset_t)0x80000000) - PAGE_SIZE)
+#endif
+
/*
* Only one memory domain.
*/
OpenPOWER on IntegriCloud