Browse Source

Add phys_to_user() and copy_user().

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
c6a4055fae
1 changed files with 29 additions and 2 deletions
  1. 29
    2
      src/arch/i386/include/librm.h

+ 29
- 2
src/arch/i386/include/librm.h View File

120
  */
120
  */
121
 static inline __attribute__ (( always_inline )) void
121
 static inline __attribute__ (( always_inline )) void
122
 copy_to_user ( userptr_t buffer, off_t offset, const void *src, size_t len ) {
122
 copy_to_user ( userptr_t buffer, off_t offset, const void *src, size_t len ) {
123
-	memcpy ( ( void * ) buffer + offset, src, len );
123
+	memcpy ( ( ( void * ) buffer + offset ), src, len );
124
 }
124
 }
125
 
125
 
126
 /**
126
 /**
133
  */
133
  */
134
 static inline __attribute__ (( always_inline )) void
134
 static inline __attribute__ (( always_inline )) void
135
 copy_from_user ( void *dest, userptr_t buffer, off_t offset, size_t len ) {
135
 copy_from_user ( void *dest, userptr_t buffer, off_t offset, size_t len ) {
136
-	memcpy ( dest, ( void * ) buffer + offset, len );
136
+	memcpy ( dest, ( ( void * ) buffer + offset ), len );
137
+}
138
+
139
+/**
140
+ * Copy data between user buffers
141
+ *
142
+ * @v dest	Destination user buffer
143
+ * @v dest_off	Offset within destination buffer
144
+ * @v src	Source user buffer
145
+ * @v src_off	Offset within source buffer
146
+ * @v len	Length
147
+ */
148
+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 ) {
151
+	memcpy ( ( ( void * ) dest + dest_off ), ( ( void * ) src + src_off ),
152
+		 len );
137
 }
153
 }
138
 
154
 
139
 /**
155
 /**
163
 	return virt_to_user ( VIRTUAL ( segment, offset ) );
179
 	return virt_to_user ( VIRTUAL ( segment, offset ) );
164
 }
180
 }
165
 
181
 
182
+/**
183
+ * Convert physical address to user buffer
184
+ *
185
+ * @v physical	Physical address
186
+ * @ret buffer	User buffer
187
+ */
188
+static inline __attribute__ (( always_inline )) userptr_t
189
+phys_to_user ( physaddr_t physical ) {
190
+	return virt_to_user ( phys_to_virt ( physical ) );
191
+}
192
+
166
 /* Copy to/from real-mode stack */
193
 /* Copy to/from real-mode stack */
167
 extern uint16_t copy_to_rm_stack ( void *data, size_t size );
194
 extern uint16_t copy_to_rm_stack ( void *data, size_t size );
168
 extern void remove_from_rm_stack ( void *data, size_t size );
195
 extern void remove_from_rm_stack ( void *data, size_t size );

Loading…
Cancel
Save