Browse Source

buffer.c should be using copy_{to,from}_user, rather than

copy_{to,from}_phys.
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
fbfed96965
4 changed files with 12 additions and 13 deletions
  1. 5
    6
      src/core/buffer.c
  2. 5
    5
      src/include/gpxe/buffer.h
  3. 1
    1
      src/tests/buffertest.c
  4. 1
    1
      src/tests/ftptest.c

+ 5
- 6
src/core/buffer.c View File

@@ -20,7 +20,7 @@
20 20
 #include <string.h>
21 21
 #include <errno.h>
22 22
 #include <assert.h>
23
-#include <io.h>
23
+#include <gpxe/uaccess.h>
24 24
 #include <gpxe/buffer.h>
25 25
 
26 26
 /** @file
@@ -49,7 +49,7 @@
49 49
  * block consists of the 1025th byte.
50 50
  * 
51 51
  * Note that the rather convoluted way of manipulating the buffer
52
- * descriptors (using copy_{to,from}_phys rather than straightforward
52
+ * descriptors (using copy_{to,from}_user rather than straightforward
53 53
  * pointers) is needed to cope with operation as a PXE stack, when we
54 54
  * may be running in real mode or 16-bit protected mode, and therefore
55 55
  * cannot directly access arbitrary areas of memory using simple
@@ -97,7 +97,7 @@ static int get_next_free_block ( struct buffer *buffer,
97 97
 		block->next = block->end = buffer->len;
98 98
 	} else {
99 99
 		/* Retrieve block descriptor */
100
-		copy_from_phys ( block, ( buffer->addr + block->start ),
100
+		copy_from_user ( block, buffer->addr, block->start,
101 101
 				 sizeof ( *block ) );
102 102
 	}
103 103
 
@@ -115,8 +115,7 @@ static void store_free_block ( struct buffer *buffer,
115 115
 	size_t free_block_size = ( block->end - block->start );
116 116
 
117 117
 	assert ( free_block_size >= sizeof ( *block ) );
118
-	copy_to_phys ( ( buffer->addr + block->start ), block,
119
-		       sizeof ( *block ) );
118
+	copy_to_user ( buffer->addr, block->start, block, sizeof ( *block ) );
120 119
 }
121 120
 
122 121
 /**
@@ -230,7 +229,7 @@ int fill_buffer ( struct buffer *buffer, const void *data,
230 229
 	}
231 230
 
232 231
 	/* Copy data into buffer */
233
-	copy_to_phys ( ( buffer->addr + data_start ), data, len );
232
+	copy_to_user ( buffer->addr, data_start, data, len );
234 233
 
235 234
 	return 0;
236 235
 }

+ 5
- 5
src/include/gpxe/buffer.h View File

@@ -2,7 +2,7 @@
2 2
 #define _GPXE_BUFFER_H
3 3
 
4 4
 #include <stdint.h>
5
-#include <io.h>
5
+#include <gpxe/uaccess.h>
6 6
 
7 7
 /** @file
8 8
  *
@@ -28,7 +28,7 @@
28 28
  *   size_t len;
29 29
  *   
30 30
  *   // We have an area of memory [buf_start,buf_start+len) into which to
31
- *   // load a file, where buf_start is a physical addresse.
31
+ *   // load a file, where buf_start is a userptr_t.
32 32
  *   memset ( &buffer, 0, sizeof ( buffer ) );
33 33
  *   buffer->start = buf_start;
34 34
  *   buffer->len = len;
@@ -43,7 +43,7 @@
43 43
  *   }
44 44
  *   ...
45 45
  *   // The whole file is now present at [buf_start,buf_start+filesize),
46
- *   // where buf_start is a physical address.  The struct buffer can simply
46
+ *   // where buf_start is a userptr_t.  The struct buffer can simply
47 47
  *   // be discarded.
48 48
  *
49 49
  * @endcode
@@ -77,8 +77,8 @@
77 77
  *
78 78
  */
79 79
 struct buffer {
80
-	/** Physical start address of buffer */
81
-	physaddr_t addr;
80
+	/** Start of buffer */
81
+	userptr_t addr;
82 82
 	/** Total length of buffer */
83 83
 	size_t len;
84 84
 	/** Offset to first free block within buffer */

+ 1
- 1
src/tests/buffertest.c View File

@@ -34,7 +34,7 @@ int test_buffer ( void ) {
34 34
 	test.source_len = sizeof ( source );
35 35
 	test.dest = dest;
36 36
 	test.dest_len = sizeof ( dest );
37
-	test.buffer.addr = virt_to_phys ( dest );
37
+	test.buffer.addr = virt_to_user ( dest );
38 38
 	test.buffer.len = sizeof ( dest );
39 39
 
40 40
 	test_fill_buffer ( &test,  20,  38 );

+ 1
- 1
src/tests/ftptest.c View File

@@ -32,7 +32,7 @@ void test_ftp ( struct sockaddr_tcpip *server, const char *filename ) {
32 32
 	printf ( "FTP fetching %s\n", filename );
33 33
 	
34 34
 	memset ( &buffer, 0, sizeof ( buffer ) );
35
-	buffer.addr = virt_to_phys ( data );
35
+	buffer.addr = virt_to_user ( data );
36 36
 	buffer.len = sizeof ( data );
37 37
 
38 38
 	memset ( &ftp, 0, sizeof ( ftp ) );

Loading…
Cancel
Save