xref: /OK3568_Linux_fs/kernel/arch/mips/mm/pgtable.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * This file is subject to the terms and conditions of the GNU General Public
3*4882a593Smuzhiyun  * License.  See the file "COPYING" in the main directory of this archive
4*4882a593Smuzhiyun  * for more details.
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun #include <linux/export.h>
7*4882a593Smuzhiyun #include <linux/mm.h>
8*4882a593Smuzhiyun #include <linux/string.h>
9*4882a593Smuzhiyun #include <asm/pgalloc.h>
10*4882a593Smuzhiyun 
pgd_alloc(struct mm_struct * mm)11*4882a593Smuzhiyun pgd_t *pgd_alloc(struct mm_struct *mm)
12*4882a593Smuzhiyun {
13*4882a593Smuzhiyun 	pgd_t *ret, *init;
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun 	ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
16*4882a593Smuzhiyun 	if (ret) {
17*4882a593Smuzhiyun 		init = pgd_offset(&init_mm, 0UL);
18*4882a593Smuzhiyun 		pgd_init((unsigned long)ret);
19*4882a593Smuzhiyun 		memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,
20*4882a593Smuzhiyun 		       (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
21*4882a593Smuzhiyun 	}
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun 	return ret;
24*4882a593Smuzhiyun }
25*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(pgd_alloc);
26