muteki
Loading...
Searching...
No Matches
ftl.h File Reference

Flash Translation Layer (FTL) and block device API. More...

#include <muteki/common.h>

Go to the source code of this file.

Data Structures

struct  nand_params_t
 NAND flash parameter. More...
 

Functions

size_t FTL_GetCurDiskSize (size_t *size_hi)
 Get the size of block device the current active drive belongs to.
 
int FTL_ReadSector (size_t sector, void *ptr, size_t count)
 Read sectors from the block device the current active drive belongs to.
 
short FTL_CreateRamDisk (size_t size)
 Allocate a RAM disk.
 
void FTL_DestroyRamDisk (void)
 Close the previously allocated RAM disk.
 
int nand_get_params (int sbz, nand_params_t *params)
 Get NAND flash parameters.
 
int nand_read_page (int sbz, size_t page, void *ptr, size_t count, short arg5)
 Read NAND flash pages at a specific page number.
 

Detailed Description

Flash Translation Layer (FTL) and block device API.

Requires -lkrnllib when dynamically linking with the shims.

Function Documentation

◆ FTL_CreateRamDisk()

short FTL_CreateRamDisk ( size_t  size)
extern

Allocate a RAM disk.

This may be used internally to buffer file writes under circumstances when low latency I/O is required, such as when streaming audio data from on-board NAND flash.

Parameters
sizeSize of the RAM disk in bytes.
Returns
The drive ID of the allocated RAM disk, or -1 if the creation was unsuccessful.

◆ FTL_DestroyRamDisk()

void FTL_DestroyRamDisk ( void  )
extern

Close the previously allocated RAM disk.

Parameters
None.
Returns
None.

◆ FTL_GetCurDiskSize()

size_t FTL_GetCurDiskSize ( size_t *  size_hi)
extern

Get the size of block device the current active drive belongs to.

When the size is >= 4GiB, the size is split into 2 parts and they must be joined together by using

size_t size_hi = 0;
size_t size_lo = FTL_GetCurDiskSize(&size_hi);
unsigned long long actual_size = (((unsigned long long) size_hi) << 32) | size_lo;
size_t FTL_GetCurDiskSize(size_t *size_hi)
Get the size of block device the current active drive belongs to.
Parameters
size_hiThe high 32-bit of the size.
Returns
The low 32-bit of the size.

◆ FTL_ReadSector()

int FTL_ReadSector ( size_t  sector,
void *  ptr,
size_t  count 
)
extern

Read sectors from the block device the current active drive belongs to.

Sector size seems to be constant 512 bytes.

Parameters
sectorStart sector number.
ptrTarget pointer. The size must be multiple of 512 bytes.
countHow many sectors to read.
Return values
0The operation was completed successfully.
-1The operation failed with error.

◆ nand_get_params()

int nand_get_params ( int  sbz,
nand_params_t params 
)

Get NAND flash parameters.

Parameters
sbzReserved. Should be set to 0.
paramsParameter structure to write to.
Return values
0The operation was completed successfully.
-1The operation failed with error.

◆ nand_read_page()

int nand_read_page ( int  sbz,
size_t  page,
void *  ptr,
size_t  count,
short  arg5 
)

Read NAND flash pages at a specific page number.

Parameters
sbzReserved. Should be set to 0.
pagePage number where the read should start.
ptrBuffer where the page content will be stored.
countNumber of pages to read.
arg5Unknown. May be related to reading spare sector?
Return values
0The operation was completed successfully.
-1The operation failed with error.