mirror of
https://github.com/ipxe/ipxe
synced 2026-04-16 03:00:10 +03:00
[umalloc] Remove userptr_t from user memory allocations
Use standard void pointers for umalloc(), urealloc(), and ufree(),
with the "u" prefix retained to indicate that these allocations are
made from external ("user") memory rather than from the internal heap.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
+4
-5
@@ -130,9 +130,9 @@ static void dma_op_free ( struct dma_mapping *map, void *addr, size_t len ) {
|
||||
* @v align Physical alignment
|
||||
* @ret addr Buffer address, or NULL on error
|
||||
*/
|
||||
static userptr_t dma_op_umalloc ( struct dma_device *dma,
|
||||
struct dma_mapping *map,
|
||||
size_t len, size_t align ) {
|
||||
static void * dma_op_umalloc ( struct dma_device *dma,
|
||||
struct dma_mapping *map,
|
||||
size_t len, size_t align ) {
|
||||
struct dma_operations *op = dma->op;
|
||||
|
||||
if ( ! op )
|
||||
@@ -147,8 +147,7 @@ static userptr_t dma_op_umalloc ( struct dma_device *dma,
|
||||
* @v addr Buffer address
|
||||
* @v len Length of buffer
|
||||
*/
|
||||
static void dma_op_ufree ( struct dma_mapping *map, userptr_t addr,
|
||||
size_t len ) {
|
||||
static void dma_op_ufree ( struct dma_mapping *map, void *addr, size_t len ) {
|
||||
struct dma_device *dma = map->dma;
|
||||
|
||||
assert ( dma != NULL );
|
||||
|
||||
@@ -71,23 +71,6 @@ struct autosized_block {
|
||||
char data[0];
|
||||
};
|
||||
|
||||
/**
|
||||
* Address for zero-length memory blocks
|
||||
*
|
||||
* @c malloc(0) or @c realloc(ptr,0) will return the special value @c
|
||||
* NOWHERE. Calling @c free(NOWHERE) will have no effect.
|
||||
*
|
||||
* This is consistent with the ANSI C standards, which state that
|
||||
* "either NULL or a pointer suitable to be passed to free()" must be
|
||||
* returned in these cases. Using a special non-NULL value means that
|
||||
* the caller can take a NULL return value to indicate failure,
|
||||
* without first having to check for a requested size of zero.
|
||||
*
|
||||
* Code outside of malloc.c do not ever need to refer to the actual
|
||||
* value of @c NOWHERE; this is an internal definition.
|
||||
*/
|
||||
#define NOWHERE ( ( void * ) ~( ( intptr_t ) 0 ) )
|
||||
|
||||
/** List of free memory blocks */
|
||||
static LIST_HEAD ( free_blocks );
|
||||
|
||||
|
||||
+6
-6
@@ -237,8 +237,8 @@ struct xfer_buffer_operations xferbuf_malloc_operations = {
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int xferbuf_umalloc_realloc ( struct xfer_buffer *xferbuf, size_t len ) {
|
||||
userptr_t *udata = xferbuf->data;
|
||||
userptr_t new_udata;
|
||||
void **udata = xferbuf->data;
|
||||
void *new_udata;
|
||||
|
||||
new_udata = urealloc ( *udata, len );
|
||||
if ( ! new_udata )
|
||||
@@ -257,9 +257,9 @@ static int xferbuf_umalloc_realloc ( struct xfer_buffer *xferbuf, size_t len ) {
|
||||
*/
|
||||
static void xferbuf_umalloc_write ( struct xfer_buffer *xferbuf, size_t offset,
|
||||
const void *data, size_t len ) {
|
||||
userptr_t *udata = xferbuf->data;
|
||||
void **udata = xferbuf->data;
|
||||
|
||||
copy_to_user ( *udata, offset, data, len );
|
||||
memcpy ( ( *udata + offset ), data, len );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,9 +272,9 @@ static void xferbuf_umalloc_write ( struct xfer_buffer *xferbuf, size_t offset,
|
||||
*/
|
||||
static void xferbuf_umalloc_read ( struct xfer_buffer *xferbuf, size_t offset,
|
||||
void *data, size_t len ) {
|
||||
userptr_t *udata = xferbuf->data;
|
||||
void **udata = xferbuf->data;
|
||||
|
||||
copy_from_user ( data, *udata, offset, len );
|
||||
memcpy ( data, ( *udata + offset ), len );
|
||||
}
|
||||
|
||||
/** umalloc()-based data buffer operations */
|
||||
|
||||
Reference in New Issue
Block a user