4 * VMU volume (ie block device) declarations
6 * Copyright (c) 2009 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #ifndef lxdream_vmuvol_H
20 #define lxdream_vmuvol_H 1
28 typedef struct vmu_volume *vmu_volume_t;
29 typedef unsigned int vmu_partnum_t;
31 #define VMU_FILE_MAGIC "%!Dreamcast$VMU\0"
32 #define VMU_FILE_VERSION 0x00010000
34 /** VMU block size is 512 bytes */
35 #define VMU_BLOCK_SIZE 512
37 /** Default VMU volume is 256 blocks */
38 #define VMU_DEFAULT_VOL_BLOCKS 256
40 /** Default VMU has 200 user blocks */
41 #define VMU_DEFAULT_VOL_USERBLOCKS 200
43 /** Default superblock is at block 255 */
44 #define VMU_DEFAULT_VOL_SUPERBLOCK 255
46 /** Default file allocation table is at block 254 */
47 #define VMU_DEFAULT_VOL_FATBLOCK 254
49 /** Default root directory block starts at block 253 */
50 #define VMU_DEFAULT_VOL_ROOTDIR 253
53 * VMU metadata structure. Note that this is structured to match the maple
54 * memory info result packet.
56 struct vmu_volume_metadata {
63 uint16_t user_block; /* ?? */
65 uint16_t unknown[3]; /* 0x001F, 0x0000, 0x0080 */
69 * Construct a new VMU volume with a single partition of the default size
70 * (128Kb). The partitions is formatted using the default filesystem
73 vmu_volume_t vmu_volume_new_default( const gchar *display_name );
75 void vmu_volume_destroy( vmu_volume_t vol );
77 void vmu_volume_set_display_name( vmu_volume_t vol, const gchar *display_name );
79 const gchar *vmu_volume_get_display_name( vmu_volume_t vol );
81 gboolean vmu_volume_is_dirty( vmu_volume_t vol );
84 * Format a VMU partition according to the standard layout
86 void vmu_volume_format( vmu_volume_t vol, vmu_partnum_t partition, gboolean quick );
91 * Load a VMU volume from a file.
93 vmu_volume_t vmu_volume_load( const gchar *filename );
96 * Save a VMU volume to a file.
98 gboolean vmu_volume_save( const gchar *filename, vmu_volume_t vol, gboolean create_only );
100 gboolean vmu_volume_read_block( vmu_volume_t vol, vmu_partnum_t partition, unsigned int block, unsigned char *out );
101 gboolean vmu_volume_write_block( vmu_volume_t vol, vmu_partnum_t partition, unsigned int block, unsigned char *in );
102 gboolean vmu_volume_write_phase( vmu_volume_t vol, vmu_partnum_t partition, unsigned int block,
103 unsigned int phase, unsigned char *in );
106 * Retrieve the metadata for the given volume. The metadata is owned by the
107 * volume and should not be modified or freed.
109 const struct vmu_volume_metadata *vmu_volume_get_metadata( vmu_volume_t vol, vmu_partnum_t partition );
116 #endif /* !lxdream_vmuvol_H */
.