1579c0614SWarner Losh /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3718cf2ccSPedro F. Giffuni * 4579c0614SWarner Losh * Copyright (c) 2009 Neelkanth Natu 5579c0614SWarner Losh * All rights reserved. 6579c0614SWarner Losh * 7579c0614SWarner Losh * Redistribution and use in source and binary forms, with or without 8579c0614SWarner Losh * modification, are permitted provided that the following conditions 9579c0614SWarner Losh * are met: 10579c0614SWarner Losh * 1. Redistributions of source code must retain the above copyright 11579c0614SWarner Losh * notice, this list of conditions and the following disclaimer. 12579c0614SWarner Losh * 2. Redistributions in binary form must reproduce the above copyright 13579c0614SWarner Losh * notice, this list of conditions and the following disclaimer in the 14579c0614SWarner Losh * documentation and/or other materials provided with the distribution. 15579c0614SWarner Losh * 16579c0614SWarner Losh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17579c0614SWarner Losh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18579c0614SWarner Losh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19579c0614SWarner Losh * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20579c0614SWarner Losh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21579c0614SWarner Losh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22579c0614SWarner Losh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23579c0614SWarner Losh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24579c0614SWarner Losh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25579c0614SWarner Losh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26579c0614SWarner Losh * SUCH DAMAGE. 27579c0614SWarner Losh */ 28579c0614SWarner Losh 29579c0614SWarner Losh #include <sys/param.h> 305f7eb1ffSNeel Natu #include <sys/kenv.h> 31579c0614SWarner Losh 32579c0614SWarner Losh #include <dev/cfe/cfe_api.h> 33579c0614SWarner Losh 34579c0614SWarner Losh __FBSDID("$FreeBSD$"); 35579c0614SWarner Losh 36579c0614SWarner Losh #ifndef CFE_ENV_SIZE 37579c0614SWarner Losh #define CFE_ENV_SIZE PAGE_SIZE /* default is one page */ 38579c0614SWarner Losh #endif 39579c0614SWarner Losh 40579c0614SWarner Losh extern void cfe_env_init(void); 41579c0614SWarner Losh 42579c0614SWarner Losh static char cfe_env_buf[CFE_ENV_SIZE]; 43579c0614SWarner Losh 44579c0614SWarner Losh void 45579c0614SWarner Losh cfe_env_init(void) 46579c0614SWarner Losh { 475f7eb1ffSNeel Natu int idx; 485f7eb1ffSNeel Natu char name[KENV_MNAMELEN], val[KENV_MVALLEN]; 49579c0614SWarner Losh 505f7eb1ffSNeel Natu init_static_kenv(cfe_env_buf, CFE_ENV_SIZE); 51579c0614SWarner Losh 52579c0614SWarner Losh idx = 0; 53579c0614SWarner Losh while (1) { 54579c0614SWarner Losh if (cfe_enumenv(idx, name, sizeof(name), val, sizeof(val)) != 0) 55579c0614SWarner Losh break; 56579c0614SWarner Losh 57d9ca757cSDavide Italiano if (kern_setenv(name, val) != 0) { 58579c0614SWarner Losh printf("No space to store CFE env: \"%s=%s\"\n", 59579c0614SWarner Losh name, val); 605f7eb1ffSNeel Natu } 61579c0614SWarner Losh ++idx; 62579c0614SWarner Losh } 63579c0614SWarner Losh } 64