URL
https://opencores.org/ocsvn/or1k_old/or1k_old/trunk
Subversion Repositories or1k_old
Compare Revisions
- This comparison shows the changes necessary to convert path
/or1k_old/trunk/rc203soc/sw/uClinux/arch/or32/mm
- from Rev 1765 to Rev 1782
- ↔ Reverse comparison
Rev 1765 → Rev 1782
/init.c
0,0 → 1,209
/* |
* linux/arch/m68knommu/mm/init.c |
* |
* Based on: linux/arch/m68knommu/mm/init.c |
* |
*/ |
|
#include <linux/config.h> |
#include <linux/signal.h> |
#include <linux/sched.h> |
#include <linux/mm.h> |
#include <linux/swap.h> |
#include <linux/kernel.h> |
#include <linux/string.h> |
#include <linux/types.h> |
#ifdef CONFIG_BLK_DEV_RAM |
#include <linux/blk.h> |
#endif |
|
#include <asm/segment.h> |
#include <asm/page.h> |
#include <asm/pgtable.h> |
#include <asm/system.h> |
#include <asm/machdep.h> |
|
#ifndef PAGE_OFFSET |
#define PAGE_OFFSET 0 |
#endif |
|
extern void die_if_kernel(char *,struct pt_regs *,long); |
extern void show_net_buffers(void); |
|
/* |
* BAD_PAGE is the page that is used for page faults when linux |
* is out-of-memory. Older versions of linux just did a |
* do_exit(), but using this instead means there is less risk |
* for a process dying in kernel mode, possibly leaving a inode |
* unused etc.. |
* |
* BAD_PAGETABLE is the accompanying page-table: it is initialized |
* to point to BAD_PAGE entries. |
* |
* ZERO_PAGE is a special page that is used for zero-initialized |
* data and COW. |
*/ |
static unsigned long empty_bad_page_table; |
|
static unsigned long empty_bad_page; |
|
unsigned long empty_zero_page; |
|
extern unsigned long rom_length; |
|
void show_mem(void) |
{ |
unsigned long i; |
int free = 0, total = 0, reserved = 0, nonshared = 0, shared = 0; |
|
printk("\nMem-info:\n"); |
show_free_areas(); |
printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); |
i = high_memory >> PAGE_SHIFT; |
while (i-- > 0) { |
total++; |
if (PageReserved(mem_map+i)) |
reserved++; |
else if (!mem_map[i].count) |
free++; |
else if (mem_map[i].count == 1) |
nonshared++; |
else |
shared += mem_map[i].count-1; |
} |
printk("%d pages of RAM\n",total); |
printk("%d free pages\n",free); |
printk("%d reserved pages\n",reserved); |
printk("%d pages nonshared\n",nonshared); |
printk("%d pages shared\n",shared); |
show_buffers(); |
#ifdef CONFIG_NET |
show_net_buffers(); |
#endif |
} |
|
extern unsigned long free_area_init(unsigned long, unsigned long); |
|
/* |
* paging_init() continues the virtual memory environment setup which |
* was begun by the code in arch/head.S. |
* The parameters are pointers to where to stick the starting and ending |
* addresses of available kernel virtual memory. |
*/ |
unsigned long paging_init(unsigned long start_mem, unsigned long end_mem) |
{ |
#ifdef DEBUG |
printk ("start_mem is %#lx\nvirtual_end is %#lx\n", |
start_mem, end_mem); |
#endif |
|
/* |
* initialize the bad page table and bad page to point |
* to a couple of allocated pages |
*/ |
empty_bad_page_table = start_mem; |
start_mem += PAGE_SIZE; |
empty_bad_page = start_mem; |
start_mem += PAGE_SIZE; |
empty_zero_page = start_mem; |
start_mem += PAGE_SIZE; |
memset((void *)empty_zero_page, 0, PAGE_SIZE); |
|
/* |
* Set up SFC/DFC registers (user data space) |
*/ |
set_fs (USER_DS); |
|
#ifdef DEBUG |
printk ("before free_area_init\n"); |
|
printk ("free_area_init -> start_mem is %#lx\nvirtual_end is %#lx\n", |
start_mem, end_mem); |
#endif |
|
return PAGE_ALIGN(free_area_init (start_mem, end_mem)); |
} |
|
void mem_init(unsigned long start_mem, unsigned long end_mem) |
{ |
int codek = 0; |
int datapages = 0; |
unsigned long tmp; |
extern char _etext, __data_start; |
unsigned long len = end_mem-(unsigned long)&__data_start; |
#ifdef CONFIG_ROMKERNEL |
extern char _romvec; |
#else |
extern char _ramvec; |
#endif |
|
#ifdef DEBUG |
printk("Mem_init: start=%lx, end=%lx\n", start_mem, end_mem); |
#endif |
|
end_mem &= PAGE_MASK; |
high_memory = end_mem; |
|
start_mem = PAGE_ALIGN(start_mem); |
while (start_mem < high_memory) { |
clear_bit(PG_reserved, &mem_map[MAP_NR(start_mem)].flags); |
start_mem += PAGE_SIZE; |
} |
|
for (tmp = PAGE_OFFSET ; tmp < end_mem ; tmp += PAGE_SIZE) { |
|
#ifdef MAX_DMA_ADDRESS |
if (VTOP (tmp) >= MAX_DMA_ADDRESS) |
clear_bit(PG_DMA, &mem_map[MAP_NR(tmp)].flags); |
#endif |
|
if (PageReserved(mem_map+MAP_NR(tmp))) { |
datapages++; |
continue; |
} |
mem_map[MAP_NR(tmp)].count = 1; |
#ifdef CONFIG_BLK_DEV_INITRD |
if (!initrd_start || |
(tmp < (initrd_start & PAGE_MASK) || tmp >= initrd_end)) |
#endif |
free_page(tmp); |
} |
|
#ifdef CONFIG_ROMKERNEL |
codek = (&_etext - &_romvec) >> 10; |
#else |
codek = (&_etext - &_ramvec) >> 10; |
#endif |
tmp = nr_free_pages << PAGE_SHIFT; |
printk("Memory available: %luk/%luk RAM, %luk/%luk ROM (%dk kernel data, %dk code)\n", |
tmp >> 10, |
len >> 10, |
(rom_length > 0) ? ((rom_length >> 10) - codek) : 0, |
rom_length >> 10, |
datapages << (PAGE_SHIFT-10), |
codek |
); |
} |
|
void si_meminfo(struct sysinfo *val) |
{ |
unsigned long i; |
|
i = (high_memory - PAGE_OFFSET) >> PAGE_SHIFT; |
val->totalram = 0; |
val->sharedram = 0; |
val->freeram = nr_free_pages << PAGE_SHIFT; |
val->bufferram = buffermem; |
while (i-- > 0) { |
if (PageReserved(mem_map+i)) |
continue; |
val->totalram++; |
if (!mem_map[i].count) |
continue; |
val->sharedram += mem_map[i].count-1; |
} |
val->totalram <<= PAGE_SHIFT; |
val->sharedram <<= PAGE_SHIFT; |
return; |
} |
|
/memory.c
0,0 → 1,107
/* |
* linux/arch/or32/mm/memory.c |
* |
* Based on: linux/arch/m68knommu/mm/memory.c |
*/ |
|
#include <linux/config.h> |
#include <linux/mm.h> |
#include <linux/kernel.h> |
#include <linux/string.h> |
#include <linux/types.h> |
#include <linux/malloc.h> |
|
#include <asm/segment.h> |
#include <asm/page.h> |
#include <asm/pgtable.h> |
#include <asm/system.h> |
#include <asm/traps.h> |
|
/* |
* The following two routines map from a physical address to a kernel |
* virtual address and vice versa. |
*/ |
unsigned long mm_vtop (unsigned long vaddr) |
{ |
return vaddr; |
} |
|
unsigned long mm_ptov (unsigned long paddr) |
{ |
return paddr; |
} |
|
/* |
* cache_clear() semantics: Clear any cache entries for the area in question, |
* without writing back dirty entries first. This is useful if the data will |
* be overwritten anyway, e.g. by DMA to memory. The range is defined by a |
* _physical_ address. |
*/ |
|
void cache_clear (unsigned long paddr, int len) |
{ |
} |
|
|
/* |
* cache_push() semantics: Write back any dirty cache data in the given area, |
* and invalidate the range in the instruction cache. It needs not (but may) |
* invalidate those entries also in the data cache. The range is defined by a |
* _physical_ address. |
*/ |
|
void cache_push (unsigned long paddr, int len) |
{ |
} |
|
|
/* |
* cache_push_v() semantics: Write back any dirty cache data in the given |
* area, and invalidate those entries at least in the instruction cache. This |
* is intended to be used after data has been written that can be executed as |
* code later. The range is defined by a _user_mode_ _virtual_ address (or, |
* more exactly, the space is defined by the %sfc/%dfc register.) |
*/ |
|
void cache_push_v (unsigned long vaddr, int len) |
{ |
} |
|
unsigned long mm_phys_to_virt (unsigned long addr) |
{ |
return PTOV (addr); |
} |
|
/* Map some physical address range into the kernel address space. The |
* code is copied and adapted from map_chunk(). |
*/ |
|
unsigned long kernel_map(unsigned long paddr, unsigned long size, |
int nocacheflag, unsigned long *memavailp ) |
{ |
return paddr; |
} |
|
|
void kernel_set_cachemode( unsigned long address, unsigned long size, |
unsigned cmode ) |
{ |
} |
|
#ifdef MAGIC_ROM_PTR |
#ifdef CONFIG_ROMKERNEL |
int is_in_rom(unsigned long addr) { |
extern unsigned long __rom_start, _flashend; |
|
/* Anything not in operational RAM is returned as in rom! */ |
if ((addr >= (unsigned long)&__rom_start) && (addr < (unsigned long)&_flashend)) |
return(1); |
return(0); |
} |
#else |
int is_in_rom(unsigned long addr) { |
return 0; |
} |
#endif |
#endif |
|
/.depend
0,0 → 1,27
init.o: \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/config.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/signal.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/sched.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/mm.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/swap.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/kernel.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/string.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/types.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/blk.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/asm/segment.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/asm/page.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/asm/pgtable.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/asm/system.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/asm/machdep.h |
memory.o: \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/config.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/mm.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/kernel.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/string.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/types.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/linux/malloc.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/asm/segment.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/asm/page.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/asm/pgtable.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/asm/system.h \ |
/home/javier/opencores/or1k/rc203soc/sw/uClinux/include/asm/traps.h |
/Makefile
0,0 → 1,13
# |
# Makefile for the linux m68k-specific parts of the memory manager. |
# |
# Note! Dependencies are done automagically by 'make dep', which also |
# removes any old dependencies. DON'T put your own dependencies here |
# unless it's something special (ie not a .c file). |
# |
# Note 2! The CFLAGS definition is now in the main makefile... |
|
O_TARGET := mm.o |
O_OBJS := init.o memory.o |
|
include $(TOPDIR)/Rules.make |