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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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