}
/* Calculate lowest usable address */
- bottom = userptr_add ( bzimg->pm_kernel, bzimg->pm_sz );
+ bottom = ( bzimg->pm_kernel + bzimg->pm_sz );
/* Check that total length fits within space available for
* reshuffling. This is a conservative check, since CPIO
size_t len;
/* Reshuffle initrds into desired order */
- initrd_reshuffle ( userptr_add ( bzimg->pm_kernel, bzimg->pm_sz ) );
+ initrd_reshuffle ( bzimg->pm_kernel + bzimg->pm_sz );
/* Find highest initrd */
for_each_image ( initrd ) {
- if ( ( highest == NULL ) ||
- ( userptr_diff ( initrd->data, highest->data ) > 0 ) ) {
+ if ( ( highest == NULL ) || ( initrd->data > highest->data ) )
highest = initrd;
- }
}
/* Do nothing if there are no initrds */
return;
/* Find highest usable address */
- top = userptr_add ( highest->data, bzimage_align ( highest->len ) );
+ top = ( highest->data + bzimage_align ( highest->len ) );
if ( user_to_phys ( top, -1 ) > bzimg->mem_limit ) {
top = phys_to_user ( ( bzimg->mem_limit + 1 ) &
~( INITRD_ALIGN - 1 ) );
}
/* Load initrd at this address */
- dest = userptr_add ( top, -offset );
+ dest = ( top - offset );
len = bzimage_load_initrd ( image, initrd, dest );
/* Record initrd location */
/* Find the highest image not yet in its final position */
highest = NULL;
for_each_image ( initrd ) {
- if ( ( userptr_diff ( initrd->data, current ) < 0 ) &&
+ if ( ( initrd->data < current ) &&
( ( highest == NULL ) ||
- ( userptr_diff ( initrd->data,
- highest->data ) > 0 ) ) ) {
+ ( initrd->data > highest->data ) ) ) {
highest = initrd;
}
}
/* Move this image to its final position */
len = ( ( highest->len + INITRD_ALIGN - 1 ) &
~( INITRD_ALIGN - 1 ) );
- current = userptr_add ( current, -len );
+ current -= len;
DBGC ( &images, "INITRD squashing %s [%#08lx,%#08lx)->"
"[%#08lx,%#08lx)\n", highest->name,
user_to_phys ( highest->data, 0 ),
/* Copy any remaining initrds (e.g. embedded images) to the region */
for_each_image ( initrd ) {
- if ( userptr_diff ( initrd->data, top ) >= 0 ) {
+ if ( initrd->data >= top ) {
len = ( ( initrd->len + INITRD_ALIGN - 1 ) &
~( INITRD_ALIGN - 1 ) );
- current = userptr_add ( current, -len );
+ current -= len;
DBGC ( &images, "INITRD copying %s [%#08lx,%#08lx)->"
"[%#08lx,%#08lx)\n", initrd->name,
user_to_phys ( initrd->data, 0 ),
/* Adjust data pointers */
high->data = low->data;
- low->data = userptr_add ( low->data, len );
+ low->data += len;
}
/**
/* Calculate location of adjacent image (if any) */
padded_len = ( ( low->len + INITRD_ALIGN - 1 ) &
~( INITRD_ALIGN - 1 ) );
- adjacent = userptr_add ( low->data, padded_len );
+ adjacent = ( low->data + padded_len );
/* Search for adjacent image */
for_each_image ( high ) {
/* Calculate limits of available space for initrds */
top = initrd_top;
- if ( userptr_diff ( initrd_bottom, bottom ) > 0 )
+ if ( initrd_bottom > bottom )
bottom = initrd_bottom;
/* Debug */
/* Calculate available free space */
free = bottom;
- free_len = userptr_diff ( used, free );
+ free_len = ( used - free );
/* Bubble-sort initrds into desired order */
while ( initrd_swap_any ( free, free_len ) ) {}
/* Calculate limits of available space for initrds */
top = initrd_top;
- if ( userptr_diff ( initrd_bottom, bottom ) > 0 )
+ if ( initrd_bottom > bottom )
bottom = initrd_bottom;
- available = userptr_diff ( top, bottom );
+ available = ( top - bottom );
/* Allow for a sensible minimum amount of free space */
len += INITRD_MIN_FREE_LEN;
* can safely reuse when rearranging).
*/
len = largest_memblock ( &initrd_bottom );
- initrd_top = userptr_add ( initrd_bottom, len );
+ initrd_top = ( initrd_bottom + len );
}
/** initrd startup function */
dest = phys_to_user ( sh.loadaddr );
break;
case NBI_LOADADDR_AFTER:
- dest = userptr_add ( dest, memsz + sh.loadaddr );
+ dest = ( dest + memsz + sh.loadaddr );
break;
case NBI_LOADADDR_BEFORE:
- dest = userptr_add ( dest, -sh.loadaddr );
+ dest = ( dest - sh.loadaddr );
break;
case NBI_LOADADDR_END:
/* Not correct according to the spec, but
return trivial_user_to_virt ( userptr, offset );
}
-static inline __always_inline userptr_t
-UACCESS_INLINE ( librm, userptr_add ) ( userptr_t userptr, off_t offset ) {
- return trivial_userptr_add ( userptr, offset );
-}
-
-static inline __always_inline off_t
-UACCESS_INLINE ( librm, userptr_diff ) ( userptr_t userptr,
- userptr_t subtrahend ) {
- return trivial_userptr_diff ( userptr, subtrahend );
-}
-
static inline __always_inline void
UACCESS_INLINE ( librm, memcpy_user ) ( userptr_t dest, off_t dest_off,
userptr_t src, off_t src_off,
userptr_t base;
heap_size = largest_memblock ( &base );
- bottom = top = userptr_add ( base, heap_size );
+ bottom = top = ( base + heap_size );
DBG ( "External heap grows downwards from %lx (size %zx)\n",
user_to_phys ( top, 0 ), heap_size );
}
DBG ( "EXTMEM freeing [%lx,%lx)\n", user_to_phys ( bottom, 0 ),
user_to_phys ( bottom, extmem.size ) );
len = ( extmem.size + sizeof ( extmem ) );
- bottom = userptr_add ( bottom, len );
+ bottom += len;
heap_size += len;
}
}
DBG ( "EXTMEM out of space\n" );
return UNULL;
}
- ptr = bottom = userptr_add ( bottom, -sizeof ( extmem ) );
+ ptr = bottom = ( bottom - sizeof ( extmem ) );
heap_size -= sizeof ( extmem );
DBG ( "EXTMEM allocating [%lx,%lx)\n",
user_to_phys ( ptr, 0 ), user_to_phys ( ptr, 0 ) );
/* Expand/shrink block if possible */
if ( ptr == bottom ) {
/* Update block */
- new = userptr_add ( ptr, - ( new_size - extmem.size ) );
+ new = ( ptr - ( new_size - extmem.size ) );
align = ( user_to_phys ( new, 0 ) & ( EM_ALIGN - 1 ) );
new_size += align;
- new = userptr_add ( new, -align );
+ new -= align;
if ( new_size > ( heap_size + extmem.size ) ) {
DBG ( "EXTMEM out of space\n" );
return UNULL;
PROVIDE_UACCESS_INLINE ( librm, user_to_phys );
PROVIDE_UACCESS_INLINE ( librm, virt_to_user );
PROVIDE_UACCESS_INLINE ( librm, user_to_virt );
-PROVIDE_UACCESS_INLINE ( librm, userptr_add );
PROVIDE_UACCESS_INLINE ( librm, memcpy_user );
PROVIDE_UACCESS_INLINE ( librm, memmove_user );
PROVIDE_UACCESS_INLINE ( librm, memset_user );
/* Move to next fragment */
frag_len = ( sandev->capacity.blksize * params.rw.count );
- params.rw.buffer = userptr_add ( params.rw.buffer, frag_len );
+ params.rw.buffer += frag_len;
params.rw.lba += params.rw.count;
remaining -= params.rw.count;
}
PROVIDE_UACCESS_INLINE ( flat, user_to_phys );
PROVIDE_UACCESS_INLINE ( flat, virt_to_user );
PROVIDE_UACCESS_INLINE ( flat, user_to_virt );
-PROVIDE_UACCESS_INLINE ( flat, userptr_add );
PROVIDE_UACCESS_INLINE ( flat, memcpy_user );
PROVIDE_UACCESS_INLINE ( flat, memmove_user );
PROVIDE_UACCESS_INLINE ( flat, memset_user );
gve_buffer ( struct gve_queue *queue, unsigned int index ) {
/* Pages are currently allocated as a single contiguous block */
- return userptr_add ( queue->qpl.data, gve_address ( queue, index ) );
+ return ( queue->qpl.data + gve_address ( queue, index ) );
}
/**
}
/* Initialise input chunk */
- deflate_chunk_init ( &in, userptr_add ( image->data, offset ), 0, len );
+ deflate_chunk_init ( &in, ( image->data + offset ), 0, len );
/* Presize extracted image */
if ( ( rc = image_set_len ( extracted,
return trivial_user_to_virt ( userptr, offset );
}
-static inline __always_inline userptr_t
-UACCESS_INLINE ( linux, userptr_add ) ( userptr_t userptr, off_t offset ) {
- return trivial_userptr_add ( userptr, offset );
-}
-
-static inline __always_inline off_t
-UACCESS_INLINE ( linux, userptr_diff ) ( userptr_t userptr,
- userptr_t subtrahend ) {
- return trivial_userptr_diff ( userptr, subtrahend );
-}
-
static inline __always_inline void
UACCESS_INLINE ( linux, memcpy_user ) ( userptr_t dest, off_t dest_off,
userptr_t src, off_t src_off,
return ( ( void * ) userptr + offset );
}
-/**
- * Add offset to user pointer
- *
- * @v userptr User pointer
- * @v offset Offset
- * @ret userptr New pointer value
- */
-static inline __always_inline userptr_t
-trivial_userptr_add ( userptr_t userptr, off_t offset ) {
- return ( userptr + offset );
-}
-
-/**
- * Subtract user pointers
- *
- * @v userptr User pointer
- * @v subtrahend User pointer to be subtracted
- * @ret offset Offset
- */
-static inline __always_inline off_t
-trivial_userptr_diff ( userptr_t userptr, userptr_t subtrahend ) {
- return ( userptr - subtrahend );
-}
-
/**
* Copy data between user buffers
*
return trivial_user_to_virt ( userptr, offset );
}
-static inline __always_inline userptr_t
-UACCESS_INLINE ( flat, userptr_add ) ( userptr_t userptr, off_t offset ) {
- return trivial_userptr_add ( userptr, offset );
-}
-
-static inline __always_inline off_t
-UACCESS_INLINE ( flat, userptr_diff ) ( userptr_t userptr,
- userptr_t subtrahend ) {
- return trivial_userptr_diff ( userptr, subtrahend );
-}
-
static inline __always_inline void
UACCESS_INLINE ( flat, memcpy_user ) ( userptr_t dest, off_t dest_off,
userptr_t src, off_t src_off,
*/
void * user_to_virt ( userptr_t userptr, off_t offset );
-/**
- * Add offset to user pointer
- *
- * @v userptr User pointer
- * @v offset Offset
- * @ret userptr New pointer value
- */
-userptr_t userptr_add ( userptr_t userptr, off_t offset );
-
-/**
- * Subtract user pointers
- *
- * @v userptr User pointer
- * @v subtrahend User pointer to be subtracted
- * @ret offset Offset
- */
-off_t userptr_diff ( userptr_t userptr, userptr_t subtrahend );
-
/**
* Convert virtual address to a physical address
*
PROVIDE_UACCESS_INLINE(linux, user_to_phys);
PROVIDE_UACCESS_INLINE(linux, virt_to_user);
PROVIDE_UACCESS_INLINE(linux, user_to_virt);
-PROVIDE_UACCESS_INLINE(linux, userptr_add);
PROVIDE_UACCESS_INLINE(linux, memcpy_user);
PROVIDE_UACCESS_INLINE(linux, memmove_user);
PROVIDE_UACCESS_INLINE(linux, memset_user);