1195331Simp/*- 2195331Simp * Copyright (c) 2009 Neelkanth Natu 3195331Simp * All rights reserved. 4195331Simp * 5195331Simp * Redistribution and use in source and binary forms, with or without 6195331Simp * modification, are permitted provided that the following conditions 7195331Simp * are met: 8195331Simp * 1. Redistributions of source code must retain the above copyright 9195331Simp * notice, this list of conditions and the following disclaimer. 10195331Simp * 2. Redistributions in binary form must reproduce the above copyright 11195331Simp * notice, this list of conditions and the following disclaimer in the 12195331Simp * documentation and/or other materials provided with the distribution. 13195331Simp * 14195331Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15195331Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16195331Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17195331Simp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18195331Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19195331Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20195331Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21195331Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22195331Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23195331Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24195331Simp * SUCH DAMAGE. 25195331Simp */ 26195331Simp 27195331Simp#include <sys/param.h> 28211158Sneel#include <sys/kenv.h> 29195331Simp 30195331Simp#include <dev/cfe/cfe_api.h> 31195331Simp 32195331Simp__FBSDID("$FreeBSD$"); 33195331Simp 34195331Simp#ifndef CFE_ENV_SIZE 35195331Simp#define CFE_ENV_SIZE PAGE_SIZE /* default is one page */ 36195331Simp#endif 37195331Simp 38195331Simpextern void cfe_env_init(void); 39195331Simp 40195331Simpstatic char cfe_env_buf[CFE_ENV_SIZE]; 41195331Simp 42195331Simpvoid 43195331Simpcfe_env_init(void) 44195331Simp{ 45211158Sneel int idx; 46211158Sneel char name[KENV_MNAMELEN], val[KENV_MVALLEN]; 47195331Simp 48211158Sneel init_static_kenv(cfe_env_buf, CFE_ENV_SIZE); 49195331Simp 50195331Simp idx = 0; 51195331Simp while (1) { 52195331Simp if (cfe_enumenv(idx, name, sizeof(name), val, sizeof(val)) != 0) 53195331Simp break; 54195331Simp 55211158Sneel if (setenv(name, val) != 0) { 56195331Simp printf("No space to store CFE env: \"%s=%s\"\n", 57195331Simp name, val); 58211158Sneel } 59195331Simp ++idx; 60195331Simp } 61195331Simp} 62