Added port_get_refs and port_mod_refs

This commit is contained in:
manu 2004-07-24 15:46:02 +00:00
parent c0431a8e23
commit 4bc8afece2
7 changed files with 127 additions and 25 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_port.c,v 1.52 2004/03/24 16:55:07 pooka Exp $ */
/* $NetBSD: mach_port.c,v 1.53 2004/07/24 15:46:02 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include "opt_compat_darwin.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_port.c,v 1.52 2004/03/24 16:55:07 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_port.c,v 1.53 2004/07/24 15:46:02 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -588,6 +588,70 @@ mach_port_request_notification(args)
return 0;
}
int
mach_port_get_refs(args)
struct mach_trap_args *args;
{
mach_port_get_refs_request_t *req = args->smsg;
mach_port_get_refs_reply_t *rep = args->rmsg;
size_t *msglen = args->rsize;
struct lwp *l = args->l;
mach_port_t mn;
struct mach_right *mr;
mach_port_right_t right = req->req_right;
mn = req->req_name;
if ((mr = mach_right_check(mn, l, right)) == NULL)
return mach_msg_error(args, EINVAL);
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
rep->rep_refs = mr->mr_refcount;
mach_set_trailer(rep, *msglen);
return 0;
}
int
mach_port_mod_refs(args)
struct mach_trap_args *args;
{
mach_port_mod_refs_request_t *req = args->smsg;
mach_port_mod_refs_reply_t *rep = args->rmsg;
size_t *msglen = args->rsize;
#if 0
struct lwp *l = args->l;
mach_port_t mn;
struct mach_right *mr;
mach_port_right_t right = req->req_right;
mn = req->req_name;
if ((mr = mach_right_check(mn, l, right)) == NULL)
return mach_msg_error(args, EINVAL);
/*
* Changing the refcount is likely to cause crashes,
* as we will free a right which might still be referenced
* within the kernel. Add a user refcount field?
*/
mr->mr_refcount += req->req_delta;
if (mr->mr_refcount <= 0)
mach_right_put(mr, right);
#endif
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
void
mach_port_init(void)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_port.h,v 1.34 2004/01/01 22:48:54 manu Exp $ */
/* $NetBSD: mach_port.h,v 1.35 2004/07/24 15:46:02 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -256,6 +256,40 @@ typedef struct {
mach_msg_trailer_t rep_trailer;
} mach_port_request_notification_reply_t;
/* port_get_refs */
typedef struct {
mach_msg_header_t req_msgh;
mach_ndr_record_t req_ndr;
mach_port_name_t req_name;
mach_port_right_t req_right;
} mach_port_get_refs_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_ndr_record_t rep_ndr;
mach_kern_return_t rep_retval;
mach_port_urefs_t rep_refs;
mach_msg_trailer_t rep_trailer;
} mach_port_get_refs_reply_t;
/* port_mod_refs */
typedef struct {
mach_msg_header_t req_msgh;
mach_ndr_record_t req_ndr;
mach_port_name_t req_name;
mach_port_right_t req_right;
mach_port_delta_t req_delta;
} mach_port_mod_refs_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_ndr_record_t rep_ndr;
mach_kern_return_t rep_retval;
mach_msg_trailer_t rep_trailer;
} mach_port_mod_refs_reply_t;
/* Kernel-private structures */
extern struct mach_port *mach_clock_port;

View File

