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