diff options
Diffstat (limited to 'arch/sparc')
| -rw-r--r-- | arch/sparc/kernel/setup.c | 5 | ||||
| -rw-r--r-- | arch/sparc/mm/fault.c | 61 | ||||
| -rw-r--r-- | arch/sparc/prom/init.c | 7 | ||||
| -rw-r--r-- | arch/sparc/prom/memory.c | 235 |
4 files changed, 67 insertions, 241 deletions
diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c index 3c13137685da..8a55c4f0df84 100644 --- a/arch/sparc/kernel/setup.c +++ b/arch/sparc/kernel/setup.c | |||
| @@ -180,11 +180,9 @@ static void __init boot_flags_init(char *commands) | |||
| 180 | 180 | ||
| 181 | /* This routine will in the future do all the nasty prom stuff | 181 | /* This routine will in the future do all the nasty prom stuff |
| 182 | * to probe for the mmu type and its parameters, etc. This will | 182 | * to probe for the mmu type and its parameters, etc. This will |
| 183 | * also be where SMP things happen plus the Sparc specific memory | 183 | * also be where SMP things happen. |
| 184 | * physical memory probe as on the alpha. | ||
| 185 | */ | 184 | */ |
| 186 | 185 | ||
| 187 | extern int prom_probe_memory(void); | ||
| 188 | extern void sun4c_probe_vac(void); | 186 | extern void sun4c_probe_vac(void); |
| 189 | extern char cputypval; | 187 | extern char cputypval; |
| 190 | extern unsigned long start, end; | 188 | extern unsigned long start, end; |
| @@ -268,7 +266,6 @@ void __init setup_arch(char **cmdline_p) | |||
| 268 | if (ARCH_SUN4C_SUN4) | 266 | if (ARCH_SUN4C_SUN4) |
| 269 | sun4c_probe_vac(); | 267 | sun4c_probe_vac(); |
| 270 | load_mmu(); | 268 | load_mmu(); |
| 271 | (void) prom_probe_memory(); | ||
| 272 | 269 | ||
| 273 | phys_base = 0xffffffffUL; | 270 | phys_base = 0xffffffffUL; |
| 274 | highest_paddr = 0UL; | 271 | highest_paddr = 0UL; |
diff --git a/arch/sparc/mm/fault.c b/arch/sparc/mm/fault.c index e4d9c8e19df5..abd50795a7b6 100644 --- a/arch/sparc/mm/fault.c +++ b/arch/sparc/mm/fault.c | |||
| @@ -47,64 +47,15 @@ int vac_size, vac_linesize, vac_do_hw_vac_flushes; | |||
| 47 | int vac_entries_per_context, vac_entries_per_segment; | 47 | int vac_entries_per_context, vac_entries_per_segment; |
| 48 | int vac_entries_per_page; | 48 | int vac_entries_per_page; |
| 49 | 49 | ||
| 50 | /* Nice, simple, prom library does all the sweating for us. ;) */ | 50 | /* Return how much physical memory we have. */ |
| 51 | int prom_probe_memory (void) | 51 | unsigned long probe_memory(void) |
| 52 | { | 52 | { |
| 53 | register struct linux_mlist_v0 *mlist; | 53 | unsigned long total = 0; |
| 54 | register unsigned long bytes, base_paddr, tally; | 54 | int i; |
| 55 | register int i; | ||
| 56 | |||
| 57 | i = 0; | ||
| 58 | mlist= *prom_meminfo()->v0_available; | ||
| 59 | bytes = tally = mlist->num_bytes; | ||
| 60 | base_paddr = (unsigned long) mlist->start_adr; | ||
| 61 | |||
| 62 | sp_banks[0].base_addr = base_paddr; | ||
| 63 | sp_banks[0].num_bytes = bytes; | ||
| 64 | |||
| 65 | while (mlist->theres_more != (void *) 0){ | ||
| 66 | i++; | ||
| 67 | mlist = mlist->theres_more; | ||
| 68 | bytes = mlist->num_bytes; | ||
| 69 | tally += bytes; | ||
| 70 | if (i > SPARC_PHYS_BANKS-1) { | ||
| 71 | printk ("The machine has more banks than " | ||
| 72 | "this kernel can support\n" | ||
| 73 | "Increase the SPARC_PHYS_BANKS " | ||
| 74 | "setting (currently %d)\n", | ||
| 75 | SPARC_PHYS_BANKS); | ||
| 76 | i = SPARC_PHYS_BANKS-1; | ||
| 77 | break; | ||
| 78 | } | ||
| 79 | |||
| 80 | sp_banks[i].base_addr = (unsigned long) mlist->start_adr; | ||
| 81 | sp_banks[i].num_bytes = mlist->num_bytes; | ||
| 82 | } | ||
| 83 | |||
| 84 | i++; | ||
| 85 | sp_banks[i].base_addr = 0xdeadbeef; | ||
| 86 | sp_banks[i].num_bytes = 0; | ||
| 87 | |||
| 88 | /* Now mask all bank sizes on a page boundary, it is all we can | ||
| 89 | * use anyways. | ||
| 90 | */ | ||
| 91 | for(i=0; sp_banks[i].num_bytes != 0; i++) | ||
| 92 | sp_banks[i].num_bytes &= PAGE_MASK; | ||
| 93 | |||
| 94 | return tally; | ||
| 95 | } | ||
| 96 | |||
| 97 | /* Traverse the memory lists in the prom to see how much physical we | ||
| 98 | * have. | ||
| 99 | */ | ||
| 100 | unsigned long | ||
| 101 | probe_memory(void) | ||
| 102 | { | ||
| 103 | int total; | ||
| 104 | 55 | ||
| 105 | total = prom_probe_memory(); | 56 | for (i = 0; sp_banks[i].num_bytes; i++) |
| 57 | total += sp_banks[i].num_bytes; | ||
| 106 | 58 | ||
| 107 | /* Oh man, much nicer, keep the dirt in promlib. */ | ||
| 108 | return total; | 59 | return total; |
| 109 | } | 60 | } |
| 110 | 61 | ||
diff --git a/arch/sparc/prom/init.c b/arch/sparc/prom/init.c index 50abfb1b880e..2fa3a474e3a2 100644 --- a/arch/sparc/prom/init.c +++ b/arch/sparc/prom/init.c | |||
| @@ -21,8 +21,6 @@ linux_sun4_romvec *sun4_romvec; | |||
| 21 | /* The root node of the prom device tree. */ | 21 | /* The root node of the prom device tree. */ |
| 22 | int prom_root_node; | 22 | int prom_root_node; |
| 23 | 23 | ||
| 24 | int prom_stdin, prom_stdout; | ||
| 25 | |||
| 26 | /* Pointer to the device tree operations structure. */ | 24 | /* Pointer to the device tree operations structure. */ |
| 27 | struct linux_nodeops *prom_nodeops; | 25 | struct linux_nodeops *prom_nodeops; |
| 28 | 26 | ||
| @@ -74,11 +72,6 @@ void __init prom_init(struct linux_romvec *rp) | |||
| 74 | (((unsigned long) prom_nodeops) == -1)) | 72 | (((unsigned long) prom_nodeops) == -1)) |
| 75 | prom_halt(); | 73 | prom_halt(); |
| 76 | 74 | ||
| 77 | if(prom_vers == PROM_V2 || prom_vers == PROM_V3) { | ||
| 78 | prom_stdout = *romvec->pv_v2bootargs.fd_stdout; | ||
| 79 | prom_stdin = *romvec->pv_v2bootargs.fd_stdin; | ||
| 80 | } | ||
| 81 | |||
| 82 | prom_meminit(); | 75 | prom_meminit(); |
| 83 | 76 | ||
| 84 | prom_ranges_init(); | 77 | prom_ranges_init(); |
diff --git a/arch/sparc/prom/memory.c b/arch/sparc/prom/memory.c index b0c0f9c4fc14..947f047dc95a 100644 --- a/arch/sparc/prom/memory.c +++ b/arch/sparc/prom/memory.c | |||
| @@ -1,215 +1,100 @@ | |||
| 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, 2008 David S. Miller (davem@davemloft.net) |
| 6 | * Copyright (C) 1997 Michael A. Griffith (grif@acm.org) | 5 | * Copyright (C) 1997 Michael A. Griffith (grif@acm.org) |
| 7 | */ | 6 | */ |
| 8 | 7 | ||
| 9 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
| 9 | #include <linux/sort.h> | ||
| 10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
| 11 | 11 | ||
| 12 | #include <asm/openprom.h> | 12 | #include <asm/openprom.h> |
| 13 | #include <asm/sun4prom.h> | 13 | #include <asm/sun4prom.h> |
| 14 | #include <asm/oplib.h> | 14 | #include <asm/oplib.h> |
| 15 | #include <asm/page.h> | ||
| 15 | 16 | ||
| 16 | /* This routine, for consistency, returns the ram parameters in the | 17 | static int __init prom_meminit_v0(void) |
| 17 | * V0 prom memory descriptor format. I choose this format because I | 18 | { |
| 18 | * think it was the easiest to work with. I feel the religious | 19 | struct linux_mlist_v0 *p; |
| 19 | * arguments now... ;) Also, I return the linked lists sorted to | 20 | int index; |
| 20 | * prevent paging_init() upset stomach as I have not yet written | 21 | |
| 21 | * the pepto-bismol kernel module yet. | 22 | index = 0; |
| 22 | */ | 23 | for (p = *(romvec->pv_v0mem.v0_available); p; p = p->theres_more) { |
| 24 | sp_banks[index].base_addr = (unsigned long) p->start_adr; | ||
| 25 | sp_banks[index].num_bytes = p->num_bytes; | ||
| 26 | index++; | ||
| 27 | } | ||
| 23 | 28 | ||
| 24 | struct linux_prom_registers prom_reg_memlist[64]; | 29 | return index; |
| 25 | struct linux_prom_registers prom_reg_tmp[64]; | 30 | } |
| 26 | 31 | ||
| 27 | struct linux_mlist_v0 prom_phys_total[64]; | 32 | static int __init prom_meminit_v2(void) |
| 28 | struct linux_mlist_v0 prom_prom_taken[64]; | 33 | { |
| 29 | struct linux_mlist_v0 prom_phys_avail[64]; | 34 | struct linux_prom_registers reg[64]; |
| 35 | int node, size, num_ents, i; | ||
| 30 | 36 | ||
| 31 | struct linux_mlist_v0 *prom_ptot_ptr = prom_phys_total; | 37 | node = prom_searchsiblings(prom_getchild(prom_root_node), "memory"); |
| 32 | struct linux_mlist_v0 *prom_ptak_ptr = prom_prom_taken; | 38 | size = prom_getproperty(node, "available", (char *) reg, sizeof(reg)); |
| 33 | struct linux_mlist_v0 *prom_pavl_ptr = prom_phys_avail; | 39 | num_ents = size / sizeof(struct linux_prom_registers); |
| 34 | 40 | ||
| 35 | struct linux_mem_v0 prom_memlist; | 41 | for (i = 0; i < num_ents; i++) { |
| 42 | sp_banks[i].base_addr = reg[i].phys_addr; | ||
| 43 | sp_banks[i].num_bytes = reg[i].reg_size; | ||
| 44 | } | ||
| 36 | 45 | ||
| 46 | return num_ents; | ||
| 47 | } | ||
| 37 | 48 | ||
| 38 | /* Internal Prom library routine to sort a linux_mlist_v0 memory | 49 | static int __init prom_meminit_sun4(void) |
| 39 | * list. Used below in initialization. | ||
| 40 | */ | ||
| 41 | static void __init | ||
| 42 | prom_sortmemlist(struct linux_mlist_v0 *thislist) | ||
| 43 | { | 50 | { |
| 44 | int swapi = 0; | 51 | #ifdef CONFIG_SUN4 |
| 45 | int i, mitr, tmpsize; | 52 | sp_banks[0].base_addr = 0; |
| 46 | char *tmpaddr; | 53 | sp_banks[0].num_bytes = *(sun4_romvec->memoryavail); |
| 47 | char *lowest; | 54 | #endif |
| 48 | 55 | return 1; | |
| 49 | for(i=0; thislist[i].theres_more; i++) { | 56 | } |
| 50 | lowest = thislist[i].start_adr; | 57 | |
| 51 | for(mitr = i+1; thislist[mitr-1].theres_more; mitr++) | 58 | static int sp_banks_cmp(const void *a, const void *b) |
| 52 | if(thislist[mitr].start_adr < lowest) { | 59 | { |
| 53 | lowest = thislist[mitr].start_adr; | 60 | const struct sparc_phys_banks *x = a, *y = b; |
| 54 | swapi = mitr; | ||
| 55 | } | ||
| 56 | if(lowest == thislist[i].start_adr) continue; | ||
| 57 | tmpaddr = thislist[swapi].start_adr; | ||
| 58 | tmpsize = thislist[swapi].num_bytes; | ||
| 59 | for(mitr = swapi; mitr > i; mitr--) { | ||
| 60 | thislist[mitr].start_adr = thislist[mitr-1].start_adr; | ||
| 61 | thislist[mitr].num_bytes = thislist[mitr-1].num_bytes; | ||
| 62 | } | ||
| 63 | thislist[i].start_adr = tmpaddr; | ||
| 64 | thislist[i].num_bytes = tmpsize; | ||
| 65 | } | ||
| 66 | 61 | ||
| 67 | return; | 62 | if (x->base_addr > y->base_addr) |
| 63 | return 1; | ||
| 64 | if (x->base_addr < y->base_addr) | ||
| 65 | return -1; | ||
| 66 | return 0; | ||
| 68 | } | 67 | } |
| 69 | 68 | ||
| 70 | /* Initialize the memory lists based upon the prom version. */ | 69 | /* Initialize the memory lists based upon the prom version. */ |
| 71 | void __init prom_meminit(void) | 70 | void __init prom_meminit(void) |
| 72 | { | 71 | { |
| 73 | int node = 0; | 72 | int i, num_ents = 0; |
| 74 | unsigned int iter, num_regs; | ||
| 75 | struct linux_mlist_v0 *mptr; /* ptr for traversal */ | ||
| 76 | 73 | ||
| 77 | switch(prom_vers) { | 74 | switch (prom_vers) { |
| 78 | case PROM_V0: | 75 | case PROM_V0: |
| 79 | /* Nice, kind of easier to do in this case. */ | 76 | num_ents = prom_meminit_v0(); |
| 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; | ||
| 98 | mptr; mptr=mptr->theres_more, iter++) { | ||
| 99 | prom_phys_avail[iter].start_adr = mptr->start_adr; | ||
| 100 | prom_phys_avail[iter].num_bytes = mptr->num_bytes; | ||
| 101 | prom_phys_avail[iter].theres_more = &prom_phys_avail[iter+1]; | ||
| 102 | } | ||
| 103 | 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); | ||
| 108 | break; | 77 | break; |
| 78 | |||
| 109 | case PROM_V2: | 79 | case PROM_V2: |
| 110 | case PROM_V3: | 80 | case PROM_V3: |
| 111 | /* Grrr, have to traverse the prom device tree ;( */ | 81 | num_ents = prom_meminit_v2(); |
| 112 | node = prom_getchild(prom_root_node); | ||
| 113 | node = prom_searchsiblings(node, "memory"); | ||
| 114 | num_regs = prom_getproperty(node, "available", | ||
| 115 | (char *) prom_reg_memlist, | ||
| 116 | sizeof(prom_reg_memlist)); | ||
| 117 | num_regs = (num_regs/sizeof(struct linux_prom_registers)); | ||
| 118 | for(iter=0; iter<num_regs; iter++) { | ||
| 119 | prom_phys_avail[iter].start_adr = | ||
| 120 | (char *) prom_reg_memlist[iter].phys_addr; | ||
| 121 | prom_phys_avail[iter].num_bytes = | ||
| 122 | (unsigned long) prom_reg_memlist[iter].reg_size; | ||
| 123 | prom_phys_avail[iter].theres_more = | ||
| 124 | &prom_phys_avail[iter+1]; | ||
| 125 | } | ||
| 126 | 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); | ||
| 179 | break; | 82 | break; |
| 180 | 83 | ||
| 181 | case PROM_SUN4: | 84 | case PROM_SUN4: |
| 182 | #ifdef CONFIG_SUN4 | 85 | num_ents = prom_meminit_sun4(); |
| 183 | /* 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; | ||
| 191 | prom_phys_avail[0].num_bytes = *(sun4_romvec->memoryavail); | ||
| 192 | prom_phys_avail[0].theres_more = NULL; | ||
| 193 | #endif | ||
| 194 | break; | 86 | break; |
| 195 | 87 | ||
| 196 | default: | 88 | default: |
| 197 | break; | 89 | break; |
| 198 | }; | 90 | } |
| 199 | 91 | sort(sp_banks, num_ents, sizeof(struct sparc_phys_banks), | |
| 200 | /* Link all the lists into the top-level descriptor. */ | 92 | sp_banks_cmp, NULL); |
| 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 | 93 | ||
| 205 | return; | 94 | /* Sentinel. */ |
| 206 | } | 95 | sp_banks[num_ents].base_addr = 0xdeadbeef; |
| 96 | sp_banks[num_ents].num_bytes = 0; | ||
| 207 | 97 | ||
| 208 | /* This returns a pointer to our libraries internal v0 format | 98 | for (i = 0; i < num_ents; i++) |
| 209 | * memory descriptor. | 99 | sp_banks[i].num_bytes &= PAGE_MASK; |
| 210 | */ | ||
| 211 | struct linux_mem_v0 * | ||
| 212 | prom_meminfo(void) | ||
| 213 | { | ||
| 214 | return &prom_memlist; | ||
| 215 | } | 100 | } |
