Path: blob/main/sys/dev/bhnd/nvram/bhnd_nvram_store.h
39536 views
/*-1* Copyright (c) 2015-2016 Landon Fuller <[email protected]>2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer,9* without modification.10* 2. Redistributions in binary form must reproduce at minimum a disclaimer11* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any12* redistribution must be conditioned upon including a substantially13* similar Disclaimer requirement for further binary redistribution.14*15* NO WARRANTY16* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS17* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY19* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL20* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,21* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF22* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS23* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER24* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)25* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF26* THE POSSIBILITY OF SUCH DAMAGES.27*28*/2930#ifndef _BHND_NVRAM_BHND_NVRAM_STORE_H_31#define _BHND_NVRAM_BHND_NVRAM_STORE_H_3233#ifdef _KERNEL34#include <sys/param.h>35#include <sys/bus.h>36#else /* !_KERNEL */37#include <errno.h>38#include <stdint.h>39#include <stdlib.h>40#endif4142#include <sys/queue.h>4344#include "bhnd_nvram_data.h"45#include "bhnd_nvram_io.h"4647struct bhnd_nvram_store;4849/**50* NVRAM export flags.51*/52enum {53BHND_NVSTORE_EXPORT_CHILDREN = (1<<0), /**< Include all subpaths */54BHND_NVSTORE_EXPORT_PRESERVE_DEVPATHS = (1<<1), /**< Preserve existing device path definitions (default) */55BHND_NVSTORE_EXPORT_COMPACT_DEVPATHS = (1<<2), /**< Re-encode all device paths using compact syntax */56BHND_NVSTORE_EXPORT_EXPAND_DEVPATHS = (1<<3), /**< Re-encode all device paths using non-compact syntax */57BHND_NVSTORE_EXPORT_ALL_VARS = (1<<6|1<<7), /**< Include all variables (default) */58BHND_NVSTORE_EXPORT_COMMITTED = (1<<6), /**< Include all committed changes */59BHND_NVSTORE_EXPORT_UNCOMMITTED = (1<<7), /**< Include all uncommitted changes (not including deletions) */60BHND_NVSTORE_EXPORT_DELETED = (1<<8), /**< Include all uncommitted deltions (as61properties of type BHND_NVRAM_TYPE_NULL) */62};6364int bhnd_nvram_store_new(struct bhnd_nvram_store **store,65struct bhnd_nvram_data *data);6667int bhnd_nvram_store_parse_new(struct bhnd_nvram_store **store,68struct bhnd_nvram_io *io, bhnd_nvram_data_class *cls);6970void bhnd_nvram_store_free(struct bhnd_nvram_store *store);7172int bhnd_nvram_store_export(struct bhnd_nvram_store *store,73const char *path, bhnd_nvram_data_class **cls,74bhnd_nvram_plist **props, bhnd_nvram_plist **options,75uint32_t flags);7677int bhnd_nvram_store_serialize(struct bhnd_nvram_store *store,78const char *path, struct bhnd_nvram_io **data, uint32_t flags);7980int bhnd_nvram_store_getvar(struct bhnd_nvram_store *sc, const char *name,81void *outp, size_t *olen, bhnd_nvram_type otype);82int bhnd_nvram_store_setvar(struct bhnd_nvram_store *sc, const char *name,83const void *inp, size_t ilen, bhnd_nvram_type itype);84int bhnd_nvram_store_unsetvar(struct bhnd_nvram_store *sc,85const char *name);8687int bhnd_nvram_store_setval(struct bhnd_nvram_store *sc, const char *name,88bhnd_nvram_val *value);8990#endif /* _BHND_NVRAM_BHND_NVRAM_STORE_H_ */919293