Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Gibson | 63551ae | 2005-06-21 17:14:44 -0700 | [diff] [blame] | 27 | pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | { |
| 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 Gibson | 63551ae | 2005-06-21 17:14:44 -0700 | [diff] [blame] | 42 | pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | { |
| 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 | |
David Gibson | 63551ae | 2005-06-21 17:14:44 -0700 | [diff] [blame] | 57 | void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, |
| 58 | pte_t *ptep, pte_t entry) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | { |
David Gibson | 63551ae | 2005-06-21 17:14:44 -0700 | [diff] [blame] | 60 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
| 62 | for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) { |
David Gibson | 63551ae | 2005-06-21 17:14:44 -0700 | [diff] [blame] | 63 | set_pte_at(mm, addr, ptep, entry); |
| 64 | ptep++; |
| 65 | addr += PAGE_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | pte_val(entry) += PAGE_SIZE; |
| 67 | } |
| 68 | } |
| 69 | |
David Gibson | 63551ae | 2005-06-21 17:14:44 -0700 | [diff] [blame] | 70 | pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, |
| 71 | pte_t *ptep) |
| 72 | { |
| 73 | pte_t entry; |
| 74 | int i; |
| 75 | |
| 76 | entry = *ptep; |
| 77 | |
| 78 | for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) { |
| 79 | pte_clear(mm, addr, ptep); |
| 80 | addr += PAGE_SIZE; |
| 81 | ptep++; |
| 82 | } |
| 83 | |
| 84 | return entry; |
| 85 | } |
| 86 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | struct page *follow_huge_addr(struct mm_struct *mm, |
| 88 | unsigned long address, int write) |
| 89 | { |
| 90 | return ERR_PTR(-EINVAL); |
| 91 | } |
| 92 | |
| 93 | int pmd_huge(pmd_t pmd) |
| 94 | { |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address, |
| 99 | pmd_t *pmd, int write) |
| 100 | { |
| 101 | return NULL; |
| 102 | } |