svn commit: r309213 - in projects/clang391-import: . lib/clang lib/libc/sys share/man/man9 sys/arm/allwinner/clk sys/boot/fdt/dts/arm sys/conf sys/dev/bhnd sys/dev/bhnd/nvram sys/dev/bhnd/tools sys...
Dimitry Andric
dim at FreeBSD.org
Sun Nov 27 14:27:54 UTC 2016
Author: dim
Date: Sun Nov 27 14:27:51 2016
New Revision: 309213
URL: https://svnweb.freebsd.org/changeset/base/309213
Log:
Merge ^/head r309170 through r309212.
Added:
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data.c
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data.h
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmreg.h
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmreg.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmvar.h
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmvar.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data_spromvar.h
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data_spromvar.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data_tlvreg.h
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlvreg.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_io.c
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_io.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_io.h
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_io.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_iobuf.c
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_iobuf.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_iores.c
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_iores.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_iovar.h
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_iovar.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_private.h
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_private.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_store.c
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_store.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_store.h
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_store.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_storevar.h
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_storevar.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_subr.c
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_value.c
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_value.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_value.h
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_value.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_value_prf.c
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_value_prf.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_valuevar.h
- copied unchanged from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_valuevar.h
projects/clang391-import/sys/mips/broadcom/bcm_nvram_cfe.c
- copied unchanged from r309212, head/sys/mips/broadcom/bcm_nvram_cfe.c
projects/clang391-import/sys/mips/broadcom/bcm_nvram_cfevar.h
- copied unchanged from r309212, head/sys/mips/broadcom/bcm_nvram_cfevar.h
Deleted:
projects/clang391-import/share/man/man9/vm_page_cache.9
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_cfe.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_common.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_common.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_parser.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_parser.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_parserreg.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_parservar.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvramvar.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_sprom_parser.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_sprom_parser.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_sprom_parservar.h
Modified:
projects/clang391-import/ObsoleteFiles.inc
projects/clang391-import/lib/clang/freebsd_cc_version.h
projects/clang391-import/lib/libc/sys/mmap.2
projects/clang391-import/share/man/man9/Makefile
projects/clang391-import/sys/arm/allwinner/clk/aw_lcdclk.c
projects/clang391-import/sys/arm/allwinner/clk/aw_pll.c
projects/clang391-import/sys/boot/fdt/dts/arm/rpi.dts
projects/clang391-import/sys/boot/fdt/dts/arm/rpi2.dts
projects/clang391-import/sys/conf/files
projects/clang391-import/sys/dev/bhnd/bhnd_subr.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram.h
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_sprom.c
projects/clang391-import/sys/dev/bhnd/nvram/bhnd_spromvar.h
projects/clang391-import/sys/dev/bhnd/nvram/nvram_map
projects/clang391-import/sys/dev/bhnd/tools/nvram_map_gen.awk
projects/clang391-import/sys/dev/bwn/bwn_mac.c
projects/clang391-import/sys/dev/usb/usb_process.c
projects/clang391-import/sys/dev/usb/wlan/if_rsu.c
projects/clang391-import/sys/dev/usb/wlan/if_rsureg.h
projects/clang391-import/sys/fs/ext2fs/ext2_vfsops.c
projects/clang391-import/sys/fs/nfs/nfs_commonport.c
projects/clang391-import/sys/fs/nfsclient/nfs_clvfsops.c
projects/clang391-import/sys/fs/nullfs/null_vfsops.c
projects/clang391-import/sys/kern/vfs_subr.c
projects/clang391-import/sys/mips/broadcom/files.broadcom
projects/clang391-import/sys/mips/conf/JZ4780
projects/clang391-import/sys/mips/conf/X1000
projects/clang391-import/sys/modules/bhnd/Makefile
projects/clang391-import/sys/netipsec/key_debug.c
projects/clang391-import/sys/netipsec/keydb.h
projects/clang391-import/sys/netpfil/ipfw/nat64/nat64_translate.c
projects/clang391-import/sys/sys/mount.h
projects/clang391-import/sys/vm/vm_page.c
projects/clang391-import/sys/x86/x86/local_apic.c
projects/clang391-import/tools/build/mk/OptionalObsoleteFiles.inc
projects/clang391-import/usr.bin/dtc/fdt.cc
projects/clang391-import/usr.bin/gzip/unpack.c
projects/clang391-import/usr.bin/nfsstat/nfsstat.1
projects/clang391-import/usr.bin/nfsstat/nfsstat.c
projects/clang391-import/usr.sbin/makefs/cd9660.c
projects/clang391-import/usr.sbin/syslogd/syslogd.c
Directory Properties:
projects/clang391-import/ (props changed)
Modified: projects/clang391-import/ObsoleteFiles.inc
==============================================================================
--- projects/clang391-import/ObsoleteFiles.inc Sun Nov 27 14:19:19 2016 (r309212)
+++ projects/clang391-import/ObsoleteFiles.inc Sun Nov 27 14:27:51 2016 (r309213)
@@ -142,6 +142,8 @@ OLD_FILES+=usr/lib/clang/3.9.0/lib/freeb
OLD_DIRS+=usr/lib/clang/3.9.0/lib/freebsd
OLD_DIRS+=usr/lib/clang/3.9.0/lib
OLD_DIRS+=usr/lib/clang/3.9.0
+# 20161127: Remove vm_page_cache(9)
+OLD_FILES+=usr/share/man/man9/vm_page_cache.9.gz
# 20161124: new clang import which bumps version from 3.8.0 to 3.9.0.
OLD_FILES+=usr/lib/clang/3.8.0/include/sanitizer/allocator_interface.h
OLD_FILES+=usr/lib/clang/3.8.0/include/sanitizer/asan_interface.h
Modified: projects/clang391-import/lib/clang/freebsd_cc_version.h
==============================================================================
--- projects/clang391-import/lib/clang/freebsd_cc_version.h Sun Nov 27 14:19:19 2016 (r309212)
+++ projects/clang391-import/lib/clang/freebsd_cc_version.h Sun Nov 27 14:27:51 2016 (r309213)
@@ -1,3 +1,3 @@
/* $FreeBSD$ */
-#define FREEBSD_CC_VERSION 1200004
+#define FREEBSD_CC_VERSION 1200005
Modified: projects/clang391-import/lib/libc/sys/mmap.2
==============================================================================
--- projects/clang391-import/lib/libc/sys/mmap.2 Sun Nov 27 14:19:19 2016 (r309212)
+++ projects/clang391-import/lib/libc/sys/mmap.2 Sun Nov 27 14:27:51 2016 (r309213)
@@ -28,7 +28,7 @@
.\" @(#)mmap.2 8.4 (Berkeley) 5/11/95
.\" $FreeBSD$
.\"
-.Dd February 18, 2015
+.Dd November 25, 2016
.Dt MMAP 2
.Os
.Sh NAME
@@ -189,6 +189,8 @@ this option any VM pages you dirty may b
(every 30-60 seconds usually) which can create performance problems if you
do not need that to occur (such as when you are using shared file-backed
mmap regions for IPC purposes).
+Dirty data will be flushed automatically when all mappings of an object are
+removed and all descriptors referencing the object are closed.
Note that VM/file system coherency is
maintained whether you use
.Dv MAP_NOSYNC
Modified: projects/clang391-import/share/man/man9/Makefile
==============================================================================
--- projects/clang391-import/share/man/man9/Makefile Sun Nov 27 14:19:19 2016 (r309212)
+++ projects/clang391-import/share/man/man9/Makefile Sun Nov 27 14:27:51 2016 (r309213)
@@ -352,7 +352,6 @@ MAN= accept_filter.9 \
vm_page_alloc.9 \
vm_page_bits.9 \
vm_page_busy.9 \
- vm_page_cache.9 \
vm_page_deactivate.9 \
vm_page_dontneed.9 \
vm_page_aflag.9 \
Modified: projects/clang391-import/sys/arm/allwinner/clk/aw_lcdclk.c
==============================================================================
--- projects/clang391-import/sys/arm/allwinner/clk/aw_lcdclk.c Sun Nov 27 14:19:19 2016 (r309212)
+++ projects/clang391-import/sys/arm/allwinner/clk/aw_lcdclk.c Sun Nov 27 14:27:51 2016 (r309213)
@@ -78,6 +78,8 @@ __FBSDID("$FreeBSD$");
#define CH1_CLK_DIV_RATIO_M_SHIFT 0
#define TCON_PLLREF 3000000ULL
+#define TCON_PLLREF_FRAC1 297000000ULL
+#define TCON_PLLREF_FRAC2 270000000ULL
#define TCON_PLL_M_MIN 1
#define TCON_PLL_M_MAX 15
#define TCON_PLL_N_MIN 9
@@ -290,7 +292,7 @@ aw_lcdclk_recalc_freq(struct clknode *cl
}
static void
-calc_tcon_pll(uint64_t fin, uint64_t fout, uint32_t *pm, uint32_t *pn)
+calc_tcon_pll_integer(uint64_t fin, uint64_t fout, uint32_t *pm, uint32_t *pn)
{
int64_t diff, fcur, best;
int m, n;
@@ -310,14 +312,86 @@ calc_tcon_pll(uint64_t fin, uint64_t fou
}
static int
+calc_tcon_pll_fractional(uint64_t fin, uint64_t fout, int *clk_div)
+{
+ int m;
+
+ /* Test for 1X match */
+ for (m = TCON_PLL_M_MIN; m <= TCON_PLL_M_MAX; m++) {
+ if (fout == (fin / m)) {
+ *clk_div = m;
+ return (CH0_CLK_SRC_SEL_PLL3_1X);
+ }
+ }
+
+ /* Test for 2X match */
+ for (m = TCON_PLL_M_MIN; m <= TCON_PLL_M_MAX; m++) {
+ if (fout == ((fin * 2) / m)) {
+ *clk_div = m;
+ return (CH0_CLK_SRC_SEL_PLL3_2X);
+ }
+ }
+
+ return (-1);
+}
+
+static int
+calc_tcon_pll(uint64_t fin, uint64_t fout, uint64_t *pll_freq, int *tcon_pll_div)
+{
+ uint32_t m, m2, n, n2;
+ uint64_t fsingle, fdouble;
+ int src_sel;
+ bool dbl;
+
+ /* Test fractional freq first */
+ src_sel = calc_tcon_pll_fractional(TCON_PLLREF_FRAC1, fout,
+ tcon_pll_div);
+ if (src_sel != -1) {
+ *pll_freq = TCON_PLLREF_FRAC1;
+ return src_sel;
+ }
+ src_sel = calc_tcon_pll_fractional(TCON_PLLREF_FRAC2, fout,
+ tcon_pll_div);
+ if (src_sel != -1) {
+ *pll_freq = TCON_PLLREF_FRAC2;
+ return src_sel;
+ }
+
+ m = n = m2 = n2 = 0;
+ dbl = false;
+
+ /* Find the frequency closes to the target dot clock, using
+ * both 1X and 2X PLL inputs as possible candidates.
+ */
+ calc_tcon_pll_integer(TCON_PLLREF, fout, &m, &n);
+ calc_tcon_pll_integer(TCON_PLLREF * 2, fout, &m2, &n2);
+
+ fsingle = m ? (n * TCON_PLLREF) / m : 0;
+ fdouble = m2 ? (n2 * TCON_PLLREF * 2) / m2 : 0;
+
+ if (fdouble > fsingle) {
+ dbl = true;
+ m = m2;
+ n = n2;
+ }
+
+ /* Set desired parent frequency */
+ *pll_freq = n * TCON_PLLREF;
+ *tcon_pll_div = m;
+
+ /* Return the desired source clock */
+ return (dbl ? CH0_CLK_SRC_SEL_PLL3_2X :
+ CH0_CLK_SRC_SEL_PLL3_1X);
+}
+
+static int
aw_lcdclk_set_freq(struct clknode *clk, uint64_t fin, uint64_t *fout,
int flags, int *stop)
{
struct aw_lcdclk_softc *sc;
- uint32_t val, m, m2, n, n2, src_sel;
- uint64_t fsingle, fdouble;
- int error;
- bool dbl;
+ uint64_t pll_freq;
+ uint32_t val, src_sel;
+ int error, tcon_pll_div;
sc = clknode_get_softc(clk);
@@ -329,26 +403,7 @@ aw_lcdclk_set_freq(struct clknode *clk,
if (sc->id != CLK_IDX_CH1_SCLK2)
return (ENXIO);
- m = n = m2 = n2 = 0;
- dbl = false;
-
- /* Find the frequency closes to the target dot clock, using
- * both 1X and 2X PLL inputs as possible candidates.
- */
- calc_tcon_pll(TCON_PLLREF, *fout, &m, &n);
- calc_tcon_pll(TCON_PLLREF * 2, *fout, &m2, &n2);
-
- fsingle = m ? (n * TCON_PLLREF) / m : 0;
- fdouble = m2 ? (n2 * TCON_PLLREF * 2) / m2 : 0;
-
- if (fdouble > fsingle) {
- dbl = true;
- m = m2;
- n = n2;
- }
-
- src_sel = dbl ? CH0_CLK_SRC_SEL_PLL3_2X :
- CH0_CLK_SRC_SEL_PLL3_1X;
+ src_sel = calc_tcon_pll(fin, *fout, &pll_freq, &tcon_pll_div);
/* Switch parent clock if necessary */
if (src_sel != clknode_get_parent_idx(clk)) {
@@ -357,10 +412,8 @@ aw_lcdclk_set_freq(struct clknode *clk,
return (error);
}
- /* Set desired parent frequency */
- fin = n * TCON_PLLREF;
-
- error = clknode_set_freq(clknode_get_parent(clk), fin, 0, 0);
+ error = clknode_set_freq(clknode_get_parent(clk), pll_freq,
+ 0, 0);
if (error != 0)
return (error);
@@ -369,7 +422,7 @@ aw_lcdclk_set_freq(struct clknode *clk,
return (error);
/* Fetch new input frequency */
- error = clknode_get_freq(clknode_get_parent(clk), &fin);
+ error = clknode_get_freq(clknode_get_parent(clk), &pll_freq);
if (error != 0)
return (error);
@@ -377,11 +430,11 @@ aw_lcdclk_set_freq(struct clknode *clk,
DEVICE_LOCK(sc);
LCDCLK_READ(sc, &val);
val &= ~CH1_CLK_DIV_RATIO_M;
- val |= ((m - 1) << CH1_CLK_DIV_RATIO_M_SHIFT);
+ val |= ((tcon_pll_div - 1) << CH1_CLK_DIV_RATIO_M_SHIFT);
LCDCLK_WRITE(sc, val);
DEVICE_UNLOCK(sc);
- *fout = fin / m;
+ *fout = pll_freq / tcon_pll_div;
*stop = 1;
break;
Modified: projects/clang391-import/sys/arm/allwinner/clk/aw_pll.c
==============================================================================
--- projects/clang391-import/sys/arm/allwinner/clk/aw_pll.c Sun Nov 27 14:19:19 2016 (r309212)
+++ projects/clang391-import/sys/arm/allwinner/clk/aw_pll.c Sun Nov 27 14:27:51 2016 (r309213)
@@ -482,11 +482,20 @@ a10_pll3_set_freq(struct aw_pll_sc *sc,
{
uint32_t val, m, mode, func;
- m = *fout / A10_PLL3_REF_FREQ;
-
- mode = A10_PLL3_MODE_SEL_INT;
- func = 0;
- *fout = m * A10_PLL3_REF_FREQ;
+ if (*fout == 297000000) {
+ func = A10_PLL3_FUNC_SET_297MHZ;
+ mode = A10_PLL3_MODE_SEL_FRACT;
+ m = 0;
+ } else if (*fout == 270000000) {
+ func = A10_PLL3_FUNC_SET_270MHZ;
+ mode = A10_PLL3_MODE_SEL_FRACT;
+ m = 0;
+ } else {
+ mode = A10_PLL3_MODE_SEL_INT;
+ func = 0;
+ m = *fout / A10_PLL3_REF_FREQ;
+ *fout = m * A10_PLL3_REF_FREQ;
+ }
DEVICE_LOCK(sc);
PLL_READ(sc, &val);
Modified: projects/clang391-import/sys/boot/fdt/dts/arm/rpi.dts
==============================================================================
--- projects/clang391-import/sys/boot/fdt/dts/arm/rpi.dts Sun Nov 27 14:19:19 2016 (r309212)
+++ projects/clang391-import/sys/boot/fdt/dts/arm/rpi.dts Sun Nov 27 14:27:51 2016 (r309213)
@@ -298,7 +298,7 @@
reg = <0x00000001>;
#address-cells = <1>;
#size-cells = <0>;
- ethernet {
+ ethernet: ethernet {
compatible = "net,ethernet",
"usb,device";
reg = <0x00000001>;
@@ -386,6 +386,7 @@
aliases {
uart0 = &uart0;
+ ethernet0 = ðernet;
};
chosen {
Modified: projects/clang391-import/sys/boot/fdt/dts/arm/rpi2.dts
==============================================================================
--- projects/clang391-import/sys/boot/fdt/dts/arm/rpi2.dts Sun Nov 27 14:19:19 2016 (r309212)
+++ projects/clang391-import/sys/boot/fdt/dts/arm/rpi2.dts Sun Nov 27 14:27:51 2016 (r309213)
@@ -315,7 +315,7 @@
reg = <0x00000001>;
#address-cells = <1>;
#size-cells = <0>;
- ethernet {
+ ethernet: ethernet {
compatible = "net,ethernet",
"usb,device";
reg = <0x00000001>;
@@ -397,6 +397,7 @@
aliases {
uart0 = &uart0;
+ ethernet0 = ðernet;
};
chosen {
Modified: projects/clang391-import/sys/conf/files
==============================================================================
--- projects/clang391-import/sys/conf/files Sun Nov 27 14:19:19 2016 (r309212)
+++ projects/clang391-import/sys/conf/files Sun Nov 27 14:27:51 2016 (r309213)
@@ -1220,14 +1220,22 @@ dev/bhnd/cores/pmu/bhnd_pmu.c optional
dev/bhnd/cores/pmu/bhnd_pmu_core.c optional bhnd
dev/bhnd/cores/pmu/bhnd_pmu_if.m optional bhnd
dev/bhnd/cores/pmu/bhnd_pmu_subr.c optional bhnd
-dev/bhnd/nvram/bhnd_nvram.c optional bhnd
-dev/bhnd/nvram/bhnd_nvram_common.c optional bhnd
-dev/bhnd/nvram/bhnd_nvram_cfe.c optional bhnd siba_nexus cfe | \
- bhnd bcma_nexus cfe
+dev/bhnd/nvram/bhnd_nvram_data.c optional bhnd
+dev/bhnd/nvram/bhnd_nvram_data_bcm.c optional bhnd
+dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c optional bhnd
+dev/bhnd/nvram/bhnd_nvram_data_btxt.c optional bhnd
+dev/bhnd/nvram/bhnd_nvram_data_sprom.c optional bhnd
+dev/bhnd/nvram/bhnd_nvram_data_tlv.c optional bhnd
dev/bhnd/nvram/bhnd_nvram_if.m optional bhnd
-dev/bhnd/nvram/bhnd_nvram_parser.c optional bhnd
+dev/bhnd/nvram/bhnd_nvram_io.c optional bhnd
+dev/bhnd/nvram/bhnd_nvram_iobuf.c optional bhnd
+dev/bhnd/nvram/bhnd_nvram_iores.c optional bhnd
+dev/bhnd/nvram/bhnd_nvram_store.c optional bhnd
+dev/bhnd/nvram/bhnd_nvram_subr.c optional bhnd
+dev/bhnd/nvram/bhnd_nvram_value.c optional bhnd
+dev/bhnd/nvram/bhnd_nvram_value_fmts.c optional bhnd
+dev/bhnd/nvram/bhnd_nvram_value_prf.c optional bhnd
dev/bhnd/nvram/bhnd_sprom.c optional bhnd
-dev/bhnd/nvram/bhnd_sprom_parser.c optional bhnd
dev/bhnd/siba/siba.c optional siba bhnd
dev/bhnd/siba/siba_bhndb.c optional siba bhnd bhndb
dev/bhnd/siba/siba_erom.c optional siba bhnd
Modified: projects/clang391-import/sys/dev/bhnd/bhnd_subr.c
==============================================================================
--- projects/clang391-import/sys/dev/bhnd/bhnd_subr.c Sun Nov 27 14:19:19 2016 (r309212)
+++ projects/clang391-import/sys/dev/bhnd/bhnd_subr.c Sun Nov 27 14:27:51 2016 (r309213)
@@ -1057,7 +1057,8 @@ bhnd_nvram_getvar_str(device_t dev, cons
int error;
larg = len;
- error = bhnd_nvram_getvar(dev, name, buf, &larg, BHND_NVRAM_TYPE_CSTR);
+ error = bhnd_nvram_getvar(dev, name, buf, &larg,
+ BHND_NVRAM_TYPE_STRING);
if (rlen != NULL)
*rlen = larg;
Modified: projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram.h
==============================================================================
--- projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram.h Sun Nov 27 14:19:19 2016 (r309212)
+++ projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram.h Sun Nov 27 14:27:51 2016 (r309213)
@@ -32,11 +32,17 @@
#ifndef _BHND_NVRAM_BHND_NVRAM_H_
#define _BHND_NVRAM_BHND_NVRAM_H_
+#ifdef _KERNEL
+#include <sys/types.h>
+#else /* !_KERNEL */
+#include <stdbool.h>
+#include <stdint.h>
+#endif /* _KERNEL */
+
/**
* NVRAM data sources supported by bhnd(4) devices.
*/
typedef enum {
-
BHND_NVRAM_SRC_OTP, /**< On-chip one-time-programmable
* memory. */
@@ -67,50 +73,52 @@ typedef enum {
*/
} bhnd_nvram_src;
-/** Supported NVRAM formats. */
-typedef enum {
- BHND_NVRAM_FMT_BCM = 0, /**< Broadcom NUL-delimited key=value pairs */
- BHND_NVRAM_FMT_TLV = 1, /**< CFE TLV encoding, as used on WGT634U */
- BHND_NVRAM_FMT_BTXT = 2, /**< Broadcom board text file. This is used
- to provide external NVRAM data for some
- fullmac WiFi devices. */
- BHND_NVRAM_FMT_SPROM = 3, /**< SPROM/OTP-specific encoding used by
- Broadcom network adapters */
- BHND_NVRAM_FMT_CIS = 4, /**< A mostly CIS-compatible encoding used
- on some Broadcom network adapters */
- BHND_NVRAM_FMT_UNKNOWN = 5 /**< Unknown or unrecognized format */
-} bhnd_nvram_format;
-
-
-/** bhnd_nvram_type bit flags */
-enum {
- BHND_NVRAM_TF_SIGNED = (1<<7),
-};
-
-#define BHND_NVRAM_TYPE_ID_MASK 0xF
-#define BHND_NVRAM_TYPE_FLAGS_MASK 0x70
-
-#define BHND_NVRAM_TYPE_ID(_id, _flags) \
- (((_id) & BHND_NVRAM_TYPE_ID_MASK) | \
- ((_flags) & BHND_NVRAM_TYPE_FLAGS_MASK))
-
-/** Supported NVRAM data types */
+/**
+ * NVRAM data types.
+ *
+ * @internal
+ *
+ * All primitive (non-array) constants should be representable as a 4-bit
+ * integer (e.g. 0-15) to support SPROM_OPCODE_TYPE_IMM encoding as used by
+ * nvram_map_gen.awk.
+ */
typedef enum {
- BHND_NVRAM_TYPE_UINT8 = BHND_NVRAM_TYPE_ID(0, 0), /**< unsigned 8-bit integer */
- BHND_NVRAM_TYPE_UINT16 = BHND_NVRAM_TYPE_ID(1, 0), /**< unsigned 16-bit integer */
- BHND_NVRAM_TYPE_UINT32 = BHND_NVRAM_TYPE_ID(2, 0), /**< unsigned 32-bit integer */
- BHND_NVRAM_TYPE_INT8 = BHND_NVRAM_TYPE_ID(4, BHND_NVRAM_TF_SIGNED), /**< signed 8-bit integer */
- BHND_NVRAM_TYPE_INT16 = BHND_NVRAM_TYPE_ID(5, BHND_NVRAM_TF_SIGNED), /**< signed 16-bit integer */
- BHND_NVRAM_TYPE_INT32 = BHND_NVRAM_TYPE_ID(6, BHND_NVRAM_TF_SIGNED), /**< signed 32-bit integer */
- BHND_NVRAM_TYPE_CHAR = BHND_NVRAM_TYPE_ID(7, BHND_NVRAM_TF_SIGNED), /**< ASCII character */
- BHND_NVRAM_TYPE_CSTR = BHND_NVRAM_TYPE_ID(8, 0), /**< NUL-terminated C string */
+ BHND_NVRAM_TYPE_UINT8 = 0, /**< unsigned 8-bit integer */
+ BHND_NVRAM_TYPE_UINT16 = 1, /**< unsigned 16-bit integer */
+ BHND_NVRAM_TYPE_UINT32 = 2, /**< unsigned 32-bit integer */
+ BHND_NVRAM_TYPE_UINT64 = 3, /**< signed 64-bit integer */
+ BHND_NVRAM_TYPE_INT8 = 4, /**< signed 8-bit integer */
+ BHND_NVRAM_TYPE_INT16 = 5, /**< signed 16-bit integer */
+ BHND_NVRAM_TYPE_INT32 = 6, /**< signed 32-bit integer */
+ BHND_NVRAM_TYPE_INT64 = 7, /**< signed 64-bit integer */
+ BHND_NVRAM_TYPE_CHAR = 8, /**< ASCII/UTF-8 character */
+ BHND_NVRAM_TYPE_STRING = 9, /**< ASCII/UTF-8 NUL-terminated
+ string */
+
+ /* 10-15 reserved for primitive (non-array) types */
+
+ BHND_NVRAM_TYPE_UINT8_ARRAY = 16, /**< array of uint8 integers */
+ BHND_NVRAM_TYPE_UINT16_ARRAY = 17, /**< array of uint16 integers */
+ BHND_NVRAM_TYPE_UINT32_ARRAY = 18, /**< array of uint32 integers */
+ BHND_NVRAM_TYPE_UINT64_ARRAY = 19, /**< array of uint64 integers */
+ BHND_NVRAM_TYPE_INT8_ARRAY = 20, /**< array of int8 integers */
+ BHND_NVRAM_TYPE_INT16_ARRAY = 21, /**< array of int16 integers */
+ BHND_NVRAM_TYPE_INT32_ARRAY = 22, /**< array of int32 integers */
+ BHND_NVRAM_TYPE_INT64_ARRAY = 23, /**< array of int64 integers */
+ BHND_NVRAM_TYPE_CHAR_ARRAY = 24, /**< array of ASCII/UTF-8
+ characters */
+ BHND_NVRAM_TYPE_STRING_ARRAY = 25, /**< array of ASCII/UTF-8
+ NUL-terminated strings */
} bhnd_nvram_type;
-#undef BHND_NVRAM_TYPE_ID_MASK
-#undef BHND_NVRAM_TYPE_FLAGS_MASK
-#undef BHND_NVRAM_TYPE_ID
+const char *bhnd_nvram_string_array_next(const char *inp, size_t ilen,
+ const char *prev);
-#define BHND_NVRAM_SIGNED_TYPE(_type) \
- (((_type) & BHND_NVRAM_TF_SIGNED) == BHND_NVRAM_TF_SIGNED)
+bool bhnd_nvram_is_signed_type(bhnd_nvram_type type);
+bool bhnd_nvram_is_unsigned_type(bhnd_nvram_type type);
+bool bhnd_nvram_is_int_type(bhnd_nvram_type type);
+bool bhnd_nvram_is_array_type(bhnd_nvram_type type);
+bhnd_nvram_type bhnd_nvram_base_type(bhnd_nvram_type type);
+const char *bhnd_nvram_type_name(bhnd_nvram_type type);
#endif /* _BHND_NVRAM_BHND_NVRAM_H_ */
Copied: projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data.c (from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data.c)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data.c Sun Nov 27 14:27:51 2016 (r309213, copy of r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data.c)
@@ -0,0 +1,527 @@
+/*-
+ * Copyright (c) 2015-2016 Landon Fuller <landonf at FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ * redistribution must be conditioned upon including a substantially
+ * similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+
+#ifdef _KERNEL
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <machine/_inttypes.h>
+
+#else /* !_KERNEL */
+
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#endif /* _KERNEL */
+
+#include "bhnd_nvram_private.h"
+#include "bhnd_nvram_io.h"
+
+#include "bhnd_nvram_datavar.h"
+#include "bhnd_nvram_data.h"
+
+/**
+ * Return a human-readable description for the given NVRAM data class.
+ *
+ * @param cls The NVRAM class.
+ */
+const char *
+bhnd_nvram_data_class_desc(bhnd_nvram_data_class_t *cls)
+{
+ return (cls->desc);
+}
+
+/**
+ * Probe to see if this NVRAM data class class supports the data mapped by the
+ * given I/O context, returning a BHND_NVRAM_DATA_PROBE probe result.
+ *
+ * @param cls The NVRAM class.
+ * @param io An I/O context mapping the NVRAM data.
+ *
+ * @retval 0 if this is the only possible NVRAM data class for @p io.
+ * @retval negative if the probe succeeds, a negative value should be returned;
+ * the class returning the highest negative value should be selected to handle
+ * NVRAM parsing.
+ * @retval ENXIO If the NVRAM format is not handled by @p cls.
+ * @retval positive if an error occurs during probing, a regular unix error
+ * code should be returned.
+ */
+int
+bhnd_nvram_data_probe(bhnd_nvram_data_class_t *cls, struct bhnd_nvram_io *io)
+{
+ return (cls->op_probe(io));
+}
+
+/**
+ * Probe to see if an NVRAM data class in @p classes supports parsing
+ * of the data mapped by @p io, returning the parsed data in @p data.
+ *
+ * The caller is responsible for deallocating the returned instance via
+ * bhnd_nvram_data_release().
+ *
+ * @param[out] data On success, the parsed NVRAM data instance.
+ * @param io An I/O context mapping the NVRAM data to be copied and parsed.
+ * @param classes An array of NVRAM data classes to be probed, or NULL to
+ * probe the default supported set.
+ * @param num_classes The number of NVRAM data classes in @p classes.
+ *
+ * @retval 0 success
+ * @retval ENXIO if no class is found capable of parsing @p io.
+ * @retval non-zero if an error otherwise occurs during allocation,
+ * initialization, or parsing of the NVRAM data, a regular unix error code
+ * will be returned.
+ */
+int
+bhnd_nvram_data_probe_classes(struct bhnd_nvram_data **data,
+ struct bhnd_nvram_io *io, bhnd_nvram_data_class_t *classes[],
+ size_t num_classes)
+{
+ bhnd_nvram_data_class_t *cls;
+ int error, prio, result;
+
+ cls = NULL;
+ prio = 0;
+ *data = NULL;
+
+ /* If class array is NULL, default to our linker set */
+ if (classes == NULL) {
+ classes = SET_BEGIN(bhnd_nvram_data_class_set);
+ num_classes = SET_COUNT(bhnd_nvram_data_class_set);
+ }
+
+ /* Try to find the best data class capable of parsing io */
+ for (size_t i = 0; i < num_classes; i++) {
+ bhnd_nvram_data_class_t *next_cls;
+
+ next_cls = classes[i];
+
+ /* Try to probe */
+ result = bhnd_nvram_data_probe(next_cls, io);
+
+ /* The parser did not match if an error was returned */
+ if (result > 0)
+ continue;
+
+ /* Lower priority than previous match; keep
+ * searching */
+ if (cls != NULL && result <= prio)
+ continue;
+
+ /* Drop any previously parsed data */
+ if (*data != NULL) {
+ bhnd_nvram_data_release(*data);
+ *data = NULL;
+ }
+
+ /* If this is a 'maybe' match, attempt actual parsing to
+ * verify that this does in fact match */
+ if (result <= BHND_NVRAM_DATA_PROBE_MAYBE) {
+ /* If parsing fails, keep searching */
+ error = bhnd_nvram_data_new(next_cls, data, io);
+ if (error)
+ continue;
+ }
+
+ /* Record best new match */
+ prio = result;
+ cls = next_cls;
+
+
+ /* Terminate search immediately on
+ * BHND_NVRAM_DATA_PROBE_SPECIFIC */
+ if (result == BHND_NVRAM_DATA_PROBE_SPECIFIC)
+ break;
+ }
+
+ /* If no match, return error */
+ if (cls == NULL)
+ return (ENXIO);
+
+ /* If the NVRAM data was not parsed above, do so now */
+ if (*data == NULL) {
+ if ((error = bhnd_nvram_data_new(cls, data, io)))
+ return (error);
+ }
+
+ return (0);
+}
+
+/**
+ * Allocate and initialize a new instance of data class @p cls, copying and
+ * parsing NVRAM data from @p io.
+ *
+ * The caller is responsible for releasing the returned parser instance
+ * reference via bhnd_nvram_data_release().
+ *
+ * @param cls If non-NULL, the data class to be allocated. If NULL,
+ * bhnd_nvram_data_probe_classes() will be used to determine the data format.
+ * @param[out] nv On success, a pointer to the newly allocated NVRAM data instance.
+ * @param io An I/O context mapping the NVRAM data to be copied and parsed.
+ *
+ * @retval 0 success
+ * @retval non-zero if an error occurs during allocation or initialization, a
+ * regular unix error code will be returned.
+ */
+int
+bhnd_nvram_data_new(bhnd_nvram_data_class_t *cls,
+ struct bhnd_nvram_data **nv, struct bhnd_nvram_io *io)
+{
+ struct bhnd_nvram_data *data;
+ int error;
+
+ /* If NULL, try to identify the appropriate class */
+ if (cls == NULL)
+ return (bhnd_nvram_data_probe_classes(nv, io, NULL, 0));
+
+ /* Allocate new instance */
+ BHND_NV_ASSERT(sizeof(struct bhnd_nvram_data) <= cls->size,
+ ("instance size %zu less than minimum %zu", cls->size,
+ sizeof(struct bhnd_nvram_data)));
+
+ data = bhnd_nv_calloc(1, cls->size);
+ data->cls = cls;
+ refcount_init(&data->refs, 1);
+
+ /* Let the class handle initialization */
+ if ((error = cls->op_new(data, io))) {
+ bhnd_nv_free(data);
+ return (error);
+ }
+
+ *nv = data;
+ return (0);
+}
+
+/**
+ * Retain and return a reference to the given data instance.
+ *
+ * @param nv The reference to be retained.
+ */
+struct bhnd_nvram_data *
+bhnd_nvram_data_retain(struct bhnd_nvram_data *nv)
+{
+ refcount_acquire(&nv->refs);
+ return (nv);
+}
+
+/**
+ * Release a reference to the given data instance.
+ *
+ * If this is the last reference, the data instance and its associated
+ * resources will be freed.
+ *
+ * @param nv The reference to be released.
+ */
+void
+bhnd_nvram_data_release(struct bhnd_nvram_data *nv)
+{
+ if (!refcount_release(&nv->refs))
+ return;
+
+ /* Free any internal resources */
+ nv->cls->op_free(nv);
+
+ /* Free the instance allocation */
+ bhnd_nv_free(nv);
+}
+
+/**
+ * Return a pointer to @p nv's data class.
+ *
+ * @param nv The NVRAM data instance to be queried.
+ */
+bhnd_nvram_data_class_t *
+bhnd_nvram_data_class(struct bhnd_nvram_data *nv)
+{
+ return (nv->cls);
+}
+
+/**
+ * Return the number of variables in @p nv.
+ *
+ * @param nv The NVRAM data to be queried.
+ */
+size_t
+bhnd_nvram_data_count(struct bhnd_nvram_data *nv)
+{
+ return (nv->cls->op_count(nv));
+}
+
+/**
+ * Compute the size of the serialized form of @p nv.
+ *
+ * Serialization may be performed via bhnd_nvram_data_serialize().
+ *
+ * @param nv The NVRAM data to be queried.
+ * @param[out] len On success, will be set to the computed size.
+ *
+ * @retval 0 success
+ * @retval non-zero if computing the serialized size otherwise fails, a
+ * regular unix error code will be returned.
+ */
+int
+bhnd_nvram_data_size(struct bhnd_nvram_data *nv, size_t *len)
+{
+ return (nv->cls->op_size(nv, len));
+}
+
+/**
+ * Serialize the NVRAM data to @p buf, using the NVRAM data class' native
+ * format.
+ *
+ * The resulting serialization may be reparsed with @p nv's BHND NVRAM data
+ * class.
+ *
+ * @param nv The NVRAM data to be serialized.
+ * @param[out] buf On success, the serialed NVRAM data will be
+ * written to this buffer. This argment may be
+ * NULL if the value is not desired.
+ * @param[in,out] len The capacity of @p buf. On success, will be set
+ * to the actual length of the serialized data.
+ *
+ * @retval 0 success
+ * @retval ENOMEM If @p buf is non-NULL and a buffer of @p len is too
+ * small to hold the serialized data.
+ * @retval non-zero If serialization otherwise fails, a regular unix error
+ * code will be returned.
+ */
+int
+bhnd_nvram_data_serialize(struct bhnd_nvram_data *nv,
+ void *buf, size_t *len)
+{
+ return (nv->cls->op_serialize(nv, buf, len));
+}
+
+/**
+ * Return the capability flags (@see BHND_NVRAM_DATA_CAP_*) for @p nv.
+ *
+ * @param nv The NVRAM data to be queried.
+ */
+uint32_t
+bhnd_nvram_data_caps(struct bhnd_nvram_data *nv)
+{
+ return (nv->cls->op_caps(nv));
+}
+
+/**
+ * Iterate over @p nv, returning the names of subsequent variables.
+ *
+ * @param nv The NVRAM data to be iterated.
+ * @param[in,out] cookiep A pointer to a cookiep value previously returned
+ * by bhnd_nvram_data_next(), or a NULL value to
+ * begin iteration.
+ *
+ * @return Returns the next variable name, or NULL if there are no more
+ * variables defined in @p nv.
+ */
+const char *
+bhnd_nvram_data_next(struct bhnd_nvram_data *nv, void **cookiep)
+{
+ return (nv->cls->op_next(nv, cookiep));
+}
+
+/**
+ * Search @p nv for a named variable, returning the variable's opaque reference
+ * if found, or NULL if unavailable.
+ *
+ * The BHND_NVRAM_DATA_CAP_INDEXED capability flag will be returned by
+ * bhnd_nvram_data_caps() if @p nv supports effecient name-based
+ * lookups.
+ *
+ * @param nv The NVRAM data to search.
+ * @param name The name to search for.
+ *
+ * @retval non-NULL If @p name is found, the opaque cookie value will be
+ * returned.
+ * @retval NULL If @p name is not found.
+ */
+void *
+bhnd_nvram_data_find(struct bhnd_nvram_data *nv, const char *name)
+{
+ return (nv->cls->op_find(nv, name));
+}
+
+/**
+ * A generic implementation of bhnd_nvram_data_find().
+ *
+ * This implementation will use bhnd_nvram_data_next() to perform a
+ * simple O(n) case-insensitve search for @p name.
+ */
+void *
+bhnd_nvram_data_generic_find(struct bhnd_nvram_data *nv, const char *name)
+{
+ const char *next;
+ void *cookiep;
+
+ cookiep = NULL;
+ while ((next = bhnd_nvram_data_next(nv, &cookiep))) {
+ if (strcasecmp(name, next) == 0)
+ return (cookiep);
+ }
+
+ /* Not found */
+ return (NULL);
+}
+
+/**
+ * Read a variable and decode as @p type.
+ *
+ * @param nv The NVRAM data.
+ * @param cookiep An NVRAM variable cookie previously returned
+ * via bhnd_nvram_data_next() or
+ * bhnd_nvram_data_find().
+ * @param[out] buf On success, the requested value will be written
+ * to this buffer. This argment may be NULL if
+ * the value is not desired.
+ * @param[in,out] len The capacity of @p buf. On success, will be set
+ * to the actual size of the requested value.
+ * @param type The data type to be written to @p buf.
+ *
+ * @retval 0 success
+ * @retval ENOMEM If @p buf is non-NULL and a buffer of @p len is too
+ * small to hold the requested value.
+ * @retval EFTYPE If the variable data cannot be coerced to @p type.
+ * @retval ERANGE If value coercion would overflow @p type.
+ */
+int
+bhnd_nvram_data_getvar(struct bhnd_nvram_data *nv, void *cookiep, void *buf,
+ size_t *len, bhnd_nvram_type type)
+{
+ return (nv->cls->op_getvar(nv, cookiep, buf, len, type));
+}
+
+/**
+ * A generic implementation of bhnd_nvram_data_getvar().
+ *
+ * This implementation will call bhnd_nvram_data_getvar_ptr() to fetch
+ * a pointer to the variable data and perform data coercion on behalf
+ * of the caller.
+ *
+ * If a variable definition for the requested variable is available via
+ * bhnd_nvram_find_vardefn(), the definition will be used to provide
+ * formatting hints to bhnd_nvram_coerce_value().
+ */
+int
+bhnd_nvram_data_generic_rp_getvar(struct bhnd_nvram_data *nv, void *cookiep,
+ void *outp, size_t *olen, bhnd_nvram_type otype)
+{
+ bhnd_nvram_val_t val;
+ const struct bhnd_nvram_vardefn *vdefn;
+ const bhnd_nvram_val_fmt_t *fmt;
+ const char *name;
+ const void *vptr;
+ bhnd_nvram_type vtype;
+ size_t vlen;
+ int error;
+
+ BHND_NV_ASSERT(bhnd_nvram_data_caps(nv) & BHND_NVRAM_DATA_CAP_READ_PTR,
+ ("instance does not advertise READ_PTR support"));
+
+ /* Fetch pointer to our variable data */
+ vptr = bhnd_nvram_data_getvar_ptr(nv, cookiep, &vlen, &vtype);
+ if (vptr == NULL)
+ return (EINVAL);
+
+ /* Use the NVRAM string support */
+ switch (vtype) {
+ case BHND_NVRAM_TYPE_STRING:
+ case BHND_NVRAM_TYPE_STRING_ARRAY:
+ fmt = &bhnd_nvram_val_bcm_string_fmt;
+ break;
+ default:
+ fmt = NULL;
+ }
+
+ /* Check the variable definition table for a matching entry; if
+ * it exists, use it to populate the value format. */
+ name = bhnd_nvram_data_getvar_name(nv, cookiep);
+ vdefn = bhnd_nvram_find_vardefn(name);
+ if (vdefn != NULL)
+ fmt = vdefn->fmt;
+
+ /* Attempt value coercion */
+ error = bhnd_nvram_val_init(&val, fmt, vptr, vlen, vtype,
+ BHND_NVRAM_VAL_BORROW_DATA);
+ if (error)
+ return (error);
+
+ error = bhnd_nvram_val_encode(&val, outp, olen, otype);
+
+ /* Clean up */
+ bhnd_nvram_val_release(&val);
+ return (error);
+}
+
+/**
+ * If available and supported by the NVRAM data instance, return a reference
+ * to the internal buffer containing an entry's variable data,
+ *
+ * Note that string values may not be NUL terminated.
+ *
+ * @param nv The NVRAM data.
+ * @param cookiep An NVRAM variable cookie previously returned
+ * via bhnd_nvram_data_next() or
+ * bhnd_nvram_data_find().
+ * @param[out] len On success, will be set to the actual size of
+ * the requested value.
+ * @param[out] type The data type of the entry data.
+ *
+ * @retval non-NULL success
+ * @retval NULL if direct data access is unsupported by @p nv, or
+ * unavailable for @p cookiep.
+ */
+const void *
+bhnd_nvram_data_getvar_ptr(struct bhnd_nvram_data *nv, void *cookiep,
+ size_t *len, bhnd_nvram_type *type)
+{
+ return (nv->cls->op_getvar_ptr(nv, cookiep, len, type));
+}
+
+
+/**
+ * Return the variable name associated with a given @p cookiep.
+ * @param nv The NVRAM data to be iterated.
+ * @param[in,out] cookiep A pointer to a cookiep value previously returned
+ * via bhnd_nvram_data_next() or
+ * bhnd_nvram_data_find().
+ *
+ * @return Returns the variable's name.
+ */
+const char *
+bhnd_nvram_data_getvar_name(struct bhnd_nvram_data *nv, void *cookiep)
+{
+ return (nv->cls->op_getvar_name(nv, cookiep));
+}
Copied: projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data.h (from r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data.h)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/clang391-import/sys/dev/bhnd/nvram/bhnd_nvram_data.h Sun Nov 27 14:27:51 2016 (r309213, copy of r309212, head/sys/dev/bhnd/nvram/bhnd_nvram_data.h)
@@ -0,0 +1,137 @@
+/*-
+ * Copyright (c) 2015-2016 Landon Fuller <landonf at FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ * redistribution must be conditioned upon including a substantially
+ * similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-projects
mailing list