Logical memory blocks

enum lmb_flags

definition of memory region attributes

Constants

LMB_NONE

no special request

LMB_NOMAP

don’t add to mmu configuration

struct lmb_property

Description of one region.

Definition

struct lmb_property {
  phys_addr_t base;
  phys_size_t size;
  enum lmb_flags flags;
};

Members

base

Base address of the region.

size

Size of the region

flags

memory region attributes

struct lmb_region

Description of a set of region.

Definition

struct lmb_region {
  unsigned long cnt;
  unsigned long max;
#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS);
  struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
#else;
  struct lmb_property *region;
#endif;
};

Members

cnt

Number of regions.

max

Size of the region array, max value of cnt.

region

Array of the region properties

region

Array of the region properties

struct lmb

Logical memory block handle.

Definition

struct lmb {
  struct lmb_region memory;
  struct lmb_region reserved;
#ifdef CONFIG_LMB_MEMORY_REGIONS;
  struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
  struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
#endif;
};

Members

memory

Description of memory regions.

reserved

Description of reserved regions.

memory_regions

Array of the memory regions (statically allocated)

reserved_regions

Array of the reserved regions (statically allocated)

Description

Clients provide storage for Logical memory block (lmb) handles. The content of the structure is managed by the lmb library. A lmb struct is initialized by lmb_init() functions. The lmb struct is passed to all other lmb APIs.

long lmb_reserve_flags(struct lmb *lmb, phys_addr_t base, phys_size_t size, enum lmb_flags flags)

Reserve one region with a specific flags bitfield.

Parameters

struct lmb *lmb

the logical memory block struct

phys_addr_t base

base address of the memory region

phys_size_t size

size of the memory region

enum lmb_flags flags

flags for the memory region

Return

0 if OK, > 0 for coalesced region or a negative error code.

int lmb_is_reserved_flags(struct lmb *lmb, phys_addr_t addr, int flags)

test if tha address is in reserved region with a bitfield flag

Parameters

struct lmb *lmb

the logical memory block struct

phys_addr_t addr

address to be tested

int flags

flags bitfied to be tested

Return

if not reserved or reserved without the requested flag else 1