]> git.saurik.com Git - apple/boot.git/blob - i386/libsaio/saio.h
boot-83.2.tar.gz
[apple/boot.git] / i386 / libsaio / saio.h
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
12 * this file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
20 * under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24 /*
25 * Mach Operating System
26 * Copyright (c) 1990 Carnegie-Mellon University
27 * Copyright (c) 1989 Carnegie-Mellon University
28 * Copyright (c) 1988 Carnegie-Mellon University
29 * All rights reserved. The CMU software License Agreement specifies
30 * the terms and conditions for use and redistribution.
31 *
32 */
33 /*
34 * Copyright (c) 1982, 1986 Regents of the University of California.
35 * All rights reserved. The Berkeley software License Agreement
36 * specifies the terms and conditions for redistribution.
37 *
38 * @(#)saio.h 7.1 (Berkeley) 6/5/86
39 */
40
41 #ifndef __LIBSAIO_SAIO_H
42 #define __LIBSAIO_SAIO_H
43
44 #include <sys/types.h>
45 #include <sys/param.h>
46 #include <sys/vnode.h>
47 #include <ufs/ufs/quota.h>
48 #include <ufs/ufs/inode.h>
49
50 /*
51 * Io block: includes an inode, cells for the use of seek, etc,
52 * and a buffer.
53 */
54 struct iob {
55 int i_flgs; /* see F_ below */
56 struct inode i_ino; /* inode, if file */
57 daddr_t i_boff; /* block offset on device */
58 unsigned int i_offset; /* seek offset in file */
59 daddr_t i_bn; /* 1st block # of next read */
60 char * i_ma; /* memory address of i/o buffer */
61 int i_cc; /* character count of transfer */
62 int i_error; /* error # return */
63 char * i_buf; /* i/o buffer */
64 struct fs * i_ffs; /* file system super block info */
65 int biosdev; /* bios device for file, i_ino inadequate */
66 daddr_t dirbuf_blkno; /* blk of currently buffered dir */
67 int partition; /* which partition */
68 };
69
70 struct dirstuff {
71 int loc;
72 struct iob * io;
73 };
74
75 #define F_READ 0x1 /* file opened for reading */
76 #define F_WRITE 0x2 /* file opened for writing */
77 #define F_ALLOC 0x4 /* buffer allocated */
78 #define F_FILE 0x8 /* file instead of device */
79 #define F_NBSF 0x10 /* no bad sector forwarding */
80 #define F_SSI 0x40 /* set skip sector inhibit */
81 #define F_MEM 0x80 /* memory instead of file or device */
82
83 /* IO types */
84 #define F_RDDATA 0x0100 /* read data */
85 #define F_WRDATA 0x0200 /* write data */
86 #define F_HDR 0x0400 /* include header on next i/o */
87
88 #define F_TYPEMASK 0xff00
89
90 extern char * devsw[];
91
92 /*
93 * Request codes. Must be the same a F_XXX above
94 */
95 #define READ 1
96 #define WRITE 2
97
98 #define NBUFS 4
99 extern char * b[NBUFS];
100 extern daddr_t blknos[NBUFS];
101
102 #define NFILES 6
103 extern struct iob iob[NFILES];
104
105 /* Error codes */
106 #define EBADF 1 /* bad file descriptor */
107 #define EOFFSET 2 /* relative seek not supported */
108 #define EDEV 3 /* improper device specification on open */
109 #define ENXIO 4 /* unknown device specified */
110 #define ESRCH 6 /* directory search for file failed */
111 #define EIO 7 /* generic error */
112 #define ECMD 10 /* undefined driver command */
113 #define EBSE 11 /* bad sector error */
114 #define EWCK 12 /* write check error */
115 #define EECC 13 /* uncorrectable ecc error */
116 #define EHER 14 /* hard error */
117
118 #define BIOS_DEV_FLOPPY 0x0
119 #define BIOS_DEV_HD 0x80
120 #define BIOS_DEV_WIN BIOS_DEV_HD
121 #define BIOS_DEV_EN 0xff /* not really a BIOS device number */
122
123 #define DEV_SD 0
124 #define DEV_HD 1
125 #define DEV_FLOPPY 2
126 #define DEV_EN 3
127
128 #define BIOSDEV(dev) ((dev) == DEV_FLOPPY ? BIOS_DEV_FLOPPY : BIOS_DEV_WIN)
129
130 #define NSECS 16 /* number of buffered 512 byte sectors */
131
132 #define Dev(x) (((x)>>B_TYPESHIFT)&B_TYPEMASK)
133
134 #ifndef max
135 #define max(a,b) ((a) > (b) ? (a) : (b))
136 #endif
137
138 #ifndef min
139 #define min(a,b) ((a) < (b) ? (a) : (b))
140 #endif
141
142 #endif /* !__LIBSAIO_SAIO_H */