This source file includes following definitions.
- __bad_pagetable
- __bad_page
- show_mem
- load_PCB
- 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/pgtable.h>
22 #include <asm/hwrpb.h>
23
24 extern void die_if_kernel(char *,struct pt_regs *,long);
25 extern void show_net_buffers(void);
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 pmd_t * __bad_pagetable(void)
41 {
42 memset((void *) EMPTY_PGT, 0, PAGE_SIZE);
43 return (pmd_t *) EMPTY_PGT;
44 }
45
46 pte_t __bad_page(void)
47 {
48 memset((void *) EMPTY_PGE, 0, PAGE_SIZE);
49 return pte_mkdirty(mk_pte((unsigned long) EMPTY_PGE, PAGE_SHARED));
50 }
51
52 void show_mem(void)
53 {
54 int i,free = 0,total = 0,reserved = 0;
55 int shared = 0;
56
57 printk("\nMem-info:\n");
58 show_free_areas();
59 printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10));
60 i = MAP_NR(high_memory);
61 while (i-- > 0) {
62 total++;
63 if (mem_map[i].reserved)
64 reserved++;
65 else if (!mem_map[i].count)
66 free++;
67 else
68 shared += mem_map[i].count-1;
69 }
70 printk("%d pages of RAM\n",total);
71 printk("%d free pages\n",free);
72 printk("%d reserved pages\n",reserved);
73 printk("%d pages shared\n",shared);
74 show_buffers();
75 #ifdef CONFIG_NET
76 show_net_buffers();
77 #endif
78 }
79
80 extern unsigned long free_area_init(unsigned long, unsigned long);
81
82 static void load_PCB(struct thread_struct * pcb)
83 {
84 __asm__ __volatile__(
85 "stq $30,0(%0)\n\t"
86 "bis %0,%0,$16\n\t"
87 "call_pal %1"
88 :
89 : "r" (pcb), "i" (PAL_swpctx)
90 : "$0", "$1", "$16", "$22", "$23", "$24", "$25");
91 }
92
93
94
95
96
97 unsigned long paging_init(unsigned long start_mem, unsigned long end_mem)
98 {
99 int i;
100 unsigned long newptbr;
101 struct memclust_struct * cluster;
102 struct memdesc_struct * memdesc;
103
104
105 start_mem = free_area_init(start_mem, end_mem);
106
107
108 memdesc = (struct memdesc_struct *) (INIT_HWRPB->mddt_offset + (unsigned long) INIT_HWRPB);
109 cluster = memdesc->cluster;
110 for (i = memdesc->numclusters ; i > 0; i--, cluster++) {
111 unsigned long pfn, nr;
112 if (cluster->usage & 1)
113 continue;
114 pfn = cluster->start_pfn;
115 nr = cluster->numpages;
116
117
118 if (cluster->usage & 2)
119 continue;
120
121 while (nr--)
122 mem_map[pfn++].reserved = 0;
123 }
124
125
126
127 memset((void *) ZERO_PAGE, 0, PAGE_SIZE);
128 memset(swapper_pg_dir, 0, PAGE_SIZE);
129 newptbr = ((unsigned long) swapper_pg_dir - PAGE_OFFSET) >> PAGE_SHIFT;
130 pgd_val(swapper_pg_dir[1023]) = (newptbr << 32) | pgprot_val(PAGE_KERNEL);
131 init_task.tss.ptbr = newptbr;
132 init_task.tss.flags = 1;
133 init_task.kernel_stack_page = INIT_STACK;
134 load_PCB(&init_task.tss);
135
136 invalidate_all();
137 return start_mem;
138 }
139
140 void mem_init(unsigned long start_mem, unsigned long end_mem)
141 {
142 unsigned long tmp;
143
144 end_mem &= PAGE_MASK;
145 high_memory = end_mem;
146 start_mem = PAGE_ALIGN(start_mem);
147
148
149
150
151 tmp = KERNEL_START;
152 while (tmp < start_mem) {
153 mem_map[MAP_NR(tmp)].reserved = 1;
154 tmp += PAGE_SIZE;
155 }
156
157 for (tmp = PAGE_OFFSET ; tmp < high_memory ; tmp += PAGE_SIZE) {
158 if (mem_map[MAP_NR(tmp)].reserved)
159 continue;
160 mem_map[MAP_NR(tmp)].count = 1;
161 free_page(tmp);
162 }
163 tmp = nr_free_pages << PAGE_SHIFT;
164 printk("Memory: %luk available\n", tmp >> 10);
165 return;
166 }
167
168 void si_meminfo(struct sysinfo *val)
169 {
170 int i;
171
172 i = MAP_NR(high_memory);
173 val->totalram = 0;
174 val->sharedram = 0;
175 val->freeram = nr_free_pages << PAGE_SHIFT;
176 val->bufferram = buffermem;
177 while (i-- > 0) {
178 if (mem_map[i].reserved)
179 continue;
180 val->totalram++;
181 if (!mem_map[i].count)
182 continue;
183 val->sharedram += mem_map[i].count-1;
184 }
185 val->totalram <<= PAGE_SHIFT;
186 val->sharedram <<= PAGE_SHIFT;
187 return;
188 }