/* * arch/ppc/kernel/prep_nvram.c * * Copyright (C) 1998 Corey Minyard * * This reads the NvRAM on PReP compliant machines (generally from IBM or * Motorola). Motorola kept the format of NvRAM in their ROM, PPCBUG, the * same, long after they had stopped producing PReP compliant machines. So * this code is useful in those cases as well. * */ #include #include #include #include #include #include #include #include static char nvramData[MAX_PREP_NVRAM]; static NVRAM_MAP *nvram=(NVRAM_MAP *)&nvramData[0]; unsigned char prep_nvram_read_val(int addr) { outb(addr, PREP_NVRAM_AS0); outb(addr>>8, PREP_NVRAM_AS1); return inb(PREP_NVRAM_DATA); } void prep_nvram_write_val(int addr, unsigned char val) { outb(addr, PREP_NVRAM_AS0); outb(addr>>8, PREP_NVRAM_AS1); outb(val, PREP_NVRAM_DATA); } void __init init_prep_nvram(void) { unsigned char *nvp; int i; int nvramSize; /* * The following could fail if the NvRAM were corrupt but * we expect the boot firmware to have checked its checksum * before boot */ nvp = (char *) &nvram->Header; for (i=0; iHeader.GEAddress+nvram->Header.GELength; if(nvramSize>MAX_PREP_NVRAM) { /* * NvRAM is too large */ nvram->Header.GELength=0; return; } /* * Read the remainder of the PReP NvRAM */ nvp = (char *) &nvram->GEArea[0]; for (i=sizeof(HEADER); iGEArea)) < nvram->Header.GELength) && (*cp == '\0')) { cp++; } if ((cp - ((char *) nvram->GEArea)) < nvram->Header.GELength) { return cp; } else { return NULL; } }