1/* 2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28 29 30#ifndef _SYSTEM_DOMAIN_H_ 31#define _SYSTEM_DOMAIN_H_ 32 33 34#include <sys/appleapiopts.h> 35#include <sys/cdefs.h> 36#include <sys/types.h> 37 38#ifdef KERNEL_PRIVATE 39#include <sys/queue.h> 40#include <libkern/locks.h> 41#include <sys/kern_control.h> 42#endif /* KERNEL_PRIVATE */ 43 44/* Kernel Events Protocol */ 45#define SYSPROTO_EVENT 1 /* kernel events protocol */ 46 47/* Kernel Control Protocol */ 48#define SYSPROTO_CONTROL 2 /* kernel control protocol */ 49#define AF_SYS_CONTROL 2 /* corresponding sub address type */ 50 51/* System family socket address */ 52struct sockaddr_sys 53{ 54 u_char ss_len; /* sizeof(struct sockaddr_sys) */ 55 u_char ss_family; /* AF_SYSTEM */ 56 u_int16_t ss_sysaddr; /* protocol address in AF_SYSTEM */ 57 u_int32_t ss_reserved[7]; /* reserved to the protocol use */ 58}; 59 60 61#ifdef KERNEL_PRIVATE 62 63/* 64 * internal structure maintained for each register controller 65 */ 66struct ctl_cb; 67struct socket; 68 69struct kctl 70{ 71 TAILQ_ENTRY(kctl) next; /* controller chain */ 72 73 /* controller information provided when registering */ 74 char name[MAX_KCTL_NAME]; /* unique nke identifier, provided by DTS */ 75 u_int32_t id; 76 u_int32_t reg_unit; 77 78 /* misc communication information */ 79 u_int32_t flags; /* support flags */ 80 u_int32_t recvbufsize; /* request more than the default buffer size */ 81 u_int32_t sendbufsize; /* request more than the default buffer size */ 82 83 /* Dispatch functions */ 84 ctl_connect_func connect; /* Make contact */ 85 ctl_disconnect_func disconnect; /* Break contact */ 86 ctl_send_func send; /* Send data to nke */ 87 ctl_setopt_func setopt; /* set kctl configuration */ 88 ctl_getopt_func getopt; /* get kctl configuration */ 89 90 TAILQ_HEAD(, ctl_cb) kcb_head; 91 u_int32_t lastunit; 92}; 93 94struct ctl_cb { 95 TAILQ_ENTRY(ctl_cb) next; /* controller chain */ 96 lck_mtx_t *mtx; 97 struct socket *so; /* controlling socket */ 98 struct kctl *kctl; /* back pointer to controller */ 99 u_int32_t unit; 100 void *userdata; 101}; 102 103 104extern struct domain systemdomain; 105 106/* built in system domain protocols init function */ 107__BEGIN_DECLS 108int kern_event_init(void) __attribute__((section("__TEXT, initcode"))); 109int kern_control_init(void) __attribute__((section("__TEXT, initcode"))); 110__END_DECLS 111 112#endif /* KERNEL_PRIVATE */ 113 114#endif /* _SYSTEM_DOMAIN_H_ */ 115 116 117