booted_dev.c revision 1.1
11.1Smrg/* $NetBSD: booted_dev.c,v 1.1 2017/07/24 08:56:29 mrg Exp $ */ 21.1Smrg 31.1Smrg/* 41.1Smrg * Copyright 2000, 2001 51.1Smrg * Broadcom Corporation. All rights reserved. 61.1Smrg * 71.1Smrg * This software is furnished under license and may be used and copied only 81.1Smrg * in accordance with the following terms and conditions. Subject to these 91.1Smrg * conditions, you may download, copy, install, use, modify and distribute 101.1Smrg * modified or unmodified copies of this software in source and/or binary 111.1Smrg * form. No title or ownership is transferred hereby. 121.1Smrg * 131.1Smrg * 1) Any source code used, modified or distributed must reproduce and 141.1Smrg * retain this copyright notice and list of conditions as they appear in 151.1Smrg * the source file. 161.1Smrg * 171.1Smrg * 2) No right is granted to use any trade name, trademark, or logo of 181.1Smrg * Broadcom Corporation. The "Broadcom Corporation" name may not be 191.1Smrg * used to endorse or promote products derived from this software 201.1Smrg * without the prior written permission of Broadcom Corporation. 211.1Smrg * 221.1Smrg * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED 231.1Smrg * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF 241.1Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 251.1Smrg * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE 261.1Smrg * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE 271.1Smrg * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 281.1Smrg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 291.1Smrg * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 301.1Smrg * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 311.1Smrg * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 321.1Smrg * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 331.1Smrg */ 341.1Smrg 351.1Smrg#include <lib/libsa/stand.h> 361.1Smrg#include <lib/libkern/libkern.h> 371.1Smrg 381.1Smrg#include "stand/common/common.h" 391.1Smrg#include "stand/common/cfe_api.h" 401.1Smrg 411.1Smrgint booted_dev_fd; 421.1Smrg#if defined(PRIMARY_BOOTBLOCK) || defined(UNIFIED_BOOTBLOCK) 431.1Smrgchar booted_dev_name[BOOTED_DEV_MAXNAMELEN]; 441.1Smrg#endif /* defined(PRIMARY_BOOTBLOCK) || defined(UNIFIED_BOOTBLOCK) */ 451.1Smrg 461.1Smrg#if defined(PRIMARY_BOOTBLOCK) || defined(UNIFIED_BOOTBLOCK) 471.1Smrgint booted_dev_open(void) 481.1Smrg{ 491.1Smrg if (cfe_getenv("BOOT_DEVICE",booted_dev_name,sizeof(booted_dev_name)) != 0) { 501.1Smrg return 0; 511.1Smrg } 521.1Smrg 531.1Smrg booted_dev_fd = cfe_open(booted_dev_name); 541.1Smrg 551.1Smrg return 1; 561.1Smrg} 571.1Smrg#endif 581.1Smrg 591.1Smrgvoid booted_dev_close(void) 601.1Smrg{ 611.1Smrg cfe_close(booted_dev_fd); 621.1Smrg} 63