1.1 --- a/libipc/lib/src/mem_ipc.c Tue Apr 26 16:34:54 2022 +0200
1.2 +++ b/libipc/lib/src/mem_ipc.c Tue Apr 26 16:36:17 2022 +0200
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Memory sharing abstractions.
1.6 *
1.7 - * Copyright (C) 2018, 2019, 2021 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2018, 2019, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -20,7 +20,6 @@
1.13 */
1.14
1.15 #include <l4/re/c/mem_alloc.h>
1.16 -#include <l4/re/c/rm.h>
1.17 #include <l4/sys/err.h>
1.18 #include <l4/sys/types.h>
1.19
1.20 @@ -40,6 +39,13 @@
1.21
1.22 long ipc_allocate(unsigned long size, void **addr, l4re_ds_t *ds)
1.23 {
1.24 + return ipc_allocate_align(size, L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_RW,
1.25 + L4_PAGESHIFT, addr, ds);
1.26 +}
1.27 +
1.28 +long ipc_allocate_align(unsigned long size, l4re_rm_flags_t flags,
1.29 + unsigned char align, void **addr, l4re_ds_t *ds)
1.30 +{
1.31 /* Allocate a capability for the dataspace. */
1.32
1.33 *ds = ipc_cap_alloc();
1.34 @@ -49,13 +55,13 @@
1.35
1.36 /* Allocate and attach the memory for the dataspace. */
1.37
1.38 - if (ipc_new_dataspace(*ds, size, 0, 0))
1.39 + if (ipc_new_dataspace(*ds, size, 0, align))
1.40 {
1.41 ipc_cap_free_um(*ds);
1.42 return -L4_ENOMEM;
1.43 }
1.44
1.45 - if (ipc_attach_dataspace(*ds, size, addr))
1.46 + if (ipc_attach_dataspace_align(*ds, size, flags, align, addr))
1.47 {
1.48 ipc_cap_free_um(*ds);
1.49 return -L4_ENOMEM;
1.50 @@ -75,6 +81,14 @@
1.51
1.52 long ipc_attach_dataspace(l4re_ds_t ds, unsigned long size, void **addr)
1.53 {
1.54 + return ipc_attach_dataspace_align(ds, size, L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_RW,
1.55 + L4_PAGESHIFT, addr);
1.56 +}
1.57 +
1.58 +long ipc_attach_dataspace_align(l4re_ds_t ds, unsigned long size,
1.59 + l4re_rm_flags_t flags, unsigned char align,
1.60 + void **addr)
1.61 +{
1.62 long err;
1.63
1.64 err = ipc_semaphore_down(ipc_mem_semaphore);
1.65 @@ -84,8 +98,7 @@
1.66 /* The region manager has changed, requiring rights flags for successful use
1.67 of the mapped region. */
1.68
1.69 - err = l4re_rm_attach(addr, size, L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_RW, ds, 0,
1.70 - L4_PAGESHIFT);
1.71 + err = l4re_rm_attach(addr, size, flags, ds, 0, align);
1.72
1.73 ipc_semaphore_up(ipc_mem_semaphore);
1.74