Search
lxdream.org :: lxdream/src/vmu/vmuvol.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/vmu/vmuvol.h
changeset 1035:e3093fd7d1da
prev1034:7044e01148f0
author nkeynes
date Wed Jun 24 05:10:25 2009 +0000 (13 years ago)
permissions -rw-r--r--
last change Set svn:keywords property on new files
file annotate diff log raw
nkeynes@1034
     1
/**
nkeynes@1035
     2
 * $Id$
nkeynes@1034
     3
 *
nkeynes@1034
     4
 * VMU volume (ie block device) declarations
nkeynes@1034
     5
 *
nkeynes@1034
     6
 * Copyright (c) 2009 Nathan Keynes.
nkeynes@1034
     7
 *
nkeynes@1034
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@1034
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@1034
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@1034
    11
 * (at your option) any later version.
nkeynes@1034
    12
 *
nkeynes@1034
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@1034
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@1034
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@1034
    16
 * GNU General Public License for more details.
nkeynes@1034
    17
 */
nkeynes@1034
    18
nkeynes@1034
    19
#ifndef lxdream_vmuvol_H
nkeynes@1034
    20
#define lxdream_vmuvol_H 1
nkeynes@1034
    21
nkeynes@1034
    22
#ifdef __cplusplus
nkeynes@1034
    23
extern "C" {
nkeynes@1034
    24
#endif
nkeynes@1034
    25
nkeynes@1034
    26
#include "lxdream.h"
nkeynes@1034
    27
nkeynes@1034
    28
typedef struct vmu_volume *vmu_volume_t;
nkeynes@1034
    29
typedef unsigned int vmu_partnum_t;
nkeynes@1034
    30
nkeynes@1034
    31
#define VMU_FILE_MAGIC "%!Dreamcast$VMU\0"
nkeynes@1034
    32
#define VMU_FILE_VERSION 0x00010000
nkeynes@1034
    33
nkeynes@1034
    34
/** VMU block size is 512 bytes */
nkeynes@1034
    35
#define VMU_BLOCK_SIZE 512
nkeynes@1034
    36
nkeynes@1034
    37
/** Default VMU volume is 256 blocks */
nkeynes@1034
    38
#define VMU_DEFAULT_VOL_BLOCKS 256
nkeynes@1034
    39
nkeynes@1034
    40
/** Default VMU has 200 user blocks */
nkeynes@1034
    41
#define VMU_DEFAULT_VOL_USERBLOCKS 200
nkeynes@1034
    42
nkeynes@1034
    43
/** Default superblock is at block 255 */
nkeynes@1034
    44
#define VMU_DEFAULT_VOL_SUPERBLOCK 255
nkeynes@1034
    45
nkeynes@1034
    46
/** Default file allocation table is at block 254 */
nkeynes@1034
    47
#define VMU_DEFAULT_VOL_FATBLOCK 254
nkeynes@1034
    48
nkeynes@1034
    49
/** Default root directory block starts at block 253 */
nkeynes@1034
    50
#define VMU_DEFAULT_VOL_ROOTDIR 253
nkeynes@1034
    51
nkeynes@1034
    52
/**
nkeynes@1034
    53
 * VMU metadata structure. Note that this is structured to match the maple 
nkeynes@1034
    54
 * memory info result packet.
nkeynes@1034
    55
 */
nkeynes@1034
    56
struct vmu_volume_metadata {
nkeynes@1034
    57
    uint32_t last_block;
nkeynes@1034
    58
    uint16_t super_block;
nkeynes@1034
    59
    uint16_t fat_block;
nkeynes@1034
    60
    uint16_t fat_size;
nkeynes@1034
    61
    uint16_t dir_block;
nkeynes@1034
    62
    uint16_t dir_size;
nkeynes@1034
    63
    uint16_t user_block; /* ?? */
nkeynes@1034
    64
    uint16_t user_size;
nkeynes@1034
    65
    uint16_t unknown[3]; /* 0x001F, 0x0000, 0x0080 */
nkeynes@1034
    66
};
nkeynes@1034
    67
nkeynes@1034
    68
/**
nkeynes@1034
    69
 * Construct a new VMU volume with a single partition of the default size 
nkeynes@1034
    70
 * (128Kb). The partitions is formatted using the default filesystem 
nkeynes@1034
    71
 * organization. 
nkeynes@1034
    72
 */
nkeynes@1034
    73
vmu_volume_t vmu_volume_new_default( const gchar *display_name );
nkeynes@1034
    74
nkeynes@1034
    75
void vmu_volume_destroy( vmu_volume_t vol );
nkeynes@1034
    76
nkeynes@1034
    77
void vmu_volume_set_display_name( vmu_volume_t vol, const gchar *display_name );
nkeynes@1034
    78
nkeynes@1034
    79
const gchar *vmu_volume_get_display_name( vmu_volume_t vol );
nkeynes@1034
    80
nkeynes@1034
    81
gboolean vmu_volume_is_dirty( vmu_volume_t vol );
nkeynes@1034
    82
nkeynes@1034
    83
/**
nkeynes@1034
    84
 * Format a VMU partition according to the standard layout
nkeynes@1034
    85
 */
nkeynes@1034
    86
void vmu_volume_format( vmu_volume_t vol, vmu_partnum_t partition, gboolean quick );
nkeynes@1034
    87
nkeynes@1034
    88
nkeynes@1034
    89
nkeynes@1034
    90
/**
nkeynes@1034
    91
 * Load a VMU volume from a file.
nkeynes@1034
    92
 */
nkeynes@1034
    93
vmu_volume_t vmu_volume_load( const gchar *filename );
nkeynes@1034
    94
nkeynes@1034
    95
/**
nkeynes@1034
    96
 * Save a VMU volume to a file.
nkeynes@1034
    97
 */
nkeynes@1034
    98
gboolean vmu_volume_save( const gchar *filename, vmu_volume_t vol, gboolean create_only ); 
nkeynes@1034
    99
nkeynes@1034
   100
gboolean vmu_volume_read_block( vmu_volume_t vol, vmu_partnum_t partition, unsigned int block, unsigned char *out );
nkeynes@1034
   101
gboolean vmu_volume_write_block( vmu_volume_t vol, vmu_partnum_t partition, unsigned int block, unsigned char *in );
nkeynes@1034
   102
gboolean vmu_volume_write_phase( vmu_volume_t vol, vmu_partnum_t partition, unsigned int block, 
nkeynes@1034
   103
                                 unsigned int phase, unsigned char *in );
nkeynes@1034
   104
nkeynes@1034
   105
/**
nkeynes@1034
   106
 * Retrieve the metadata for the given volume. The metadata is owned by the
nkeynes@1034
   107
 * volume and should not be modified or freed.
nkeynes@1034
   108
 */
nkeynes@1034
   109
const struct vmu_volume_metadata *vmu_volume_get_metadata( vmu_volume_t vol, vmu_partnum_t partition );
nkeynes@1034
   110
nkeynes@1034
   111
nkeynes@1034
   112
#ifdef __cplusplus
nkeynes@1034
   113
}
nkeynes@1034
   114
#endif
nkeynes@1034
   115
nkeynes@1034
   116
#endif /* !lxdream_vmuvol_H */
.