This source file includes following definitions.
- __bad_pagetable
- __bad_page
- __zero_page
- show_mem
- paging_init
- mem_init
- si_meminfo
1
2
3
4
5
6
7 #include <linux/config.h>
8 #include <linux/signal.h>
9 #include <linux/sched.h>
10 #include <linux/head.h>
11 #include <linux/kernel.h>
12 #include <linux/errno.h>
13 #include <linux/string.h>
14 #include <linux/types.h>
15 #include <linux/ptrace.h>
16 #include <linux/mman.h>
17 #include <linux/mm.h>
18
19 #include <asm/system.h>
20 #include <asm/segment.h>
21 #include <asm/vac-ops.h>
22 #include <asm/page.h>
23 #include <asm/pgtable.h>
24 #include <asm/vaddrs.h>
25
26 extern void show_net_buffers(void);
27
28 struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 pte_t *__bad_pagetable(void)
44 {
45 memset((void *) EMPTY_PGT, 0, PAGE_SIZE);
46 return (pte_t *) EMPTY_PGT;
47 }
48
49 pte_t __bad_page(void)
50 {
51 memset((void *) EMPTY_PGE, 0, PAGE_SIZE);
52 return pte_mkdirty(mk_pte((unsigned long) EMPTY_PGE, PAGE_SHARED));
53 }
54
55 unsigned long __zero_page(void)
56 {
57 memset((void *) ZERO_PGE, 0, PAGE_SIZE);
58 return (unsigned long) ZERO_PGE;
59 }
60
61 void show_mem(void)
62 {
63 int i,free = 0,total = 0,reserved = 0;
64 int shared = 0;
65
66 printk("\nMem-info:\n");
67 show_free_areas();
68 printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10));
69 i = MAP_NR(high_memory);
70 while (i-- > 0) {
71 total++;
72 if (mem_map[i].reserved)
73 reserved++;
74 else if (!mem_map[i].count)
75 free++;
76 else
77 shared += mem_map[i].count-1;
78 }
79 printk("%d pages of RAM\n",total);
80 printk("%d free pages\n",free);
81 printk("%d reserved pages\n",reserved);
82 printk("%d pages shared\n",shared);
83 show_buffers();
84 #ifdef CONFIG_NET
85 show_net_buffers();
86 #endif
87 }
88
89 extern pgprot_t protection_map[16];
90
91
92
93
94
95
96 extern unsigned long sun4c_paging_init(unsigned long, unsigned long);
97 extern unsigned long srmmu_paging_init(unsigned long, unsigned long);
98 extern unsigned long probe_devices(unsigned long);
99
100 unsigned long paging_init(unsigned long start_mem, unsigned long end_mem)
101 {
102 switch(sparc_cpu_model) {
103 case sun4c:
104 case sun4e:
105 start_mem = sun4c_paging_init(start_mem, end_mem);
106 break;
107 case sun4m:
108 case sun4d:
109 start_mem = srmmu_paging_init(start_mem, end_mem);
110 break;
111 default:
112 printk("paging_init: Cannot init paging on this Sparc\n");
113 printk("paging_init: sparc_cpu_model = %d\n", sparc_cpu_model);
114 printk("paging_init: Halting...\n");
115 panic("paging_init");
116 };
117
118
119
120
121 protection_map[0] = PAGE_NONE;
122 protection_map[1] = PAGE_READONLY;
123 protection_map[2] = PAGE_COPY;
124 protection_map[3] = PAGE_COPY;
125 protection_map[4] = PAGE_READONLY;
126 protection_map[5] = PAGE_READONLY;
127 protection_map[6] = PAGE_COPY;
128 protection_map[7] = PAGE_COPY;
129 protection_map[8] = PAGE_NONE;
130 protection_map[9] = PAGE_READONLY;
131 protection_map[10] = PAGE_SHARED;
132 protection_map[11] = PAGE_SHARED;
133 protection_map[12] = PAGE_READONLY;
134 protection_map[13] = PAGE_READONLY;
135 protection_map[14] = PAGE_SHARED;
136 protection_map[15] = PAGE_SHARED;
137 return probe_devices(start_mem);
138 }
139
140 extern void sun4c_test_wp(void);
141 extern void sun4c_lock_entire_kernel(unsigned long start_mem);
142 extern void srmmu_test_wp(void);
143
144 void mem_init(unsigned long start_mem, unsigned long end_mem)
145 {
146 int codepages = 0;
147 int datapages = 0;
148 unsigned long tmp2, addr;
149 extern char etext;
150
151 end_mem &= PAGE_MASK;
152 high_memory = end_mem;
153
154 start_mem = PAGE_ALIGN(start_mem);
155
156 addr = PAGE_OFFSET;
157 while(addr < start_mem) {
158 mem_map[MAP_NR(addr)].reserved = 1;
159 addr += PAGE_SIZE;
160 }
161
162 for(addr = start_mem; addr < end_mem; addr += PAGE_SIZE) {
163 for(tmp2=0; sp_banks[tmp2].num_bytes != 0; tmp2++) {
164 unsigned long phys_addr = (addr - PAGE_OFFSET);
165 unsigned long base = sp_banks[tmp2].base_addr;
166 unsigned long limit = base + sp_banks[tmp2].num_bytes;
167
168 if((phys_addr >= base) && (phys_addr < limit) &&
169 ((phys_addr + PAGE_SIZE) < limit))
170 mem_map[MAP_NR(addr)].reserved = 0;
171 }
172 }
173 for (addr = PAGE_OFFSET; addr < end_mem; addr += PAGE_SIZE) {
174 if(mem_map[MAP_NR(addr)].reserved) {
175 if (addr < (unsigned long) &etext)
176 codepages++;
177 else if(addr < start_mem)
178 datapages++;
179 continue;
180 }
181 mem_map[MAP_NR(addr)].count = 1;
182 free_page(addr);
183 }
184
185 tmp2 = nr_free_pages << PAGE_SHIFT;
186
187 printk("Memory: %luk available (%dk kernel code, %dk data)\n",
188 tmp2 >> 10,
189 codepages << (PAGE_SHIFT-10),
190 datapages << (PAGE_SHIFT-10));
191
192 switch(sparc_cpu_model) {
193 case sun4c:
194 case sun4e:
195 sun4c_lock_entire_kernel(start_mem);
196 sun4c_test_wp();
197 break;
198 case sun4m:
199 case sun4d:
200 srmmu_test_wp();
201 break;
202 default:
203 printk("mem_init: Could not test WP bit on this machine.\n");
204 printk("mem_init: sparc_cpu_model = %d\n", sparc_cpu_model);
205 printk("mem_init: Halting...\n");
206 panic("mem_init()");
207 };
208 }
209
210 void si_meminfo(struct sysinfo *val)
211 {
212 int i;
213
214 i = MAP_NR(high_memory);
215 val->totalram = 0;
216 val->sharedram = 0;
217 val->freeram = nr_free_pages << PAGE_SHIFT;
218 val->bufferram = buffermem;
219 while (i-- > 0) {
220 if (mem_map[i].reserved)
221 continue;
222 val->totalram++;
223 if (!mem_map[i].count)
224 continue;
225 val->sharedram += mem_map[i].count-1;
226 }
227 val->totalram <<= PAGE_SHIFT;
228 val->sharedram <<= PAGE_SHIFT;
229 }