1700 Add SCSI UNMAP support
[unleashed.git] / usr / src / uts / common / sys / copyops.h
blob54b754eaa226ad2721dea27ec47b36423c23d966
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_COPYOPS_H
28 #define _SYS_COPYOPS_H
30 #include <sys/types.h>
31 #include <sys/thread.h>
32 #include <sys/buf.h>
33 #include <sys/aio_req.h>
34 #include <sys/uio.h>
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
40 #ifdef _KERNEL
43 * Copy in/out vector operations. This structure is used to interpose
44 * on the kernel copyin/copyout/etc. operations for various purposes
45 * such as handling watchpoints in the affected user memory. When one of the
46 * copy operations causes a fault, the corresponding function in this vector is
47 * called to handle it.
49 * The 64-bit operations in the structure fetch and store extended
50 * words and are only used on platforms with 64 bit general
51 * registers e.g. sun4u.
53 * Since the only users of these interfaces (watchpoints and pxfs) perform the
54 * default action unless there is a page fault, we can save the overhead of
55 * having to go through this indirection unless there is a page fault. This
56 * improves performance both in general and when watchpoints are enabled. If,
57 * in the future, a consumer relies on being able to interpose on all actions,
58 * then this assumption will have to be undone.
60 * No consumers should call these functions directly. They are automatically
61 * handled by the generic versions.
63 typedef struct copyops {
65 * unstructured byte copyin/out functions
67 int (*cp_copyin)(const void *, void *, size_t);
68 int (*cp_xcopyin)(const void *, void *, size_t);
69 int (*cp_copyout)(const void *, void *, size_t);
70 int (*cp_xcopyout)(const void *, void *, size_t);
71 int (*cp_copyinstr)(const char *, char *, size_t, size_t *);
72 int (*cp_copyoutstr)(const char *, char *, size_t, size_t *);
75 * fetch/store byte/halfword/word/extended word
77 int (*cp_fuword8)(const void *, uint8_t *);
78 int (*cp_fuword16)(const void *, uint16_t *);
79 int (*cp_fuword32)(const void *, uint32_t *);
80 int (*cp_fuword64)(const void *, uint64_t *);
82 int (*cp_suword8)(void *, uint8_t);
83 int (*cp_suword16)(void *, uint16_t);
84 int (*cp_suword32)(void *, uint32_t);
85 int (*cp_suword64)(void *, uint64_t);
87 int (*cp_physio)(int (*)(struct buf *), struct buf *, dev_t,
88 int, void (*)(struct buf *), struct uio *);
89 } copyops_t;
91 extern int default_physio(int (*)(struct buf *), struct buf *,
92 dev_t, int, void (*)(struct buf *), struct uio *);
95 * Interfaces for installing and removing copyops.
97 extern void install_copyops(kthread_id_t tp, copyops_t *cp);
98 extern void remove_copyops(kthread_id_t tp);
99 extern int copyops_installed(kthread_id_t tp);
101 #endif /* _KERNEL */
103 #ifdef __cplusplus
105 #endif
107 #endif /* _SYS_COPYOPS_H */