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

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

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

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

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

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

32
 	printf ( "FTP fetching %s\n", filename );
32
 	printf ( "FTP fetching %s\n", filename );
33
 	
33
 	
34
 	memset ( &buffer, 0, sizeof ( buffer ) );
34
 	memset ( &buffer, 0, sizeof ( buffer ) );
35
-	buffer.addr = virt_to_phys ( data );
35
+	buffer.addr = virt_to_user ( data );
36
 	buffer.len = sizeof ( data );
36
 	buffer.len = sizeof ( data );
37
 
37
 
38
 	memset ( &ftp, 0, sizeof ( ftp ) );
38
 	memset ( &ftp, 0, sizeof ( ftp ) );

Loading…
Cancel
Save