Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
cvmx-bootmem.c File Reference
#include <linux/kernel.h>
#include <linux/module.h>
#include <asm/octeon/cvmx.h>
#include <asm/octeon/cvmx-spinlock.h>
#include <asm/octeon/cvmx-bootmem.h>

Go to the source code of this file.

Macros

#define NEXT_OFFSET   0
 
#define SIZE_OFFSET   8
 

Functions

voidcvmx_bootmem_alloc_range (uint64_t size, uint64_t alignment, uint64_t min_addr, uint64_t max_addr)
 
voidcvmx_bootmem_alloc_address (uint64_t size, uint64_t address, uint64_t alignment)
 
voidcvmx_bootmem_alloc (uint64_t size, uint64_t alignment)
 
voidcvmx_bootmem_alloc_named_range (uint64_t size, uint64_t min_addr, uint64_t max_addr, uint64_t align, char *name)
 
voidcvmx_bootmem_alloc_named_address (uint64_t size, uint64_t address, char *name)
 
voidcvmx_bootmem_alloc_named (uint64_t size, uint64_t alignment, char *name)
 
 EXPORT_SYMBOL (cvmx_bootmem_alloc_named)
 
int cvmx_bootmem_free_named (char *name)
 
struct
cvmx_bootmem_named_block_desc
cvmx_bootmem_find_named_block (char *name)
 
 EXPORT_SYMBOL (cvmx_bootmem_find_named_block)
 
void cvmx_bootmem_lock (void)
 
void cvmx_bootmem_unlock (void)
 
int cvmx_bootmem_init (void *mem_desc_ptr)
 
int64_t cvmx_bootmem_phy_alloc (uint64_t req_size, uint64_t address_min, uint64_t address_max, uint64_t alignment, uint32_t flags)
 
int __cvmx_bootmem_phy_free (uint64_t phy_addr, uint64_t size, uint32_t flags)
 
struct
cvmx_bootmem_named_block_desc
cvmx_bootmem_phy_named_block_find (char *name, uint32_t flags)
 
int cvmx_bootmem_phy_named_block_free (char *name, uint32_t flags)
 
int64_t cvmx_bootmem_phy_named_block_alloc (uint64_t size, uint64_t min_addr, uint64_t max_addr, uint64_t alignment, char *name, uint32_t flags)
 

Macro Definition Documentation

#define NEXT_OFFSET   0

Definition at line 53 of file cvmx-bootmem.c.

#define SIZE_OFFSET   8

Definition at line 54 of file cvmx-bootmem.c.

Function Documentation

int __cvmx_bootmem_phy_free ( uint64_t  phy_addr,
uint64_t  size,
uint32_t  flags 
)

Frees a block to the bootmem allocator list. This must be used with care, as the size provided must match the size of the block that was allocated, or the list will become corrupted.

IMPORTANT: This is only intended to be used as part of named block frees and initial population of the free memory list.

  • : physical address of block : size of block in bytes. : flags for passing options

Returns 1 on success, 0 on failure

Definition at line 398 of file cvmx-bootmem.c.

void* cvmx_bootmem_alloc ( uint64_t  size,
uint64_t  alignment 
)

Allocate a block of memory from the free list that was passed to the application by the bootloader. This is an allocate-only algorithm, so freeing memory is not possible.

: Size in bytes of block to allocate : Alignment required - must be power of 2

Returns pointer to block of memory, NULL on error

Definition at line 96 of file cvmx-bootmem.c.

void* cvmx_bootmem_alloc_address ( uint64_t  size,
uint64_t  address,
uint64_t  alignment 
)

Allocate a block of memory from the free list that was passed to the application by the bootloader at a specific address. This is an allocate-only algorithm, so freeing memory is not possible. Allocation will fail if memory cannot be allocated at the specified address.

: Size in bytes of block to allocate : Physical address to allocate memory at. If this memory is not available, the allocation fails. : Alignment required - must be power of 2 Returns pointer to block of memory, NULL on error

Definition at line 89 of file cvmx-bootmem.c.

void* cvmx_bootmem_alloc_named ( uint64_t  size,
uint64_t  alignment,
char name 
)

Definition at line 122 of file cvmx-bootmem.c.

void* cvmx_bootmem_alloc_named_address ( uint64_t  size,
uint64_t  address,
char name 
)

Definition at line 115 of file cvmx-bootmem.c.

void* cvmx_bootmem_alloc_named_range ( uint64_t  size,
uint64_t  min_addr,
uint64_t  max_addr,
uint64_t  align,
char name 
)

