在arch/mips/include/asm/pgtable-32.h中:
#define VMALLOC_START MAP_BASE
#define PKMAP_BASE (0xfe000000UL)
#ifdef CONFIG_HIGHMEM
# define VMALLOC_END (PKMAP_BASE-2*PAGE_SIZE)
#else
# define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
#endif
其中的MAP_BASE定义在在arch/mips/include/asm/mach-generic/pgtable-32.h中:
#ifdef CONFIG_32BIT
#define CAC_BASE _AC(0x80000000, UL)
#define IO_BASE _AC(0xa0000000, UL)
#define UNCAC_BASE _AC(0xa0000000, UL)
#ifndef MAP_BASE
#define MAP_BASE _AC(0xc0000000, UL)
#endif
#endif
其中的FIXADDR_START定义在arch/mips/incude/asm/fixmap.h中:
/*
* used by vmalloc.c.
*
* Leave one empty page between vmalloc'ed areas and
* the start of the fixmap, and leave one page empty
* at the top of mem..
*/
#ifdef CONFIG_BCM63XX
#define FIXADDR_TOP ((unsigned long)(long)(int)0xff000000)
#else
#if defined(CONFIG_CPU_TX39XX) || defined(CONFIG_CPU_TX49XX)
#define FIXADDR_TOP ((unsigned long)(long)(int)(0xff000000 - 0x20000))
#else
#define FIXADDR_TOP ((unsigned long)(long)(int)0xfffe0000)
#endif
#endif
#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
__end_of_fixed_addresses的值见下面的enum
enum fixed_addresses {
#define FIX_N_COLOURS 8
FIX_CMAP_BEGIN,
#ifdef CONFIG_MIPS_MT_SMTC
FIX_CMAP_END = FIX_CMAP_BEGIN + (FIX_N_COLOURS * NR_CPUS * 2),
#else
FIX_CMAP_END = FIX_CMAP_BEGIN + (FIX_N_COLOURS * 2),
#endif
#ifdef CONFIG_HIGHMEM
/* reserved pte's for temporary kernel mappings */
FIX_KMAP_BEGIN = FIX_CMAP_END + 1,
FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
#endif
__end_of_fixed_addresses
};
所以对mips32而言
VMALLOC_START的值为0xc0000000UL
VMALLOC_END的值:
在未使能CONFIG_HIGHMEM时,VMALLOC_END
= (FIXADDR_START-2*PAGE_SIZE)
= (FIXADDR_TOP - FIXADDR_SIZE - 2*PAGE_SIZE)
= 0xfffe0000 - 0x2000 - (__end_of_fixed_addresses<<PAGE_SHIFT)
= 对于未定义CONFIG_MIPS_MT_SMTC且未使能CONFIG_HIGHMEM时,
= 0xfffe0000 - 0x2000 - (17<<PAGE_SHIFT)
= 0xFFFCD000
在使能CONFIG_HIGHMEM时,VMALLOC_END
= (PKMAP_BASE-2*PAGE_SIZE)
= 0xfe000000 - 0x2000
= 0xFDFFE000
下面是打印的结果(使能highmem)
[ 7.804000] sys_mips_mmap VMALLOC_START=0xc0000000, VMALLOC_END=0xfdffe000
下面是打印的结果(不使能highmem)
[ 41.592000] sys_mips_mmap VMALLOC_START=0xc0000000, VMALLOC_END=0xfffcd000