diff options
-rw-r--r-- | arch/sparc/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/sparc/prom/memory.c | 103 | ||||
-rw-r--r-- | include/asm-sparc/oplib.h | 13 |
3 files changed, 8 insertions, 110 deletions
diff --git a/arch/sparc/mm/fault.c b/arch/sparc/mm/fault.c index e4d9c8e19df5..f25876a56fe6 100644 --- a/arch/sparc/mm/fault.c +++ b/arch/sparc/mm/fault.c | |||
@@ -55,7 +55,7 @@ int prom_probe_memory (void) | |||
55 | register int i; | 55 | register int i; |
56 | 56 | ||
57 | i = 0; | 57 | i = 0; |
58 | mlist= *prom_meminfo()->v0_available; | 58 | mlist= prom_meminfo(); |
59 | bytes = tally = mlist->num_bytes; | 59 | bytes = tally = mlist->num_bytes; |
60 | base_paddr = (unsigned long) mlist->start_adr; | 60 | base_paddr = (unsigned long) mlist->start_adr; |
61 | 61 | ||
diff --git a/arch/sparc/prom/memory.c b/arch/sparc/prom/memory.c index b0c0f9c4fc14..08ac1bf2e588 100644 --- a/arch/sparc/prom/memory.c +++ b/arch/sparc/prom/memory.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* $Id: memory.c,v 1.15 2000/01/29 01:09:12 anton Exp $ | 1 | /* memory.c: Prom routine for acquiring various bits of information |
2 | * memory.c: Prom routine for acquiring various bits of information | ||
3 | * about RAM on the machine, both virtual and physical. | 2 | * about RAM on the machine, both virtual and physical. |
4 | * | 3 | * |
5 | * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) | 4 | * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) |
@@ -22,19 +21,9 @@ | |||
22 | */ | 21 | */ |
23 | 22 | ||
24 | struct linux_prom_registers prom_reg_memlist[64]; | 23 | struct linux_prom_registers prom_reg_memlist[64]; |
25 | struct linux_prom_registers prom_reg_tmp[64]; | ||
26 | 24 | ||
27 | struct linux_mlist_v0 prom_phys_total[64]; | ||
28 | struct linux_mlist_v0 prom_prom_taken[64]; | ||
29 | struct linux_mlist_v0 prom_phys_avail[64]; | 25 | struct linux_mlist_v0 prom_phys_avail[64]; |
30 | 26 | ||
31 | struct linux_mlist_v0 *prom_ptot_ptr = prom_phys_total; | ||
32 | struct linux_mlist_v0 *prom_ptak_ptr = prom_prom_taken; | ||
33 | struct linux_mlist_v0 *prom_pavl_ptr = prom_phys_avail; | ||
34 | |||
35 | struct linux_mem_v0 prom_memlist; | ||
36 | |||
37 | |||
38 | /* Internal Prom library routine to sort a linux_mlist_v0 memory | 27 | /* Internal Prom library routine to sort a linux_mlist_v0 memory |
39 | * list. Used below in initialization. | 28 | * list. Used below in initialization. |
40 | */ | 29 | */ |
@@ -77,23 +66,6 @@ void __init prom_meminit(void) | |||
77 | switch(prom_vers) { | 66 | switch(prom_vers) { |
78 | case PROM_V0: | 67 | case PROM_V0: |
79 | /* Nice, kind of easier to do in this case. */ | 68 | /* Nice, kind of easier to do in this case. */ |
80 | /* First, the total physical descriptors. */ | ||
81 | for(mptr = (*(romvec->pv_v0mem.v0_totphys)), iter=0; | ||
82 | mptr; mptr=mptr->theres_more, iter++) { | ||
83 | prom_phys_total[iter].start_adr = mptr->start_adr; | ||
84 | prom_phys_total[iter].num_bytes = mptr->num_bytes; | ||
85 | prom_phys_total[iter].theres_more = &prom_phys_total[iter+1]; | ||
86 | } | ||
87 | prom_phys_total[iter-1].theres_more = NULL; | ||
88 | /* Second, the total prom taken descriptors. */ | ||
89 | for(mptr = (*(romvec->pv_v0mem.v0_prommap)), iter=0; | ||
90 | mptr; mptr=mptr->theres_more, iter++) { | ||
91 | prom_prom_taken[iter].start_adr = mptr->start_adr; | ||
92 | prom_prom_taken[iter].num_bytes = mptr->num_bytes; | ||
93 | prom_prom_taken[iter].theres_more = &prom_prom_taken[iter+1]; | ||
94 | } | ||
95 | prom_prom_taken[iter-1].theres_more = NULL; | ||
96 | /* Last, the available physical descriptors. */ | ||
97 | for(mptr = (*(romvec->pv_v0mem.v0_available)), iter=0; | 69 | for(mptr = (*(romvec->pv_v0mem.v0_available)), iter=0; |
98 | mptr; mptr=mptr->theres_more, iter++) { | 70 | mptr; mptr=mptr->theres_more, iter++) { |
99 | prom_phys_avail[iter].start_adr = mptr->start_adr; | 71 | prom_phys_avail[iter].start_adr = mptr->start_adr; |
@@ -101,9 +73,6 @@ void __init prom_meminit(void) | |||
101 | prom_phys_avail[iter].theres_more = &prom_phys_avail[iter+1]; | 73 | prom_phys_avail[iter].theres_more = &prom_phys_avail[iter+1]; |
102 | } | 74 | } |
103 | prom_phys_avail[iter-1].theres_more = NULL; | 75 | prom_phys_avail[iter-1].theres_more = NULL; |
104 | /* Sort all the lists. */ | ||
105 | prom_sortmemlist(prom_phys_total); | ||
106 | prom_sortmemlist(prom_prom_taken); | ||
107 | prom_sortmemlist(prom_phys_avail); | 76 | prom_sortmemlist(prom_phys_avail); |
108 | break; | 77 | break; |
109 | case PROM_V2: | 78 | case PROM_V2: |
@@ -124,69 +93,12 @@ void __init prom_meminit(void) | |||
124 | &prom_phys_avail[iter+1]; | 93 | &prom_phys_avail[iter+1]; |
125 | } | 94 | } |
126 | prom_phys_avail[iter-1].theres_more = NULL; | 95 | prom_phys_avail[iter-1].theres_more = NULL; |
127 | |||
128 | num_regs = prom_getproperty(node, "reg", | ||
129 | (char *) prom_reg_memlist, | ||
130 | sizeof(prom_reg_memlist)); | ||
131 | num_regs = (num_regs/sizeof(struct linux_prom_registers)); | ||
132 | for(iter=0; iter<num_regs; iter++) { | ||
133 | prom_phys_total[iter].start_adr = | ||
134 | (char *) prom_reg_memlist[iter].phys_addr; | ||
135 | prom_phys_total[iter].num_bytes = | ||
136 | (unsigned long) prom_reg_memlist[iter].reg_size; | ||
137 | prom_phys_total[iter].theres_more = | ||
138 | &prom_phys_total[iter+1]; | ||
139 | } | ||
140 | prom_phys_total[iter-1].theres_more = NULL; | ||
141 | |||
142 | node = prom_getchild(prom_root_node); | ||
143 | node = prom_searchsiblings(node, "virtual-memory"); | ||
144 | num_regs = prom_getproperty(node, "available", | ||
145 | (char *) prom_reg_memlist, | ||
146 | sizeof(prom_reg_memlist)); | ||
147 | num_regs = (num_regs/sizeof(struct linux_prom_registers)); | ||
148 | |||
149 | /* Convert available virtual areas to taken virtual | ||
150 | * areas. First sort, then convert. | ||
151 | */ | ||
152 | for(iter=0; iter<num_regs; iter++) { | ||
153 | prom_prom_taken[iter].start_adr = | ||
154 | (char *) prom_reg_memlist[iter].phys_addr; | ||
155 | prom_prom_taken[iter].num_bytes = | ||
156 | (unsigned long) prom_reg_memlist[iter].reg_size; | ||
157 | prom_prom_taken[iter].theres_more = | ||
158 | &prom_prom_taken[iter+1]; | ||
159 | } | ||
160 | prom_prom_taken[iter-1].theres_more = NULL; | ||
161 | |||
162 | prom_sortmemlist(prom_prom_taken); | ||
163 | |||
164 | /* Finally, convert. */ | ||
165 | for(iter=0; iter<num_regs; iter++) { | ||
166 | prom_prom_taken[iter].start_adr = | ||
167 | prom_prom_taken[iter].start_adr + | ||
168 | prom_prom_taken[iter].num_bytes; | ||
169 | prom_prom_taken[iter].num_bytes = | ||
170 | prom_prom_taken[iter+1].start_adr - | ||
171 | prom_prom_taken[iter].start_adr; | ||
172 | } | ||
173 | prom_prom_taken[iter-1].num_bytes = | ||
174 | 0xffffffff - (unsigned long) prom_prom_taken[iter-1].start_adr; | ||
175 | |||
176 | /* Sort the other two lists. */ | ||
177 | prom_sortmemlist(prom_phys_total); | ||
178 | prom_sortmemlist(prom_phys_avail); | 96 | prom_sortmemlist(prom_phys_avail); |
179 | break; | 97 | break; |
180 | 98 | ||
181 | case PROM_SUN4: | 99 | case PROM_SUN4: |
182 | #ifdef CONFIG_SUN4 | 100 | #ifdef CONFIG_SUN4 |
183 | /* how simple :) */ | 101 | /* how simple :) */ |
184 | prom_phys_total[0].start_adr = NULL; | ||
185 | prom_phys_total[0].num_bytes = *(sun4_romvec->memorysize); | ||
186 | prom_phys_total[0].theres_more = NULL; | ||
187 | prom_prom_taken[0].start_adr = NULL; | ||
188 | prom_prom_taken[0].num_bytes = 0x0; | ||
189 | prom_prom_taken[0].theres_more = NULL; | ||
190 | prom_phys_avail[0].start_adr = NULL; | 102 | prom_phys_avail[0].start_adr = NULL; |
191 | prom_phys_avail[0].num_bytes = *(sun4_romvec->memoryavail); | 103 | prom_phys_avail[0].num_bytes = *(sun4_romvec->memoryavail); |
192 | prom_phys_avail[0].theres_more = NULL; | 104 | prom_phys_avail[0].theres_more = NULL; |
@@ -196,20 +108,13 @@ void __init prom_meminit(void) | |||
196 | default: | 108 | default: |
197 | break; | 109 | break; |
198 | }; | 110 | }; |
199 | |||
200 | /* Link all the lists into the top-level descriptor. */ | ||
201 | prom_memlist.v0_totphys=&prom_ptot_ptr; | ||
202 | prom_memlist.v0_prommap=&prom_ptak_ptr; | ||
203 | prom_memlist.v0_available=&prom_pavl_ptr; | ||
204 | |||
205 | return; | ||
206 | } | 111 | } |
207 | 112 | ||
208 | /* This returns a pointer to our libraries internal v0 format | 113 | /* This returns a pointer to our libraries internal v0 format |
209 | * memory descriptor. | 114 | * available memory list. |
210 | */ | 115 | */ |
211 | struct linux_mem_v0 * | 116 | struct linux_mlist_v0 * |
212 | prom_meminfo(void) | 117 | prom_meminfo(void) |
213 | { | 118 | { |
214 | return &prom_memlist; | 119 | return prom_phys_avail; |
215 | } | 120 | } |
diff --git a/include/asm-sparc/oplib.h b/include/asm-sparc/oplib.h index 17ba82ee220a..6ff1a3bb15bc 100644 --- a/include/asm-sparc/oplib.h +++ b/include/asm-sparc/oplib.h | |||
@@ -86,17 +86,10 @@ extern void prom_seek(int device_handle, unsigned int seek_hival, | |||
86 | 86 | ||
87 | /* Machine memory configuration routine. */ | 87 | /* Machine memory configuration routine. */ |
88 | 88 | ||
89 | /* This function returns a V0 format memory descriptor table, it has three | 89 | /* This function returns a V0 format available memory descriptor entry. |
90 | * entries. One for the total amount of physical ram on the machine, one | 90 | * This list is pre-sorted, |
91 | * for the amount of physical ram available, and one describing the virtual | ||
92 | * areas which are allocated by the prom. So, in a sense the physical | ||
93 | * available is a calculation of the total physical minus the physical mapped | ||
94 | * by the prom with virtual mappings. | ||
95 | * | ||
96 | * These lists are returned pre-sorted, this should make your life easier | ||
97 | * since the prom itself is way too lazy to do such nice things. | ||
98 | */ | 91 | */ |
99 | extern struct linux_mem_v0 *prom_meminfo(void); | 92 | extern struct linux_mlist_v0 *prom_meminfo(void); |
100 | 93 | ||
101 | /* Miscellaneous routines, don't really fit in any category per se. */ | 94 | /* Miscellaneous routines, don't really fit in any category per se. */ |
102 | 95 | ||