/* * linux/arch/ppc/kernel/prep_nvram.c * * Copyright (C) 1998 Corey Minyard * */ #include #include #include #include #include #include #include #include #include /* * Allow for a maximum of 32K of PReP NvRAM data */ #define MAX_PREP_NVRAM 0x8000 static char nvramData[MAX_PREP_NVRAM]; static NVRAM_MAP *nvram=(NVRAM_MAP *)&nvramData[0]; #define PREP_NVRAM_AS0 0x74 #define PREP_NVRAM_AS1 0x75 #define PREP_NVRAM_DATA 0x77 unsigned char *rs_pcNvRAM; 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); } /* * Most Radstone boards have NvRAM memory mapped at offset 8M in ISA space */ unsigned char rs_nvram_read_val(int addr) { return rs_pcNvRAM[addr]; } void rs_nvram_write_val(int addr, unsigned char val) { rs_pcNvRAM[addr]=val; } __initfunc(void init_prep_nvram(void)) { unsigned char *nvp; int i; int nvramSize; /* * I'm making the assumption that 32k will always cover the * nvramsize. If this isn't the case please let me know and we can * map the header, then get the size from the header, then map * the whole size. -- Cort */ if ( _prep_type == _PREP_Radstone ) rs_pcNvRAM = (unsigned char *)ioremap(_ISA_MEM_BASE+0x00800000, 32<<10); request_region(PREP_NVRAM_AS0, 0x8, "PReP NVRAM"); /* * 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; } }