Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
resource.c File Reference
#include <linux/export.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/fs.h>
#include <linux/proc_fs.h>
#include <linux/sched.h>
#include <linux/seq_file.h>
#include <linux/device.h>
#include <linux/pfn.h>
#include <asm/io.h>

Go to the source code of this file.

Data Structures

struct  resource_constraint
 
struct  region_devres
 

Macros

#define pr_fmt(fmt)   KBUILD_MODNAME ": " fmt
 

Functions

 EXPORT_SYMBOL (ioport_resource)
 
 EXPORT_SYMBOL (iomem_resource)
 
void release_child_resources (struct resource *r)
 
struct resourcerequest_resource_conflict (struct resource *root, struct resource *new)
 
int request_resource (struct resource *root, struct resource *new)
 
 EXPORT_SYMBOL (request_resource)
 
int release_resource (struct resource *old)
 
 EXPORT_SYMBOL (release_resource)
 
int walk_system_ram_range (unsigned long start_pfn, unsigned long nr_pages, void *arg, int(*func)(unsigned long, unsigned long, void *))
 
int __weak page_is_ram (unsigned long pfn)
 
void __weak arch_remove_reservations (struct resource *avail)
 
int reallocate_resource (struct resource *root, struct resource *old, resource_size_t newsize, struct resource_constraint *constraint)
 
int allocate_resource (struct resource *root, struct resource *new, resource_size_t size, resource_size_t min, resource_size_t max, resource_size_t align, resource_size_t(*alignf)(void *, const struct resource *, resource_size_t, resource_size_t), void *alignf_data)
 
 EXPORT_SYMBOL (allocate_resource)
 
struct resourcelookup_resource (struct resource *root, resource_size_t start)
 
struct resourceinsert_resource_conflict (struct resource *parent, struct resource *new)
 
int insert_resource (struct resource *parent, struct resource *new)
 
void insert_resource_expand_to_fit (struct resource *root, struct resource *new)
 
int adjust_resource (struct resource *res, resource_size_t start, resource_size_t size)
 
 EXPORT_SYMBOL (adjust_resource)
 
void __init reserve_region_with_split (struct resource *root, resource_size_t start, resource_size_t end, const char *name)
 
resource_size_t resource_alignment (struct resource *res)
 

Variables

struct resource ioport_resource
 
struct resource iomem_resource
 

: reserving caller's ID string

__request_region - create a new busy resource region : parent resource descriptor : resource start address
: resource region size

: IO resource flags

#define MAXRESERVE   4
 
struct resource__request_region (struct resource *parent, resource_size_t start, resource_size_t n, const char *name, int flags)
 
 EXPORT_SYMBOL (__request_region)
 
int __check_region (struct resource *parent, resource_size_t start, resource_size_t n)
 
 EXPORT_SYMBOL (__check_region)
 
void __release_region (struct resource *parent, resource_size_t start, resource_size_t n)
 
 EXPORT_SYMBOL (__release_region)
 
struct resource__devm_request_region (struct device *dev, struct resource *parent, resource_size_t start, resource_size_t n, const char *name)
 
 EXPORT_SYMBOL (__devm_request_region)
 
void __devm_release_region (struct device *dev, struct resource *parent, resource_size_t start, resource_size_t n)
 
 EXPORT_SYMBOL (__devm_release_region)
 
 __setup ("reserve=", reserve_setup)
 
int iomem_map_sanity_check (resource_size_t addr, unsigned long size)
 
int iomem_is_exclusive (u64 addr)
 

Macro Definition Documentation

#define MAXRESERVE   4

Definition at line 1079 of file resource.c.

#define pr_fmt (   fmt)    KBUILD_MODNAME ": " fmt

Definition at line 10 of file resource.c.

Function Documentation

int __check_region ( struct resource parent,
resource_size_t  start,
resource_size_t  n 
)

__check_region - check if a resource region is busy or free : parent resource descriptor : resource start address
: resource region size

Returns 0 if the region is free at the moment it is checked, returns %-EBUSY if the region is busy.

NOTE: This function is deprecated because its use is racy. Even if it returns 0, a subsequent call to request_region() may fail because another driver etc. just allocated the region. Do NOT use it. It will be removed from the kernel.

Definition at line 951 of file resource.c.

void __devm_release_region ( struct device dev,
struct resource parent,
resource_size_t  start,
resource_size_t  n 
)

Definition at line 1065 of file resource.c.

struct resource* __devm_request_region ( struct device dev,
struct resource parent,
resource_size_t  start,
resource_size_t  n,
const char name 
)
read

Definition at line 1039 of file resource.c.

void __release_region ( struct resource parent,
resource_size_t  start,
resource_size_t  n 
)

__release_region - release a previously reserved resource region : parent resource descriptor : resource start address
: resource region size

The described resource region must match a currently busy region.

Definition at line 974 of file resource.c.

struct resource* __request_region ( struct resource parent,
resource_size_t  start,
resource_size_t  n,
const char name,
int  flags 
)
read

Definition at line 888 of file resource.c.

__setup ( )
int adjust_resource ( struct resource res,
resource_size_t  start,
resource_size_t  size 
)

adjust_resource - modify a resource's start and size : resource to modify : new start value : new size

