paul@272 | 1 | /* |
paul@272 | 2 | * A memory card region accessor. |
paul@272 | 3 | * |
paul@272 | 4 | * Copyright (C) 2021, 2024 Paul Boddie <paul@boddie.org.uk> |
paul@272 | 5 | * |
paul@272 | 6 | * This program is free software; you can redistribute it and/or |
paul@272 | 7 | * modify it under the terms of the GNU General Public License as |
paul@272 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@272 | 9 | * the License, or (at your option) any later version. |
paul@272 | 10 | * |
paul@272 | 11 | * This program is distributed in the hope that it will be useful, |
paul@272 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@272 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@272 | 14 | * GNU General Public License for more details. |
paul@272 | 15 | * |
paul@272 | 16 | * You should have received a copy of the GNU General Public License |
paul@272 | 17 | * along with this program; if not, write to the Free Software |
paul@272 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@272 | 19 | * Boston, MA 02110-1301, USA |
paul@272 | 20 | */ |
paul@272 | 21 | |
paul@272 | 22 | #pragma once |
paul@272 | 23 | |
paul@272 | 24 | #include <stdio.h> |
paul@272 | 25 | |
paul@272 | 26 | #include <fsserver/accessor.h> |
paul@272 | 27 | |
paul@272 | 28 | #include "msc_region_operations.h" |
paul@272 | 29 | |
paul@272 | 30 | |
paul@272 | 31 | |
paul@272 | 32 | /* A memory card region accessor, providing flexpages corresponding to the |
paul@272 | 33 | regions within an exposed memory card region or partition. */ |
paul@272 | 34 | |
paul@272 | 35 | class MscRegionAccessor : public Accessor |
paul@272 | 36 | { |
paul@272 | 37 | protected: |
paul@272 | 38 | MscRegionOperations *_ops; |
paul@272 | 39 | uint32_t _start; |
paul@272 | 40 | offset_t _size; |
paul@272 | 41 | |
paul@272 | 42 | /* Data transfer helper methods. */ |
paul@272 | 43 | |
paul@272 | 44 | virtual void fill_populated(Flexpage *flexpage); |
paul@272 | 45 | |
paul@272 | 46 | virtual void flush_populated(Flexpage *flexpage); |
paul@272 | 47 | |
paul@272 | 48 | public: |
paul@272 | 49 | explicit MscRegionAccessor(MscRegionOperations *ops, uint32_t start_block, |
paul@272 | 50 | uint32_t num_blocks, fileid_t fileid); |
paul@272 | 51 | |
paul@272 | 52 | virtual offset_t get_size(); |
paul@272 | 53 | |
paul@272 | 54 | virtual void set_size(offset_t size); |
paul@272 | 55 | }; |
paul@272 | 56 | |
paul@272 | 57 | // vim: tabstop=4 expandtab shiftwidth=4 |