|
@@ -110,6 +110,18 @@ copy_from_real_librm ( void *dest, unsigned int src_seg,
|
110
|
110
|
*/
|
111
|
111
|
typedef intptr_t userptr_t;
|
112
|
112
|
|
|
113
|
+/**
|
|
114
|
+ * Add offset to user pointer
|
|
115
|
+ *
|
|
116
|
+ * @v ptr User pointer
|
|
117
|
+ * @v offset Offset
|
|
118
|
+ * @ret new_ptr New pointer value
|
|
119
|
+ */
|
|
120
|
+static inline __attribute__ (( always_inline )) userptr_t
|
|
121
|
+userptr_add ( userptr_t ptr, off_t offset ) {
|
|
122
|
+ return ( ptr + offset );
|
|
123
|
+}
|
|
124
|
+
|
113
|
125
|
/**
|
114
|
126
|
* Copy data to user buffer
|
115
|
127
|
*
|
|
@@ -146,12 +158,28 @@ copy_from_user ( void *dest, userptr_t buffer, off_t offset, size_t len ) {
|
146
|
158
|
* @v len Length
|
147
|
159
|
*/
|
148
|
160
|
static inline __attribute__ (( always_inline )) void
|
149
|
|
-copy_user ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off,
|
150
|
|
- size_t len ) {
|
|
161
|
+memcpy_user ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off,
|
|
162
|
+ size_t len ) {
|
151
|
163
|
memcpy ( ( ( void * ) dest + dest_off ), ( ( void * ) src + src_off ),
|
152
|
164
|
len );
|
153
|
165
|
}
|
154
|
166
|
|
|
167
|
+/**
|
|
168
|
+ * Copy data between user buffers, allowing for overlap
|
|
169
|
+ *
|
|
170
|
+ * @v dest Destination user buffer
|
|
171
|
+ * @v dest_off Offset within destination buffer
|
|
172
|
+ * @v src Source user buffer
|
|
173
|
+ * @v src_off Offset within source buffer
|
|
174
|
+ * @v len Length
|
|
175
|
+ */
|
|
176
|
+static inline __attribute__ (( always_inline )) void
|
|
177
|
+memmove_user ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off,
|
|
178
|
+ size_t len ) {
|
|
179
|
+ memmove ( ( ( void * ) dest + dest_off ), ( ( void * ) src + src_off ),
|
|
180
|
+ len );
|
|
181
|
+}
|
|
182
|
+
|
155
|
183
|
/**
|
156
|
184
|
* Fill user buffer with a constant byte
|
157
|
185
|
*
|