/[gxemul]/trunk/src/include/diskimage.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/src/include/diskimage.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 38 - (show annotations)
Mon Oct 8 16:21:53 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 5791 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1515 2007/04/14 05:39:46 debug Exp $
20070324	Adding a "--debug" option to the configure script, to disable
		optimizations in unstable development builds.
		Moving out SCSI-specific stuff from diskimage.c into a new
		diskimage_scsicmd.c.
		Applying Hĺvard Eidnes' patch for SCSICDROM_READ_DISKINFO and
		SCSICDROM_READ_TRACKINFO. (Not really tested yet.)
		Implementing disk image "overlays" (to allow simple roll-back
		to previous disk state). Adding a 'V' disk flag for this, and
		updating the man page and misc.html.
20070325	Stability fix to cpu_dyntrans.c, when multiple physical pages
		share the same initial table entry. (The ppp == NULL check
		should be physpage_ofs == 0.) Bug found by analysing GXemul
		against a version patched for Godson.
		Fixing a second occurance of the same problem (also in
		cpu_dyntrans.c).
		Fixing a MAJOR physical page leak in cpu_dyntrans.c; pages
		weren't _added_ to the set of translated pages, they _replaced_
		all previous pages. It's amazing that this bug has been able
		to live for this long. (Triggered when emulating >128MB RAM.)
20070326	Removing the GDB debugging stub support; it was too hackish
		and ugly.
20070328	Moving around some native code generation skeleton code.
20070329	The -lm check in the configure script now also checks for sin()
		in addition to sqrt(). (Thanks to Nigel Horne for noticing that
		sqrt was not enough on Fedora Core 6.) (Not verified yet.)
20070330	Fixing an indexing bug in dev_sh4.c, found by using gcc version
		4.3.0 20070323.
20070331	Some more experimentation with native code generation.
20070404	Attempting to fix some more SH4 SCIF interrupt bugs; rewriting
		the SH interrupt assertion/deassertion code somewhat.
20070410	Splitting src/file.c into separate files in src/file/.
		Cleanup: Removing the dummy TS7200, Walnut, PB1000, and
		Meshcube emulation modes, and dev_epcom and dev_au1x00.
		Removing the experimental CHIP8/RCA180x code; it wasn't really
		working much lately, anyway. It was fun while it lasted.
		Also removing the experimental Transputer CPU support.
20070412	Moving the section about how the dynamic translation system
		works from intro.html to a separate translation.html file.
		Minor SH fixes; attempting to get OpenBSD/landisk to run
		without randomly bugging out, but no success yet.
20070413	SH SCI (serial bit interface) should now work together with a
		(new) RS5C313 clock device (for Landisk emulation).
20070414	Moving Redhat/MIPS down from supported to experimental, in
		guestoses.html.
		Preparing for a new release; doing some regression testing etc.

==============  RELEASE 0.4.5  ==============


