blob: 95bb1a6c60609fa7567d4fa0928a44e689c3fc6e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * arch/sh/mm/hugetlbpage.c
3 *
4 * SuperH HugeTLB page support.
5 *
6 * Cloned from sparc64 by Paul Mundt.
7 *
8 * Copyright (C) 2002, 2003 David S. Miller (davem@redhat.com)
9 */
10
11#include <linux/config.h>
12#include <linux/init.h>
13#include <linux/fs.h>
14#include <linux/mm.h>
15#include <linux/hugetlb.h>
16#include <linux/pagemap.h>
17#include <linux/smp_lock.h>
18#include <linux/slab.h>
19#include <linux/sysctl.h>
20
21#include <asm/mman.h>
22#include <asm/pgalloc.h>
23#include <asm/tlb.h>
24#include <asm/tlbflush.h>
25#include <asm/cacheflush.h>
26
David Gibson63551ae2005-06-21 17:14:44 -070027pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070028{
29 pgd_t *pgd;
30 pmd_t *pmd;
31 pte_t *pte = NULL;
32
33 pgd = pgd_offset(mm, addr);
34 if (pgd) {
35 pmd = pmd_alloc(mm, pgd, addr);
36 if (pmd)
37 pte = pte_alloc_map(mm, pmd, addr);
38 }
39 return pte;
40}
41
David Gibson63551ae2005-06-21 17:14:44 -070042pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070043{
44 pgd_t *pgd;
45 pmd_t *pmd;
46 pte_t *pte = NULL;
47
48 pgd = pgd_offset(mm, addr);
49 if (pgd) {
50 pmd = pmd_offset(pgd, addr);
51 if (pmd)
52 pte = pte_offset_map(pmd, addr);
53 }
54 return pte;
55}
56
57#define mk_pte_huge(entry) do { pte_val(entry) |= _PAGE_SZHUGE; } while (0)
58
David Gibson63551ae2005-06-21 17:14:44 -070059void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
60 pte_t *ptep, pte_t entry)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061{
David Gibson63551ae2005-06-21 17:14:44 -070062 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
David Gibson63551ae2005-06-21 17:14:44 -070065 set_pte_at(mm, addr, ptep, entry);
66 ptep++;
67 addr += PAGE_SIZE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 pte_val(entry) += PAGE_SIZE;
69 }
70}
71
David Gibson63551ae2005-06-21 17:14:44 -070072pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
73 pte_t *ptep)
74{
75 pte_t entry;
76 int i;
77
78 entry = *ptep;
79
80 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
81 pte_clear(mm, addr, ptep);
82 addr += PAGE_SIZE;
83 ptep++;
84 }
85
86 return entry;
87}
88
Linus Torvalds1da177e2005-04-16 15:20:36 -070089/*
90 * This function checks for proper alignment of input addr and len parameters.
91 */
92int is_aligned_hugepage_range(unsigned long addr, unsigned long len)
93{
94 if (len & ~HPAGE_MASK)
95 return -EINVAL;
96 if (addr & ~HPAGE_MASK)
97 return -EINVAL;
98 return 0;
99}
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101struct page *follow_huge_addr(struct mm_struct *mm,
102 unsigned long address, int write)
103{
104 return ERR_PTR(-EINVAL);
105}
106
107int pmd_huge(pmd_t pmd)
108{
109 return 0;
110}
111
112struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
113 pmd_t *pmd, int write)
114{
115 return NULL;
116}