xref: /titanic_51/usr/src/uts/intel/sys/bootvfs.h (revision d040c7642a81e4878a822db25cce20beb93585b4)
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 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/bootstat.h>
34 #include <sys/dirent.h>
35 
36 /* same as those in /usr/include/unistd.h */
37 #define	SEEK_SET	0	/* Offset */
38 #define	SEEK_CUR	1	/* Current + Offset */
39 #define	SEEK_END	2	/* EOF + Offset */
40 
41 /* mountroot/unmountroot return values */
42 #define	VFS_SUCCESS	0
43 #define	VFS_FAILURE	-1
44 
45 /*
46  * unified (vfs-like) file system operations for booters
47  */
48 
49 struct boot_fs_ops {
50     char	*fsw_name;
51     int		(*fsw_mountroot)(char *str);
52     int		(*fsw_unmountroot)(void);
53     int		(*fsw_open)(char *filename, int flags);
54     int		(*fsw_close)(int fd);
55     ssize_t	(*fsw_read)(int fd, caddr_t buf, size_t size);
56     off_t	(*fsw_lseek)(int filefd, off_t addr, int whence);
57     int		(*fsw_fstat)(int filefd, struct bootstat *buf);
58     void	(*fsw_closeall)(int flag);
59     int		(*fsw_getdents)(int fd, struct dirent *buf, unsigned size);
60 };
61 
62 /*
63  *  Function prototypes
64  *
65  *	fstat() (if exists) supports size and mode right now.
66  */
67 
68 extern struct boot_fs_ops *bfs_ops;
69 
70 #ifdef _KERNEL
71 
72 extern int BRD_MOUNTROOT(struct boot_fs_ops *, char *);
73 extern int BRD_UNMOUNTROOT(struct boot_fs_ops *);
74 extern int BRD_OPEN(struct boot_fs_ops *, char *, int);
75 extern int BRD_CLOSE(struct boot_fs_ops *, int);
76 extern ssize_t BRD_READ(struct boot_fs_ops *, int, caddr_t, size_t);
77 extern off_t BRD_SEEK(struct boot_fs_ops *, int, off_t, int);
78 extern int BRD_FSTAT(struct boot_fs_ops *, int, struct bootstat *);
79 
80 #else
81 
82 #define	BRD_MOUNTROOT(ops, str)		((ops)->fsw_mountroot)(str)
83 #define	BRD_UNMOUNTROOT(ops)		((ops)->fsw_unmountroot)()
84 #define	BRD_OPEN(ops, file, flag)	((ops)->fsw_open)(file, flag)
85 #define	BRD_CLOSE(ops, fd)		((ops)->fsw_close)(fd)
86 #define	BRD_READ(ops, fd, buf, s)	((ops)->fsw_read)(fd, buf, s)
87 #define	BRD_SEEK(ops, fd, addr, w)	((ops)->fsw_lseek)(fd, addr, w)
88 #define	BRD_FSTAT(ops, fd, stp)		((ops)->fsw_fstat)(fd, stp)
89 
90 #endif
91 
92 #define	SYSTEM_BOOT_PATH	"/system/boot"
93 #define	BFD_F_SYSTEM_BOOT	0x40000000
94 
95 #ifdef _BOOT
96 
97 extern	int	mountroot(char *str);
98 extern	int	unmountroot(void);
99 extern	int	open(const char *filename, int flags);
100 extern	int	close(int fd);
101 extern	ssize_t	read(int fd, void *buf, size_t size);
102 extern	off_t	lseek(int filefd, off_t addr, int whence);
103 extern	void	closeall(int flag);
104 
105 #endif /* _BOOT */
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif /* _SYS_BOOTVFS_H */
112