1 #ifndef DISKIMAGE_H
2 #define DISKIMAGE_H
3
4 /*
5 * Copyright (C) 2003-2007 Anders Gavare. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 *
31 * $Id: diskimage.h,v 1.36 2007/03/24 06:39:29 debug Exp $
32 *
33 * Generic disk image functions. (See diskimage.c for more info.)
34 */
35
36 #include <stdio.h>
37 #include <sys/types.h>
38
39 #include "misc.h"
40
41 /* Diskimage types: */
42 #define DISKIMAGE_SCSI 1
43 #define DISKIMAGE_IDE 2
44 #define DISKIMAGE_FLOPPY 3
45
46 #define DISKIMAGE_TYPES { "(NONE)", "SCSI", "IDE", "FLOPPY" }
47
48
49 /* 512 bytes per overlay block. Don't change this. */
50 #define OVERLAY_BLOCK_SIZE 512
51
52 struct diskimage_overlay {
53 char *overlay_basename;
54 FILE *f_data;
55 FILE *f_bitmap;
56 };
57
58 struct diskimage {
59 struct diskimage *next;
60 int type; /* DISKIMAGE_SCSI, etc */
61 int id; /* SCSI id */
62
63 /* Filename in host's file system: */
64 char *fname;
65 FILE *f;
66
67 /* Overlays: */
68 int nr_of_overlays;
69 struct diskimage_overlay *overlays;
70
71 int chs_override;
72 int cylinders;
73 int heads;
74 int sectors_per_track;
75
76 off_t total_size;
77 int64_t override_base_offset;
78 int logical_block_size;
79
80 int writable;
81 int is_a_cdrom;
82 int is_boot_device;
83
84 int is_a_tape;
85 uint64_t tape_offset;
86 int tape_filenr;
87 int filemark;
88
89 int rpms;
90 int ncyls;
91 };
92
93
94 /* Transfer command, sent from a SCSI controller device to a disk: */
95 struct scsi_transfer {
96 struct scsi_transfer *next_free;
97
98 /* These should be set by the SCSI controller before the call: */
99 unsigned char *msg_out;
100 size_t msg_out_len;
101 unsigned char *cmd;
102 size_t cmd_len;
103
104 /* data_out_len is set by the SCSI disk, if it needs data_out,
105 which is then filled in during a second pass in the controller. */
106 unsigned char *data_out;
107 size_t data_out_len;
108 size_t data_out_offset;
109
110 /* These should be set by the SCSI (disk) device before returning: */
111 unsigned char *data_in;
112 size_t data_in_len;
113 unsigned char *msg_in;
114 size_t msg_in_len;
115 unsigned char *status;
116 size_t status_len;
117 };
118
119
120 struct machine;
121
122
123 /* diskimage_scsicmd.c: */
124 struct scsi_transfer *scsi_transfer_alloc(void);
125 void scsi_transfer_free(struct scsi_transfer *);
126 void scsi_transfer_allocbuf(size_t *lenp, unsigned char **pp,
127 size_t want_len, int clearflag);
128 int diskimage_scsicommand(struct cpu *cpu, int id, int type,
129 struct scsi_transfer *);
130
131
132 /* diskimage.c: */
133 int64_t diskimage_getsize(struct machine *machine, int id, int type);
134 int64_t diskimage_get_baseoffset(struct machine *machine, int id, int type);
135 void diskimage_getchs(struct machine *machine, int id, int type,
136 int *c, int *h, int *s);
137 int diskimage__internal_access(struct diskimage *d, int writeflag,
138 off_t offset, unsigned char *buf, size_t len);
139 int diskimage_access(struct machine *machine, int id, int type, int writeflag,
140 off_t offset, unsigned char *buf, size_t len);
141 void diskimage_add_overlay(struct diskimage *d, char *overlay_basename);
142 void diskimage_recalc_size(struct diskimage *d);
143 int diskimage_exist(struct machine *machine, int id, int type);
144 int diskimage_bootdev(struct machine *machine, int *typep);
145 int diskimage_add(struct machine *machine, char *fname);
146 int diskimage_getname(struct machine *machine, int id, int type,
147 char *buf, size_t bufsize);
148 int diskimage_is_a_cdrom(struct machine *machine, int id, int type);
149 int diskimage_is_a_tape(struct machine *machine, int id, int type);
150 void diskimage_dump_info(struct machine *machine);
151
152
153 /*
154 * SCSI commands:
155 */
156 #define SCSICMD_TEST_UNIT_READY 0x00 /* Mandatory */
157 #define SCSICMD_REQUEST_SENSE 0x03 /* Mandatory */
158 #define SCSICMD_INQUIRY 0x12 /* Mandatory */
159
160 #define SCSICMD_READ 0x08
161 #define SCSICMD_READ_10 0x28
162 #define SCSICMD_WRITE 0x0a
163 #define SCSICMD_WRITE_10 0x2a
164 #define SCSICMD_MODE_SELECT 0x15
165 #define SCSICMD_MODE_SENSE 0x1a
166 #define SCSICMD_START_STOP_UNIT 0x1b
167 #define SCSICMD_PREVENT_ALLOW_REMOVE 0x1e
168 #define SCSICMD_MODE_SENSE10 0x5a
169
170 #define SCSICMD_SYNCHRONIZE_CACHE 0x35
171
172 /* SCSI block device commands: */
173 #define SCSIBLOCKCMD_READ_CAPACITY 0x25
174
175 /* SCSI CD-ROM commands: */
176 #define SCSICDROM_READ_SUBCHANNEL 0x42
177 #define SCSICDROM_READ_TOC 0x43
178 #define SCSICDROM_READ_DISCINFO 0x51
179 #define SCSICDROM_READ_TRACKINFO 0x52
180
181 /* SCSI tape commands: */
182 #define SCSICMD_REWIND 0x01
183 #define SCSICMD_READ_BLOCK_LIMITS 0x05
184 #define SCSICMD_SPACE 0x11
185
186
187 #endif /* DISKIMAGE_H */

  ViewVC Help
Powered by ViewVC 1.1.26