2 * Copyright (c) 2004-2007 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * $DragonFly: src/sys/sys/syslink.h,v 1.11 2007/06/29 00:18:03 dillon Exp $
38 * The syslink infrastructure implements an optimized RPC mechanism across a
39 * communications link. RPC functions are grouped together into larger
40 * protocols. Prototypes are typically associated with system structures
41 * but do not have to be.
43 * syslink - Implements a communications end-point and protocol. A
44 * syslink is typically directly embedded in a related
48 #ifndef _SYS_SYSLINK_H_
49 #define _SYS_SYSLINK_H_
52 #include <sys/types.h>
55 #include <sys/sysid.h>
60 #ifndef _SYS_SYSLINK_MSG_H_
61 #include <sys/syslink_msg.h>
65 * Additional headers are required to support kernel-only
68 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
75 #ifndef _SYS_MSGPORT_H_
76 #include <sys/msgport.h>
80 /***************************************************************************
82 ***************************************************************************
84 * These structures implement the programming interface for end-points and
90 struct syslink_generic_args;
92 typedef int (*syslink_func_t)(struct syslink_generic_args *);
94 #define SYSLINK_CMD_NEW 0x00000001 /* create unassociated desc */
97 * Typically an extension of the syslink_info structure is passed
98 * to the kernel, or NULL for commands that do not need one.
100 struct syslink_info {
106 #define SYSLINK_INFO_VERSION 1
111 * Create a pair of syslink descriptors representing a two-way
112 * communications channel.
114 struct syslink_info_new {
115 struct syslink_info head;
119 union syslink_info_all {
120 struct syslink_info head;
121 struct syslink_info_new cmd_new;
125 * Kernel-only data structures.
127 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
130 * slmsg - internal kernel representation of a syslink message, organized
131 * as a LWKT message, out of band DMA buffer(s), and related memory.
132 * This structure is typically arranged via two object caches,
133 * one which maintains buffers for short syslink messages and one
134 * for long syslink messages.
136 TAILQ_HEAD(slmsgq,slmsg);
137 RB_HEAD(slmsg_rb_tree, slmsg);
138 RB_PROTOTYPE2(slmsg_rb_tree, slmsg, entry.rbnode, rb_slmsg_compare, sysid_t);
141 TAILQ_ENTRY(slmsg) tqnode; /* inq */
142 RB_ENTRY(slmsg) rbnode; /* held for reply matching */
147 struct slmsg *rep; /* reply (kernel backend) */
149 struct syslink_msg *msg;
152 #define SLMSGF_ONINQ 0x0001
153 #define SLMSGF_HASXIO 0x0002
160 int syslink_ukbackend(int *fdp, struct sldesc **kslp);
161 struct slmsg *syslink_kallocmsg(void);
162 int syslink_kdomsg(struct sldesc *ksl, struct slmsg *msg);
163 void syslink_kfreemsg(struct sldesc *ksl, struct slmsg *msg);
164 void syslink_kshutdown(struct sldesc *ksl, int how);
165 void syslink_kclose(struct sldesc *ksl);
169 int syslink(int, struct syslink_info *, size_t);