blob: 0346c7e6245230689360f52921032f8869cbb793 [file] [log] [blame]
Sam Ravnborgf5e706a2008-07-17 21:55:51 -07001#ifndef _SPARC_PGALLOC_H
2#define _SPARC_PGALLOC_H
3
4#include <linux/kernel.h>
5#include <linux/sched.h>
6
Sam Ravnborg642ea3e2012-05-13 08:40:27 +02007#include <asm/pgtsrmmu.h>
Sam Ravnborg642ea3e2012-05-13 08:40:27 +02008#include <asm/pgtable.h>
9#include <asm/vaddrs.h>
10#include <asm/page.h>
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070011
12struct page;
13
Sam Ravnborgf71a2aa2012-07-26 11:02:14 +000014void *srmmu_get_nocache(int size, int align);
15void srmmu_free_nocache(void *addr, int size);
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020016
Sam Ravnborgc31f7652014-04-21 21:39:27 +020017extern struct resource sparc_iomap;
18
Sam Ravnborg37743482012-05-12 08:04:12 +000019#define check_pgt_cache() do { } while (0)
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070020
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020021pgd_t *get_pgd_fast(void);
22static inline void free_pgd_fast(pgd_t *pgd)
23{
Sam Ravnborgf71a2aa2012-07-26 11:02:14 +000024 srmmu_free_nocache(pgd, SRMMU_PGD_TABLE_SIZE);
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020025}
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070026
27#define pgd_free(mm, pgd) free_pgd_fast(pgd)
28#define pgd_alloc(mm) get_pgd_fast()
29
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020030static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
31{
Sam Ravnborg6b1cabe2016-04-22 19:41:07 +020032 unsigned long pa = __nocache_pa(pmdp);
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020033
Sam Ravnborg6e6e4182016-04-22 19:41:06 +020034 set_pte((pte_t *)pgdp, __pte((SRMMU_ET_PTD | (pa >> 4))));
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020035}
36
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070037#define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
38
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020039static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
40 unsigned long address)
41{
Sam Ravnborgf71a2aa2012-07-26 11:02:14 +000042 return srmmu_get_nocache(SRMMU_PMD_TABLE_SIZE,
43 SRMMU_PMD_TABLE_SIZE);
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020044}
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070045
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020046static inline void free_pmd_fast(pmd_t * pmd)
47{
Sam Ravnborgf71a2aa2012-07-26 11:02:14 +000048 srmmu_free_nocache(pmd, SRMMU_PMD_TABLE_SIZE);
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020049}
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070050
Benjamin Herrenschmidt9e1b32c2009-07-22 15:44:28 +100051#define pmd_free(mm, pmd) free_pmd_fast(pmd)
52#define __pmd_free_tlb(tlb, pmd, addr) pmd_free((tlb)->mm, pmd)
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070053
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020054void pmd_populate(struct mm_struct *mm, pmd_t *pmdp, struct page *ptep);
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070055#define pmd_pgtable(pmd) pmd_page(pmd)
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070056
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020057void pmd_set(pmd_t *pmdp, pte_t *ptep);
58#define pmd_populate_kernel(MM, PMD, PTE) pmd_set(PMD, PTE)
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070059
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020060pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address);
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070061
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020062static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
63 unsigned long address)
64{
Sam Ravnborgf71a2aa2012-07-26 11:02:14 +000065 return srmmu_get_nocache(PTE_SIZE, PTE_SIZE);
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020066}
67
68
69static inline void free_pte_fast(pte_t *pte)
70{
Sam Ravnborgf71a2aa2012-07-26 11:02:14 +000071 srmmu_free_nocache(pte, PTE_SIZE);
Sam Ravnborg642ea3e2012-05-13 08:40:27 +020072}
73
74#define pte_free_kernel(mm, pte) free_pte_fast(pte)
75
76void pte_free(struct mm_struct * mm, pgtable_t pte);
Benjamin Herrenschmidt9e1b32c2009-07-22 15:44:28 +100077#define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, pte)
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070078
79#endif /* _SPARC_PGALLOC_H */