177cb4d3eSLandon J. Fuller /*- 277cb4d3eSLandon J. Fuller * Copyright (c) 2015-2016 Landon Fuller <landonf@FreeBSD.org> 377cb4d3eSLandon J. Fuller * All rights reserved. 477cb4d3eSLandon J. Fuller * 577cb4d3eSLandon J. Fuller * Redistribution and use in source and binary forms, with or without 677cb4d3eSLandon J. Fuller * modification, are permitted provided that the following conditions 777cb4d3eSLandon J. Fuller * are met: 877cb4d3eSLandon J. Fuller * 1. Redistributions of source code must retain the above copyright 977cb4d3eSLandon J. Fuller * notice, this list of conditions and the following disclaimer, 1077cb4d3eSLandon J. Fuller * without modification. 1177cb4d3eSLandon J. Fuller * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1277cb4d3eSLandon J. Fuller * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 1377cb4d3eSLandon J. Fuller * redistribution must be conditioned upon including a substantially 1477cb4d3eSLandon J. Fuller * similar Disclaimer requirement for further binary redistribution. 1577cb4d3eSLandon J. Fuller * 1677cb4d3eSLandon J. Fuller * NO WARRANTY 1777cb4d3eSLandon J. Fuller * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1877cb4d3eSLandon J. Fuller * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1977cb4d3eSLandon J. Fuller * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 2077cb4d3eSLandon J. Fuller * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 2177cb4d3eSLandon J. Fuller * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 2277cb4d3eSLandon J. Fuller * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2377cb4d3eSLandon J. Fuller * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2477cb4d3eSLandon J. Fuller * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 2577cb4d3eSLandon J. Fuller * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2677cb4d3eSLandon J. Fuller * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 2777cb4d3eSLandon J. Fuller * THE POSSIBILITY OF SUCH DAMAGES. 2877cb4d3eSLandon J. Fuller */ 2977cb4d3eSLandon J. Fuller 3077cb4d3eSLandon J. Fuller #ifndef _BHND_NVRAM_BHND_NVRAM_BCMVAR_H_ 3177cb4d3eSLandon J. Fuller #define _BHND_NVRAM_BHND_NVRAM_BCMVAR_H_ 3277cb4d3eSLandon J. Fuller 33a7c43ebdSLandon J. Fuller #define BCM_NVRAM_ENCODE_OPT_VERSION "bcm_version" 34a7c43ebdSLandon J. Fuller 3577cb4d3eSLandon J. Fuller /** 3677cb4d3eSLandon J. Fuller * BCM NVRAM header value data. 3777cb4d3eSLandon J. Fuller */ 3877cb4d3eSLandon J. Fuller union bhnd_nvram_bcm_hvar_value { 3977cb4d3eSLandon J. Fuller uint16_t u16; 4077cb4d3eSLandon J. Fuller uint32_t u32; 4177cb4d3eSLandon J. Fuller }; 4277cb4d3eSLandon J. Fuller 4377cb4d3eSLandon J. Fuller /** 4477cb4d3eSLandon J. Fuller * Internal representation of BCM NVRAM values that mirror (and must be 4577cb4d3eSLandon J. Fuller * vended as) NVRAM variables. 4677cb4d3eSLandon J. Fuller */ 4777cb4d3eSLandon J. Fuller struct bhnd_nvram_bcm_hvar { 4877cb4d3eSLandon J. Fuller const char *name; /**< variable name */ 4977cb4d3eSLandon J. Fuller bhnd_nvram_type type; /**< value type */ 5077cb4d3eSLandon J. Fuller size_t nelem; /**< value element count */ 5177cb4d3eSLandon J. Fuller size_t len; /**< value length */ 5277cb4d3eSLandon J. Fuller const char *envp; /**< Pointer to the NVRAM variable mirroring 5377cb4d3eSLandon J. Fuller this header value, or NULL. */ 5477cb4d3eSLandon J. Fuller bool stale; /**< header value does not match 5577cb4d3eSLandon J. Fuller mirrored NVRAM value */ 5677cb4d3eSLandon J. Fuller 5777cb4d3eSLandon J. Fuller /** variable data */ 5877cb4d3eSLandon J. Fuller union bhnd_nvram_bcm_hvar_value value; 5977cb4d3eSLandon J. Fuller }; 6077cb4d3eSLandon J. Fuller 6177cb4d3eSLandon J. Fuller /** BCM NVRAM header */ 6277cb4d3eSLandon J. Fuller struct bhnd_nvram_bcmhdr { 6377cb4d3eSLandon J. Fuller uint32_t magic; 6477cb4d3eSLandon J. Fuller uint32_t size; 6577cb4d3eSLandon J. Fuller uint32_t cfg0; /**< crc:8, version:8, sdram_init:16 */ 6677cb4d3eSLandon J. Fuller uint32_t cfg1; /**< sdram_config:16, sdram_refresh:16 */ 6777cb4d3eSLandon J. Fuller uint32_t sdram_ncdl; /**< sdram_ncdl */ 6877cb4d3eSLandon J. Fuller } __packed; 6977cb4d3eSLandon J. Fuller 70*591e79bcSLandon J. Fuller int bhnd_nvram_bcm_getvar_direct_common(struct bhnd_nvram_io *io, 71*591e79bcSLandon J. Fuller const char *name, void *outp, size_t *olen, bhnd_nvram_type otype, 72*591e79bcSLandon J. Fuller bool have_header); 73*591e79bcSLandon J. Fuller 7477cb4d3eSLandon J. Fuller #endif /* _BHND_NVRAM_BHND_NVRAM_BCMVAR_H_ */ 75