Commit 155bb144 authored by Russell King's avatar Russell King

[PATCH] ARM: Add inline functions to find the pmd from virtual address

Add pmd_off() and pmd_off_k() to obtain the pmd pointer for a
virtual address, and use them throughout the mm initialisation.
Signed-off-by: default avatarRussell King <rmk@arm.linux.org.uk>
parent 88d7bd8c
...@@ -142,6 +142,16 @@ __setup("noalign", noalign_setup); ...@@ -142,6 +142,16 @@ __setup("noalign", noalign_setup);
#define FIRST_KERNEL_PGD_NR (FIRST_USER_PGD_NR + USER_PTRS_PER_PGD) #define FIRST_KERNEL_PGD_NR (FIRST_USER_PGD_NR + USER_PTRS_PER_PGD)
static inline pmd_t *pmd_off(pgd_t *pgd, unsigned long virt)
{
return pmd_offset(pgd, virt);
}
static inline pmd_t *pmd_off_k(unsigned long virt)
{
return pmd_off(pgd_offset_k(virt), virt);
}
/* /*
* need to get a 16k page for level 1 * need to get a 16k page for level 1
*/ */
...@@ -220,7 +230,7 @@ void free_pgd_slow(pgd_t *pgd) ...@@ -220,7 +230,7 @@ void free_pgd_slow(pgd_t *pgd)
return; return;
/* pgd is always present and good */ /* pgd is always present and good */
pmd = (pmd_t *)pgd; pmd = pmd_off(pgd, 0);
if (pmd_none(*pmd)) if (pmd_none(*pmd))
goto free; goto free;
if (pmd_bad(*pmd)) { if (pmd_bad(*pmd)) {
...@@ -246,9 +256,8 @@ free: ...@@ -246,9 +256,8 @@ free:
static inline void static inline void
alloc_init_section(unsigned long virt, unsigned long phys, int prot) alloc_init_section(unsigned long virt, unsigned long phys, int prot)
{ {
pmd_t *pmdp; pmd_t *pmdp = pmd_off_k(virt);
pmdp = pmd_offset(pgd_offset_k(virt), virt);
if (virt & (1 << 20)) if (virt & (1 << 20))
pmdp++; pmdp++;
...@@ -283,11 +292,9 @@ alloc_init_supersection(unsigned long virt, unsigned long phys, int prot) ...@@ -283,11 +292,9 @@ alloc_init_supersection(unsigned long virt, unsigned long phys, int prot)
static inline void static inline void
alloc_init_page(unsigned long virt, unsigned long phys, unsigned int prot_l1, pgprot_t prot) alloc_init_page(unsigned long virt, unsigned long phys, unsigned int prot_l1, pgprot_t prot)
{ {
pmd_t *pmdp; pmd_t *pmdp = pmd_off_k(virt);
pte_t *ptep; pte_t *ptep;
pmdp = pmd_offset(pgd_offset_k(virt), virt);
if (pmd_none(*pmdp)) { if (pmd_none(*pmdp)) {
unsigned long pmdval; unsigned long pmdval;
ptep = alloc_bootmem_low_pages(2 * PTRS_PER_PTE * ptep = alloc_bootmem_low_pages(2 * PTRS_PER_PTE *
...@@ -310,7 +317,7 @@ alloc_init_page(unsigned long virt, unsigned long phys, unsigned int prot_l1, pg ...@@ -310,7 +317,7 @@ alloc_init_page(unsigned long virt, unsigned long phys, unsigned int prot_l1, pg
*/ */
static inline void clear_mapping(unsigned long virt) static inline void clear_mapping(unsigned long virt)
{ {
pmd_clear(pmd_offset(pgd_offset_k(virt), virt)); pmd_clear(pmd_off_k(virt));
} }
struct mem_types { struct mem_types {
...@@ -578,7 +585,7 @@ void setup_mm_for_reboot(char mode) ...@@ -578,7 +585,7 @@ void setup_mm_for_reboot(char mode)
PMD_TYPE_SECT; PMD_TYPE_SECT;
if (cpu_arch <= CPU_ARCH_ARMv5) if (cpu_arch <= CPU_ARCH_ARMv5)
pmdval |= PMD_BIT4; pmdval |= PMD_BIT4;
pmd = pmd_offset(pgd + i, i << PGDIR_SHIFT); pmd = pmd_off(pgd, i << PGDIR_SHIFT);
pmd[0] = __pmd(pmdval); pmd[0] = __pmd(pmdval);
pmd[1] = __pmd(pmdval + (1 << (PGDIR_SHIFT - 1))); pmd[1] = __pmd(pmdval + (1 << (PGDIR_SHIFT - 1)));
flush_pmd_entry(pmd); flush_pmd_entry(pmd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment