Flash Translation Layer  1.0
Data Structures | Macros | Typedefs | Enumerations | Functions
device.h File Reference

contain the device information header More...

#include <glib.h>
#include <pthread.h>
#include <stdint.h>
#include <stdlib.h>
#include "include/log.h"
Include dependency graph for device.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  device_address
 generic device address format More...
 
struct  device_request
 request for device More...
 
struct  device_page
 flash board's page information More...
 
struct  device_block
 flash board's block information More...
 
struct  device_package
 flash board's package(nand chip) information More...
 
struct  device_info
 flash board's architecture information More...
 
struct  device
 metadata of the device More...
 
struct  device_operations
 operations for device More...
 

Macros

#define PADDR_EMPTY   ((uint32_t)UINT32_MAX)
 
#define DEVICE_PAGE_SIZE   (8192)
 
#define DEVICE_NR_BUS_BITS   (3)
 device address information More...
 
#define DEVICE_NR_CHIPS_BITS   (3)
 
#define DEVICE_NR_PAGES_BITS   (7)
 
#define DEVICE_NR_BLOCKS_BITS   (19)
 

Typedefs

typedef void(* device_end_req_fn) (struct device_request *)
 I/O end request function. More...
 

Enumerations

enum  { DEVICE_DEFAULT_REQUEST = 0 }
 request allocation flags More...
 
enum  { DEVICE_WRITE = 0, DEVICE_READ, DEVICE_ERASE }
 flash board I/O direction More...
 
enum  { RAMDISK_MODULE = 0, BLUEDBM_MODULE, ZONE_MODULE }
 support module list More...
 

Functions

struct device_requestdevice_alloc_request (uint64_t flags)
 dynamic allocate the device request More...
 
void device_free_request (struct device_request *)
 free pre-allocated device_request resource More...
 
int device_module_init (const uint64_t modnum, struct device **, uint64_t flags)
 initialize the device module More...
 
int device_module_exit (struct device *)
 deallocate the device module More...
 
static size_t device_get_nr_segments (struct device *dev)
 get the number of segments in a flash board More...
 
static size_t device_get_blocks_per_segment (struct device *dev)
 
static size_t device_get_pages_per_segment (struct device *dev)
 get the number of pages in a segment More...
 
static size_t device_get_page_size (struct device *dev)
 get flash board's NAND page size More...
 
static size_t device_get_total_size (struct device *dev)
 total size of a flash board More...
 
static size_t device_get_total_pages (struct device *dev)
 get total the number of pages in a flash board More...
 

Detailed Description

contain the device information header

Author
Gijun Oh
Version
0.2
Date
2021-10-01

Macro Definition Documentation

◆ DEVICE_NR_BLOCKS_BITS

#define DEVICE_NR_BLOCKS_BITS   (19)

◆ DEVICE_NR_BUS_BITS

#define DEVICE_NR_BUS_BITS   (3)

device address information

Note
If you want to use the ZONE_MODULE, you must change the DEVICE_NR_PAGES_BITS and DEVICE_NR_BLOCKS_BITS based on the zone's size.

◆ DEVICE_NR_CHIPS_BITS

#define DEVICE_NR_CHIPS_BITS   (3)

◆ DEVICE_NR_PAGES_BITS

#define DEVICE_NR_PAGES_BITS   (7)

◆ DEVICE_PAGE_SIZE

#define DEVICE_PAGE_SIZE   (8192)

◆ PADDR_EMPTY

#define PADDR_EMPTY   ((uint32_t)UINT32_MAX)

< to use the TOSTRING

Typedef Documentation

◆ device_end_req_fn

typedef void(* device_end_req_fn) (struct device_request *)

I/O end request function.

Parameters
requestdevice request structure's pointer
Note
You must specify the call routine of this function in your custom device module

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

request allocation flags

Enumerator
DEVICE_DEFAULT_REQUEST 

◆ anonymous enum

anonymous enum

flash board I/O direction

Enumerator
DEVICE_WRITE 

write flag

DEVICE_READ 

read flag

DEVICE_ERASE 

erase flag

◆ anonymous enum

anonymous enum

support module list

Enumerator
RAMDISK_MODULE 

select the ramdisk module

BLUEDBM_MODULE 

select the bluedbm module

ZONE_MODULE 

select the zone module

Function Documentation

◆ device_alloc_request()

struct device_request* device_alloc_request ( uint64_t  flags)

dynamic allocate the device request

Parameters
flagsflags for allocate the device request
Returns
device_request pointer when it is allocated or NULL when it is not allocated

◆ device_free_request()

void device_free_request ( struct device_request request)

free pre-allocated device_request resource

Parameters
requestpointer of the device request

◆ device_get_blocks_per_segment()

static size_t device_get_blocks_per_segment ( struct device dev)
static

◆ device_get_nr_segments()

static size_t device_get_nr_segments ( struct device dev)
static

get the number of segments in a flash board

Parameters
devdevice structure pointer
Returns
the number of segments in a flash board

◆ device_get_page_size()

static size_t device_get_page_size ( struct device dev)
static

get flash board's NAND page size

Parameters
devdevice structure pointer
Returns
NAND page size (generally, 8192 or 4096)

◆ device_get_pages_per_segment()

static size_t device_get_pages_per_segment ( struct device dev)
static

get the number of pages in a segment

Parameters
devdevice structure pointer
Returns
the number of pages in a segment
Here is the call graph for this function:

◆ device_get_total_pages()

static size_t device_get_total_pages ( struct device dev)
static

get total the number of pages in a flash board

Parameters
devdevice structure pointer
Returns
the number of pages in a flash board.
Here is the call graph for this function:

◆ device_get_total_size()

static size_t device_get_total_size ( struct device dev)
static

total size of a flash board

Parameters
devdevice structure pointer
Returns
flash board's total size (byte)
Here is the call graph for this function:

◆ device_module_exit()

int device_module_exit ( struct device dev)

deallocate the device module

Parameters
devpointer of the device module's structure
Returns
0 for success, negative value for fail

◆ device_module_init()

int device_module_init ( const uint64_t  modnum,
struct device **  __dev,
uint64_t  flags 
)

initialize the device module

Parameters
modnummodule's number
__devdevice structure pointer (will be allocated)
flagsinitializing flag
Returns
0 for success, negative value for fail
Here is the call graph for this function: