- added instructions how to update the online documentation
[bochs-mirror.git] / iodev / vmware4.h
blob55096bf16ec041a59b99b6b4877998f0dfff0acd
1 /////////////////////////////////////////////////////////////////////////
2 // $Id: vmware4.h,v 1.1 2006/12/17 08:17:28 vruppert Exp $
3 /////////////////////////////////////////////////////////////////////////
5 /*
6 * This file provides support for VMWare's virtual disk image
7 * format version 4 and above.
9 * Author: Sharvil Nanavati
10 * Contact: snrrrub@gmail.com
12 * Copyright (C) 2006 Sharvil Nanavati.
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef _VMWARE4_H
30 #define _VMWARE4_H 1
32 class vmware4_image_t : public device_image_t
34 public:
35 vmware4_image_t();
36 virtual ~vmware4_image_t();
38 int open(const char* pathname);
39 void close();
40 Bit64s lseek(Bit64s offset, int whence);
41 ssize_t read(void* buf, size_t count);
42 ssize_t write(const void* buf, size_t count);
44 private:
45 static const off_t INVALID_OFFSET;
46 static const int SECTOR_SIZE;
48 #if defined(_MSC_VER)
49 #pragma pack(push, 1)
50 #elif defined(__MWERKS__) && defined(macintosh)
51 #pragma options align=packed
52 #endif
53 typedef struct _VM4_Header
55 Bit8u id[4];
56 Bit32u version;
57 Bit32u flags;
58 Bit64u total_sectors;
59 Bit64u tlb_size_sectors;
60 Bit64u description_offset_sectors;
61 Bit64u description_size_sectors;
62 Bit32u slb_count;
63 Bit64u flb_offset_sectors;
64 Bit64u flb_copy_offset_sectors;
65 Bit64u tlb_offset_sectors;
67 #if !defined(_MSC_VER)
68 GCC_ATTRIBUTE((packed))
69 #endif
70 VM4_Header;
72 #if defined(_MSC_VER)
73 #pragma pack(pop)
74 #elif defined(__MWERKS__) && defined(macintosh)
75 #pragma options align=reset
76 #endif
78 bool is_open() const;
79 bool is_valid_header() const;
81 bool read_header();
82 off_t perform_seek();
83 void flush();
84 Bit32u read_block_index(Bit64u sector, Bit32u index);
85 void write_block_index(Bit64u sector, Bit32u index, Bit32u block_sector);
87 int file_descriptor;
88 VM4_Header header;
89 Bit8u* tlb;
90 off_t tlb_offset;
91 off_t current_offset;
92 bool is_dirty;
95 #endif