extern struct v3_os_hooks * os_hooks; \
void * ptr = 0; \
if ((os_hooks) && (os_hooks)->allocate_pages) { \
- ptr = (os_hooks)->allocate_pages(num_pages,PAGE_SIZE_4KB,-1,0); \
+ ptr = (os_hooks)->allocate_pages(num_pages,PAGE_SIZE_4KB,-1,0,0); \
} \
ptr; \
})
extern struct v3_os_hooks * os_hooks; \
void * ptr = 0; \
if ((os_hooks) && (os_hooks)->allocate_pages) { \
- ptr = (os_hooks)->allocate_pages(num_pages,align,-1,0); \
+ ptr = (os_hooks)->allocate_pages(num_pages,align,-1,0,0); \
} \
ptr; \
})
extern struct v3_os_hooks * os_hooks; \
void * ptr = 0; \
if ((os_hooks) && (os_hooks)->allocate_pages) { \
- ptr = (os_hooks)->allocate_pages(num_pages, PAGE_SIZE_4KB, node_id,0); \
+ ptr = (os_hooks)->allocate_pages(num_pages, PAGE_SIZE_4KB, node_id,0,0); \
} \
ptr; \
})
-#define V3_AllocPagesExtended(num_pages, align, node_id, constraints) \
+#define V3_AllocPagesExtended(num_pages, align, node_id, filter_func, filter_state) \
({ \
extern struct v3_os_hooks * os_hooks; \
void * ptr = 0; \
if ((os_hooks) && (os_hooks)->allocate_pages) { \
- ptr = (os_hooks)->allocate_pages(num_pages, align, node_id,constraints); \
+ ptr = (os_hooks)->allocate_pages(num_pages, align, node_id, filter_func, filter_state); \
} \
ptr; \
})
} \
} while (0)
+#define V3_VMalloc(size) ({ \
+ extern struct v3_os_hooks * os_hooks; \
+ void * var = 0; \
+ if ((os_hooks) && (os_hooks)->vmalloc) { \
+ var = (os_hooks)->vmalloc(size); \
+ } \
+ if (!var) PrintError(VM_NONE,VCORE_NONE,"VMALLOC FAILURE. Memory LEAK!!\n"); \
+ var; \
+ })
+
+#define V3_VFree(addr) \
+ do { \
+ extern struct v3_os_hooks * os_hooks; \
+ if ((os_hooks) && (os_hooks)->vfree) { \
+ (os_hooks)->vfree(addr); \
+ } \
+ } while (0)
+
// uint_t V3_CPU_KHZ();
#define V3_CPU_KHZ() ({ \
unsigned int khz = 0; \
// For page allocation:
// - node_id -1 => any node, otherwise the numa node we want to alloc from
// - constraint = 0 => no constraints, otherwise a bitwise-or of the following flags
-#define V3_ALLOC_PAGES_CONSTRAINT_4GB 1
- void *(*allocate_pages)(int num_pages, unsigned int alignment, int node_id, int constraint);
+ // Allocates physically contiguous pages
+ // - with desired alignment
+ // - that the filter_func returns nonzero on (if filter_func is given)
+ void *(*allocate_pages)(int num_pages, unsigned int alignment, int node_id, int (*filter_func)(void *paddr, void *filter_state), void *filter_state);
void (*free_pages)(void * page, int num_pages);
+ // Allocates virtually contiguous memory
+ void *(*vmalloc)(unsigned int size);
+ void (*vfree)(void * addr);
+
+ // Allocates virtually and physically contiguous memory
void *(*malloc)(unsigned int size);
void (*free)(void * addr);