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 Sat Mar 03 15:52:59 2012 +1000 (12 years ago)
permissions -rw-r--r--
last change Swap between run + pause icons when pressed
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * VMU volume (ie block device) declarations
     5  *
     6  * Copyright (c) 2009 Nathan Keynes.
     7  *
     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.
    12  *
    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.
    17  */
    19 #ifndef lxdream_vmuvol_H
    20 #define lxdream_vmuvol_H 1
    22 #ifdef __cplusplus
    23 extern "C" {
    24 #endif
    26 #include "lxdream.h"
    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
    52 /**
    53  * VMU metadata structure. Note that this is structured to match the maple 
    54  * memory info result packet.
    55  */
    56 struct vmu_volume_metadata {
    57     uint32_t last_block;
    58     uint16_t super_block;
    59     uint16_t fat_block;
    60     uint16_t fat_size;
    61     uint16_t dir_block;
    62     uint16_t dir_size;
    63     uint16_t user_block; /* ?? */
    64     uint16_t user_size;
    65     uint16_t unknown[3]; /* 0x001F, 0x0000, 0x0080 */
    66 };
    68 /**
    69  * Construct a new VMU volume with a single partition of the default size 
    70  * (128Kb). The partitions is formatted using the default filesystem 
    71  * organization. 
    72  */
    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 );
    83 /**
    84  * Format a VMU partition according to the standard layout
    85  */
    86 void vmu_volume_format( vmu_volume_t vol, vmu_partnum_t partition, gboolean quick );
    90 /**
    91  * Load a VMU volume from a file.
    92  */
    93 vmu_volume_t vmu_volume_load( const gchar *filename );
    95 /**
    96  * Save a VMU volume to a file.
    97  */
    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 );
   105 /**
   106  * Retrieve the metadata for the given volume. The metadata is owned by the
   107  * volume and should not be modified or freed.
   108  */
   109 const struct vmu_volume_metadata *vmu_volume_get_metadata( vmu_volume_t vol, vmu_partnum_t partition );
   112 #ifdef __cplusplus
   113 }
   114 #endif
   116 #endif /* !lxdream_vmuvol_H */
.