Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Interfaces for Memory Controllers (MEMC). More...

Files

file  memc.h
 Main header file for Memory Controller (MEMC) driver API.

Data Structures

struct  memc_driver_api
 @driver_ops{MEMC} More...

Functions

int memc_read (const struct device *dev, uint32_t addr, uint8_t *data, size_t len)
 Read data from external memory.
int memc_write (const struct device *dev, uint32_t addr, const uint8_t *data, size_t len)
 Write data to external memory.
static void * memc_get_mem_base (const struct device *dev)
 Get the memory-mapped base address of a MEMC device.
int memc_get_size (const struct device *dev, uint64_t *size)
 Get the size of external memory.
int memc_read_id (const struct device *dev, uint8_t *id, size_t len)
 Read the ID of external memory.
typedef int(* memc_api_read) (const struct device *dev, uint32_t addr, uint8_t *data, size_t len)
 @def_driverbackendgroup{MEMC,memc_interface}
typedef int(* memc_api_write) (const struct device *dev, uint32_t addr, const uint8_t *data, size_t len)
 Callback API for writing to external memory.
typedef int(* memc_api_get_size) (const struct device *dev, uint64_t *size)
 Callback API for getting the size of external memory.
typedef int(* memc_api_read_id) (const struct device *dev, uint8_t *id, size_t len)
 Callback API for reading the ID of external memory.
typedef void *(* memc_api_get_mem_base) (const struct device *dev)
 Callback API for getting the base address of external memory.

Detailed Description

Interfaces for Memory Controllers (MEMC).

Since
4.5
Version
0.1.0

Typedef Documentation

◆ memc_api_get_mem_base

typedef void *(* memc_api_get_mem_base) (const struct device *dev)

#include <memc.h>

Callback API for getting the base address of external memory.

See memc_get_mem_base() for argument description.

◆ memc_api_get_size

typedef int(* memc_api_get_size) (const struct device *dev, uint64_t *size)

#include <memc.h>

Callback API for getting the size of external memory.

See memc_get_size() for argument description.

◆ memc_api_read

typedef int(* memc_api_read) (const struct device *dev, uint32_t addr, uint8_t *data, size_t len)

#include <memc.h>

@def_driverbackendgroup{MEMC,memc_interface}

Callback API for reading from external memory. See memc_read() for argument description.

◆ memc_api_read_id

typedef int(* memc_api_read_id) (const struct device *dev, uint8_t *id, size_t len)

#include <memc.h>

Callback API for reading the ID of external memory.

See memc_read_id() for argument description.

◆ memc_api_write

typedef int(* memc_api_write) (const struct device *dev, uint32_t addr, const uint8_t *data, size_t len)

#include <memc.h>

Callback API for writing to external memory.

See memc_write() for argument description.

Function Documentation

◆ memc_get_mem_base()

void * memc_get_mem_base ( const struct device * dev)
inlinestatic

#include <memc.h>

Get the memory-mapped base address of a MEMC device.

Note
This function is available in kernel mode only (not a syscall). The returned pointer is a kernel-space address and cannot be used from userspace directly. Use memc_read() / memc_write() for portable access.
Parameters
devMEMC device.
Returns
Pointer to the mapped base address, or NULL if not memory-mapped or if the device does not implement the memc API

◆ memc_get_size()

int memc_get_size ( const struct device * dev,
uint64_t * size )

#include <memc.h>

Get the size of external memory.

Parameters
devMEMC device.
sizePointer to variable to store size in bytes.
Returns
0 on success, negative errno code on failure.
Return values
-ENOTSUPif the device does not implement the memc API or the optional callback.

◆ memc_read()

int memc_read ( const struct device * dev,
uint32_t addr,
uint8_t * data,
size_t len )

#include <memc.h>

Read data from external memory.

Parameters
devMEMC device.
addrByte offset from the base address to read from.
dataBuffer to store read data.
lenNumber of bytes to read.
Returns
0 on success, negative errno code on failure.
Return values
-ENOTSUPif the device does not implement the memc API, or if neither get_mem_base nor read is implemented.

◆ memc_read_id()

int memc_read_id ( const struct device * dev,
uint8_t * id,
size_t len )

#include <memc.h>

Read the ID of external memory.

Parameters
devMEMC device.
idBuffer to store ID (size depends on device, typically 2-4 bytes).
lenNumber of bytes to read. Drivers may return fewer bytes than requested if the device ID is shorter.
Returns
0 on success, negative errno code on failure.
Return values
-ENOTSUPif the device does not implement the memc API or the optional callback.

◆ memc_write()

int memc_write ( const struct device * dev,
uint32_t addr,
const uint8_t * data,
size_t len )

#include <memc.h>

Write data to external memory.

Parameters
devMEMC device.
addrByte offset from the base address to write to.
dataBuffer containing data to write.
lenNumber of bytes to write.
Returns
0 on success, negative errno code on failure.
Return values
-ENOTSUPif the device does not implement the memc API, or if neither get_mem_base nor write is implemented.