mirror of
https://github.com/ipxe/ipxe
synced 2026-02-14 02:31:26 +03:00
[uaccess] Rename userptr_sub() to userptr_diff()
Clarify the intended usage of userptr_sub() by renaming it to userptr_diff() (to avoid confusion with userptr_add()), and fix the existing call sites that erroneously use userptr_sub() to subtract an offset from a userptr_t value. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -476,7 +476,7 @@ static void bzimage_load_initrds ( struct image *image,
|
|||||||
/* Find highest initrd */
|
/* Find highest initrd */
|
||||||
for_each_image ( initrd ) {
|
for_each_image ( initrd ) {
|
||||||
if ( ( highest == NULL ) ||
|
if ( ( highest == NULL ) ||
|
||||||
( userptr_sub ( initrd->data, highest->data ) > 0 ) ) {
|
( userptr_diff ( initrd->data, highest->data ) > 0 ) ) {
|
||||||
highest = initrd;
|
highest = initrd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,10 +61,10 @@ static userptr_t initrd_squash_high ( userptr_t top ) {
|
|||||||
/* Find the highest image not yet in its final position */
|
/* Find the highest image not yet in its final position */
|
||||||
highest = NULL;
|
highest = NULL;
|
||||||
for_each_image ( initrd ) {
|
for_each_image ( initrd ) {
|
||||||
if ( ( userptr_sub ( initrd->data, current ) < 0 ) &&
|
if ( ( userptr_diff ( initrd->data, current ) < 0 ) &&
|
||||||
( ( highest == NULL ) ||
|
( ( highest == NULL ) ||
|
||||||
( userptr_sub ( initrd->data,
|
( userptr_diff ( initrd->data,
|
||||||
highest->data ) > 0 ) ) ) {
|
highest->data ) > 0 ) ) ) {
|
||||||
highest = initrd;
|
highest = initrd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ static userptr_t initrd_squash_high ( userptr_t top ) {
|
|||||||
/* Move this image to its final position */
|
/* Move this image to its final position */
|
||||||
len = ( ( highest->len + INITRD_ALIGN - 1 ) &
|
len = ( ( highest->len + INITRD_ALIGN - 1 ) &
|
||||||
~( INITRD_ALIGN - 1 ) );
|
~( INITRD_ALIGN - 1 ) );
|
||||||
current = userptr_sub ( current, len );
|
current = userptr_add ( current, -len );
|
||||||
DBGC ( &images, "INITRD squashing %s [%#08lx,%#08lx)->"
|
DBGC ( &images, "INITRD squashing %s [%#08lx,%#08lx)->"
|
||||||
"[%#08lx,%#08lx)\n", highest->name,
|
"[%#08lx,%#08lx)\n", highest->name,
|
||||||
user_to_phys ( highest->data, 0 ),
|
user_to_phys ( highest->data, 0 ),
|
||||||
@@ -87,10 +87,10 @@ static userptr_t initrd_squash_high ( userptr_t top ) {
|
|||||||
|
|
||||||
/* Copy any remaining initrds (e.g. embedded images) to the region */
|
/* Copy any remaining initrds (e.g. embedded images) to the region */
|
||||||
for_each_image ( initrd ) {
|
for_each_image ( initrd ) {
|
||||||
if ( userptr_sub ( initrd->data, top ) >= 0 ) {
|
if ( userptr_diff ( initrd->data, top ) >= 0 ) {
|
||||||
len = ( ( initrd->len + INITRD_ALIGN - 1 ) &
|
len = ( ( initrd->len + INITRD_ALIGN - 1 ) &
|
||||||
~( INITRD_ALIGN - 1 ) );
|
~( INITRD_ALIGN - 1 ) );
|
||||||
current = userptr_sub ( current, len );
|
current = userptr_add ( current, -len );
|
||||||
DBGC ( &images, "INITRD copying %s [%#08lx,%#08lx)->"
|
DBGC ( &images, "INITRD copying %s [%#08lx,%#08lx)->"
|
||||||
"[%#08lx,%#08lx)\n", initrd->name,
|
"[%#08lx,%#08lx)\n", initrd->name,
|
||||||
user_to_phys ( initrd->data, 0 ),
|
user_to_phys ( initrd->data, 0 ),
|
||||||
@@ -235,7 +235,7 @@ void initrd_reshuffle ( userptr_t bottom ) {
|
|||||||
|
|
||||||
/* Calculate limits of available space for initrds */
|
/* Calculate limits of available space for initrds */
|
||||||
top = initrd_top;
|
top = initrd_top;
|
||||||
if ( userptr_sub ( initrd_bottom, bottom ) > 0 )
|
if ( userptr_diff ( initrd_bottom, bottom ) > 0 )
|
||||||
bottom = initrd_bottom;
|
bottom = initrd_bottom;
|
||||||
|
|
||||||
/* Debug */
|
/* Debug */
|
||||||
@@ -248,7 +248,7 @@ void initrd_reshuffle ( userptr_t bottom ) {
|
|||||||
|
|
||||||
/* Calculate available free space */
|
/* Calculate available free space */
|
||||||
free = bottom;
|
free = bottom;
|
||||||
free_len = userptr_sub ( used, free );
|
free_len = userptr_diff ( used, free );
|
||||||
|
|
||||||
/* Bubble-sort initrds into desired order */
|
/* Bubble-sort initrds into desired order */
|
||||||
while ( initrd_swap_any ( free, free_len ) ) {}
|
while ( initrd_swap_any ( free, free_len ) ) {}
|
||||||
@@ -270,9 +270,9 @@ int initrd_reshuffle_check ( size_t len, userptr_t bottom ) {
|
|||||||
|
|
||||||
/* Calculate limits of available space for initrds */
|
/* Calculate limits of available space for initrds */
|
||||||
top = initrd_top;
|
top = initrd_top;
|
||||||
if ( userptr_sub ( initrd_bottom, bottom ) > 0 )
|
if ( userptr_diff ( initrd_bottom, bottom ) > 0 )
|
||||||
bottom = initrd_bottom;
|
bottom = initrd_bottom;
|
||||||
available = userptr_sub ( top, bottom );
|
available = userptr_diff ( top, bottom );
|
||||||
|
|
||||||
/* Allow for a sensible minimum amount of free space */
|
/* Allow for a sensible minimum amount of free space */
|
||||||
len += INITRD_MIN_FREE_LEN;
|
len += INITRD_MIN_FREE_LEN;
|
||||||
|
|||||||
@@ -143,9 +143,9 @@ UACCESS_INLINE ( librm, userptr_add ) ( userptr_t userptr, off_t offset ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline off_t
|
static inline __always_inline off_t
|
||||||
UACCESS_INLINE ( librm, userptr_sub ) ( userptr_t userptr,
|
UACCESS_INLINE ( librm, userptr_diff ) ( userptr_t userptr,
|
||||||
userptr_t subtrahend ) {
|
userptr_t subtrahend ) {
|
||||||
return trivial_userptr_sub ( userptr, subtrahend );
|
return trivial_userptr_diff ( userptr, subtrahend );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline void
|
static inline __always_inline void
|
||||||
|
|||||||
@@ -75,9 +75,9 @@ UACCESS_INLINE ( linux, userptr_add ) ( userptr_t userptr, off_t offset ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline off_t
|
static inline __always_inline off_t
|
||||||
UACCESS_INLINE ( linux, userptr_sub ) ( userptr_t userptr,
|
UACCESS_INLINE ( linux, userptr_diff ) ( userptr_t userptr,
|
||||||
userptr_t subtrahend ) {
|
userptr_t subtrahend ) {
|
||||||
return trivial_userptr_sub ( userptr, subtrahend );
|
return trivial_userptr_diff ( userptr, subtrahend );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline void
|
static inline __always_inline void
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ trivial_userptr_add ( userptr_t userptr, off_t offset ) {
|
|||||||
* @ret offset Offset
|
* @ret offset Offset
|
||||||
*/
|
*/
|
||||||
static inline __always_inline off_t
|
static inline __always_inline off_t
|
||||||
trivial_userptr_sub ( userptr_t userptr, userptr_t subtrahend ) {
|
trivial_userptr_diff ( userptr_t userptr, userptr_t subtrahend ) {
|
||||||
return ( userptr - subtrahend );
|
return ( userptr - subtrahend );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,9 +248,9 @@ UACCESS_INLINE ( flat, userptr_add ) ( userptr_t userptr, off_t offset ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline off_t
|
static inline __always_inline off_t
|
||||||
UACCESS_INLINE ( flat, userptr_sub ) ( userptr_t userptr,
|
UACCESS_INLINE ( flat, userptr_diff ) ( userptr_t userptr,
|
||||||
userptr_t subtrahend ) {
|
userptr_t subtrahend ) {
|
||||||
return trivial_userptr_sub ( userptr, subtrahend );
|
return trivial_userptr_diff ( userptr, subtrahend );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline void
|
static inline __always_inline void
|
||||||
@@ -349,7 +349,7 @@ userptr_t userptr_add ( userptr_t userptr, off_t offset );
|
|||||||
* @v subtrahend User pointer to be subtracted
|
* @v subtrahend User pointer to be subtracted
|
||||||
* @ret offset Offset
|
* @ret offset Offset
|
||||||
*/
|
*/
|
||||||
off_t userptr_sub ( userptr_t userptr, userptr_t subtrahend );
|
off_t userptr_diff ( userptr_t userptr, userptr_t subtrahend );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert virtual address to a physical address
|
* Convert virtual address to a physical address
|
||||||
|
|||||||
Reference in New Issue
Block a user