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, unsigned long flags) 13 { 14 // NOTE: To introduce flags properly in the flexpage abstractions. 15 16 return l4_fpage(send_flexpage->base_addr, send_flexpage->order, 17 (flags & L4RE_DS_MAP_FLAG_RW) ? L4_FPAGE_RW : L4_FPAGE_RO); 18 } 19 20 /* Make a representation of a flexpage for the IPC system. */ 21 22 long ipc_prepare_flexpage(Flexpage *flexpage, unsigned long offset, 23 unsigned long max_offset, l4_addr_t hot_spot, 24 unsigned long flags, l4_snd_fpage_t *region) 25 { 26 SendFlexpage send_flexpage = flexpage->to_send(offset, hot_spot, max_offset); 27 28 if (!send_flexpage.order) 29 return -L4_ERANGE; 30 31 region->fpage = ipc_get_fpage(&send_flexpage, flags); 32 region->snd_base = hot_spot; 33 34 return L4_EOK; 35 } 36 37 /* Unmap the given flexpage. */ 38 39 void ipc_unmap_flexpage(Flexpage *flexpage) 40 { 41 SendFlexpage send_flexpage = flexpage->to_unmap(); 42 43 // NOTE: To introduce flags properly in the flexpage abstractions. 44 45 l4_task_unmap(L4RE_THIS_TASK_CAP, ipc_get_fpage(&send_flexpage, L4_FPAGE_RW), L4_FP_OTHER_SPACES); 46 } 47 48 // vim: tabstop=4 expandtab shiftwidth=4