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