Definition at line 101 of file cvmx-bootmem.c.

void* cvmx_bootmem_alloc_range ( uint64_t  size,
uint64_t  alignment,
uint64_t  min_addr,
uint64_t  max_addr 
)

Allocate a block of memory from the free list that was passed to the application by the bootloader within a specified address range. This is an allocate-only algorithm, so freeing memory is not possible. Allocation will fail if memory cannot be allocated in the requested range.

: Size in bytes of block to allocate : defines the minimum address of the range : defines the maximum address of the range : Alignment required - must be power of 2 Returns pointer to block of memory, NULL on error

Definition at line 76 of file cvmx-bootmem.c.

struct cvmx_bootmem_named_block_desc* cvmx_bootmem_find_named_block ( char name)
read

Definition at line 133 of file cvmx-bootmem.c.

int cvmx_bootmem_free_named ( char name)

Definition at line 128 of file cvmx-bootmem.c.

int cvmx_bootmem_init ( void mem_desc_ptr)

Initialize the boot alloc memory structures. This is normally called inside of cvmx_user_app_init()

: Address of the free memory list

Definition at line 149 of file cvmx-bootmem.c.

void cvmx_bootmem_lock ( void  )

Locks the bootmem allocator. This is useful in certain situations where multiple allocations must be made without being interrupted. This should be used with the CVMX_BOOTMEM_FLAG_NO_LOCKING flag.

Definition at line 139 of file cvmx-bootmem.c.

int64_t cvmx_bootmem_phy_alloc ( uint64_t  req_size,
uint64_t  address_min,
uint64_t  address_max,
uint64_t  alignment,
uint32_t  flags 
)

Allocates a block of physical memory from the free list, at (optional) requested address and alignment.

: size of region to allocate. All requests are rounded up to be a multiple CVMX_BOOTMEM_ALIGNMENT_SIZE bytes size

: Minimum address that block can occupy.

: Specifies the maximum address_min (inclusive) that the allocation can use.

: Requested alignment of the block. If this alignment cannot be met, the allocation fails. This must be a power of 2. (Note: Alignment of CVMX_BOOTMEM_ALIGNMENT_SIZE bytes is required, and internally enforced. Requested alignments of less than CVMX_BOOTMEM_ALIGNMENT_SIZE are set to CVMX_BOOTMEM_ALIGNMENT_SIZE.)

: Flags to control options for the allocation.

Returns physical address of block allocated, or -1 on failure

Definition at line 185 of file cvmx-bootmem.c.

int64_t cvmx_bootmem_phy_named_block_alloc ( uint64_t  size,
uint64_t  min_addr,
uint64_t  max_addr,
uint64_t  alignment,
char name,
uint32_t  flags 
)

Allocates a named block of physical memory from the free list, at (optional) requested address and alignment.

Parameters
sizesize of region to allocate. All requests are rounded up to be a multiple CVMX_BOOTMEM_ALIGNMENT_SIZE bytes size
min_addrMinimum address that block can occupy.
max_addrSpecifies the maximum address_min (inclusive) that the allocation can use.
alignmentRequested alignment of the block. If this alignment cannot be met, the allocation fails. This must be a power of 2. (Note: Alignment of CVMX_BOOTMEM_ALIGNMENT_SIZE bytes is required, and internally enforced. Requested alignments of less than CVMX_BOOTMEM_ALIGNMENT_SIZE are set to CVMX_BOOTMEM_ALIGNMENT_SIZE.)
namename to assign to named block
flagsFlags to control options for the allocation.
Returns
physical address of block allocated, or -1 on failure

Definition at line 617 of file cvmx-bootmem.c.

struct cvmx_bootmem_named_block_desc* cvmx_bootmem_phy_named_block_find ( char name,
uint32_t  flags 
)
read

Definition at line 522 of file cvmx-bootmem.c.

int cvmx_bootmem_phy_named_block_free ( char name,
uint32_t  flags 
)

Definition at line 573 of file cvmx-bootmem.c.

void cvmx_bootmem_unlock ( void  )

Unlocks the bootmem allocator. This is useful in certain situations where multiple allocations must be made without being interrupted. This should be used with the CVMX_BOOTMEM_FLAG_NO_LOCKING flag.

Definition at line 144 of file cvmx-bootmem.c.

EXPORT_SYMBOL ( cvmx_bootmem_alloc_named  )
EXPORT_SYMBOL ( cvmx_bootmem_find_named_block  )