paul@2 | 1 | #include <l4/re/c/dataspace.h> |
paul@4 | 2 | #include <l4/re/consts.h> |
paul@4 | 3 | #include <l4/sys/task.h> |
paul@2 | 4 | |
paul@2 | 5 | #include "ipc.h" |
paul@2 | 6 | #include "send_flexpage.h" |
paul@2 | 7 | |
paul@2 | 8 | |
paul@2 | 9 | |
paul@4 | 10 | /* Make an L4 representation of the given flexpage. */ |
paul@4 | 11 | |
paul@11 | 12 | static l4_fpage_t ipc_get_fpage(SendFlexpage *send_flexpage) |
paul@4 | 13 | { |
paul@4 | 14 | return l4_fpage(send_flexpage->base_addr, send_flexpage->order, |
paul@11 | 15 | (send_flexpage->flags & L4RE_DS_MAP_FLAG_RW) ? L4_FPAGE_RW : L4_FPAGE_RO); |
paul@4 | 16 | } |
paul@4 | 17 | |
paul@4 | 18 | /* Make a representation of a flexpage for the IPC system. */ |
paul@4 | 19 | |
paul@4 | 20 | long ipc_prepare_flexpage(Flexpage *flexpage, unsigned long offset, |
paul@4 | 21 | unsigned long max_offset, l4_addr_t hot_spot, |
paul@86 | 22 | flags_t flags, l4_snd_fpage_t *region) |
paul@2 | 23 | { |
paul@86 | 24 | SendFlexpage send_flexpage = flexpage->to_send(offset, hot_spot, flags, |
paul@86 | 25 | max_offset); |
paul@4 | 26 | |
paul@25 | 27 | /* NOTE: Consider l4_fpage_invalid() as the fpage here. */ |
paul@25 | 28 | |
paul@4 | 29 | if (!send_flexpage.order) |
paul@4 | 30 | return -L4_ERANGE; |
paul@4 | 31 | |
paul@11 | 32 | region->fpage = ipc_get_fpage(&send_flexpage); |
paul@4 | 33 | region->snd_base = hot_spot; |
paul@2 | 34 | |
paul@4 | 35 | return L4_EOK; |
paul@4 | 36 | } |
paul@4 | 37 | |
paul@4 | 38 | /* Unmap the given flexpage. */ |
paul@4 | 39 | |
paul@4 | 40 | void ipc_unmap_flexpage(Flexpage *flexpage) |
paul@4 | 41 | { |
paul@4 | 42 | SendFlexpage send_flexpage = flexpage->to_unmap(); |
paul@4 | 43 | |
paul@11 | 44 | l4_task_unmap(L4RE_THIS_TASK_CAP, ipc_get_fpage(&send_flexpage), L4_FP_OTHER_SPACES); |
paul@2 | 45 | } |
paul@2 | 46 | |
paul@2 | 47 | // vim: tabstop=4 expandtab shiftwidth=4 |