1 /* 2 * Access to memory cards. 3 * 4 * Copyright (C) 2023, 2024 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #pragma once 23 24 #include <mutex> 25 26 #include <l4/devices/boot.h> 27 #include <l4/devices/dma.h> 28 #include <l4/devices/msc-generic.h> 29 #include <systypes/base.h> 30 31 32 33 #ifdef __cplusplus 34 35 class MscRegionOperations 36 { 37 protected: 38 std::mutex _lock; 39 Msc_channel *_msc_channel; 40 uint8_t _card; 41 struct dma_region _region; 42 43 public: 44 explicit MscRegionOperations(Msc_channel *msc_channel, uint8_t card, 45 struct dma_region region); 46 47 long get_partition(uint8_t partition, uint32_t *start_block, 48 uint32_t *num_blocks); 49 50 long read_partition_table(struct partition_table_entry **entry); 51 52 void read(l4_addr_t vaddr, l4re_dma_space_dma_addr_t paddr, offset_t pos, 53 offset_t size); 54 55 void write(l4_addr_t vaddr, l4re_dma_space_dma_addr_t paddr, offset_t pos, 56 offset_t size); 57 }; 58 59 #endif /* __cplusplus */