[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / ppc / syslib / prep_nvram.c
blob2bcf8a16d1c936180acae6965438678ef417a17d
1 /*
2 * arch/ppc/kernel/prep_nvram.c
4 * Copyright (C) 1998 Corey Minyard
6 * This reads the NvRAM on PReP compliant machines (generally from IBM or
7 * Motorola). Motorola kept the format of NvRAM in their ROM, PPCBUG, the
8 * same, long after they had stopped producing PReP compliant machines. So
9 * this code is useful in those cases as well.
12 #include <linux/init.h>
13 #include <linux/delay.h>
14 #include <linux/slab.h>
15 #include <linux/ioport.h>
17 #include <asm/sections.h>
18 #include <asm/segment.h>
19 #include <asm/io.h>
20 #include <asm/machdep.h>
21 #include <asm/prep_nvram.h>
23 static char nvramData[MAX_PREP_NVRAM];
24 static NVRAM_MAP *nvram=(NVRAM_MAP *)&nvramData[0];
26 unsigned char __prep prep_nvram_read_val(int addr)
28 outb(addr, PREP_NVRAM_AS0);
29 outb(addr>>8, PREP_NVRAM_AS1);
30 return inb(PREP_NVRAM_DATA);
33 void __prep prep_nvram_write_val(int addr,
34 unsigned char val)
36 outb(addr, PREP_NVRAM_AS0);
37 outb(addr>>8, PREP_NVRAM_AS1);
38 outb(val, PREP_NVRAM_DATA);
41 void __init init_prep_nvram(void)
43 unsigned char *nvp;
44 int i;
45 int nvramSize;
48 * The following could fail if the NvRAM were corrupt but
49 * we expect the boot firmware to have checked its checksum
50 * before boot
52 nvp = (char *) &nvram->Header;
53 for (i=0; i<sizeof(HEADER); i++)
55 *nvp = ppc_md.nvram_read_val(i);
56 nvp++;
60 * The PReP NvRAM may be any size so read in the header to
61 * determine how much we must read in order to get the complete
62 * GE area
64 nvramSize=(int)nvram->Header.GEAddress+nvram->Header.GELength;
65 if(nvramSize>MAX_PREP_NVRAM)
68 * NvRAM is too large
70 nvram->Header.GELength=0;
71 return;
75 * Read the remainder of the PReP NvRAM
77 nvp = (char *) &nvram->GEArea[0];
78 for (i=sizeof(HEADER); i<nvramSize; i++)
80 *nvp = ppc_md.nvram_read_val(i);
81 nvp++;
85 __prep
86 char __prep *prep_nvram_get_var(const char *name)
88 char *cp;
89 int namelen;
91 namelen = strlen(name);
92 cp = prep_nvram_first_var();
93 while (cp != NULL) {
94 if ((strncmp(name, cp, namelen) == 0)
95 && (cp[namelen] == '='))
97 return cp+namelen+1;
99 cp = prep_nvram_next_var(cp);
102 return NULL;
105 __prep
106 char __prep *prep_nvram_first_var(void)
108 if (nvram->Header.GELength == 0) {
109 return NULL;
110 } else {
111 return (((char *)nvram)
112 + ((unsigned int) nvram->Header.GEAddress));
116 __prep
117 char __prep *prep_nvram_next_var(char *name)
119 char *cp;
122 cp = name;
123 while (((cp - ((char *) nvram->GEArea)) < nvram->Header.GELength)
124 && (*cp != '\0'))
126 cp++;
129 /* Skip over any null characters. */
130 while (((cp - ((char *) nvram->GEArea)) < nvram->Header.GELength)
131 && (*cp == '\0'))
133 cp++;
136 if ((cp - ((char *) nvram->GEArea)) < nvram->Header.GELength) {
137 return cp;
138 } else {
139 return NULL;