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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [arch/] [or32/] [mm/] [init.c] - Blame information for rev 863

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 666 simons
/*
2
 *  linux/arch/m68knommu/mm/init.c
3
 *
4
 *  Based on: linux/arch/m68knommu/mm/init.c
5
 *
6
 */
7
 
8
#include <linux/config.h>
9
#include <linux/signal.h>
10
#include <linux/sched.h>
11
#include <linux/mm.h>
12
#include <linux/swap.h>
13
#include <linux/kernel.h>
14
#include <linux/string.h>
15
#include <linux/types.h>
16
#ifdef CONFIG_BLK_DEV_RAM
17
#include <linux/blk.h>
18
#endif
19
 
20
#include <asm/segment.h>
21
#include <asm/page.h>
22
#include <asm/pgtable.h>
23
#include <asm/system.h>
24
#include <asm/machdep.h>
25
 
26
#ifndef PAGE_OFFSET
27
#define PAGE_OFFSET 0
28
#endif
29
 
30
extern void die_if_kernel(char *,struct pt_regs *,long);
31
extern void show_net_buffers(void);
32
 
33
/*
34
 * BAD_PAGE is the page that is used for page faults when linux
35
 * is out-of-memory. Older versions of linux just did a
36
 * do_exit(), but using this instead means there is less risk
37
 * for a process dying in kernel mode, possibly leaving a inode
38
 * unused etc..
39
 *
40
 * BAD_PAGETABLE is the accompanying page-table: it is initialized
41
 * to point to BAD_PAGE entries.
42
 *
43
 * ZERO_PAGE is a special page that is used for zero-initialized
44
 * data and COW.
45
 */
46
static unsigned long empty_bad_page_table;
47
 
48
static unsigned long empty_bad_page;
49
 
50
unsigned long empty_zero_page;
51
 
52
extern unsigned long rom_length;
53
 
