diff --git a/VERSION b/VERSION index c9e5550a..fcba5cef 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-40-g968b313993+1 \ No newline at end of file +B1-41-g453b8e6a4d+1 \ No newline at end of file diff --git a/porthole/include/porthole/types.h b/porthole/include/porthole/types.h index 03d9ad94..a18629e4 100644 --- a/porthole/include/porthole/types.h +++ b/porthole/include/porthole/types.h @@ -22,18 +22,10 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include -typedef struct -{ - unsigned int size; - void * data; -} -PortholeSegment; - typedef struct { uint32_t id; unsigned int size; unsigned int num_segments; - PortholeSegment segments[0]; } PortholeMap; \ No newline at end of file diff --git a/porthole/include/porthole/util.h b/porthole/include/porthole/util.h index d8b4a4b3..dbc53cef 100644 --- a/porthole/include/porthole/util.h +++ b/porthole/include/porthole/util.h @@ -51,4 +51,12 @@ void porthole_copy_map_to_mem(PortholeMap * src, void * dst, size_t len, off_t o * @param src_off The offset into the src PortholeMap * @param dst_off The offset into the dst PortholeMap */ -void porthole_copy_map_to_map(PortholeMap * src, PortholeMap * dst, size_t len, off_t src_off, off_t dst_off); \ No newline at end of file +void porthole_copy_map_to_map(PortholeMap * src, PortholeMap * dst, size_t len, off_t src_off, off_t dst_off); + +/** + * Get the pointer to the base of a PortholeMap + * + * @param map The map to get the pointer for + * @return The base address of the mapping, or NULL if the mapping is not contiguous + */ +void * porthole_get_map_ptr(PortholeMap *map); diff --git a/porthole/src/util.c b/porthole/src/util.c index 57ee7def..4ab6421b 100644 --- a/porthole/src/util.c +++ b/porthole/src/util.c @@ -17,6 +17,7 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "types.h" #include "porthole/util.h" #include "common/debug.h" @@ -28,7 +29,7 @@ void porthole_copy_mem_to_map(void * src, PortholeMap * dst, size_t len, off_t o DEBUG_FATAL("Attempt to write beyond the length of destination mapping"); /* find the start segment */ - PortholeSegment * seg = &dst->segments[0]; + PortholeSegment * seg = PH_SEGMENTS(dst); while(off) { if (seg->size > off) @@ -62,7 +63,7 @@ void porthole_copy_map_to_mem(PortholeMap * src, void * dst, size_t len, off_t o DEBUG_FATAL("Attempt to read beyond the length of the source mapping"); /* find the start segment */ - PortholeSegment * seg = &src->segments[0]; + PortholeSegment * seg = PH_SEGMENTS(src); while(off) { if (seg->size > off) @@ -99,7 +100,7 @@ void porthole_copy_map_to_map(PortholeMap * src, PortholeMap * dst, size_t len, DEBUG_FATAL("Attempt to write beyond the length of the destination mapping"); /* find the start segments */ - PortholeSegment * src_seg = &src->segments[0]; + PortholeSegment * src_seg = PH_SEGMENTS(src); while(src_off) { if (src_seg->size > src_off) @@ -109,7 +110,7 @@ void porthole_copy_map_to_map(PortholeMap * src, PortholeMap * dst, size_t len, ++src_seg; } - PortholeSegment * dst_seg = &dst->segments[0]; + PortholeSegment * dst_seg = PH_SEGMENTS(dst); while(dst_off) { if (dst_seg->size > dst_off) @@ -149,4 +150,12 @@ void porthole_copy_map_to_map(PortholeMap * src, PortholeMap * dst, size_t len, len -= avail; } +} + +void * porthole_get_map_ptr(PortholeMap *map) +{ + if (map->num_segments != 1) + return NULL; + + return PH_SEGMENTS(map)[0].data; } \ No newline at end of file