2005-04-16 16:20:36 -06:00
|
|
|
/* highmem.c: arch-specific highmem stuff
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
|
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
#include <linux/highmem.h>
|
2006-01-08 02:01:19 -07:00
|
|
|
#include <linux/module.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
void *kmap(struct page *page)
|
|
|
|
{
|
|
|
|
might_sleep();
|
|
|
|
if (!PageHighMem(page))
|
|
|
|
return page_address(page);
|
|
|
|
return kmap_high(page);
|
|
|
|
}
|
|
|
|
|
2006-01-08 02:01:19 -07:00
|
|
|
EXPORT_SYMBOL(kmap);
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
void kunmap(struct page *page)
|
|
|
|
{
|
|
|
|
if (in_interrupt())
|
|
|
|
BUG();
|
|
|
|
if (!PageHighMem(page))
|
|
|
|
return;
|
|
|
|
kunmap_high(page);
|
|
|
|
}
|
|
|
|
|
2006-01-08 02:01:19 -07:00
|
|
|
EXPORT_SYMBOL(kunmap);
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
struct page *kmap_atomic_to_page(void *ptr)
|
|
|
|
{
|
|
|
|
return virt_to_page(ptr);
|
|
|
|
}
|
2010-10-26 15:21:51 -06:00
|
|
|
|
|
|
|
void *__kmap_atomic(struct page *page)
|
|
|
|
{
|
|
|
|
unsigned long paddr;
|
|
|
|
int type;
|
|
|
|
|
|
|
|
pagefault_disable();
|
|
|
|
type = kmap_atomic_idx_push();
|
|
|
|
paddr = page_to_phys(page);
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
/*
|
|
|
|
* The first 4 primary maps are reserved for architecture code
|
|
|
|
*/
|
|
|
|
case 0: return __kmap_atomic_primary(4, paddr, 6);
|
|
|
|
case 1: return __kmap_atomic_primary(5, paddr, 7);
|
|
|
|
case 2: return __kmap_atomic_primary(6, paddr, 8);
|
|
|
|
case 3: return __kmap_atomic_primary(7, paddr, 9);
|
|
|
|
case 4: return __kmap_atomic_primary(8, paddr, 10);
|
|
|
|
|
|
|
|
case 5 ... 5 + NR_TLB_LINES - 1:
|
|
|
|
return __kmap_atomic_secondary(type - 5, paddr);
|
|
|
|
|
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(__kmap_atomic);
|
|
|
|
|
|
|
|
void __kunmap_atomic(void *kvaddr)
|
|
|
|
{
|
2010-10-27 16:32:58 -06:00
|
|
|
int type = kmap_atomic_idx();
|
2010-10-26 15:21:51 -06:00
|
|
|
switch (type) {
|
|
|
|
case 0: __kunmap_atomic_primary(4, 6); break;
|
|
|
|
case 1: __kunmap_atomic_primary(5, 7); break;
|
|
|
|
case 2: __kunmap_atomic_primary(6, 8); break;
|
|
|
|
case 3: __kunmap_atomic_primary(7, 9); break;
|
|
|
|
case 4: __kunmap_atomic_primary(8, 10); break;
|
|
|
|
|
|
|
|
case 5 ... 5 + NR_TLB_LINES - 1:
|
|
|
|
__kunmap_atomic_secondary(type - 5, kvaddr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
}
|
2010-10-27 16:32:58 -06:00
|
|
|
kmap_atomic_idx_pop();
|
2010-10-26 15:21:51 -06:00
|
|
|
pagefault_enable();
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(__kunmap_atomic);
|