Fix markup. Fix backslashes to surive roff.
[netbsd-mini2440.git] / dist / pdisk / media.h
blobfcc237fe95b599c6d979297f85b661c496b1f524
1 /*
2 * media.h -
4 * Written by Eryk Vershen
5 */
7 /*
8 * Copyright 1997,1998 by Apple Computer, Inc.
9 * All Rights Reserved
11 * Permission to use, copy, modify, and distribute this software and
12 * its documentation for any purpose and without fee is hereby granted,
13 * provided that the above copyright notice appears in all copies and
14 * that both the copyright notice and this permission notice appear in
15 * supporting documentation.
17 * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
18 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE.
21 * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
22 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
23 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
24 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
25 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28 #ifndef __media__
29 #define __media__
33 * Media is an abstraction of a disk device.
35 * A media object has the following visible attributes:
37 * a granularity (e.g. 512, 1024, 1, etc.)
38 * a total size in bytes
40 * And the following operations are available:
42 * open
43 * read @ byte offset for size in bytes
44 * write @ byte offset for size in bytes
45 * close
47 * XXX Should really split public media interface from "protected" interface.
52 * Defines
57 * Types
59 /* those whose use media objects need just the pointer type */
60 typedef struct media *MEDIA;
62 /* those who define media objects need the struct and internal routine types */
63 typedef long (*media_read)(MEDIA m, long long offset, unsigned long count, void *address);
64 typedef long (*media_write)(MEDIA m, long long offset, unsigned long count, void *address);
65 typedef long (*media_close)(MEDIA m);
66 typedef long (*media_os_reload)(MEDIA m);
68 struct media {
69 long kind; /* kind of media - SCSI, IDE, etc. */
70 unsigned long grain; /* granularity (offset & size) */
71 long long size_in_bytes; /* offset granularity */
72 media_read do_read; /* device specific routines */
73 media_write do_write;
74 media_close do_close;
75 media_os_reload do_os_reload;
76 /* specific media kinds will add extra info */
79 /* those whose use media object iterators need just the pointer type */
80 typedef struct media_iterator *MEDIA_ITERATOR;
82 /* those who define media object iterators need the struct and internal routine types */
83 typedef void (*media_iterator_reset)(MEDIA_ITERATOR m);
84 typedef char* (*media_iterator_step)(MEDIA_ITERATOR m);
85 typedef void (*media_iterator_delete)(MEDIA_ITERATOR m);
87 typedef enum {
88 kInit,
89 kReset,
90 kIterating,
91 kEnd
92 } media_iterator_state;
94 struct media_iterator {
95 long kind; /* kind of media - SCSI, IDE, etc. */
96 media_iterator_state state; /* init, reset, iterating, at_end */
97 media_iterator_reset do_reset; /* device specific routines */
98 media_iterator_step do_step;
99 media_iterator_delete do_delete;
100 /* specific media kinds will add extra info */
105 * Global Constants
110 * Global Variables
115 * Forward declarations
117 /* those whose use media objects need these routines */
118 unsigned long media_granularity(MEDIA m);
119 long long media_total_size(MEDIA m);
120 long read_media(MEDIA m, long long offset, unsigned long count, void *address);
121 long write_media(MEDIA m, long long offset, unsigned long count, void *address);
122 void close_media(MEDIA m);
123 void os_reload_media(MEDIA m);
125 /* those who define media objects need these routines also */
126 long allocate_media_kind(void);
127 MEDIA new_media(long size);
128 void delete_media(MEDIA m);
130 /* those whose use media object iterators need these routines */
131 void reset_media_iterator(MEDIA_ITERATOR m);
132 char *step_media_iterator(MEDIA_ITERATOR m);
133 void delete_media_iterator(MEDIA_ITERATOR m);
135 /* those who define media object iterators need these routines also */
136 MEDIA_ITERATOR new_media_iterator(long size);
137 void private_delete_media_iterator(MEDIA_ITERATOR m);
139 #endif /* __media__ */