paul@1 | 1 | #include <l4/re/c/dataspace.h> |
paul@1 | 2 | |
paul@1 | 3 | #include "dataspace_server.h" |
paul@72 | 4 | #include "memory_incremental.h" |
paul@2 | 5 | #include "ipc.h" |
paul@1 | 6 | #include "simple_pager.h" |
paul@1 | 7 | |
paul@1 | 8 | |
paul@1 | 9 | |
paul@1 | 10 | SimplePager::SimplePager(Memory *memory) |
paul@1 | 11 | { |
paul@1 | 12 | if (memory == NULL) |
paul@72 | 13 | _memory = new MemoryIncremental(); |
paul@1 | 14 | else |
paul@1 | 15 | _memory = memory; |
paul@1 | 16 | |
paul@1 | 17 | _region = _memory->region(); |
paul@1 | 18 | } |
paul@1 | 19 | |
paul@1 | 20 | void SimplePager::close() |
paul@1 | 21 | { |
paul@1 | 22 | if (_region != NULL) |
paul@1 | 23 | { |
paul@1 | 24 | _memory->release(_region); |
paul@1 | 25 | _region = NULL; |
paul@1 | 26 | } |
paul@1 | 27 | } |
paul@1 | 28 | |
paul@1 | 29 | /* Map a flexpage corresponding to the dataspace 'offset' involving a 'hot_spot' |
paul@1 | 30 | (flexpage offset). */ |
paul@1 | 31 | |
paul@54 | 32 | long SimplePager::map(offset_t offset, l4_addr_t hot_spot, flags_t flags, l4_snd_fpage_t *region) |
paul@1 | 33 | { |
paul@1 | 34 | Flexpage flexpage(_region); |
paul@1 | 35 | |
paul@1 | 36 | flexpage.reset(offset); |
paul@11 | 37 | flexpage.upgrade(flags); |
paul@1 | 38 | |
paul@1 | 39 | /* Send the flexpage explicitly. */ |
paul@1 | 40 | |
paul@11 | 41 | long err = ipc_prepare_flexpage(&flexpage, offset, _region->size(), hot_spot, region); |
paul@1 | 42 | |
paul@4 | 43 | if (err) |
paul@10 | 44 | return err; |
paul@4 | 45 | |
paul@4 | 46 | err = complete_Dataspace_map(*region); |
paul@1 | 47 | |
paul@1 | 48 | if (err) |
paul@10 | 49 | return err; |
paul@1 | 50 | |
paul@1 | 51 | return IPC_MESSAGE_SENT; |
paul@1 | 52 | } |
paul@1 | 53 | |
paul@54 | 54 | long SimplePager::info(offset_t *size, flags_t *flags) |
paul@10 | 55 | { |
paul@10 | 56 | *size = _region->size(); |
paul@10 | 57 | *flags = L4_FPAGE_RW; |
paul@10 | 58 | |
paul@10 | 59 | return L4_EOK; |
paul@10 | 60 | } |
paul@10 | 61 | |
paul@1 | 62 | // vim: tabstop=4 expandtab shiftwidth=4 |