paul@272 | 1 | /* |
paul@272 | 2 | * Access to memory cards. |
paul@272 | 3 | * |
paul@272 | 4 | * Copyright (C) 2023, 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 <mutex> |
paul@272 | 25 | |
paul@272 | 26 | #include <l4/devices/boot.h> |
paul@272 | 27 | #include <l4/devices/dma.h> |
paul@272 | 28 | #include <l4/devices/msc-common.h> |
paul@272 | 29 | #include <systypes/base.h> |
paul@272 | 30 | |
paul@272 | 31 | |
paul@272 | 32 | |
paul@272 | 33 | #ifdef __cplusplus |
paul@272 | 34 | |
paul@272 | 35 | class MscRegionOperations |
paul@272 | 36 | { |
paul@272 | 37 | protected: |
paul@272 | 38 | std::mutex _lock; |
paul@272 | 39 | Msc_channel *_msc_channel; |
paul@272 | 40 | uint8_t _card; |
paul@272 | 41 | struct dma_region _region; |
paul@272 | 42 | |
paul@272 | 43 | public: |
paul@272 | 44 | explicit MscRegionOperations(Msc_channel *msc_channel, uint8_t card, |
paul@272 | 45 | struct dma_region region); |
paul@272 | 46 | |
paul@272 | 47 | long get_partition(uint8_t partition, uint32_t *start_block, |
paul@272 | 48 | uint32_t *num_blocks); |
paul@272 | 49 | |
paul@272 | 50 | long read_partition_table(struct partition_table_entry **entry); |
paul@272 | 51 | |
paul@272 | 52 | void read(l4_addr_t vaddr, l4re_dma_space_dma_addr_t paddr, offset_t pos, |
paul@272 | 53 | offset_t size); |
paul@272 | 54 | |
paul@272 | 55 | void write(l4_addr_t vaddr, l4re_dma_space_dma_addr_t paddr, offset_t pos, |
paul@272 | 56 | offset_t size); |
paul@272 | 57 | }; |
paul@272 | 58 | |
paul@272 | 59 | #endif /* __cplusplus */ |