Flash Translation Layer  1.0
Functions | Variables
bluedbm.c File Reference

implementation of the bluedbm abstraction layer which is inherited by the device More...

#include <stdlib.h>
#include <errno.h>
#include <libmemio.h>
#include <pthread.h>
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#include <string.h>
#include "include/bluedbm.h"
#include "include/device.h"
#include "include/log.h"
#include "include/bits.h"
Include dependency graph for bluedbm.c:

Functions

static void bluedbm_erase_end_request (uint64_t segnum, uint8_t is_bad)
 end request for the erase More...
 
static int bluedbm_clear (struct device *dev)
 clear all segments in the flash board More...
 
static void bluedbm_wait_erase_finish (struct device *dev, size_t segnum, size_t nr_segments)
 wait the erase is finished More...
 
int bluedbm_open (struct device *dev, const char *name, int flags)
 open the bluedbm based device More...
 
static void bluedbm_end_rw_request (async_bdbm_req *rw_req)
 end request for the read/write More...
 
ssize_t bluedbm_write (struct device *dev, struct device_request *request)
 write to the flash board More...
 
ssize_t bluedbm_read (struct device *dev, struct device_request *request)
 read from the flash board More...
 
int bluedbm_erase (struct device *dev, struct device_request *request)
 erase a segment More...
 
int bluedbm_close (struct device *dev)
 close the bluedbm More...
 
int bluedbm_device_init (struct device *dev, uint64_t flags)
 initialize the device and bluedbm module More...
 
int bluedbm_device_exit (struct device *dev)
 deallocate the device module More...
 

Variables

gint * g_badseg_counter = NULL
 
gint * g_erase_counter = NULL
 
const struct device_operations __bluedbm_dops
 bluedbm module operations More...
 

Detailed Description

implementation of the bluedbm abstraction layer which is inherited by the device

Author
Gijun Oh
Version
0.2
Date
2021-10-20

Function Documentation

◆ bluedbm_clear()

static int bluedbm_clear ( struct device dev)
static

clear all segments in the flash board

Parameters
devpointer of the device structure
Returns
0 for success, negative value for fail
Here is the call graph for this function:

◆ bluedbm_close()

int bluedbm_close ( struct device dev)

close the bluedbm

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

◆ bluedbm_device_exit()

int bluedbm_device_exit ( struct device dev)

deallocate the device module

Parameters
devpointer of the device structure
Returns
0 for success, negative value for fail
Here is the call graph for this function:

◆ bluedbm_device_init()

int bluedbm_device_init ( struct device dev,
uint64_t  flags 
)

initialize the device and bluedbm module

Parameters
devpointer of the device structure
flagsflags for bluedbm and device
Returns
0 for success, negative value for fail
Here is the call graph for this function:

◆ bluedbm_end_rw_request()

static void bluedbm_end_rw_request ( async_bdbm_req *  rw_req)
static

end request for the read/write

Parameters
rw_reqread/write request pointer

◆ bluedbm_erase()

int bluedbm_erase ( struct device dev,
struct device_request request 
)

erase a segment

Parameters
devpointer of the device structure
requestpointer of the device request structure
Returns
0 for success, negative value for fail
Here is the call graph for this function:

◆ bluedbm_erase_end_request()

static void bluedbm_erase_end_request ( uint64_t  segnum,
uint8_t  is_bad 
)
static

end request for the erase

Parameters
segnumerased segment number
is_baderased segment is bad segment or not
Note
Do not use the non atomic operation or complex operation in this routine. It may occur serious problem.

◆ bluedbm_open()

int bluedbm_open ( struct device dev,
const char *  name,
int  flags 
)

open the bluedbm based device

Parameters
devpointer of the device structure
namethis does not use in this module
flagsopen flags for this module
Returns
0 for success, negative value to fail
Here is the call graph for this function:

◆ bluedbm_read()

ssize_t bluedbm_read ( struct device dev,
struct device_request request 
)

read from the flash board

Parameters
devpointer of the device structure
requestpointer of the device request structure
Returns
read size (bytes)
Here is the call graph for this function:

◆ bluedbm_wait_erase_finish()

static void bluedbm_wait_erase_finish ( struct device dev,
size_t  segnum,
size_t  nr_segments 
)
static

wait the erase is finished

Parameters
devpointer of the device structure
segnuminitial position to erase target segment
nr_segmentsnumber of segments to erase
Note
If you fail to execute the erase the target segment, this function may block the thread forever.
Here is the call graph for this function:

◆ bluedbm_write()

ssize_t bluedbm_write ( struct device dev,
struct device_request request 
)

write to the flash board

Parameters
devpointer of the device structure
requestpointer of the device request structure
Returns
written size (bytes)
Here is the call graph for this function:

Variable Documentation

◆ __bluedbm_dops

const struct device_operations __bluedbm_dops
Initial value:
= {
.open = bluedbm_open,
.write = bluedbm_write,
.read = bluedbm_read,
.erase = bluedbm_erase,
.close = bluedbm_close,
}
int bluedbm_close(struct device *dev)
close the bluedbm
Definition: bluedbm.c:499
ssize_t bluedbm_read(struct device *dev, struct device_request *request)
read from the flash board
Definition: bluedbm.c:352
int bluedbm_open(struct device *dev, const char *name, int flags)
open the bluedbm based device
Definition: bluedbm.c:134
int bluedbm_erase(struct device *dev, struct device_request *request)
erase a segment
Definition: bluedbm.c:441
ssize_t bluedbm_write(struct device *dev, struct device_request *request)
write to the flash board
Definition: bluedbm.c:260

bluedbm module operations

◆ g_badseg_counter

gint* g_badseg_counter = NULL

counter for bad segemnt detection

◆ g_erase_counter

gint* g_erase_counter = NULL

counter for # of erase in the segment