Xemu [doxygen]  hyppo 0a42be3a057156924bc1b626a687bd6e27349c45 @ Sat 19 Mar 02:15:11 CET 2022
fat32.h
Go to the documentation of this file.
1 /* A work-in-progess MEGA65 (Commodore 65 clone origins) emulator
2  Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu
3  Copyright (C)2016-2020 LGB (Gábor Lénárt) <lgblgblgb@gmail.com>
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
18 
19 #ifndef XEMU_MEGA65_FAT32_H_INCLUDED
20 #define XEMU_MEGA65_FAT32_H_INCLUDED
21 
22 #define MFAT_FIND_VOL 1
23 #define MFAT_FIND_DIR 2
24 #define MFAT_FIND_FILE 4
25 
26 #define IS_MFAT_DIR(p) (!!((p)&0x10))
27 #define IS_MFAT_VOL(p) (!!((p)&0x08))
28 #define IS_MFAT_FILE(p) (((p)&0x18)==0)
29 
31 
32 struct mfat_part_st {
36  //Uint32 blocks_per_cluster;
37  int part_type;
38  int valid; // partition seems to be valid by part_type and size and layout requirements
39  int fs_validated; // FAT32 is validated already, all data below is filled
40  Uint32 clusters; // total number of clusters (don't forget, the two first clusters cannot be used, but it counts here!)
41  Uint32 data_area_fake_ofs; // the 'fake' offset (taking account the cluster<2 invalidity) which must be added to the converted cluster->block value
42  Uint32 cluster_size_in_blocks; // cluster size in blocks
47 };
48 
49 typedef struct {
53  int eof;
55  int file_pos;
59 
60 typedef struct {
62  char name[8+3+1+1]; // 8-char-base-name + 1-char-DOT + 3 char-extension + 1-end-of-c-string-marker
63  char fat_name[8+3+1];
67  time_t time;
69 
71 extern int mfat_init_mbr ( void );
72 extern int mfat_use_part ( int part );
73 
74 extern int mfat_normalize_name ( char *d, const char *s );
75 extern int mfat_fatize_name ( char *d, const char *s );
76 extern int mfat_read_directory ( mfat_dirent_t *p, int type_filter );
77 extern int mfat_search_in_directory ( mfat_dirent_t *p, const char *name, int type_filter );
78 extern void mfat_open_rootdir ( mfat_stream_t *p );
79 extern Uint32 mfat_get_real_size ( mfat_stream_t *p, int *fragmented );
81 
82 #endif
mfat_dirent_t
Definition: fat32.h:60
mfat_search_in_directory
int mfat_search_in_directory(mfat_dirent_t *p, const char *name, int type_filter)
Definition: fat32.c:786
mfat_init
void mfat_init(mfat_io_callback_func_t reader, mfat_io_callback_func_t writer, Uint32 device_size)
Definition: fat32.c:323
mfat_stream_t::start_cluster
Uint32 start_cluster
Definition: fat32.h:57
mfat_part_st::part_type
int part_type
Definition: fat32.h:37
mfat_part_st::data_area_fake_ofs
Uint32 data_area_fake_ofs
Definition: fat32.h:41
mfat_dirent_t::type
Uint8 type
Definition: fat32.h:66
mfat_part_st
Definition: fat32.h:32
mfat_stream_t::in_cluster_block
int in_cluster_block
Definition: fat32.h:51
mfat_stream_t::file_pos
int file_pos
Definition: fat32.h:55
mfat_part_st::cluster_size_in_blocks
Uint32 cluster_size_in_blocks
Definition: fat32.h:42
mfat_stream_t::partition
struct mfat_part_st * partition
Definition: fat32.h:56
reader
mfat_io_callback_func_t reader
Definition: fat32.c:72
mfat_stream_t::size_constraint
int size_constraint
Definition: fat32.h:54
mfat_use_part
int mfat_use_part(int part)
Definition: fat32.c:406
mfat_dirent_t::time
time_t time
Definition: fat32.h:67
mfat_stream_t::eof
int eof
Definition: fat32.h:53
m65-memcontent-generator.data
data
Definition: m65-memcontent-generator.py:119
Uint32
uint32_t Uint32
Definition: fat32.c:49
writer
mfat_io_callback_func_t writer
Definition: fat32.c:72
mfat_part_st::fs_validated
int fs_validated
Definition: fat32.h:39
Uint8
uint8_t Uint8
Definition: fat32.c:51
mfat_init_mbr
int mfat_init_mbr(void)
Definition: fat32.c:339
block
Uint32 block
Definition: fat32.c:156
mfat_part_st::fs_info_block_number
Uint32 fs_info_block_number
Definition: fat32.h:45
mfat_dirent_t::size
Uint32 size
Definition: fat32.h:65
mfat_io_callback_func_t
int(* mfat_io_callback_func_t)(Uint32 block, Uint8 *data)
Definition: fat32.h:30
mfat_stream_t
Definition: fat32.h:49
mfat_part_st::valid
int valid
Definition: fat32.h:38
mfat_open_rootdir
void mfat_open_rootdir(mfat_stream_t *p)
Definition: fat32.c:542
mfat_part_st::root_dir_cluster
Uint32 root_dir_cluster
Definition: fat32.h:44
mfat_overwrite_file_with_direct_linear_device_block_write
Uint32 mfat_overwrite_file_with_direct_linear_device_block_write(mfat_dirent_t *dirent, const char *name, Uint32 size)
Definition: fat32.c:813
mfat_read_directory
int mfat_read_directory(mfat_dirent_t *p, int type_filter)
Definition: fat32.c:718
mfat_dirent_t::stream
mfat_stream_t stream
Definition: fat32.h:61
size
int size
Definition: inject.c:37
mfat_part_st::fat2_start
Uint32 fat2_start
Definition: fat32.h:43
mfat_fatize_name
int mfat_fatize_name(char *d, const char *s)
Definition: fat32.c:921
mfat_part_st::last_block
Uint32 last_block
Definition: fat32.h:34
mfat_normalize_name
int mfat_normalize_name(char *d, const char *s)
Definition: fat32.c:956
mfat_stream_t::cluster
Uint32 cluster
Definition: fat32.h:50
name
const char * name
Definition: joystick.c:46
mfat_part_st::eoc_marker
Uint32 eoc_marker
Definition: fat32.h:46
mfat_stream_t::in_block_pos
int in_block_pos
Definition: fat32.h:52
mfat_part_st::fat1_start
Uint32 fat1_start
Definition: fat32.h:43
mfat_part_st::blocks
Uint32 blocks
Definition: fat32.h:35
mfat_dirent_t::cluster
Uint32 cluster
Definition: fat32.h:64
mfat_part_st::first_block
Uint32 first_block
Definition: fat32.h:33
mfat_part_st::clusters
Uint32 clusters
Definition: fat32.h:40
part
int part
Definition: fat32.c:74
mfat_get_real_size
Uint32 mfat_get_real_size(mfat_stream_t *p, int *fragmented)
Definition: fat32.c:560