RTEMS CPU Kit with SuperCore
Data Structures | Macros | Typedefs | Functions
nvdisk.c File Reference

Non-Volatile 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 <inttypes.h>
#include "rtems/blkdev.h"
#include "rtems/diskdevs.h"
#include "rtems/nvdisk.h"
Include dependency graph for nvdisk.c:

Data Structures

struct  rtems_nvdisk_device_ctl
 NV Device Control holds the segment controls. More...
 
struct  rtems_mvdisk
 The NV disk control structure for a single disk. More...
 

Macros

#define RTEMS_NVDISK_TRACE   0
 Control tracing. More...
 
#define rtems_nvdisk_calc_crc16(_b, _c)   rtems_nvdisk_crc16_factor[((_b) ^ ((_c) & 0xff)) & 0xff] ^ (((_c) >> 8) & 0xff)
 Calculate the CRC16 checksum. More...
 

Typedefs

typedef struct rtems_nvdisk_device_ctl rtems_nvdisk_device_ctl
 NV Device Control holds the segment controls.
 
typedef struct rtems_mvdisk rtems_nvdisk
 The NV disk control structure for a single disk. More...
 

Functions

rtems_device_driver rtems_nvdisk_initialize (rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
 NV disk device driver initialization. More...
 

Detailed Description

Non-Volatile Disk Block Device Implementation.

Macro Definition Documentation

◆ rtems_nvdisk_calc_crc16

#define rtems_nvdisk_calc_crc16 (   _b,
  _c 
)    rtems_nvdisk_crc16_factor[((_b) ^ ((_c) & 0xff)) & 0xff] ^ (((_c) >> 8) & 0xff)

Calculate the CRC16 checksum.

Parameters
_bThe byte to checksum.
_cThe current checksum.

◆ RTEMS_NVDISK_TRACE

#define RTEMS_NVDISK_TRACE   0

Control tracing.

Note

The use of pages can vary. The rtems_nvdisk_*_page set routines use an absolute page number relative to the segment while all other page numbera are relative to the number of page descriptor pages a segment has. You need to add the number of page descriptor pages (pages_desc) to the page number when call the rtems_nvdisk_*_page functions.

You must always show the page number as relative in any trace or error message as device-page and if you have to the page number as absolute use device~page. This can be seen in the page copy routine.

The code is like this to avoid needing the pass the pages_desc value around. It is only used in selected places and so the extra parameter was avoided. It can be compiled out of the code for small footprint targets. Leave in by default.

Typedef Documentation

◆ rtems_nvdisk

typedef struct rtems_mvdisk rtems_nvdisk

The NV disk control structure for a single disk.

There is one for each minor disk in the system.

Function Documentation

◆ rtems_nvdisk_initialize()

rtems_device_driver rtems_nvdisk_initialize ( rtems_device_major_number  major,
rtems_device_minor_number  minor,
void *  arg 
)

NV disk device driver initialization.

Non-volatile disk device driver initialization.

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