Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mm_drv_bank.h File Reference

Memory Banks Driver APIs. More...

#include <zephyr/kernel.h>
#include <zephyr/sys/mem_stats.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  mem_drv_bank
 

Macros

#define SRAM_BANK_PAGE_NUM   (SRAM_BANK_SIZE / CONFIG_MM_DRV_PAGE_SIZE)
 

Functions

void sys_mm_drv_bank_init (struct mem_drv_bank *bank, uint32_t bank_pages)
 Initialize a memory bank's data structure.
 
uint32_t sys_mm_drv_bank_page_mapped (struct mem_drv_bank *bank)
 Track the mapping of a page in the specified memory bank.
 
uint32_t sys_mm_drv_bank_page_unmapped (struct mem_drv_bank *bank)
 Track the unmapping of a page in the specified memory bank.
 
void sys_mm_drv_bank_stats_reset_max (struct mem_drv_bank *bank)
 Reset the max number of pages mapped in the bank.
 
void sys_mm_drv_bank_stats_get (struct mem_drv_bank *bank, struct sys_memory_stats *stats)
 Retrieve the memory usage stats for the specified memory bank.
 

Detailed Description

Memory Banks Driver APIs.

This contains generic APIs to be used by a system-wide memory management driver to track page usage within memory banks. It is incumbent upon the caller to ensure that proper locking is used to protect the data when using these APIs.

Macro Definition Documentation

◆ SRAM_BANK_PAGE_NUM

#define SRAM_BANK_PAGE_NUM   (SRAM_BANK_SIZE / CONFIG_MM_DRV_PAGE_SIZE)

Function Documentation

◆ sys_mm_drv_bank_init()

void sys_mm_drv_bank_init ( struct mem_drv_bank bank,
uint32_t  bank_pages 
)

Initialize a memory bank's data structure.

The driver may wish to track various information about the memory banks that it uses. This routine will initialize a generic structure containing that information. Since at the power on all memory banks are switched on it will start with all pages mapped. In next phase of driver initialization unused pages will be unmapped.

Parameters
bankPointer to the memory bank structure used for tracking
bank_pagesNumber of pages in the memory bank

◆ sys_mm_drv_bank_page_mapped()

uint32_t sys_mm_drv_bank_page_mapped ( struct mem_drv_bank bank)

Track the mapping of a page in the specified memory bank.

This function is used to update the number of mapped pages within the specified memory bank.

Parameters
bankPointer to the memory bank's data structure
Returns
The number of pages mapped within the memory bank

◆ sys_mm_drv_bank_page_unmapped()

uint32_t sys_mm_drv_bank_page_unmapped ( struct mem_drv_bank bank)

Track the unmapping of a page in the specified memory bank.

This function is used to update the number of unmapped pages within the specified memory bank.

Parameters
bankPointer to the memory bank's data structure
Returns
The number of unmapped pages within the memory bank

◆ sys_mm_drv_bank_stats_get()

void sys_mm_drv_bank_stats_get ( struct mem_drv_bank bank,
struct sys_memory_stats stats 
)

Retrieve the memory usage stats for the specified memory bank.

This routine extracts the system memory stats from the memory bank.

Parameters
bankPointer to the memory bank's data structure
statsPointer to memory into which to copy the system memory stats

◆ sys_mm_drv_bank_stats_reset_max()

void sys_mm_drv_bank_stats_reset_max ( struct mem_drv_bank bank)

Reset the max number of pages mapped in the bank.

This routine is used to reset the maximum number of pages mapped in the specified memory bank to the current number of pages mapped in that memory bank.

Parameters
bankPointer to the memory bank's data structure