xref: /illumos-gate/usr/src/uts/intel/sys/bootvfs.h (revision ea8dc4b6)
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
5*ea8dc4b6Seschrock  * Common Development and Distribution License (the "License").
6*ea8dc4b6Seschrock  * 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 /*
22*ea8dc4b6Seschrock  * 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef __cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <sys/bootstat.h>
367c478bd9Sstevel@tonic-gate #include <sys/dirent.h>
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate /* same as those in /usr/include/unistd.h */
397c478bd9Sstevel@tonic-gate #define	SEEK_SET	0	/* Offset */
407c478bd9Sstevel@tonic-gate #define	SEEK_CUR	1	/* Current + Offset */
417c478bd9Sstevel@tonic-gate #define	SEEK_END	2	/* EOF + Offset */
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /* mountroot/unmountroot return values */
447c478bd9Sstevel@tonic-gate #define	VFS_SUCCESS	0
457c478bd9Sstevel@tonic-gate #define	VFS_FAILURE	-1
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate /*
487c478bd9Sstevel@tonic-gate  * unified (vfs-like) file system operations for booters
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate struct boot_fs_ops {
527c478bd9Sstevel@tonic-gate     char	*fsw_name;
537c478bd9Sstevel@tonic-gate     int		(*fsw_mountroot)(char *str);
547c478bd9Sstevel@tonic-gate     int		(*fsw_unmountroot)(void);
557c478bd9Sstevel@tonic-gate     int		(*fsw_open)(char *filename, int flags);
567c478bd9Sstevel@tonic-gate     int		(*fsw_close)(int fd);
577c478bd9Sstevel@tonic-gate     ssize_t	(*fsw_read)(int fd, caddr_t buf, size_t size);
587c478bd9Sstevel@tonic-gate     off_t	(*fsw_lseek)(int filefd, off_t addr, int whence);
597c478bd9Sstevel@tonic-gate     int		(*fsw_fstat)(int filefd, struct bootstat *buf);
607c478bd9Sstevel@tonic-gate     void	(*fsw_closeall)(int flag);
617c478bd9Sstevel@tonic-gate     int		(*fsw_getdents)(int fd, struct dirent *buf, unsigned size);
627c478bd9Sstevel@tonic-gate };
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  *  Function prototypes
667c478bd9Sstevel@tonic-gate  *
677c478bd9Sstevel@tonic-gate  *	fstat() (if exists) supports size and mode right now.
687c478bd9Sstevel@tonic-gate  */
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate extern struct boot_fs_ops *bfs_ops;
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate #define	BRD_MOUNTROOT(ops, str)		((ops)->fsw_mountroot)(str)
737c478bd9Sstevel@tonic-gate #define	BRD_UNMOUNTROOT(ops)		((ops)->fsw_unmountroot)()
747c478bd9Sstevel@tonic-gate #define	BRD_OPEN(ops, file, flag)	((ops)->fsw_open)(file, flag)
757c478bd9Sstevel@tonic-gate #define	BRD_CLOSE(ops, fd)		((ops)->fsw_close)(fd)
767c478bd9Sstevel@tonic-gate #define	BRD_READ(ops, fd, buf, s)	((ops)->fsw_read)(fd, buf, s)
777c478bd9Sstevel@tonic-gate #define	BRD_SEEK(ops, fd, addr, w)	((ops)->fsw_lseek)(fd, addr, w)
78*ea8dc4b6Seschrock #define	BRD_FSTAT(ops, fd, stp)		((ops)->fsw_fstat)(fd, stp)
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate #ifdef _BOOT
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate extern	int	mountroot(char *str);
837c478bd9Sstevel@tonic-gate extern	int	unmountroot(void);
847c478bd9Sstevel@tonic-gate extern	int	open(const char *filename, int flags);
857c478bd9Sstevel@tonic-gate extern	int	close(int fd);
867c478bd9Sstevel@tonic-gate extern	ssize_t	read(int fd, void *buf, size_t size);
877c478bd9Sstevel@tonic-gate extern	off_t	lseek(int filefd, off_t addr, int whence);
887c478bd9Sstevel@tonic-gate extern	void	closeall(int flag);
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate #endif /* _BOOT */
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate #ifdef __cplusplus
937c478bd9Sstevel@tonic-gate }
947c478bd9Sstevel@tonic-gate #endif
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate #endif /* _SYS_BOOTVFS_H */
97