More IOKit shell. This makes ioreg looping on device discovery: foobar

has a child called foobar, and so on.
This commit is contained in:
manu 2003-02-07 20:40:37 +00:00
parent 351f7a02f1
commit 44af8c7eb4
3 changed files with 233 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_iokit.c,v 1.3 2003/02/07 16:56:19 manu Exp $ */
/* $NetBSD: mach_iokit.c,v 1.4 2003/02/07 20:40:37 manu Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_iokit.c,v 1.3 2003/02/07 16:56:19 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_iokit.c,v 1.4 2003/02/07 20:40:37 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -324,4 +324,132 @@ mach_io_connect_set_notification_port(args)
return 0;
}
int
mach_io_registry_get_root_entry(args)
struct mach_trap_args *args;
{
mach_io_registry_get_root_entry_request_t *req = args->smsg;
mach_io_registry_get_root_entry_reply_t *rep = args->rmsg;
size_t *msglen = args->rsize;
struct lwp *l = args->l;
struct mach_port *mp;
struct mach_right *mr;
mp = mach_port_get();
mp->mp_flags |= MACH_MP_INKERNEL;
mr = mach_right_get(mp, l, MACH_PORT_TYPE_SEND, 0);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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_body.msgh_descriptor_count = 1;
rep->rep_root.name = (mach_port_t)mr->mr_name;
rep->rep_root.disposition = 0x11; /* XXX */
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
return 0;
}
int
mach_io_registry_entry_get_child_iterator(args)
struct mach_trap_args *args;
{
mach_io_registry_entry_get_child_iterator_request_t *req = args->smsg;
mach_io_registry_entry_get_child_iterator_reply_t *rep = args->rmsg;
size_t *msglen = args->rsize;
struct lwp *l = args->l;
struct mach_port *mp;
struct mach_right *mr;
mp = mach_port_get();
mp->mp_flags |= MACH_MP_INKERNEL;
mr = mach_right_get(mp, l, MACH_PORT_TYPE_SEND, 0);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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_body.msgh_descriptor_count = 1;
rep->rep_iterator.name = (mach_port_t)mr->mr_name;
rep->rep_iterator.disposition = 0x11; /* XXX */
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
return 0;
}
int
mach_io_registry_entry_get_name_in_plane(args)
struct mach_trap_args *args;
{
mach_io_registry_entry_get_name_in_plane_request_t *req = args->smsg;
mach_io_registry_entry_get_name_in_plane_reply_t *rep = args->rmsg;
size_t *msglen = args->rsize;
char foobarbuz[] = "foobarbuz";
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;
/* XXX Just return a dummy name for now */
rep->rep_namecount = sizeof(foobarbuz);
memcpy(&rep->rep_name, foobarbuz, sizeof(foobarbuz));
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
return 0;
}
int
mach_io_object_get_class(args)
struct mach_trap_args *args;
{
mach_io_object_get_class_request_t *req = args->smsg;
mach_io_object_get_class_reply_t *rep = args->rmsg;
size_t *msglen = args->rsize;
char foobarbuz[] = "FoobarClass";
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;
/* XXX Just return a dummy name for now */
rep->rep_namecount = sizeof(foobarbuz);
memcpy(&rep->rep_name, foobarbuz, sizeof(foobarbuz));
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
return 0;
}
int
mach_io_registry_entry_get_location_in_plane(args)
struct mach_trap_args *args;
{
mach_io_registry_entry_get_location_in_plane_request_t *req =
args->smsg;
mach_io_registry_entry_get_location_in_plane_reply_t *rep = args->rmsg;
size_t *msglen = args->rsize;
char foobarbuz[] = "/";
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;
/* XXX Just return a dummy name for now */
rep->rep_locationcount = sizeof(foobarbuz);
memcpy(&rep->rep_location, foobarbuz, sizeof(foobarbuz));
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_iokit.h,v 1.3 2003/02/07 16:56:19 manu Exp $ */
/* $NetBSD: mach_iokit.h,v 1.4 2003/02/07 20:40:37 manu Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -219,6 +219,92 @@ typedef struct {
mach_msg_trailer_t rep_trailer;
} mach_io_connect_set_notification_port_reply_t;
/* io_registry_get_root_entry */
typedef struct {
mach_msg_header_t req_msgh;
} mach_io_registry_get_root_entry_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_msg_body_t rep_body;
mach_msg_port_descriptor_t rep_root;
mach_msg_trailer_t rep_trailer;
} mach_io_registry_get_root_entry_reply_t;
/* io_registry_entry_get_child_iterator */
typedef struct {
mach_msg_header_t req_msgh;
mach_ndr_record_t req_ndr;
mach_msg_type_number_t req_planeoffset;
mach_msg_type_number_t req_planecount;
char req_plane[128];
} mach_io_registry_entry_get_child_iterator_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_msg_body_t rep_body;
mach_msg_port_descriptor_t rep_iterator;
mach_msg_trailer_t rep_trailer;
} mach_io_registry_entry_get_child_iterator_reply_t;
/* io_registry_entry_get_name_in_plane */
typedef struct {
mach_msg_header_t req_msgh;
mach_ndr_record_t req_ndr;
mach_msg_type_number_t req_planeoffset;
mach_msg_type_number_t req_planecount;
char req_plane[128];
} mach_io_registry_entry_get_name_in_plane_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_ndr_record_t rep_ndr;
mach_kern_return_t rep_retval;
mach_msg_type_number_t rep_nameoffset;
mach_msg_type_number_t rep_namecount;
char rep_name[128];
mach_msg_trailer_t rep_trailer;
} mach_io_registry_entry_get_name_in_plane_reply_t;
/* io_object_get_class */
typedef struct {
mach_msg_header_t req_msgh;
} mach_io_object_get_class_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_ndr_record_t rep_ndr;
mach_kern_return_t rep_retval;
mach_msg_type_number_t rep_nameoffset;
mach_msg_type_number_t rep_namecount;
char rep_name[128];
mach_msg_trailer_t rep_trailer;
} mach_io_object_get_class_reply_t;
/* io_registry_entry_get_location_in_plane */
typedef struct {
mach_msg_header_t req_msgh;
mach_ndr_record_t req_ndr;
mach_msg_type_number_t req_nameoffset;
mach_msg_type_number_t req_namecount;
char req_plane[128];
} mach_io_registry_entry_get_location_in_plane_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_ndr_record_t rep_ndr;
mach_kern_return_t rep_retval;
mach_msg_type_number_t rep_locationoffset;
mach_msg_type_number_t rep_locationcount;
char rep_location[128];
mach_msg_trailer_t rep_trailer;
} mach_io_registry_entry_get_location_in_plane_reply_t;
int mach_io_service_get_matching_services(struct mach_trap_args *);
int mach_io_iterator_next(struct mach_trap_args *);
int mach_io_service_open(struct mach_trap_args *);
@ -229,6 +315,11 @@ int mach_io_registry_entry_create_iterator(struct mach_trap_args *);
int mach_io_object_conforms_to(struct mach_trap_args *);
int mach_io_service_add_interest_notification(struct mach_trap_args *);
int mach_io_connect_set_notification_port(struct mach_trap_args *);
int mach_io_registry_get_root_entry(struct mach_trap_args *);
int mach_io_registry_entry_get_child_iterator(struct mach_trap_args *);
int mach_io_registry_entry_get_name_in_plane(struct mach_trap_args *);
int mach_io_object_get_class(struct mach_trap_args *);
int mach_io_registry_entry_get_location_in_plane(struct mach_trap_args *);
#endif /* _MACH_IOKIT_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_namemap.c,v 1.16 2003/02/07 16:56:19 manu Exp $ */
/* $NetBSD: mach_namemap.c,v 1.17 2003/02/07 20:40:37 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.16 2003/02/07 16:56:19 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.17 2003/02/07 20:40:37 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -62,22 +62,31 @@ struct mach_subsystem_namemap mach_namemap[] = {
/* { 403, mach_boostrap_register, "boostrap_register" }, */
{ 404, mach_bootstrap_look_up, "bootstrap_look_up" },
{ 1000, mach_clock_get_time, "clock_get_time" },
{ 2800, mach_io_object_get_class, "io_object_get_class" },
{ 2801, mach_io_object_conforms_to, "io_object_conforms_to" },
{ 2802, mach_io_iterator_next, "io_iterator_next" },
{ 2804, mach_io_service_get_matching_services,
"io_service_get_matching_services" },
{ 2805, mach_io_registry_entry_get_property,
"io_registry_entry_get_property" },
{ 2813, mach_io_registry_entry_get_child_iterator,
"io_registry_entry_get_child_iterator" },
{ 2815, mach_io_service_open, "io_service_open" },
{ 2817, mach_io_connect_get_service, "io_connect_get_service" },
{ 2818, mach_io_connect_set_notification_port,
"io_connect_set_notification_port" },
{ 2822, mach_io_connect_method_scalari_scalaro,
"io_connect_method_scalari_scalaro" },
{ 2827, mach_io_registry_get_root_entry,
"io_registry_get_root_entry" },
{ 2833, mach_io_registry_entry_create_iterator,
"io_registry_entry_create_iterator" },
{ 2843, mach_io_registry_entry_get_name_in_plane,
"io_registry_entry_get_name_in_plane" },
{ 2850, mach_io_service_add_interest_notification,
"io_service_add_interest_notification" },
{ 2854, mach_io_registry_entry_get_location_in_plane,
"io_registry_entry_get_location_in_plane" },
{ 3201, mach_port_type, "port_type" },
{ 3204, mach_port_allocate, "port_allocate" },
{ 3205, mach_port_destroy, "port_destroy" },