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