* The size to allocate. Will be rounded up to next multiple of page size.
* @param type
* Memory region type to use for the allocated memory. Can be 0.
+ * @param flags
+ * Flags of the allocated memory region.
*
* @return
* A pointer to the allocated memory on success, NULL otherwise.
*/
-void *ukplat_memregion_alloc(__sz size, int type);
+void *ukplat_memregion_alloc(__sz size, int type, __u16 flags);
#ifdef __cplusplus
}
return plat_allocator;
}
-void *ukplat_memregion_alloc(__sz size, int type)
+void *ukplat_memregion_alloc(__sz size, int type, __u16 flags)
{
struct ukplat_memregion_desc *mrd, alloc_mrd = {0};
__vaddr_t unmap_start, unmap_end;
mrd->vbase = pstart;
mrd->len = pend - pstart;
mrd->type = type;
- mrd->flags = UKPLAT_MEMRF_READ |
- UKPLAT_MEMRF_WRITE |
- UKPLAT_MEMRF_MAP;
+ mrd->flags = flags | UKPLAT_MEMRF_MAP;
return (void *)pstart;
}
alloc_mrd.pbase = pstart;
alloc_mrd.len = size;
alloc_mrd.type = type;
- alloc_mrd.flags = UKPLAT_MEMRF_READ |
- UKPLAT_MEMRF_WRITE |
- UKPLAT_MEMRF_MAP;
+ alloc_mrd.flags = flags | UKPLAT_MEMRF_MAP;
bi = ukplat_bootinfo_get();
if (unlikely(!bi))
* by `ukplat_entry_argp` to obtain argc/argv. So mark it as a kernel
* resource instead.
*/
- cmdline = ukplat_memregion_alloc(cmdline_len + 1, UKPLAT_MEMRT_KERNEL);
+ cmdline = ukplat_memregion_alloc(cmdline_len + 1, UKPLAT_MEMRT_KERNEL,
+ UKPLAT_MEMRF_READ |
+ UKPLAT_MEMRF_WRITE |
+ UKPLAT_MEMRF_MAP);
if (unlikely(!cmdline))
return -ENOMEM;
UK_CRASH("Cmdline init failed: %d\n", rc);
/* Allocate boot stack */
- bstack = ukplat_memregion_alloc(__STACK_SIZE, UKPLAT_MEMRT_STACK);
+ bstack = ukplat_memregion_alloc(__STACK_SIZE, UKPLAT_MEMRT_STACK,
+ UKPLAT_MEMRF_READ |
+ UKPLAT_MEMRF_WRITE |
+ UKPLAT_MEMRF_MAP);
if (unlikely(!bstack))
UK_CRASH("Boot stack alloc failed\n");
if (!cmdline_len)
cmdline_len = sizeof(CONFIG_UK_NAME) - 1;
- cmdline = ukplat_memregion_alloc(cmdline_len, UKPLAT_MEMRT_CMDLINE);
+ cmdline = ukplat_memregion_alloc(cmdline_len, UKPLAT_MEMRT_CMDLINE,
+ UKPLAT_MEMRF_READ | UKPLAT_MEMRF_MAP);
if (unlikely(!cmdline))
UK_CRASH("Could not allocate command-line memory");
/* Tag this scratch cmdline as a kernel resource, to distinguish it
* from the original cmdline obtained above
*/
- cmdline = ukplat_memregion_alloc(cmdline_len, UKPLAT_MEMRT_KERNEL);
+ cmdline = ukplat_memregion_alloc(cmdline_len, UKPLAT_MEMRT_KERNEL,
+ UKPLAT_MEMRF_READ | UKPLAT_MEMRF_MAP);
if (unlikely(!cmdline))
UK_CRASH("Could not allocate scratch command-line memory");