e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw/*
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * CDDL HEADER START
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw *
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * The contents of this file are subject to the terms of the
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * Common Development and Distribution License (the "License").
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * You may not use this file except in compliance with the License.
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw *
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * or http://www.opensolaris.org/os/licensing.
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * See the License for the specific language governing permissions
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * and limitations under the License.
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw *
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * When distributing Covered Code, include this CDDL HEADER in each
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * If applicable, add the following below this CDDL HEADER, with the
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * fields enclosed by brackets "[]" replaced with your own identifying
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * information: Portions Copyright [yyyy] [name of copyright owner]
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw *
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * CDDL HEADER END
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw */
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw/*
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * Use is subject to license terms.
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw */
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw#pragma ident "%Z%%M% %I% %E% SMI"
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw#include <sys/param.h>
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw#include <sys/sysmacros.h>
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw#include <sys/stat.h>
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw#include <sys/bootvfs.h>
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw#include <sys/bootsyms.h>
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw#include <sys/promif.h>
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw#include <sys/salib.h>
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw/*
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * Function prototypes
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw */
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic int promfs_mountroot(char *str);
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic int promfs_unmountroot(void);
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic int promfs_open(char *filename, int flags);
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic int promfs_close(int fd);
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic ssize_t promfs_read(int fd, caddr_t buf, size_t size);
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic off_t promfs_lseek(int fd, off_t offset, int whence);
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic int promfs_fstat(int fd, struct bootstat *stp);
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic void promfs_closeall(int flag);
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstruct boot_fs_ops promfs_ops = {
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw "promfs",
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw promfs_mountroot,
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw promfs_unmountroot,
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw promfs_open,
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw promfs_close,
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw promfs_read,
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw promfs_lseek,
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw promfs_fstat,
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw promfs_closeall,
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw NULL
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw};
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic ihandle_t fsih;
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic int
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwpromfs_mountroot(char *str)
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw{
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw (void) prom_getprop(prom_chosennode(), str, (caddr_t)&fsih);
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw return (fsih == -1);
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw}
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic int
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwpromfs_unmountroot(void)
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw{
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw (void) prom_close(fsih);
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw return (0);
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw}
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw/*ARGSUSED*/
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic int
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwpromfs_open(char *filename, int flags)
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw{
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw return (prom_fopen(fsih, filename));
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw}
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic int
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwpromfs_close(int fd)
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw{
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw prom_fclose(fsih, fd);
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw return (0);
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw}
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic ssize_t
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwpromfs_read(int fd, caddr_t buf, size_t size)
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw{
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw return (prom_fread(fsih, fd, buf, size));
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw}
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw/*ARGSUSED*/
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic off_t
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwpromfs_lseek(int fd, off_t offset, int whence)
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw{
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw return (prom_fseek(fsih, fd, offset));
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw}
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic int
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwpromfs_fstat(int fd, struct bootstat *stp)
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw{
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw return (prom_fsize(fsih, fd, (size_t *)&stp->st_size));
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw}
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw/*ARGSUSED*/
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwstatic void
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gwpromfs_closeall(int flag)
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw{
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw}