Skip to content

Commit

Permalink
[PATCH] ARM: Add inline functions to find the pmd from virtual address
Browse files Browse the repository at this point in the history
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: Russell King <rmk@arm.linux.org.uk>
  • Loading branch information
Russell King committed May 9, 2005
1 parent 88d7bd8 commit 155bb14
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions arch/arm/mm/mm-armv.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ __setup("noalign", noalign_setup);

#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
*/
Expand Down Expand Up @@ -220,7 +230,7 @@ void free_pgd_slow(pgd_t *pgd)
return;

/* pgd is always present and good */
pmd = (pmd_t *)pgd;
pmd = pmd_off(pgd, 0);
if (pmd_none(*pmd))
goto free;
if (pmd_bad(*pmd)) {
Expand All @@ -246,9 +256,8 @@ void free_pgd_slow(pgd_t *pgd)
static inline void
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))
pmdp++;

Expand Down Expand Up @@ -283,11 +292,9 @@ alloc_init_supersection(unsigned long virt, unsigned long phys, int prot)
static inline void
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;

pmdp = pmd_offset(pgd_offset_k(virt), virt);

if (pmd_none(*pmdp)) {
unsigned long pmdval;
ptep = alloc_bootmem_low_pages(2 * PTRS_PER_PTE *
Expand All @@ -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)
{
pmd_clear(pmd_offset(pgd_offset_k(virt), virt));
pmd_clear(pmd_off_k(virt));
}

struct mem_types {
Expand Down Expand Up @@ -578,7 +585,7 @@ void setup_mm_for_reboot(char mode)
PMD_TYPE_SECT;
if (cpu_arch <= CPU_ARCH_ARMv5)
pmdval |= PMD_BIT4;
pmd = pmd_offset(pgd + i, i << PGDIR_SHIFT);
pmd = pmd_off(pgd, i << PGDIR_SHIFT);
pmd[0] = __pmd(pmdval);
pmd[1] = __pmd(pmdval + (1 << (PGDIR_SHIFT - 1)));
flush_pmd_entry(pmd);
Expand Down

0 comments on commit 155bb14

Please sign in to comment.