Specifications

This is the Title of the Book, eMatter Edition
Copyright © 2005 O’Reilly & Associates, Inc. All rights reserved.
460
|
Chapter 15: Memory Mapping and DMA
unsigned long kmap(struct page *page);
void kunmap(struct page *page);
kmap returns a kernel virtual address that is mapped to the given page, creating
the mapping if need be. kunmap deletes the mapping for the given page.
#include <linux/highmem.h>
#include <asm/kmap_types.h>
void *kmap_atomic(struct page *page, enum km_type type);
void kunmap_atomic(void *addr, enum km_type type);
The high-performance version of kmap; the resulting mappings can be held only by
atomic code. For drivers,
type should be KM_USER0, KM_USER1, KM_IRQ0, or KM_IRQ1.
struct vm_area_struct;
Structure describing a VMA.
Implementing mmap
int remap_pfn_range(struct vm_area_struct *vma, unsigned long virt_add,
unsigned long pfn, unsigned long size, pgprot_t prot);
int io_remap_page_range(struct vm_area_struct *vma, unsigned long virt_add,
unsigned long phys_add, unsigned long size, pgprot_t prot);
Functions that sit at the heart of mmap. They map size bytes of physical
addresses, starting at the page number indicated by
pfn to the virtual address
virt_add. The protection bits associated with the virtual space are specified in
prot. io_remap_page_range should be used when the target address is in I/O
memory space.
struct page *vmalloc_to_page(void *vmaddr);
Converts a kernel virtual address obtained from vmalloc to its corresponding
struct page pointer.
Implementing Direct I/O
int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned
long start, int len, int write, int force, struct page **pages, struct
vm_area_struct **vmas);
Function that locks a user-space buffer into memory and returns the correspond-
ing
struct page pointers. The caller must hold mm->mmap_sem.
SetPageDirty(struct page *page);
Macro that marks the given page as “dirty” (modified) and in need of writing to
its backing store before it can be freed.
void page_cache_release(struct page *page);
Frees the given page from the page cache.
,ch15.13676 Page 460 Friday, January 21, 2005 11:04 AM