Make UEFI boot-platform build again
[haiku.git] / headers / private / kernel / arch / sparc / stand.h
blobe84234c41cae603c925c34f4f77143e6ebd7d430
1 /* $OpenBSD: stand.h,v 1.35 1998/07/29 00:38:36 mickey Exp $ */
2 /* $NetBSD: stand.h,v 1.18 1996/11/30 04:35:51 gwr Exp $ */
4 /*-
5 * Copyright (c) 1993
6 * The Regents of the University of California. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
36 * @(#)stand.h 8.1 (Berkeley) 6/11/93
39 #include <sys/types.h>
40 #include <sys/stat.h>
41 #ifdef __STDC__
42 #include <machine/stdarg.h>
43 #else
44 #include <machine/varargs.h>
45 #endif
46 #include "saioctl.h"
47 #include "saerrno.h"
49 #ifndef NULL
50 #define NULL 0
51 #endif
53 struct open_file;
56 * Useful macros
58 #define NENTS(x) sizeof(x)/sizeof(x[0])
59 /* don't define if libkern included */
60 #ifndef LIBKERN_INLINE
61 #define max(a,b) (((a)>(b))? (a) : (b))
62 #define min(a,b) (((a)>(b))? (b) : (a))
63 #endif
66 * This structure is used to define file system operations in a file system
67 * independent way.
69 struct fs_ops {
70 int (*open) __P((char *path, struct open_file *f));
71 int (*close) __P((struct open_file *f));
72 int (*read) __P((struct open_file *f, void *buf,
73 size_t size, size_t *resid));
74 int (*write) __P((struct open_file *f, void *buf,
75 size_t size, size_t *resid));
76 off_t (*seek) __P((struct open_file *f, off_t offset, int where));
77 int (*stat) __P((struct open_file *f, struct stat *sb));
78 int (*readdir) __P((struct open_file *f, char *));
81 extern struct fs_ops file_system[];
82 extern int nfsys;
84 /* where values for lseek(2) */
85 #define SEEK_SET 0 /* set file offset to offset */
86 #define SEEK_CUR 1 /* set file offset to current plus offset */
87 #define SEEK_END 2 /* set file offset to EOF plus offset */
89 /* Device switch */
90 struct devsw {
91 char *dv_name;
92 int (*dv_strategy) __P((void *devdata, int rw,
93 daddr_t blk, size_t size,
94 void *buf, size_t *rsize));
95 int (*dv_open) __P((struct open_file *f, ...));
96 int (*dv_close) __P((struct open_file *f));
97 int (*dv_ioctl) __P((struct open_file *f, u_long cmd, void *data));
100 extern struct devsw devsw[]; /* device array */
101 extern int ndevs; /* number of elements in devsw[] */
103 extern struct consdev constab[];
104 extern struct consdev *cn_tab;
106 struct open_file {
107 int f_flags; /* see F_* below */
108 struct devsw *f_dev; /* pointer to device operations */
109 void *f_devdata; /* device specific data */
110 struct fs_ops *f_ops; /* pointer to file system operations */
111 void *f_fsdata; /* file system specific data */
112 off_t f_offset; /* current file offset (F_RAW) */
115 #define SOPEN_MAX 4
116 extern struct open_file files[];
118 /* f_flags values */
119 #define F_READ 0x0001 /* file opened for reading */
120 #define F_WRITE 0x0002 /* file opened for writing */
121 #define F_RAW 0x0004 /* raw device open - no file system */
122 #define F_NODEV 0x0008 /* network open - no device */
124 #define isupper(c) ((c) >= 'A' && (c) <= 'Z')
125 #define islower(c) ((c) >= 'a' && (c) <= 'z')
126 #define isalpha(c) (isupper(c)||islower(c))
127 #define tolower(c) (isupper(c)?((c) - 'A' + 'a'):(c))
128 #define toupper(c) (islower(c)?((c) - 'a' + 'A'):(c))
129 #define isspace(c) ((c) == ' ' || (c) == '\t')
130 #define isdigit(c) ((c) >= '0' && (c) <= '9')
132 #define btochs(b,c,h,s,nh,ns) \
133 c = (b) / ((nh) * (ns)); \
134 h = ((b) % ((nh) * (ns))) / (ns); \
135 s = ((b) % ((nh) * (ns))) % (ns);
137 void *alloc __P((u_int));
138 void *alloca __P((size_t));
139 void free __P((void *, u_int));
140 struct disklabel;
141 char *getdisklabel __P((const char *, struct disklabel *));
142 u_int dkcksum __P((struct disklabel *));
144 void printf __P((const char *, ...));
145 void sprintf __P((char *, const char *, ...));
146 void vprintf __P((const char *, _BSD_VA_LIST_));
147 void twiddle __P((void));
148 void gets __P((char *));
149 __dead void panic __P((const char *, ...)) __attribute__((noreturn));
150 __dead void _rtt __P((void)) __attribute__((noreturn));
151 #define bzero(s,n) ((void)memset((s),0,(n)))
152 #define bcmp(s1,s2,n) (memcmp((s2),(s1),(n)))
153 #define bcopy(s1,s2,n) ((void)memcpy((s2),(s1),(n)))
154 void *memcpy __P((void *, const void *, size_t));
155 int memcmp __P((const void *, const void*, size_t));
156 char *strncpy __P((char *, const char *, size_t));
157 char *strcpy __P((char *, const char *));
158 int strncmp __P((const char *, const char *, size_t));
159 size_t strlen __P((const char *));
160 long strtol __P((const char *, char **, int));
161 char *strchr __P((const char *, int));
162 void *memset __P((void *, int, size_t));
163 void exec __P((char *, void *, int));
164 void exit __P((void));
165 int open __P((const char *, int));
166 int close __P((int));
167 void closeall __P((void));
168 ssize_t read __P((int, void *, size_t));
169 ssize_t write __P((int, void *, size_t));
170 int stat __P((const char *path, struct stat *sb));
171 int fstat __P((int fd, struct stat *sb));
172 int opendir __P((char *));
173 int readdir __P((int, char *));
174 void closedir __P((int));
175 int nodev __P((void));
176 int noioctl __P((struct open_file *, u_long, void *));
177 void nullsys __P((void));
179 int null_open __P((char *path, struct open_file *f));
180 int null_close __P((struct open_file *f));
181 ssize_t null_read __P((struct open_file *f, void *buf,
182 size_t size, size_t *resid));
183 ssize_t null_write __P((struct open_file *f, void *buf,
184 size_t size, size_t *resid));
185 off_t null_seek __P((struct open_file *f, off_t offset, int where));
186 int null_stat __P((struct open_file *f, struct stat *sb));
187 int null_readdir __P((struct open_file *f, char *name));
188 char *ttyname __P((int)); /* match userland decl, but ignore !0 */
189 dev_t ttydev __P((char *));
190 void cninit __P((void));
191 int cnset __P((dev_t));
192 void cnputc __P((int));
193 int cngetc __P((void));
194 int cnischar __P((void));
195 int cnspeed __P((dev_t, int));
196 u_int sleep __P((u_int));
197 void usleep __P((u_int));
198 char *ctime __P((const time_t *));
200 void putchar __P((int));
201 int getchar __P((void));
203 #ifdef __INTERNAL_LIBSA_CREAD
204 int oopen __P((const char *, int));
205 int oclose __P((int));
206 ssize_t oread __P((int, void *, size_t));
207 off_t olseek __P((int, off_t, int));
208 #endif
210 /* Machine dependent functions */
211 int devopen __P((struct open_file *, const char *, char **));
212 void machdep_start __P((char *, int, char *, char *, char *));
213 time_t getsecs __P((void));