BA
/
BaBoRo1
Embed:
(wiki syntax)
Show/hide line numbers
lfs_emubd.h
00001 /* 00002 * Block device emulated on standard files 00003 * 00004 * Copyright (c) 2017 ARM Limited 00005 * 00006 * Licensed under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #ifndef LFS_EMUBD_H 00019 #define LFS_EMUBD_H 00020 00021 #include "lfs.h" 00022 #include "lfs_util.h" 00023 00024 00025 // Config options 00026 #ifndef LFS_EMUBD_READ_SIZE 00027 #define LFS_EMUBD_READ_SIZE 1 00028 #endif 00029 00030 #ifndef LFS_EMUBD_PROG_SIZE 00031 #define LFS_EMUBD_PROG_SIZE 1 00032 #endif 00033 00034 #ifndef LFS_EMUBD_ERASE_SIZE 00035 #define LFS_EMUBD_ERASE_SIZE 512 00036 #endif 00037 00038 #ifndef LFS_EMUBD_TOTAL_SIZE 00039 #define LFS_EMUBD_TOTAL_SIZE 524288 00040 #endif 00041 00042 00043 // The emu bd state 00044 typedef struct lfs_emubd { 00045 char *path; 00046 char *child; 00047 00048 struct { 00049 uint64_t read_count; 00050 uint64_t prog_count; 00051 uint64_t erase_count; 00052 } stats; 00053 00054 struct { 00055 uint32_t read_size; 00056 uint32_t prog_size; 00057 uint32_t block_size; 00058 uint32_t block_count; 00059 } cfg; 00060 } lfs_emubd_t; 00061 00062 00063 // Create a block device using path for the directory to store blocks 00064 int lfs_emubd_create(const struct lfs_config *cfg, const char *path); 00065 00066 // Clean up memory associated with emu block device 00067 void lfs_emubd_destroy(const struct lfs_config *cfg); 00068 00069 // Read a block 00070 int lfs_emubd_read(const struct lfs_config *cfg, lfs_block_t block, 00071 lfs_off_t off, void *buffer, lfs_size_t size); 00072 00073 // Program a block 00074 // 00075 // The block must have previously been erased. 00076 int lfs_emubd_prog(const struct lfs_config *cfg, lfs_block_t block, 00077 lfs_off_t off, const void *buffer, lfs_size_t size); 00078 00079 // Erase a block 00080 // 00081 // A block must be erased before being programmed. The 00082 // state of an erased block is undefined. 00083 int lfs_emubd_erase(const struct lfs_config *cfg, lfs_block_t block); 00084 00085 // Sync the block device 00086 int lfs_emubd_sync(const struct lfs_config *cfg); 00087 00088 00089 #endif
Generated on Tue Jul 12 2022 12:21:58 by
