RTEMS  5.1
Data Structures | Macros | Typedefs | Functions
flashdisk.c File Reference

Flash Disk Block Device Implementation. More...

#include <rtems.h>
#include <rtems/libio.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <inttypes.h>
#include <rtems/blkdev.h>
#include <rtems/flashdisk.h>
#include <rtems/thread.h>

Data Structures

struct  rtems_fdisk_page_desc
 
struct  rtems_fdisk_segment_ctl
 
struct  rtems_fdisk_segment_ctl_queue
 
struct  rtems_fdisk_device_ctl
 
struct  rtems_fdisk_block_ctl
 
struct  rtems_flashdisk
 

Macros

#define RTEMS_FDISK_TRACE   1
 
#define RTEMS_FDISK_PAGE_ACTIVE   (1 << 0)
 
#define RTEMS_FDISK_PAGE_USED   (1 << 1)
 
#define rtems_fdisk_calc_crc16(_b, _c)   rtems_fdisk_crc16_factor[((_b) ^ ((_c) & 0xff)) & 0xff] ^ (((_c) >> 8) & 0xff)
 

Typedefs

typedef struct rtems_fdisk_page_desc rtems_fdisk_page_desc
 
typedef struct rtems_fdisk_segment_ctl rtems_fdisk_segment_ctl
 
typedef struct rtems_fdisk_segment_ctl_queue rtems_fdisk_segment_ctl_queue
 
typedef struct rtems_fdisk_device_ctl rtems_fdisk_device_ctl
 
typedef struct rtems_fdisk_block_ctl rtems_fdisk_block_ctl
 
typedef struct rtems_flashdisk rtems_flashdisk
 

Functions

rtems_device_driver rtems_fdisk_initialize (rtems_device_major_number major, rtems_device_minor_number minor, void *arg RTEMS_UNUSED)
 

Detailed Description

Flash Disk Block Device Implementation.

Macro Definition Documentation

◆ rtems_fdisk_calc_crc16

#define rtems_fdisk_calc_crc16 (   _b,
  _c 
)    rtems_fdisk_crc16_factor[((_b) ^ ((_c) & 0xff)) & 0xff] ^ (((_c) >> 8) & 0xff)

Calculate the CRC16 checksum.

Parameters
_bThe byte to checksum.
_cThe current checksum.

◆ RTEMS_FDISK_PAGE_ACTIVE

#define RTEMS_FDISK_PAGE_ACTIVE   (1 << 0)

Flag the page as active.

◆ RTEMS_FDISK_PAGE_USED

#define RTEMS_FDISK_PAGE_USED   (1 << 1)

Flag the page as used.

◆ RTEMS_FDISK_TRACE

#define RTEMS_FDISK_TRACE   1

Control tracing. It can be compiled out of the code for small footprint targets. Leave in by default.

Typedef Documentation

◆ rtems_fdisk_block_ctl

The Block control holds the segment and page with the data.

◆ rtems_fdisk_device_ctl

Flash Device Control holds the segment controls

◆ rtems_fdisk_page_desc

The start of a segment has a segment control table. This hold the CRC and block number for the page.

Todo:
A sequence number for the block could be added. This would mean a larger descriptor size. Need to make the sequence large like 20+ bits so a large file system would not have more blocks available than the sequence number.

◆ rtems_fdisk_segment_ctl

Flash Segment Control holds the pointer to the segment, number of pages, various page stats and the memory copy of the page descriptors.

◆ rtems_fdisk_segment_ctl_queue

Segment control table queue.

◆ rtems_flashdisk

The virtual block table holds the mapping for blocks as seen by the disk drivers to the device, segment and page numbers of the physical device.

Function Documentation

◆ rtems_fdisk_initialize()

rtems_device_driver rtems_fdisk_initialize ( rtems_device_major_number  major,
rtems_device_minor_number  minor,
void *arg  RTEMS_UNUSED 
)

Flash disk device driver initialization.

Todo:
Memory clean up on error is really badly handled.
Parameters
majorFlash disk major device number.
minorMinor device number, not applicable.
argInitialization argument, not applicable.