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