/* * linux/mm/nommu.c * * Replacement code for mm functions to support CPU's that don't * have any form of memory management unit (thus no virtual memory). * * See Documentation/nommu-mmap.txt * * Copyright (c) 2004-2005 David Howells <dhowells@redhat.com> * Copyright (c) 2000-2003 David McCullough <davidm@snapgear.com> * Copyright (c) 2000-2001 D Jeff Dionne <jeff@uClinux.org> * Copyright (c) 2002 Greg Ungerer <gerg@snapgear.com> */#include<linux/mm.h>#include<linux/mman.h>#include<linux/swap.h>#include<linux/file.h>#include<linux/highmem.h>#include<linux/pagemap.h>#include<linux/slab.h>#include<linux/vmalloc.h>#include<linux/ptrace.h>#include<linux/blkdev.h>#include<linux/backing-dev.h>#include<linux/mount.h>#include<linux/personality.h>#include<linux/security.h>#include<linux/syscalls.h>#include<asm/uaccess.h>#include<asm/tlb.h>#include<asm/tlbflush.h>void*high_memory;structpage*mem_map;unsignedlongmax_mapnr;unsignedlongnum_physpages;unsignedlongaskedalloc,realalloc;atomic_tvm_committed_space=ATOMIC_INIT(0);intsysctl_overcommit_memory=OVERCOMMIT_GUESS;/* heuristic overcommit */intsysctl_overcommit_ratio=50;/* default is 50% */intsysctl_max_map_count=DEFAULT_MAX_MAP_COUNT;intheap_stack_gap=0;EXPORT_SYMBOL(mem_map);EXPORT_SYMBOL(__vm_enough_memory);/* list of shareable VMAs */structrb_rootnommu_vma_tree=RB_ROOT;DECLARE_RWSEM(nommu_vma_sem);structvm_operations_structgeneric_file_vm_ops={};EXPORT_SYMBOL(vfree);EXPORT_SYMBOL(vmalloc_to_page);EXPORT_SYMBOL(vmalloc_32);EXPORT_SYMBOL(vmap);EXPORT_SYMBOL(vunmap);/* * Handle all mappings that got truncated by a "truncate()" * system call. * * NOTE! We have to be ready to update the memory sharing * between the file and the memory map for a potential last * incomplete page. Ugly, but necessary. */intvmtruncate(structinode*inode,loff_toffset){structaddress_space*mapping=inode->i_mapping;unsignedlonglimit;if(inode->i_size<offset)gotodo_expand;i_size_write(inode,offset);truncate_inode_pages(mapping,offset);gotoout_truncate;do_expand:limit=current->signal->rlim[RLIMIT_FSIZE].rlim_cur;if(limit!=RLIM_INFINITY&&offset>limit)gotoout_sig;if(offset>inode->i_sb->s_maxbytes)goto