diff options
author | Eric Anholt | 2008-04-23 13:22:59 -0500 |
---|---|---|
committer | Eric Anholt | 2008-04-23 13:23:40 -0500 |
commit | 8665b666c7e2ecdee7d27e1ad540910a0223ba6d (patch) | |
tree | 8e97be4727bfb5d45a2b5a02174e815a7a0568b0 | |
parent | 47a2b7dc03e35d4eaf8148b87aeea8dd96723b4d (diff) | |
download | external-libdrm-8665b666c7e2ecdee7d27e1ad540910a0223ba6d.tar.gz external-libdrm-8665b666c7e2ecdee7d27e1ad540910a0223ba6d.tar.xz external-libdrm-8665b666c7e2ecdee7d27e1ad540910a0223ba6d.zip |
Move mmfs.h userland interface to shared-core.
l---------[-rw-r--r--] | linux-core/mmfs.h | 177 | ||||
-rw-r--r-- | linux-core/mmfs_drv.h | 65 | ||||
-rw-r--r-- | shared-core/mmfs.h | 139 | ||||
-rw-r--r-- | tests/Makefile.am | 1 |
4 files changed, 205 insertions, 177 deletions
diff --git a/linux-core/mmfs.h b/linux-core/mmfs.h index bdc148b9..3e589504 100644..120000 --- a/linux-core/mmfs.h +++ b/linux-core/mmfs.h | |||
@@ -1,176 +1 @@ | |||
1 | /* | ../shared-core/mmfs.h \ No newline at end of file | |
2 | * Copyright © 2008 Intel Corporation | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice (including the next | ||
12 | * paragraph) shall be included in all copies or substantial portions of the | ||
13 | * Software. | ||
14 | * | ||
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
21 | * IN THE SOFTWARE. | ||
22 | * | ||
23 | * Authors: | ||
24 | * Eric Anholt <eric@anholt.net> | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | /** @file mmfs.h | ||
29 | * This file provides ioctl and ioctl argument definitions for using the | ||
30 | * mmfs device. | ||
31 | */ | ||
32 | #ifdef __KERNEL__ | ||
33 | #include <linux/spinlock.h> | ||
34 | #include <linux/idr.h> | ||
35 | |||
36 | /** @file mmfs_priv.h | ||
37 | * This file provides internal structure definitions for mmfs.. | ||
38 | */ | ||
39 | |||
40 | /** | ||
41 | * This structure defines the mmfs memory object, which will be used by the | ||
42 | * DRM for its buffer objects. | ||
43 | */ | ||
44 | struct mmfs_object { | ||
45 | /** File representing the shmem storage */ | ||
46 | struct file *filp; | ||
47 | |||
48 | spinlock_t lock; | ||
49 | |||
50 | size_t size; | ||
51 | /** Reference count of this object, protected by object_lock */ | ||
52 | int refcount; | ||
53 | }; | ||
54 | |||
55 | /** | ||
56 | * This structure defines the process (actually per-fd) mapping of object | ||
57 | * handles to mmfs objects. | ||
58 | */ | ||
59 | struct mmfs_file { | ||
60 | /** Mapping of object handles to object pointers. */ | ||
61 | struct idr object_idr; | ||
62 | /** | ||
63 | * Lock for synchronization of access to object->refcount and | ||
64 | * object_idr. See note in mmfs_unreference_ioctl. | ||
65 | */ | ||
66 | spinlock_t delete_lock; | ||
67 | }; | ||
68 | |||
69 | void mmfs_object_reference(struct mmfs_object *obj); | ||
70 | void mmfs_object_unreference(struct mmfs_object *obj); | ||
71 | |||
72 | #endif /* __KERNEL__ */ | ||
73 | |||
74 | #define MMFS_DEVICE_PATH "/dev/mmfs" | ||
75 | /* XXX: Choose non-experimental major */ | ||
76 | #define MMFS_DEVICE_MAJOR 246 | ||
77 | |||
78 | struct mmfs_alloc_args { | ||
79 | /** | ||
80 | * Requested size for the object. | ||
81 | * | ||
82 | * The (page-aligned) allocated size for the object will be returned. | ||
83 | */ | ||
84 | uint32_t size; | ||
85 | /** Returned handle for the object. */ | ||
86 | uint32_t handle; | ||
87 | }; | ||
88 | |||
89 | struct mmfs_unreference_args { | ||
90 | /** Handle of the object to be unreferenced. */ | ||
91 | uint32_t handle; | ||
92 | }; | ||
93 | |||
94 | struct mmfs_link_args { | ||
95 | /** Handle for the object being given a name. */ | ||
96 | uint32_t handle; | ||
97 | /** Requested file name to export the object under. */ | ||
98 | char *name; | ||
99 | /** Requested file mode to export the object under. */ | ||
100 | mode_t mode; | ||
101 | }; | ||
102 | |||
103 | struct mmfs_pread_args { | ||
104 | /** Handle for the object being read. */ | ||
105 | uint32_t handle; | ||
106 | /** Offset into the object to read from */ | ||
107 | off_t offset; | ||
108 | /** Length of data to read */ | ||
109 | size_t size; | ||
110 | /** Pointer to write the data into. */ | ||
111 | void *data; | ||
112 | }; | ||
113 | |||
114 | struct mmfs_pwrite_args { | ||
115 | /** Handle for the object being written to. */ | ||
116 | uint32_t handle; | ||
117 | /** Offset into the object to write to */ | ||
118 | off_t offset; | ||
119 | /** Length of data to write */ | ||
120 | size_t size; | ||
121 | /** Pointer to read the data from. */ | ||
122 | void *data; | ||
123 | }; | ||
124 | |||
125 | struct mmfs_mmap_args { | ||
126 | /** Handle for the object being mapped. */ | ||
127 | uint32_t handle; | ||
128 | /** Offset in the object to map. */ | ||
129 | off_t offset; | ||
130 | /** | ||
131 | * Length of data to map. | ||
132 | * | ||
133 | * The value will be page-aligned. | ||
134 | */ | ||
135 | size_t size; | ||
136 | /** Returned pointer the data was mapped at */ | ||
137 | void *addr; | ||
138 | }; | ||
139 | |||
140 | /** | ||
141 | * \name Ioctls Definitions | ||
142 | */ | ||
143 | /* @{ */ | ||
144 | |||
145 | #define MMFS_IOCTL_BASE 'm' | ||
146 | #define MMFS_IO(nr) _IO(MMFS_IOCTL_BASE, nr) | ||
147 | #define MMFS_IOR(nr,type) _IOR(MMFS_IOCTL_BASE, nr, type) | ||
148 | #define MMFS_IOW(nr,type) _IOW(MMFS_IOCTL_BASE, nr, type) | ||
149 | #define MMFS_IOWR(nr,type) _IOWR(MMFS_IOCTL_BASE, nr, type) | ||
150 | |||
151 | /** This ioctl allocates an object and returns a handle referencing it. */ | ||
152 | #define MMFS_IOCTL_ALLOC MMFS_IOWR(0x00, struct mmfs_alloc_args) | ||
153 | |||
154 | /** | ||
155 | * This ioctl releases the reference on the handle returned from | ||
156 | * MMFS_IOCTL_ALLOC. | ||
157 | */ | ||
158 | #define MMFS_IOCTL_UNREFERENCE MMFS_IOR(0x01, struct mmfs_unreference_args) | ||
159 | |||
160 | /** | ||
161 | * This ioctl creates a file in the mmfs filesystem representing an object. | ||
162 | * | ||
163 | * XXX: Need a way to get handle from fd or name. | ||
164 | */ | ||
165 | #define MMFS_IOCTL_LINK MMFS_IOWR(0x02, struct mmfs_link_args) | ||
166 | |||
167 | /** This ioctl copies data from an object into a user address. */ | ||
168 | #define MMFS_IOCTL_PREAD MMFS_IOWR(0x03, struct mmfs_pread_args) | ||
169 | |||
170 | /** This ioctl copies data from a user address into an object. */ | ||
171 | #define MMFS_IOCTL_PWRITE MMFS_IOWR(0x04, struct mmfs_pwrite_args) | ||
172 | |||
173 | /** This ioctl maps data from the object into the user address space. */ | ||
174 | #define MMFS_IOCTL_MMAP MMFS_IOWR(0x05, struct mmfs_mmap_args) | ||
175 | |||
176 | /* }@ */ | ||
diff --git a/linux-core/mmfs_drv.h b/linux-core/mmfs_drv.h new file mode 100644 index 00000000..1944d2af --- /dev/null +++ b/linux-core/mmfs_drv.h | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * Copyright © 2008 Intel Corporation | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice (including the next | ||
12 | * paragraph) shall be included in all copies or substantial portions of the | ||
13 | * Software. | ||
14 | * | ||
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
21 | * IN THE SOFTWARE. | ||
22 | * | ||
23 | * Authors: | ||
24 | * Eric Anholt <eric@anholt.net> | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | #include <linux/spinlock.h> | ||
29 | #include <linux/idr.h> | ||
30 | |||
31 | /** @file mmfs_drv.h | ||
32 | * This file provides structure definitions and function prototypes for mmfs. | ||
33 | */ | ||
34 | |||
35 | /** | ||
36 | * This structure defines the mmfs memory object, which will be used by the | ||
37 | * DRM for its buffer objects. | ||
38 | */ | ||
39 | struct mmfs_object { | ||
40 | /** File representing the shmem storage */ | ||
41 | struct file *filp; | ||
42 | |||
43 | spinlock_t lock; | ||
44 | |||
45 | size_t size; | ||
46 | /** Reference count of this object, protected by object_lock */ | ||
47 | int refcount; | ||
48 | }; | ||
49 | |||
50 | /** | ||
51 | * This structure defines the process (actually per-fd) mapping of object | ||
52 | * handles to mmfs objects. | ||
53 | */ | ||
54 | struct mmfs_file { | ||
55 | /** Mapping of object handles to object pointers. */ | ||
56 | struct idr object_idr; | ||
57 | /** | ||
58 | * Lock for synchronization of access to object->refcount and | ||
59 | * object_idr. See note in mmfs_unreference_ioctl. | ||
60 | */ | ||
61 | spinlock_t delete_lock; | ||
62 | }; | ||
63 | |||
64 | void mmfs_object_reference(struct mmfs_object *obj); | ||
65 | void mmfs_object_unreference(struct mmfs_object *obj); | ||
diff --git a/shared-core/mmfs.h b/shared-core/mmfs.h new file mode 100644 index 00000000..4cad3bdc --- /dev/null +++ b/shared-core/mmfs.h | |||
@@ -0,0 +1,139 @@ | |||
1 | /* | ||
2 | * Copyright © 2008 Intel Corporation | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice (including the next | ||
12 | * paragraph) shall be included in all copies or substantial portions of the | ||
13 | * Software. | ||
14 | * | ||
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
21 | * IN THE SOFTWARE. | ||
22 | * | ||
23 | * Authors: | ||
24 | * Eric Anholt <eric@anholt.net> | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | /** @file mmfs.h | ||
29 | * This file provides ioctl and ioctl argument definitions for using the | ||
30 | * mmfs device. | ||
31 | */ | ||
32 | |||
33 | #ifdef __KERNEL__ | ||
34 | #include "mmfs_drv.h" | ||
35 | #endif /* __KERNEL__ */ | ||
36 | |||
37 | #define MMFS_DEVICE_PATH "/dev/mmfs" | ||
38 | /* XXX: Choose non-experimental major */ | ||
39 | #define MMFS_DEVICE_MAJOR 246 | ||
40 | |||
41 | struct mmfs_alloc_args { | ||
42 | /** | ||
43 | * Requested size for the object. | ||
44 | * | ||
45 | * The (page-aligned) allocated size for the object will be returned. | ||
46 | */ | ||
47 | uint32_t size; | ||
48 | /** Returned handle for the object. */ | ||
49 | uint32_t handle; | ||
50 | }; | ||
51 | |||
52 | struct mmfs_unreference_args { | ||
53 | /** Handle of the object to be unreferenced. */ | ||
54 | uint32_t handle; | ||
55 | }; | ||
56 | |||
57 | struct mmfs_link_args { | ||
58 | /** Handle for the object being given a name. */ | ||
59 | uint32_t handle; | ||
60 | /** Requested file name to export the object under. */ | ||
61 | char *name; | ||
62 | /** Requested file mode to export the object under. */ | ||
63 | mode_t mode; | ||
64 | }; | ||
65 | |||
66 | struct mmfs_pread_args { | ||
67 | /** Handle for the object being read. */ | ||
68 | uint32_t handle; | ||
69 | /** Offset into the object to read from */ | ||
70 | off_t offset; | ||
71 | /** Length of data to read */ | ||
72 | size_t size; | ||
73 | /** Pointer to write the data into. */ | ||
74 | void *data; | ||
75 | }; | ||
76 | |||
77 | struct mmfs_pwrite_args { | ||
78 | /** Handle for the object being written to. */ | ||
79 | uint32_t handle; | ||
80 | /** Offset into the object to write to */ | ||
81 | off_t offset; | ||
82 | /** Length of data to write */ | ||
83 | size_t size; | ||
84 | /** Pointer to read the data from. */ | ||
85 | void *data; | ||
86 | }; | ||
87 | |||
88 | struct mmfs_mmap_args { | ||
89 | /** Handle for the object being mapped. */ | ||
90 | uint32_t handle; | ||
91 | /** Offset in the object to map. */ | ||
92 | off_t offset; | ||
93 | /** | ||
94 | * Length of data to map. | ||
95 | * | ||
96 | * The value will be page-aligned. | ||
97 | */ | ||
98 | size_t size; | ||
99 | /** Returned pointer the data was mapped at */ | ||
100 | void *addr; | ||
101 | }; | ||
102 | |||
103 | /** | ||
104 | * \name Ioctls Definitions | ||
105 | */ | ||
106 | /* @{ */ | ||
107 | |||
108 | #define MMFS_IOCTL_BASE 'm' | ||
109 | #define MMFS_IO(nr) _IO(MMFS_IOCTL_BASE, nr) | ||
110 | #define MMFS_IOR(nr,type) _IOR(MMFS_IOCTL_BASE, nr, type) | ||
111 | #define MMFS_IOW(nr,type) _IOW(MMFS_IOCTL_BASE, nr, type) | ||
112 | #define MMFS_IOWR(nr,type) _IOWR(MMFS_IOCTL_BASE, nr, type) | ||
113 | |||
114 | /** This ioctl allocates an object and returns a handle referencing it. */ | ||
115 | #define MMFS_IOCTL_ALLOC MMFS_IOWR(0x00, struct mmfs_alloc_args) | ||
116 | |||
117 | /** | ||
118 | * This ioctl releases the reference on the handle returned from | ||
119 | * MMFS_IOCTL_ALLOC. | ||
120 | */ | ||
121 | #define MMFS_IOCTL_UNREFERENCE MMFS_IOR(0x01, struct mmfs_unreference_args) | ||
122 | |||
123 | /** | ||
124 | * This ioctl creates a file in the mmfs filesystem representing an object. | ||
125 | * | ||
126 | * XXX: Need a way to get handle from fd or name. | ||
127 | */ | ||
128 | #define MMFS_IOCTL_LINK MMFS_IOWR(0x02, struct mmfs_link_args) | ||
129 | |||
130 | /** This ioctl copies data from an object into a user address. */ | ||
131 | #define MMFS_IOCTL_PREAD MMFS_IOWR(0x03, struct mmfs_pread_args) | ||
132 | |||
133 | /** This ioctl copies data from a user address into an object. */ | ||
134 | #define MMFS_IOCTL_PWRITE MMFS_IOWR(0x04, struct mmfs_pwrite_args) | ||
135 | |||
136 | /** This ioctl maps data from the object into the user address space. */ | ||
137 | #define MMFS_IOCTL_MMAP MMFS_IOWR(0x05, struct mmfs_mmap_args) | ||
138 | |||
139 | /* }@ */ | ||
diff --git a/tests/Makefile.am b/tests/Makefile.am index 4a7b0119..97752774 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am | |||
@@ -1,5 +1,4 @@ | |||
1 | AM_CFLAGS = \ | 1 | AM_CFLAGS = \ |
2 | -I $(top_srcdir)/linux-core \ | ||
3 | -I $(top_srcdir)/shared-core \ | 2 | -I $(top_srcdir)/shared-core \ |
4 | -I $(top_srcdir)/libdrm | 3 | -I $(top_srcdir)/libdrm |
5 | 4 | ||