54
void show_mem(void)
55
{
56
    unsigned long i;
57
    int free = 0, total = 0, reserved = 0, nonshared = 0, shared = 0;
58
 
59
    printk("\nMem-info:\n");
60
    show_free_areas();
61
    printk("Free swap:       %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10));
62
    i = high_memory >> PAGE_SHIFT;
63
    while (i-- > 0) {
64
        total++;
65
        if (PageReserved(mem_map+i))
66
            reserved++;
67
        else if (!mem_map[i].count)
68
            free++;
69
        else if (mem_map[i].count == 1)
70
            nonshared++;
71
        else
72
            shared += mem_map[i].count-1;
73
    }
74
    printk("%d pages of RAM\n",total);
75
    printk("%d free pages\n",free);
76
    printk("%d reserved pages\n",reserved);
77
    printk("%d pages nonshared\n",nonshared);
78
    printk("%d pages shared\n",shared);
79
    show_buffers();
80
#ifdef CONFIG_NET
81
    show_net_buffers();
82
#endif
83
}
84
 
85
extern unsigned long free_area_init(unsigned long, unsigned long);
86
 
87
/*
88
 * paging_init() continues the virtual memory environment setup which
89
 * was begun by the code in arch/head.S.
90
 * The parameters are pointers to where to stick the starting and ending
91
 * addresses  of available kernel virtual memory.
92
 */
93
unsigned long paging_init(unsigned long start_mem, unsigned long end_mem)
94
{
95
#ifdef DEBUG
96
        printk ("start_mem is %#lx\nvirtual_end is %#lx\n",
97
                start_mem, end_mem);
98
#endif
99
 
100
        /*
101
         * initialize the bad page table and bad page to point
102
         * to a couple of allocated pages
103
         */
104
        empty_bad_page_table = start_mem;
105
        start_mem += PAGE_SIZE;
106
        empty_bad_page = start_mem;
107
        start_mem += PAGE_SIZE;
108
        empty_zero_page = start_mem;
109
        start_mem += PAGE_SIZE;
110
        memset((void *)empty_zero_page, 0, PAGE_SIZE);
111
 
112
        /*
113
         * Set up SFC/DFC registers (user data space)
114
         */
115
        set_fs (USER_DS);
116
 
117
#ifdef DEBUG
118
        printk ("before free_area_init\n");
119
 
120
        printk ("free_area_init -> start_mem is %#lx\nvirtual_end is %#lx\n",
121
                start_mem, end_mem);
122
#endif
123
 
124
        return PAGE_ALIGN(free_area_init (start_mem, end_mem));
125
}
126
 
127
void mem_init(unsigned long start_mem, unsigned long end_mem)
128
{
129
        int codek = 0;
130
        int datapages = 0;
131
        unsigned long tmp;
132 863 simons
        extern char _etext, __data_start;
133 666 simons
        unsigned long len = end_mem-(unsigned long)&__data_start;
134 863 simons
#ifdef CONFIG_ROMKERNEL
135
        extern char _romvec;
136
#else
137
        extern char _ramvec;
138
#endif
139 666 simons
 
140
#ifdef DEBUG
141
        printk("Mem_init: start=%lx, end=%lx\n", start_mem, end_mem);
142
#endif
143
 
144
        end_mem &= PAGE_MASK;
145
        high_memory = end_mem;
146
 
147
        start_mem = PAGE_ALIGN(start_mem);
148
        while (start_mem < high_memory) {
149
                clear_bit(PG_reserved, &mem_map[MAP_NR(start_mem)].flags);
150
                start_mem += PAGE_SIZE;
151
        }
152
 
153
        for (tmp = PAGE_OFFSET ; tmp < end_mem ; tmp += PAGE_SIZE) {
154
 
155
#ifdef MAX_DMA_ADDRESS
156
                if (VTOP (tmp) >= MAX_DMA_ADDRESS)
157
                        clear_bit(PG_DMA, &mem_map[MAP_NR(tmp)].flags);
158
#endif
159
 
160
                if (PageReserved(mem_map+MAP_NR(tmp))) {
161
                        datapages++;
162
                        continue;
163
                }
164
                mem_map[MAP_NR(tmp)].count = 1;
165
#ifdef CONFIG_BLK_DEV_INITRD
166
                if (!initrd_start ||
167
                    (tmp < (initrd_start & PAGE_MASK) || tmp >= initrd_end))
168
#endif
169
                        free_page(tmp);
170
        }
171
 
172 863 simons
#ifdef CONFIG_ROMKERNEL
173 666 simons
        codek = (&_etext - &_romvec) >> 10;
174 863 simons
#else
175
        codek = (&_etext - &_ramvec) >> 10;
176
#endif
177 666 simons
        tmp = nr_free_pages << PAGE_SHIFT;
178
        printk("Memory available: %luk/%luk RAM, %luk/%luk ROM (%dk kernel data, %dk code)\n",
179
               tmp >> 10,
180
               len >> 10,
181
               (rom_length > 0) ? ((rom_length >> 10) - codek) : 0,
182
               rom_length >> 10,
183
               datapages << (PAGE_SHIFT-10),
184
               codek
185
               );
186
}
187
 
188
void si_meminfo(struct sysinfo *val)
189
{
190
    unsigned long i;
191
 
192
    i = (high_memory - PAGE_OFFSET) >> PAGE_SHIFT;
193
    val->totalram = 0;
194
    val->sharedram = 0;
195
    val->freeram = nr_free_pages << PAGE_SHIFT;
196
    val->bufferram = buffermem;
197
    while (i-- > 0) {
198
        if (PageReserved(mem_map+i))
199
            continue;
200
        val->totalram++;
201
        if (!mem_map[i].count)
202
            continue;
203
        val->sharedram += mem_map[i].count-1;
204
    }
205
    val->totalram <<= PAGE_SHIFT;
206
    val->sharedram <<= PAGE_SHIFT;
207
    return;
208
}
209
 

powered by: WebSVN 2.1.0

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