xref: /titanic_44/usr/src/uts/common/sys/copyops.h (revision 843e19887f64dde75055cf8842fc4db2171eff45)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_COPYOPS_H
28 #define	_SYS_COPYOPS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <sys/thread.h>
34 #include <sys/buf.h>
35 #include <sys/aio_req.h>
36 #include <sys/uio.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 #ifdef _KERNEL
43 
44 /*
45  * Copy in/out vector operations.  This structure is used to interpose
46  * on the kernel copyin/copyout/etc. operations for various purposes
47  * such as handling watchpoints in the affected user memory.  When one of the
48  * copy operations causes a fault, the corresponding function in this vector is
49  * called to handle it.
50  *
51  * The 64-bit operations in the structure fetch and store extended
52  * words and are only used on platforms with 64 bit general
53  * registers e.g. sun4u.
54  *
55  * Since the only users of these interfaces (watchpoints and pxfs) perform the
56  * default action unless there is a page fault, we can save the overhead of
57  * having to go through this indirection unless there is a page fault.  This
58  * improves performance both in general and when watchpoints are enabled.  If,
59  * in the future, a consumer relies on being able to interpose on all actions,
60  * then this assumption will have to be undone.
61  *
62  * No consumers should call these functions directly.  They are automatically
63  * handled by the generic versions.
64  */
65 typedef struct copyops {
66 	/*
67 	 * unstructured byte copyin/out functions
68 	 */
69 	int	(*cp_copyin)(const void *, void *, size_t);
70 	int	(*cp_xcopyin)(const void *, void *, size_t);
71 	int	(*cp_copyout)(const void *, void *, size_t);
72 	int	(*cp_xcopyout)(const void *, void *, size_t);
73 	int	(*cp_copyinstr)(const char *, char *, size_t, size_t *);
74 	int	(*cp_copyoutstr)(const char *, char *, size_t, size_t *);
75 
76 	/*
77 	 * fetch/store byte/halfword/word/extended word
78 	 */
79 	int	(*cp_fuword8)(const void *, uint8_t *);
80 	int	(*cp_fuword16)(const void *, uint16_t *);
81 	int	(*cp_fuword32)(const void *, uint32_t *);
82 	int	(*cp_fuword64)(const void *, uint64_t *);
83 
84 	int	(*cp_suword8)(void *, uint8_t);
85 	int	(*cp_suword16)(void *, uint16_t);
86 	int	(*cp_suword32)(void *, uint32_t);
87 	int	(*cp_suword64)(void *, uint64_t);
88 
89 	int	(*cp_physio)(int (*)(struct buf *), struct buf *, dev_t,
90 	    int, void (*)(struct buf *), struct uio *);
91 } copyops_t;
92 
93 extern int	default_physio(int (*)(struct buf *), struct buf *,
94     dev_t, int, void (*)(struct buf *), struct uio *);
95 
96 /*
97  * Interfaces for installing and removing copyops.
98  */
99 extern void install_copyops(kthread_id_t tp, copyops_t *cp);
100 extern void remove_copyops(kthread_id_t tp);
101 extern int copyops_installed(kthread_id_t tp);
102 
103 #endif	/* _KERNEL */
104 
105 #ifdef	__cplusplus
106 }
107 #endif
108 
109 #endif /* _SYS_COPYOPS_H */
110