/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Tim Rightnour
*
* 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.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE.
*/
static char *nvramData;
static NVRAM_MAP *nvram;
static char *nvramGEAp; /* pointer to the GE area */
static char *nvramCAp; /* pointer to the Config area */
static char *nvramOSAp; /* pointer to the OSArea */
/*
* now read the whole nvram in, one chunk at a time, marking down
* the main start points as we go.
*/
for (i = 0; i < sizeof(HEADER) && i < nvlen; i++)
*p++ = prep_nvram_read_val(i);
nvramGEAp = p;
cur = i;
for (; i < cur + prep_nvram_header.GELength && i < nvlen; i++)
*p++ = prep_nvram_read_val(i);
nvramOSAp = p;
cur = i;
for (; i < cur + prep_nvram_header.OSAreaLength && i < nvlen; i++)
*p++ = prep_nvram_read_val(i);
nvramCAp = p;
cur = i;
for (; i < cur + prep_nvram_header.ConfigLength && i < nvlen; i++)
*p++ = prep_nvram_read_val(i);
/* we should be done here. umm.. yay? */
nvram = (NVRAM_MAP *)&nvramData[0];
aprint_normal("\n");
aprint_verbose("%s: Read %d bytes from nvram of size %d\n",
device_xname(self), i, nvlen);
#if defined(NVRAM_DUMP)
printf("Boot device: %s\n", prep_nvram_get_var("fw-boot-device"));
printf("Dumping nvram\n");
for (cur=0; cur < i; cur++) {
printf("%c", nvramData[cur]);
if (cur % 70 == 0)
printf("\n");
}
#endif
strncpy(bootpath, prep_nvram_get_var("fw-boot-device"), 256);
if (prep_clock_mk48txx == 0)
return;
/* otherwise, we have a motorolla clock chip. Set it up. */
sc->sc_mksc.sc_model = "mk48t18";
sc->sc_mksc.sc_year0 = 1900;
sc->sc_mksc.sc_nvrd = mkclock_pnpbus_nvrd;
sc->sc_mksc.sc_nvwr = mkclock_pnpbus_nvwr;
/* copy down the bus space tags */
sc->sc_mksc.sc_bst = sc->sc_as;
sc->sc_mksc.sc_bsh = sc->sc_ash;
sc->sc_mksc.sc_data = sc->sc_data;
sc->sc_mksc.sc_datah = sc->sc_datah;
case PNVIOCGETNEXTNAME:
/* if the first one is null, we give them the first name */
if (pnv->pnv_name == NULL) {
cp = nvramGEAp;
} else {
error = nvramgetstr(pnv->pnv_namelen, pnv->pnv_name,
&name);
if (!error) {
np = prep_nvram_find_var(name);
cp = prep_nvram_next_var(np);
}
}
if (cp == NULL)
error = EINVAL;
if (error)
break;
np = cp;
while (*np != '=')
np++;
len = np-cp;
if (len > pnv->pnv_buflen) {
error = ENOMEM;
break;
}
error = copyout(cp, pnv->pnv_buf, len);
if (error)
break;
pnv->pnv_buflen = len;
break;
case PNVIOCGETNUMGE:
/* count the GE variables */
pnv->pnv_num = prep_nvram_count_vars();
break;
case PNVIOCSET:
/* this will require some real work. Not ready yet */
return ENOTSUP;