RTEMS  5.1
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/nvdisk.h>
#include <rtems/thread.h>

Data Structures

struct  rtems_nvdisk_device_ctl
 
struct  rtems_nvdisk
 

Macros

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

Typedefs

typedef struct rtems_nvdisk_device_ctl rtems_nvdisk_device_ctl
 

Functions

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

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
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.Control tracing. It can be compiled out of the code for small footprint targets. Leave in by default.

Typedef Documentation

◆ rtems_nvdisk_device_ctl

NV Device Control holds the segment controls

Function Documentation

◆ rtems_nvdisk_initialize()

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

NV 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.