In mach_reply_port, don't increment the returned port for now, this confuses
the binary on the second launch. In mach_vm_map, hack in a failure so that we fail exactly like Darwin when mapping a page at address 0 Add vm_allocate trap
This commit is contained in:
parent
3eb20e3576
commit
f130f7a839
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mach_errno.c,v 1.2 2002/11/12 05:18:31 manu Exp $ */
|
||||
/* $NetBSD: mach_errno.c,v 1.3 2002/11/12 06:14:39 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_errno.c,v 1.2 2002/11/12 05:18:31 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_errno.c,v 1.3 2002/11/12 06:14:39 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -59,7 +59,7 @@ int native_to_mach_errno[] = {
|
|||
MACH_KERN_FAILURE, /* EBADF */
|
||||
MACH_KERN_FAILURE, /* ECHILD */ /* 10 */
|
||||
MACH_KERN_FAILURE, /* EDEADLK */
|
||||
MACH_KERN_FAILURE, /* ENOMEM */
|
||||
MACH_KERN_NO_SPACE, /* ENOMEM */
|
||||
MACH_KERN_FAILURE, /* EACCES */
|
||||
MACH_KERN_INVALID_ADDRESS, /* EFAULT */
|
||||
MACH_KERN_FAILURE, /* ENOTBLK */ /* 15 */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mach_host.c,v 1.6 2002/11/11 09:28:00 manu Exp $ */
|
||||
/* $NetBSD: mach_host.c,v 1.7 2002/11/12 06:14:39 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_host.c,v 1.6 2002/11/11 09:28:00 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_host.c,v 1.7 2002/11/12 06:14:39 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/malloc.h>
|
||||
|
@ -86,8 +86,8 @@ mach_host_info(p, msgh)
|
|||
info->max_cpus = 1; /* XXX fill this accurately */
|
||||
info->avail_cpus = 1;
|
||||
info->memory_size = uvmexp.active + uvmexp.inactive;
|
||||
info->cpu_type = 0;
|
||||
info->cpu_subtype = 0;
|
||||
info->cpu_type = 12;
|
||||
info->cpu_subtype = 9;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mach_namemap.c,v 1.3 2002/11/10 21:53:40 manu Exp $ */
|
||||
/* $NetBSD: mach_namemap.c,v 1.4 2002/11/12 06:14:39 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.3 2002/11/10 21:53:40 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.4 2002/11/12 06:14:39 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -57,6 +57,7 @@ struct mach_subsystem_namemap mach_namemap[] = {
|
|||
{ 3206, mach_port_deallocate, "port_deallocate" },
|
||||
{ 3404, mach_ports_lookup, "ports_lookup" },
|
||||
{ 3409, mach_task_get_special_port, "task_get_special_port" },
|
||||
{ 3801, mach_vm_allocate, "vm_allocate" },
|
||||
{ 3802, mach_vm_deallocate, "vm_deallocate" },
|
||||
{ 3812, mach_vm_map, "vm_map" },
|
||||
{ 0, NULL, NULL },
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mach_port.c,v 1.3 2002/11/11 09:28:00 manu Exp $ */
|
||||
/* $NetBSD: mach_port.c,v 1.4 2002/11/12 06:14:39 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_port.c,v 1.3 2002/11/11 09:28:00 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_port.c,v 1.4 2002/11/12 06:14:39 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -58,7 +58,7 @@ mach_sys_reply_port(p, v, retval)
|
|||
{
|
||||
static int current_port = 0x80b;
|
||||
|
||||
*retval = current_port++; /* XXX */
|
||||
*retval = current_port; /* XXX */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mach_vm.c,v 1.5 2002/11/12 05:18:32 manu Exp $ */
|
||||
/* $NetBSD: mach_vm.c,v 1.6 2002/11/12 06:14:39 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.5 2002/11/12 05:18:32 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.6 2002/11/12 06:14:39 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -67,6 +67,12 @@ mach_vm_map(p, msgh)
|
|||
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
|
||||
return error;
|
||||
|
||||
#if 1
|
||||
/* XXX Darwin fails on mapping a page at address 0 */
|
||||
if (req.req_address == 0)
|
||||
return MACH_MSG_ERROR(msgh, &req, &rep, ENOMEM);
|
||||
#endif
|
||||
|
||||
bzero(&rep, sizeof(rep));
|
||||
|
||||
DPRINTF(("vm_map(addr = %p, size = 0x%08x)\n",
|
||||
|
@ -93,6 +99,44 @@ mach_vm_map(p, msgh)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
mach_vm_allocate(p, msgh)
|
||||
struct proc *p;
|
||||
mach_msg_header_t *msgh;
|
||||
{
|
||||
mach_vm_allocate_request_t req;
|
||||
mach_vm_allocate_reply_t rep;
|
||||
struct sys_mmap_args cup;
|
||||
int error;
|
||||
|
||||
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
|
||||
return error;
|
||||
|
||||
bzero(&rep, sizeof(rep));
|
||||
|
||||
SCARG(&cup, addr) = (caddr_t)req.req_address;
|
||||
SCARG(&cup, len) = req.req_size;
|
||||
SCARG(&cup, prot) = PROT_READ | PROT_WRITE;
|
||||
SCARG(&cup, flags) = MAP_ANON;
|
||||
if (req.req_flags)
|
||||
SCARG(&cup, flags) |= MAP_FIXED;
|
||||
SCARG(&cup, fd) = -1;
|
||||
SCARG(&cup, pos) = 0;
|
||||
|
||||
if ((error = sys_mmap(p, &cup, &rep.rep_address)) != 0)
|
||||
return MACH_MSG_ERROR(msgh, &req, &rep, error);
|
||||
|
||||
rep.rep_msgh.msgh_bits =
|
||||
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
|
||||
rep.rep_msgh.msgh_size = sizeof(rep) - sizeof(rep.rep_trailer);
|
||||
rep.rep_msgh.msgh_local_port = req.req_msgh.msgh_local_port;
|
||||
rep.rep_msgh.msgh_id = req.req_msgh.msgh_id + 100;
|
||||
rep.rep_trailer.msgh_trailer_size = 8;
|
||||
|
||||
if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
|
||||
return error;
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
mach_vm_deallocate(p, msgh)
|
||||
struct proc *p;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mach_vm.h,v 1.1 2002/11/10 21:53:41 manu Exp $ */
|
||||
/* $NetBSD: mach_vm.h,v 1.2 2002/11/12 06:14:39 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -72,6 +72,24 @@ typedef struct {
|
|||
mach_msg_trailer_t rep_trailer;
|
||||
} mach_vm_map_reply_t;
|
||||
|
||||
/* vm_allocate */
|
||||
typedef struct {
|
||||
mach_msg_header_t req_msgh;
|
||||
mach_ndr_record_t req_ndr;
|
||||
mach_vm_address_t req_address;
|
||||
mach_vm_size_t req_size;
|
||||
int req_flags;
|
||||
} mach_vm_allocate_request_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
mach_msg_header_t rep_msgh;
|
||||
mach_ndr_record_t rep_ndr;
|
||||
mach_kern_return_t rep_retval;
|
||||
mach_vm_address_t rep_address;
|
||||
mach_msg_trailer_t rep_trailer;
|
||||
} mach_vm_allocate_reply_t;
|
||||
|
||||
/* vm_deallocate */
|
||||
|
||||
typedef struct {
|
||||
|
@ -89,6 +107,7 @@ typedef struct {
|
|||
} mach_vm_deallocate_reply_t;
|
||||
|
||||
int mach_vm_map __P((struct proc *, mach_msg_header_t *));
|
||||
int mach_vm_allocate __P((struct proc *, mach_msg_header_t *));
|
||||
int mach_vm_deallocate __P((struct proc *, mach_msg_header_t *));
|
||||
|
||||
#endif /* _MACH_VM_H_ */
|
||||
|
|
Loading…
Reference in New Issue