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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [m68knommu/] [mm/] [init.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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