Linux Audio

Check our new training course

Yocto / OpenEmbedded training

Feb 10-13, 2025
Register
Loading...
v5.4
  1/*
  2 * This file is subject to the terms and conditions of the GNU General Public
  3 * License.  See the file "COPYING" in the main directory of this archive
  4 * for more details.
  5 *
  6 * Copyright (C) 1999, 2000 by Silicon Graphics
  7 * Copyright (C) 2003 by Ralf Baechle
  8 */
  9#include <linux/export.h>
 10#include <linux/init.h>
 11#include <linux/mm.h>
 12#include <asm/fixmap.h>
 13#include <asm/pgtable.h>
 14#include <asm/pgalloc.h>
 15#include <asm/tlbflush.h>
 16
 17void pgd_init(unsigned long page)
 18{
 19	unsigned long *p, *end;
 20	unsigned long entry;
 21
 22#if !defined(__PAGETABLE_PUD_FOLDED)
 23	entry = (unsigned long)invalid_pud_table;
 24#elif !defined(__PAGETABLE_PMD_FOLDED)
 25	entry = (unsigned long)invalid_pmd_table;
 26#else
 27	entry = (unsigned long)invalid_pte_table;
 28#endif
 29
 30	p = (unsigned long *) page;
 31	end = p + PTRS_PER_PGD;
 32
 33	do {
 34		p[0] = entry;
 35		p[1] = entry;
 36		p[2] = entry;
 37		p[3] = entry;
 38		p[4] = entry;
 39		p += 8;
 40		p[-3] = entry;
 41		p[-2] = entry;
 42		p[-1] = entry;
 43	} while (p != end);
 44}
 45
 46#ifndef __PAGETABLE_PMD_FOLDED
 47void pmd_init(unsigned long addr, unsigned long pagetable)
 48{
 49	unsigned long *p, *end;
 50
 51	p = (unsigned long *) addr;
 52	end = p + PTRS_PER_PMD;
 53
 54	do {
 55		p[0] = pagetable;
 56		p[1] = pagetable;
 57		p[2] = pagetable;
 58		p[3] = pagetable;
 59		p[4] = pagetable;
 60		p += 8;
 61		p[-3] = pagetable;
 62		p[-2] = pagetable;
 63		p[-1] = pagetable;
 64	} while (p != end);
 65}
 66EXPORT_SYMBOL_GPL(pmd_init);
 67#endif
 68
 69#ifndef __PAGETABLE_PUD_FOLDED
 70void pud_init(unsigned long addr, unsigned long pagetable)
 71{
 72	unsigned long *p, *end;
 73
 74	p = (unsigned long *)addr;
 75	end = p + PTRS_PER_PUD;
 76
 77	do {
 78		p[0] = pagetable;
 79		p[1] = pagetable;
 80		p[2] = pagetable;
 81		p[3] = pagetable;
 82		p[4] = pagetable;
 83		p += 8;
 84		p[-3] = pagetable;
 85		p[-2] = pagetable;
 86		p[-1] = pagetable;
 87	} while (p != end);
 88}
 89#endif
 90
 91pmd_t mk_pmd(struct page *page, pgprot_t prot)
 92{
 93	pmd_t pmd;
 94
 95	pmd_val(pmd) = (page_to_pfn(page) << _PFN_SHIFT) | pgprot_val(prot);
 96
 97	return pmd;
 98}
 99