@ -1,14 +1,14 @@
/* $NetBSD: mach_services.c,v 1.13 2003/12/29 01:30:27 manu Exp $ */
/* $NetBSD: mach_services.c,v 1.14 2004/07/24 15:46:02 manu Exp $ */
/*
* Mach services table.
*
* DO NOT EDIT -- this file is automatically generated.
* created from NetBSD: mach_services.master,v 1.9 2003/12/24 23:22:22 manu Exp
* created from NetBSD: mach_services.master,v 1.10 2003/12/29 01:30:27 manu Exp
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_services.c,v 1.13 2003/12/29 01:30:27 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_services.c,v 1.14 2004/07/24 15:46:02 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -57,7 +57,7 @@ struct mach_service mach_services_table[] = {
{400, NULL, "unimpl. host_get_boot_info", 0, 0},
{401, NULL, "unimpl. host_reboot", 0, 0},
{402, NULL, "unimpl. host_priv_statistics", 0, 0},
{403, NULL, "unimpl. host_default_memory_manager", 0, 0},
{403, NULL, "unimpl. boostrap_register", 0, 0},
{404, mach_bootstrap_look_up, "bootstrap_look_up", sizeof(mach_bootstrap_look_up_request_t), sizeof(mach_bootstrap_look_up_reply_t)},
{405, NULL, "unimpl. thread_wire", 0, 0},
{406, NULL, "unimpl. vm_allocate_cpm", 0, 0},
@ -197,8 +197,8 @@ struct mach_service mach_services_table[] = {
{3204, mach_port_allocate, "port_allocate", sizeof(mach_port_allocate_request_t), sizeof(mach_port_allocate_reply_t)},
{3205, mach_port_destroy, "port_destroy", sizeof(mach_port_destroy_request_t), sizeof(mach_port_destroy_reply_t)},
{3206, mach_port_deallocate, "port_deallocate", sizeof(mach_port_deallocate_request_t), sizeof(mach_port_deallocate_reply_t)},
{3207, NULL, "unimpl. port_get_refs", 0, 0},
{3208, NULL, "unimpl. port_mod_refs", 0, 0},
{3207, mach_port_get_refs, "port_get_refs", sizeof(mach_port_get_refs_request_t), sizeof(mach_port_get_refs_reply_t)},
{3208, mach_port_mod_refs, "port_mod_refs", sizeof(mach_port_mod_refs_request_t), sizeof(mach_port_mod_refs_reply_t)},
{3210, NULL, "unimpl. port_set_mscount", 0, 0},
{3211, NULL, "unimpl. port_get_set_status", 0, 0},
{3212, mach_port_move_member, "port_move_member", sizeof(mach_port_move_member_request_t), sizeof(mach_port_move_member_reply_t)},

View File

@ -1,14 +1,14 @@
/* $NetBSD: mach_services.h,v 1.13 2003/12/29 01:30:27 manu Exp $ */
/* $NetBSD: mach_services.h,v 1.14 2004/07/24 15:46:02 manu Exp $ */
/*
* Mach services prototypes.
*
* DO NOT EDIT -- this file is automatically generated.
* created from NetBSD: mach_services.master,v 1.9 2003/12/24 23:22:22 manu Exp
* created from NetBSD: mach_services.master,v 1.10 2003/12/29 01:30:27 manu Exp
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_services.h,v 1.13 2003/12/29 01:30:27 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_services.h,v 1.14 2004/07/24 15:46:02 manu Exp $");
#include <compat/mach/mach_types.h>
#include <compat/mach/mach_message.h>
@ -55,6 +55,8 @@ int mach_port_type(struct mach_trap_args *);
int mach_port_allocate(struct mach_trap_args *);
int mach_port_destroy(struct mach_trap_args *);
int mach_port_deallocate(struct mach_trap_args *);
int mach_port_get_refs(struct mach_trap_args *);
int mach_port_mod_refs(struct mach_trap_args *);
int mach_port_move_member(struct mach_trap_args *);
int mach_port_request_notification(struct mach_trap_args *);
int mach_port_insert_right(struct mach_trap_args *);

View File

@ -1,4 +1,4 @@
$NetBSD: mach_services.master,v 1.10 2003/12/29 01:30:27 manu Exp $
$NetBSD: mach_services.master,v 1.11 2004/07/24 15:46:02 manu Exp $
;
; Mach services list.
;
@ -63,9 +63,9 @@
400 UNIMPL host_get_boot_info
401 UNIMPL host_reboot
402 UNIMPL host_priv_statistics
; Would be boostrap_register instead?
403 UNIMPL host_default_memory_manager
; Would be vm_wire instead?
; Implemented by mach_init, clashes with host_default_memory_manager
403 UNIMPL boostrap_register
; Implemented by mach_init, clashes with vm_wire
404 STD bootstrap_look_up
405 UNIMPL thread_wire
406 UNIMPL vm_allocate_cpm
@ -267,8 +267,8 @@
3204 STD port_allocate
3205 STD port_destroy
3206 STD port_deallocate
3207 UNIMPL port_get_refs
3208 UNIMPL port_mod_refs
3207 STD port_get_refs
3208 STD port_mod_refs
3210 UNIMPL port_set_mscount
3211 UNIMPL port_get_set_status
3212 STD port_move_member

View File

@ -1,15 +1,15 @@
/* $NetBSD: mach_services_names.c,v 1.10 2003/12/29 01:30:27 manu Exp $ */
/* $NetBSD: mach_services_names.c,v 1.11 2004/07/24 15:46:02 manu Exp $ */
/*
* Mach services names. This file is not built
* by the kernel, it is included by kdump sources.
*
* DO NOT EDIT -- this file is automatically generated.
* created from NetBSD: mach_services.master,v 1.9 2003/12/24 23:22:22 manu Exp
* created from NetBSD: mach_services.master,v 1.10 2003/12/29 01:30:27 manu Exp
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_services_names.c,v 1.10 2003/12/29 01:30:27 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_services_names.c,v 1.11 2004/07/24 15:46:02 manu Exp $");
struct mach_service_name {
int srv_id;
@ -46,7 +46,7 @@ struct mach_service_name mach_services_names[] = {
{400, "unimpl. host_get_boot_info"},
{401, "unimpl. host_reboot"},
{402, "unimpl. host_priv_statistics"},
{403, "unimpl. host_default_memory_manager"},
{403, "unimpl. boostrap_register"},
{404, "bootstrap_look_up"},
{405, "unimpl. thread_wire"},
{406, "unimpl. vm_allocate_cpm"},
@ -186,8 +186,8 @@ struct mach_service_name mach_services_names[] = {
{3204, "port_allocate"},
{3205, "port_destroy"},
{3206, "port_deallocate"},
{3207, "unimpl. port_get_refs"},
{3208, "unimpl. port_mod_refs"},
{3207, "port_get_refs"},
{3208, "port_mod_refs"},
{3210, "unimpl. port_set_mscount"},
{3211, "unimpl. port_get_set_status"},
{3212, "port_move_member"},

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_types.h,v 1.20 2003/12/30 00:14:20 manu Exp $ */
/* $NetBSD: mach_types.h,v 1.21 2004/07/24 15:46:02 manu Exp $ */
/*-
* Copyright (c) 2001-2003 The NetBSD Foundation, Inc.
@ -77,6 +77,8 @@ typedef mach_natural_t mach_thread_flavor_t;
typedef int mach_policy_t;
typedef int mach_vm_machine_attribute_val_t;
typedef unsigned int mach_vm_machine_attribute_t;
typedef mach_natural_t mach_port_urefs_t;
typedef int mach_port_delta_t;
/*