xref: /illumos-gate/usr/src/uts/intel/sys/bootvfs.h (revision 0181461b)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5ea8dc4b6Seschrock  * Common Development and Distribution License (the "License").
6ea8dc4b6Seschrock  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22ea8dc4b6Seschrock  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_BOOTVFS_H
277c478bd9Sstevel@tonic-gate #define	_SYS_BOOTVFS_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef __cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/bootstat.h>
347c478bd9Sstevel@tonic-gate #include <sys/dirent.h>
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate /* same as those in /usr/include/unistd.h */
377c478bd9Sstevel@tonic-gate #define	SEEK_SET	0	/* Offset */
387c478bd9Sstevel@tonic-gate #define	SEEK_CUR	1	/* Current + Offset */
397c478bd9Sstevel@tonic-gate #define	SEEK_END	2	/* EOF + Offset */
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /* mountroot/unmountroot return values */
427c478bd9Sstevel@tonic-gate #define	VFS_SUCCESS	0
437c478bd9Sstevel@tonic-gate #define	VFS_FAILURE	-1
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * unified (vfs-like) file system operations for booters
477c478bd9Sstevel@tonic-gate  */
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate struct boot_fs_ops {
507c478bd9Sstevel@tonic-gate     char	*fsw_name;
517c478bd9Sstevel@tonic-gate     int		(*fsw_mountroot)(char *str);
527c478bd9Sstevel@tonic-gate     int		(*fsw_unmountroot)(void);
537c478bd9Sstevel@tonic-gate     int		(*fsw_open)(char *filename, int flags);
547c478bd9Sstevel@tonic-gate     int		(*fsw_close)(int fd);
557c478bd9Sstevel@tonic-gate     ssize_t	(*fsw_read)(int fd, caddr_t buf, size_t size);
567c478bd9Sstevel@tonic-gate     off_t	(*fsw_lseek)(int filefd, off_t addr, int whence);
577c478bd9Sstevel@tonic-gate     int		(*fsw_fstat)(int filefd, struct bootstat *buf);
587c478bd9Sstevel@tonic-gate     void	(*fsw_closeall)(int flag);
597c478bd9Sstevel@tonic-gate     int		(*fsw_getdents)(int fd, struct dirent *buf, unsigned size);
607c478bd9Sstevel@tonic-gate };
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /*
637c478bd9Sstevel@tonic-gate  *  Function prototypes
647c478bd9Sstevel@tonic-gate  *
657c478bd9Sstevel@tonic-gate  *	fstat() (if exists) supports size and mode right now.
667c478bd9Sstevel@tonic-gate  */
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate extern struct boot_fs_ops *bfs_ops;
697c478bd9Sstevel@tonic-gate 
70*0181461bSKeith M Wesolowski #ifdef _KERNEL
71*0181461bSKeith M Wesolowski 
72*0181461bSKeith M Wesolowski extern int BRD_MOUNTROOT(struct boot_fs_ops *, char *);
73*0181461bSKeith M Wesolowski extern int BRD_UNMOUNTROOT(struct boot_fs_ops *);
74*0181461bSKeith M Wesolowski extern int BRD_OPEN(struct boot_fs_ops *, char *, int);
75*0181461bSKeith M Wesolowski extern int BRD_CLOSE(struct boot_fs_ops *, int);
76*0181461bSKeith M Wesolowski extern ssize_t BRD_READ(struct boot_fs_ops *, int, caddr_t, size_t);
77*0181461bSKeith M Wesolowski extern off_t BRD_SEEK(struct boot_fs_ops *, int, off_t, int);
78*0181461bSKeith M Wesolowski extern int BRD_FSTAT(struct boot_fs_ops *, int, struct bootstat *);
79*0181461bSKeith M Wesolowski 
80*0181461bSKeith M Wesolowski #else
81*0181461bSKeith M Wesolowski 
827c478bd9Sstevel@tonic-gate #define	BRD_MOUNTROOT(ops, str)		((ops)->fsw_mountroot)(str)
837c478bd9Sstevel@tonic-gate #define	BRD_UNMOUNTROOT(ops)		((ops)->fsw_unmountroot)()
847c478bd9Sstevel@tonic-gate #define	BRD_OPEN(ops, file, flag)	((ops)->fsw_open)(file, flag)
857c478bd9Sstevel@tonic-gate #define	BRD_CLOSE(ops, fd)		((ops)->fsw_close)(fd)
867c478bd9Sstevel@tonic-gate #define	BRD_READ(ops, fd, buf, s)	((ops)->fsw_read)(fd, buf, s)
877c478bd9Sstevel@tonic-gate #define	BRD_SEEK(ops, fd, addr, w)	((ops)->fsw_lseek)(fd, addr, w)
88ea8dc4b6Seschrock #define	BRD_FSTAT(ops, fd, stp)		((ops)->fsw_fstat)(fd, stp)
897c478bd9Sstevel@tonic-gate 
90*0181461bSKeith M Wesolowski #endif
91*0181461bSKeith M Wesolowski 
92*0181461bSKeith M Wesolowski #define	SYSTEM_BOOT_PATH	"/system/boot"
93*0181461bSKeith M Wesolowski #define	BFD_F_SYSTEM_BOOT	0x40000000
94*0181461bSKeith M Wesolowski 
957c478bd9Sstevel@tonic-gate #ifdef _BOOT
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate extern	int	mountroot(char *str);
987c478bd9Sstevel@tonic-gate extern	int	unmountroot(void);
997c478bd9Sstevel@tonic-gate extern	int	open(const char *filename, int flags);
1007c478bd9Sstevel@tonic-gate extern	int	close(int fd);
1017c478bd9Sstevel@tonic-gate extern	ssize_t	read(int fd, void *buf, size_t size);
1027c478bd9Sstevel@tonic-gate extern	off_t	lseek(int filefd, off_t addr, int whence);
1037c478bd9Sstevel@tonic-gate extern	void	closeall(int flag);
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate #endif /* _BOOT */
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1087c478bd9Sstevel@tonic-gate }
1097c478bd9Sstevel@tonic-gate #endif
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate #endif /* _SYS_BOOTVFS_H */
112