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