100void set_pmd_at(struct mm_struct *mm, unsigned long addr,
101		pmd_t *pmdp, pmd_t pmd)
102{
103	*pmdp = pmd;
104	flush_tlb_all();
105}
106
107void __init pagetable_init(void)
108{
109	unsigned long vaddr;
110	pgd_t *pgd_base;
111
112	/* Initialize the entire pgd.  */
113	pgd_init((unsigned long)swapper_pg_dir);
114#ifndef __PAGETABLE_PUD_FOLDED
115	pud_init((unsigned long)invalid_pud_table, (unsigned long)invalid_pmd_table);
116#endif
117#ifndef __PAGETABLE_PMD_FOLDED
118	pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table);
119#endif
120	pgd_base = swapper_pg_dir;
121	/*
122	 * Fixed mappings:
123	 */
124	vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
125	fixrange_init(vaddr, vaddr + FIXADDR_SIZE, pgd_base);
126}
v5.9
  1/*
  2 * This file is subject to the terms and conditions of the GNU General Public
  3 * License.  See the file "COPYING" in the main directory of this archive
  4 * for more details.
  5 *
  6 * Copyright (C) 1999, 2000 by Silicon Graphics
  7 * Copyright (C) 2003 by Ralf Baechle
  8 */
  9#include <linux/export.h>
 10#include <linux/init.h>
 11#include <linux/mm.h>
 12#include <asm/fixmap.h>
 
 13#include <asm/pgalloc.h>
 14#include <asm/tlbflush.h>
 15
 16void pgd_init(unsigned long page)
 17{
 18	unsigned long *p, *end;
 19	unsigned long entry;
 20
 21#if !defined(__PAGETABLE_PUD_FOLDED)
 22	entry = (unsigned long)invalid_pud_table;
 23#elif !defined(__PAGETABLE_PMD_FOLDED)
 24	entry = (unsigned long)invalid_pmd_table;
 25#else
 26	entry = (unsigned long)invalid_pte_table;
 27#endif
 28
 29	p = (unsigned long *) page;
 30	end = p + PTRS_PER_PGD;
 31
 32	do {
 33		p[0] = entry;
 34		p[1] = entry;
 35		p[2] = entry;
 36		p[3] = entry;
 37		p[4] = entry;
 38		p += 8;
 39		p[-3] = entry;
 40		p[-2] = entry;
 41		p[-1] = entry;
 42	} while (p != end);
 43}
 44
 45#ifndef __PAGETABLE_PMD_FOLDED
 46void pmd_init(unsigned long addr, unsigned long pagetable)
 47{
 48	unsigned long *p, *end;
 49
 50	p = (unsigned long *) addr;
 51	end = p + PTRS_PER_PMD;
 52
 53	do {
 54		p[0] = pagetable;
 55		p[1] = pagetable;
 56		p[2] = pagetable;
 57		p[3] = pagetable;
 58		p[4] = pagetable;
 59		p += 8;
 60		p[-3] = pagetable;
 61		p[-2] = pagetable;
 62		p[-1] = pagetable;
 63	} while (p != end);
 64}
 65EXPORT_SYMBOL_GPL(pmd_init);
 66#endif
 67
 68#ifndef __PAGETABLE_PUD_FOLDED
 69void pud_init(unsigned long addr, unsigned long pagetable)
 70{
 71	unsigned long *p, *end;
 72
 73	p = (unsigned long *)addr;
 74	end = p + PTRS_PER_PUD;
 75
 76	do {
 77		p[0] = pagetable;
 78		p[1] = pagetable;
 79		p[2] = pagetable;
 80		p[3] = pagetable;
 81		p[4] = pagetable;
 82		p += 8;
 83		p[-3] = pagetable;
 84		p[-2] = pagetable;
 85		p[-1] = pagetable;
 86	} while (p != end);
 87}
 88#endif
 89
 90pmd_t mk_pmd(struct page *page, pgprot_t prot)
 91{
 92	pmd_t pmd;
 93
 94	pmd_val(pmd) = (page_to_pfn(page) << _PFN_SHIFT) | pgprot_val(prot);
 95
 96	return pmd;
 97}
 98
 99void set_pmd_at(struct mm_struct *mm, unsigned long addr,
100		pmd_t *pmdp, pmd_t pmd)
101{
102	*pmdp = pmd;
103	flush_tlb_all();
104}
105
106void __init pagetable_init(void)
107{
108	unsigned long vaddr;
109	pgd_t *pgd_base;
110
111	/* Initialize the entire pgd.  */
112	pgd_init((unsigned long)swapper_pg_dir);
113#ifndef __PAGETABLE_PUD_FOLDED
114	pud_init((unsigned long)invalid_pud_table, (unsigned long)invalid_pmd_table);
115#endif
116#ifndef __PAGETABLE_PMD_FOLDED
117	pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table);
118#endif
119	pgd_base = swapper_pg_dir;
120	/*
121	 * Fixed mappings:
122	 */
123	vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
124	fixrange_init(vaddr, vaddr + FIXADDR_SIZE, pgd_base);
125}