OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [m68k/] [mm/] [init.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 *  linux/arch/m68k/mm/init.c
3
 *
4
 *  Copyright (C) 1995  Hamish Macdonald
5
 *
6
 *  Contains common initialization routines, specific init code moved
7
 *  to motorola.c and sun3mmu.c
8
 */
9
 
10
#include <linux/config.h>
11
#include <linux/signal.h>
12
#include <linux/sched.h>
13
#include <linux/mm.h>
14
#include <linux/swap.h>
15
#include <linux/kernel.h>
16
#include <linux/string.h>
17
#include <linux/types.h>
18
#include <linux/init.h>
19
#include <linux/bootmem.h>
20
#ifdef CONFIG_BLK_DEV_RAM
21
#include <linux/blk.h>
22
#endif
23
 
24
#include <asm/setup.h>
25
#include <asm/uaccess.h>
26
#include <asm/page.h>
27
#include <asm/pgalloc.h>
28
#include <asm/system.h>
29
#include <asm/machdep.h>
30
#include <asm/io.h>
31
#ifdef CONFIG_ATARI
32
#include <asm/atari_stram.h>
33
#endif
34
#include <asm/tlb.h>
35
 
36
mmu_gather_t mmu_gathers[NR_CPUS];
37
 
38
unsigned long totalram_pages = 0;
39
 
40
int do_check_pgt_cache(int low, int high)
41
{
42
        int freed = 0;
43
        if(pgtable_cache_size > high) {
44
                do {
45
                        if(pmd_quicklist)
46
                                freed += free_pmd_slow(get_pmd_fast());
47
                        if(pte_quicklist)
48
                                free_pte_slow(get_pte_fast()), freed++;
49
                } while(pgtable_cache_size > low);
50
        }
51
        return freed;
52
}
53
 
54
/*
55
 * BAD_PAGE is the page that is used for page faults when linux
56
 * is out-of-memory. Older versions of linux just did a
57
 * do_exit(), but using this instead means there is less risk
58
 * for a process dying in kernel mode, possibly leaving an inode
59
 * unused etc..
60
 *
61
 * BAD_PAGETABLE is the accompanying page-table: it is initialized
62
 * to point to BAD_PAGE entries.
63
 *
64
 * ZERO_PAGE is a special page that is used for zero-initialized
65
 * data and COW.
66
 */
67
unsigned long empty_bad_page_table;
68
 
69
pte_t *__bad_pagetable(void)
70
{
71
    memset((void *)empty_bad_page_table, 0, PAGE_SIZE);
72
    return (pte_t *)empty_bad_page_table;
73
}
74
 
75
unsigned long empty_bad_page;
76
 
77
pte_t __bad_page(void)
78
{
79
    memset ((void *)empty_bad_page, 0, PAGE_SIZE);
80
    return pte_mkdirty(__mk_pte(empty_bad_page, PAGE_SHARED));
81
}
82
 
83
unsigned long empty_zero_page;
84
 
85
void show_mem(void)
86
{
87
    unsigned long i;
88
    int free = 0, total = 0, reserved = 0, shared = 0;
89
    int cached = 0;
90
 
91
    printk("\nMem-info:\n");
92
    show_free_areas();
93
    printk("Free swap:       %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10));
94
    i = max_mapnr;
95
    while (i-- > 0) {
96
        total++;
97
        if (PageReserved(mem_map+i))
98
            reserved++;
99
        else if (PageSwapCache(mem_map+i))
100
            cached++;
101
        else if (!page_count(mem_map+i))
102
            free++;
103
        else
104
            shared += page_count(mem_map+i) - 1;
105
    }
106
    printk("%d pages of RAM\n",total);
107
    printk("%d free pages\n",free);
108
    printk("%d reserved pages\n",reserved);
109
    printk("%d pages shared\n",shared);
110
    printk("%d pages swap cached\n",cached);
111
    printk("%ld pages in page table cache\n",pgtable_cache_size);
112
    show_buffers();
113
}
114
 
115
extern void init_pointer_table(unsigned long ptable);
116
 
117
/* References to section boundaries */
118
 
119
extern char _text, _etext, _edata, __bss_start, _end;
120
extern char __init_begin, __init_end;
121
 
122
extern pmd_t *zero_pgtable;
123
 
124
void __init mem_init(void)
125
{
126
        int codepages = 0;
127
        int datapages = 0;
128
        int initpages = 0;
129
        unsigned long tmp;
130
        int i;
131
 
132
        max_mapnr = num_physpages = MAP_NR(high_memory);
133
 
134
#ifdef CONFIG_ATARI
135
        if (MACH_IS_ATARI)
136
                atari_stram_mem_init_hook();
137
#endif
138
 
139
        /* this will put all memory onto the freelists */
140
        totalram_pages = free_all_bootmem();
141
 
142
        for (tmp = PAGE_OFFSET ; tmp < (unsigned long)high_memory; tmp += PAGE_SIZE) {
143
#if 0
144
#ifndef CONFIG_SUN3
145
                if (virt_to_phys ((void *)tmp) >= mach_max_dma_address)
146
                        clear_bit(PG_DMA, &virt_to_page(tmp)->flags);
147
#endif
148
#endif
149
                if (PageReserved(virt_to_page(tmp))) {
150
                        if (tmp >= (unsigned long)&_text
151
                            && tmp < (unsigned long)&_etext)
152
                                codepages++;
153
                        else if (tmp >= (unsigned long) &__init_begin
154
                                 && tmp < (unsigned long) &__init_end)
155
                                initpages++;
156
                        else
157
                                datapages++;
158
                        continue;
159
                }
160
#if 0
161
                set_page_count(virt_to_page(tmp), 1);
162
#ifdef CONFIG_BLK_DEV_INITRD
163
                if (!initrd_start ||
164
                    (tmp < (initrd_start & PAGE_MASK) || tmp >= initrd_end))
165
#endif
166
                        free_page(tmp);
167
#endif
168
        }
169
 
170
#ifndef CONFIG_SUN3
171
        /* insert pointer tables allocated so far into the tablelist */
172
        init_pointer_table((unsigned long)kernel_pg_dir);
173
        for (i = 0; i < PTRS_PER_PGD; i++) {
174
                if (pgd_present(kernel_pg_dir[i]))
175
                        init_pointer_table(__pgd_page(kernel_pg_dir[i]));
176
        }
177
 
178
        /* insert also pointer table that we used to unmap the zero page */
179
        if (zero_pgtable)
180
                init_pointer_table((unsigned long)zero_pgtable);
181
#endif
182
 
183
        printk("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk init)\n",
184
               (unsigned long)nr_free_pages() << (PAGE_SHIFT-10),
185
               max_mapnr << (PAGE_SHIFT-10),
186
               codepages << (PAGE_SHIFT-10),
187
               datapages << (PAGE_SHIFT-10),
188
               initpages << (PAGE_SHIFT-10));
189
}
190
 
191
#ifdef CONFIG_BLK_DEV_INITRD
192
void free_initrd_mem(unsigned long start, unsigned long end)
193
{
194
        int pages = 0;
195
        for (; start < end; start += PAGE_SIZE) {
196
                ClearPageReserved(virt_to_page(start));
197
                set_page_count(virt_to_page(start), 1);
198
                free_page(start);
199
                totalram_pages++;
200
                pages++;
201
        }
202
        printk ("Freeing initrd memory: %dk freed\n", pages);
203
}
204
#endif
205
 
206
void si_meminfo(struct sysinfo *val)
207
{
208
    unsigned long i;
209
 
210
    i = max_mapnr;
211
    val->totalram = totalram_pages;
212
    val->sharedram = 0;
213
    val->freeram = nr_free_pages();
214
    val->bufferram = atomic_read(&buffermem_pages);
215
    val->totalhigh = 0;
216
    val->freehigh = 0;
217
    val->mem_unit = PAGE_SIZE;
218
    return;
219
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.