xref: /titanic_41/usr/src/uts/intel/sys/bootvfs.h (revision 66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_BOOTVFS_H
28 #define	_SYS_BOOTVFS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/bootstat.h>
37 #include <sys/dirent.h>
38 
39 /* same as those in /usr/include/unistd.h */
40 #define	SEEK_SET	0	/* Offset */
41 #define	SEEK_CUR	1	/* Current + Offset */
42 #define	SEEK_END	2	/* EOF + Offset */
43 
44 /* mountroot/unmountroot return values */
45 #define	VFS_SUCCESS	0
46 #define	VFS_FAILURE	-1
47 
48 /*
49  * unified (vfs-like) file system operations for booters
50  */
51 
52 struct boot_fs_ops {
53     char	*fsw_name;
54     int		(*fsw_mountroot)(char *str);
55     int		(*fsw_unmountroot)(void);
56     int		(*fsw_open)(char *filename, int flags);
57     int		(*fsw_close)(int fd);
58     ssize_t	(*fsw_read)(int fd, caddr_t buf, size_t size);
59     off_t	(*fsw_lseek)(int filefd, off_t addr, int whence);
60     int		(*fsw_fstat)(int filefd, struct bootstat *buf);
61     void	(*fsw_closeall)(int flag);
62     int		(*fsw_getdents)(int fd, struct dirent *buf, unsigned size);
63 };
64 
65 /*
66  *  Function prototypes
67  *
68  *	fstat() (if exists) supports size and mode right now.
69  */
70 
71 extern struct boot_fs_ops *bfs_ops;
72 
73 #define	BRD_MOUNTROOT(ops, str)		((ops)->fsw_mountroot)(str)
74 #define	BRD_UNMOUNTROOT(ops)		((ops)->fsw_unmountroot)()
75 #define	BRD_OPEN(ops, file, flag)	((ops)->fsw_open)(file, flag)
76 #define	BRD_CLOSE(ops, fd)		((ops)->fsw_close)(fd)
77 #define	BRD_READ(ops, fd, buf, s)	((ops)->fsw_read)(fd, buf, s)
78 #define	BRD_SEEK(ops, fd, addr, w)	((ops)->fsw_lseek)(fd, addr, w)
79 
80 #ifdef _BOOT
81 
82 extern	int	mountroot(char *str);
83 extern	int	unmountroot(void);
84 extern	int	open(const char *filename, int flags);
85 extern	int	close(int fd);
86 extern	ssize_t	read(int fd, void *buf, size_t size);
87 extern	off_t	lseek(int filefd, off_t addr, int whence);
88 extern	void	closeall(int flag);
89 
90 #endif /* _BOOT */
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif /* _SYS_BOOTVFS_H */
97