Given an existing resource, change its start and size to match the arguments. Returns 0 on success, -EBUSY if it can't fit. Existing children of the resource are assumed to be immutable.

Definition at line 719 of file resource.c.

int allocate_resource ( struct resource root,
struct resource new,
resource_size_t  size,
resource_size_t  min,
resource_size_t  max,
resource_size_t  align,
resource_size_t(*)(void *, const struct resource *, resource_size_t, resource_size_t alignf,
void alignf_data 
)

allocate_resource - allocate empty slot in the resource tree given range & alignment. The resource will be reallocated with a new size if it was already allocated : root resource descriptor : resource descriptor desired by caller : requested resource region size : minimum boundary to allocate : maximum boundary to allocate : alignment requested, in bytes : alignment function, optional, called if not NULL : arbitrary data to pass to the function

Definition at line 526 of file resource.c.

void __weak arch_remove_reservations ( struct resource avail)

Definition at line 370 of file resource.c.

EXPORT_SYMBOL ( ioport_resource  )
EXPORT_SYMBOL ( iomem_resource  )
EXPORT_SYMBOL ( request_resource  )
EXPORT_SYMBOL ( release_resource  )
EXPORT_SYMBOL ( allocate_resource  )
EXPORT_SYMBOL ( adjust_resource  )
EXPORT_SYMBOL ( __request_region  )
EXPORT_SYMBOL ( __check_region  )
EXPORT_SYMBOL ( __release_region  )
EXPORT_SYMBOL ( __devm_request_region  )
EXPORT_SYMBOL ( __devm_release_region  )
int insert_resource ( struct resource parent,
struct resource new 
)

insert_resource - Inserts a resource in the resource tree : parent of the new resource : new resource to insert

Returns 0 on success, -EBUSY if the resource can't be inserted.

Definition at line 667 of file resource.c.

struct resource* insert_resource_conflict ( struct resource parent,
struct resource new 
)
read

insert_resource_conflict - Inserts resource in the resource tree : parent of the new resource : new resource to insert

Returns 0 on success, conflict resource if the resource can't be inserted.

This function is equivalent to request_resource_conflict when no conflict happens. If a conflict happens, and the conflicting resources entirely fit within the range of the new resource, then the new resource is inserted and the conflicting resources become children of the new resource.

Definition at line 650 of file resource.c.

void insert_resource_expand_to_fit ( struct resource root,
struct resource new 
)

insert_resource_expand_to_fit - Insert a resource into the resource tree : root resource descriptor : new resource to insert

Insert a resource into the resource tree, possibly expanding it in order to make it encompass any conflicting resources.

Definition at line 683 of file resource.c.

int iomem_is_exclusive ( u64  addr)

Definition at line 1166 of file resource.c.

int iomem_map_sanity_check ( resource_size_t  addr,
unsigned long  size 
)

Definition at line 1113 of file resource.c.

struct resource* lookup_resource ( struct resource root,
resource_size_t  start 
)
read

lookup_resource - find an existing resource by a resource start address : root resource descriptor : resource start address

Returns a pointer to the resource if found, NULL otherwise

Definition at line 570 of file resource.c.

int __weak page_is_ram ( unsigned long  pfn)

Definition at line 365 of file resource.c.

int reallocate_resource ( struct resource root,
struct resource old,
resource_size_t  newsize,
struct resource_constraint constraint 
)

reallocate_resource - allocate a slot in the resource tree given range & alignment. The resource will be relocated if the new size cannot be reallocated in the current location.

: root resource descriptor : resource descriptor desired by caller : new size of the resource descriptor : the size and alignment constraints to be met.

Definition at line 475 of file resource.c.

void release_child_resources ( struct resource r)

Definition at line 225 of file resource.c.

int release_resource ( struct resource old)

release_resource - release a previously reserved resource : resource pointer

Definition at line 270 of file resource.c.

int request_resource ( struct resource root,
struct resource new 
)

request_resource - request and reserve an I/O or memory resource : root resource descriptor : resource descriptor desired by caller

Returns 0 for success, negative error code on error.

Definition at line 256 of file resource.c.

struct resource* request_resource_conflict ( struct resource root,
struct resource new 
)
read

request_resource_conflict - request and reserve an I/O or memory resource : root resource descriptor : resource descriptor desired by caller

Returns 0 for success, conflict resource on error.

Definition at line 239 of file resource.c.

void __init reserve_region_with_split ( struct resource root,
resource_size_t  start,
resource_size_t  end,
const char name 
)

Definition at line 818 of file resource.c.

resource_size_t resource_alignment ( struct resource res)

resource_alignment - calculate resource's alignment : resource pointer

Returns alignment on success, 0 (invalid alignment) on failure.

Definition at line 853 of file resource.c.

int walk_system_ram_range ( unsigned long  start_pfn,
unsigned long  nr_pages,
void arg,
int(*)(unsigned long, unsigned long, void *)  func 
)

Definition at line 329 of file resource.c.

Variable Documentation

struct resource iomem_resource
Initial value:
= {
.name = "PCI mem",
.start = 0,
.end = -1,
.flags = IORESOURCE_MEM,
}

Definition at line 35 of file resource.c.

struct resource ioport_resource
Initial value:
= {
.name = "PCI IO",
.start = 0,
.flags = IORESOURCE_IO,
}

Definition at line 27 of file resource.c.