Browse Source

Rename copy_user() to memcpy_user(). Add memmove_user() and

userptr_add().
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
1d313234b3
3 changed files with 32 additions and 4 deletions
  1. 1
    1
      src/arch/i386/image/multiboot.c
  2. 30
    2
      src/arch/i386/include/librm.h
  3. 1
    1
      src/image/elf.c

+ 1
- 1
src/arch/i386/image/multiboot.c View File

@@ -255,7 +255,7 @@ static int multiboot_load_raw ( struct image *image,
255 255
 	}
256 256
 
257 257
 	/* Copy image to segment */
258
-	copy_user ( buffer, 0, image->data, offset, filesz );
258
+	memcpy_user ( buffer, 0, image->data, offset, filesz );
259 259
 
260 260
 	/* Record execution entry point */
261 261
 	image->entry = hdr->mb.entry_addr;

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

@@ -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
  *

+ 1
- 1
src/image/elf.c View File

@@ -94,7 +94,7 @@ static int elf_load_segment ( struct image *image, Elf_Phdr *phdr ) {
94 94
 	}
95 95
 
96 96
 	/* Copy image to segment */
97
-	copy_user ( buffer, 0, image->data, phdr->p_offset, phdr->p_filesz );
97
+	memcpy_user ( buffer, 0, image->data, phdr->p_offset, phdr->p_filesz );
98 98
 
99 99
 	return 0;
100 100
 }

Loading…
Cancel
Save