paul@93 | 1 | /* |
paul@93 | 2 | * A pipe accessor merely resetting allocated memory for use. |
paul@93 | 3 | * |
paul@93 | 4 | * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> |
paul@93 | 5 | * |
paul@93 | 6 | * This program is free software; you can redistribute it and/or |
paul@93 | 7 | * modify it under the terms of the GNU General Public License as |
paul@93 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@93 | 9 | * the License, or (at your option) any later version. |
paul@93 | 10 | * |
paul@93 | 11 | * This program is distributed in the hope that it will be useful, |
paul@93 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@93 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@93 | 14 | * GNU General Public License for more details. |
paul@93 | 15 | * |
paul@93 | 16 | * You should have received a copy of the GNU General Public License |
paul@93 | 17 | * along with this program; if not, write to the Free Software |
paul@93 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@93 | 19 | * Boston, MA 02110-1301, USA |
paul@93 | 20 | */ |
paul@93 | 21 | |
paul@65 | 22 | #include "pipe_accessor.h" |
paul@65 | 23 | |
paul@65 | 24 | #include <string.h> |
paul@65 | 25 | |
paul@65 | 26 | PipeAccessor::PipeAccessor() |
paul@65 | 27 | : Accessor(0) |
paul@65 | 28 | { |
paul@65 | 29 | } |
paul@65 | 30 | |
paul@101 | 31 | /* Return the size of the file. */ |
paul@101 | 32 | |
paul@101 | 33 | offset_t PipeAccessor::get_size() |
paul@101 | 34 | { |
paul@101 | 35 | return _size; |
paul@101 | 36 | } |
paul@101 | 37 | |
paul@101 | 38 | /* Update the size of the file. */ |
paul@101 | 39 | |
paul@101 | 40 | void PipeAccessor::set_size(offset_t size) |
paul@101 | 41 | { |
paul@101 | 42 | _size = size; |
paul@101 | 43 | } |
paul@101 | 44 | |
paul@65 | 45 | /* Perform any closing operation on the file. */ |
paul@65 | 46 | |
paul@65 | 47 | void PipeAccessor::close() |
paul@65 | 48 | { |
paul@65 | 49 | } |
paul@65 | 50 | |
paul@65 | 51 | /* Perform any opening operation on the file. */ |
paul@65 | 52 | |
paul@65 | 53 | void PipeAccessor::open() |
paul@65 | 54 | { |
paul@65 | 55 | } |
paul@65 | 56 | |
paul@65 | 57 | /* Data transfer helper methods. */ |
paul@65 | 58 | |
paul@65 | 59 | void PipeAccessor::fill_populated(Flexpage *flexpage) |
paul@65 | 60 | { |
paul@65 | 61 | offset_t filepos = flexpage->base_offset; |
paul@65 | 62 | offset_t addr = flexpage->base_addr; |
paul@65 | 63 | |
paul@65 | 64 | /* Tag the region with file state. */ |
paul@65 | 65 | |
paul@65 | 66 | flexpage->region->fill(fileid, filepos); |
paul@65 | 67 | |
paul@65 | 68 | /* File the flexpage with zero. */ |
paul@65 | 69 | |
paul@65 | 70 | memset((void *) addr, 0, flexpage->size); |
paul@65 | 71 | } |
paul@65 | 72 | |
paul@65 | 73 | void PipeAccessor::flush_populated(Flexpage *flexpage) |
paul@65 | 74 | { |
paul@65 | 75 | flexpage->region->flush(); |
paul@65 | 76 | } |
paul@65 | 77 | |
paul@65 | 78 | // vim: tabstop=4 expandtab shiftwidth=4 |