RTEMS CPU Kit with SuperCore  4.11.3
Data Structures | Macros | Typedefs | Enumerations | Functions

Block device buffer management. More...

#include <limits.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <pthread.h>
#include <rtems.h>
#include <rtems/error.h>
#include "rtems/bdbuf.h"
Include dependency graph for bdbuf.c:

Data Structures

struct  rtems_bdbuf_swapout_transfer
 A swapout transfer transaction data. More...
 
struct  rtems_bdbuf_swapout_worker
 Swapout worker thread. More...
 
struct  rtems_bdbuf_waiters
 Buffer waiters synchronization. More...
 
struct  rtems_bdbuf_cache
 The BD buffer cache. More...
 

Macros

#define RTEMS_BDBUF_TRACE   0
 Set to 1 to enable debug tracing.
 
#define BDBUF_INVALID_DEV   NULL
 
#define bdbuf_config   rtems_bdbuf_configuration
 
#define RTEMS_BDBUF_SWAPOUT_SYNC   RTEMS_EVENT_2
 The events used in this code. More...
 
#define RTEMS_BDBUF_READ_AHEAD_WAKE_UP   RTEMS_EVENT_1
 
#define RTEMS_BDBUF_CACHE_LOCK_ATTRIBS
 Lock semaphore attributes. More...
 
#define RTEMS_BDBUF_CACHE_WAITER_ATTRIBS
 Waiter semaphore attributes. More...
 
#define RTEMS_BDBUF_WAIT_TIMEOUT   RTEMS_NO_TIMEOUT
 Waiter timeout. More...
 
#define rtems_bdbuf_tracer   (0)
 
#define rtems_bdbuf_show_usage()   ((void) 0)
 
#define rtems_bdbuf_show_users(_w, _b)   ((void) 0)
 
#define RTEMS_BDBUF_AVL_MAX_HEIGHT   (32)
 The default maximum height of 32 allows for AVL trees having between 5,704,880 and 4,294,967,295 nodes, depending on order of insertion. More...
 
#define bdbuf_alloc(size)   __builtin_alloca (size)
 

Typedefs

typedef struct rtems_bdbuf_swapout_transfer rtems_bdbuf_swapout_transfer
 A swapout transfer transaction data. More...
 
typedef struct rtems_bdbuf_swapout_worker rtems_bdbuf_swapout_worker
 Swapout worker thread. More...
 
typedef rtems_id rtems_bdbuf_lock_type
 
typedef struct rtems_bdbuf_waiters rtems_bdbuf_waiters
 Buffer waiters synchronization.
 
typedef struct rtems_bdbuf_cache rtems_bdbuf_cache
 The BD buffer cache.
 

Enumerations

enum  rtems_bdbuf_fatal_code {
  RTEMS_BDBUF_FATAL_CACHE_LOCK, RTEMS_BDBUF_FATAL_CACHE_UNLOCK, RTEMS_BDBUF_FATAL_CACHE_WAIT_2, RTEMS_BDBUF_FATAL_CACHE_WAIT_TO,
  RTEMS_BDBUF_FATAL_CACHE_WAKE, RTEMS_BDBUF_FATAL_PREEMPT_DIS, RTEMS_BDBUF_FATAL_PREEMPT_RST, RTEMS_BDBUF_FATAL_RA_WAKE_UP,
  RTEMS_BDBUF_FATAL_RECYCLE, RTEMS_BDBUF_FATAL_SO_WAKE_1, RTEMS_BDBUF_FATAL_SO_WAKE_2, RTEMS_BDBUF_FATAL_STATE_0,
  RTEMS_BDBUF_FATAL_STATE_2, RTEMS_BDBUF_FATAL_STATE_4, RTEMS_BDBUF_FATAL_STATE_5, RTEMS_BDBUF_FATAL_STATE_6,
  RTEMS_BDBUF_FATAL_STATE_7, RTEMS_BDBUF_FATAL_STATE_8, RTEMS_BDBUF_FATAL_STATE_9, RTEMS_BDBUF_FATAL_STATE_10,
  RTEMS_BDBUF_FATAL_STATE_11, RTEMS_BDBUF_FATAL_SWAPOUT_RE, RTEMS_BDBUF_FATAL_SYNC_LOCK, RTEMS_BDBUF_FATAL_SYNC_UNLOCK,
  RTEMS_BDBUF_FATAL_TREE_RM, RTEMS_BDBUF_FATAL_WAIT_EVNT, RTEMS_BDBUF_FATAL_WAIT_TRANS_EVNT, RTEMS_BDBUF_FATAL_ONCE,
  RTEMS_BDBUF_FATAL_MTX_ATTR_INIT, RTEMS_BDBUF_FATAL_MTX_ATTR_SETPROTO, RTEMS_BDBUF_FATAL_CV_WAIT, RTEMS_BDBUF_FATAL_CV_BROADCAST
}
 

Functions

rtems_status_code rtems_bdbuf_init (void)
 Prepare buffering layer to work - initialize buffer descritors and (if it is neccessary) buffers. More...
 
rtems_status_code rtems_bdbuf_get (rtems_disk_device *dd, rtems_blkdev_bnum block, rtems_bdbuf_buffer **bd_ptr)
 Get block buffer for data to be written into. More...
 
rtems_status_code rtems_bdbuf_read (rtems_disk_device *dd, rtems_blkdev_bnum block, rtems_bdbuf_buffer **bd_ptr)
 Get the block buffer and if not already in the cache read from the disk. More...
 
rtems_status_code rtems_bdbuf_release (rtems_bdbuf_buffer *bd)
 Release the buffer obtained by a read call back to the cache. More...
 
rtems_status_code rtems_bdbuf_release_modified (rtems_bdbuf_buffer *bd)
 Release the buffer allocated with a get or read call placing it on the modified list. More...
 
rtems_status_code rtems_bdbuf_sync (rtems_bdbuf_buffer *bd)
 Release the buffer as modified and wait until it has been synchronized with the disk by writing it. More...
 
rtems_status_code rtems_bdbuf_syncdev (rtems_disk_device *dd)
 Synchronize all modified buffers for this device with the disk and wait until the transfers have completed. More...
 
void rtems_bdbuf_purge_dev (rtems_disk_device *dd)
 Purges all buffers corresponding to the disk device dd. More...
 
rtems_status_code rtems_bdbuf_set_block_size (rtems_disk_device *dd, uint32_t block_size, bool sync)
 Sets the block size of a disk device. More...
 
void rtems_bdbuf_get_device_stats (const rtems_disk_device *dd, rtems_blkdev_stats *stats)
 Returns the block device statistics.
 
void rtems_bdbuf_reset_device_stats (rtems_disk_device *dd)
 Resets the block device statistics.
 

Detailed Description

Block device buffer management.

Macro Definition Documentation

◆ RTEMS_BDBUF_AVL_MAX_HEIGHT

#define RTEMS_BDBUF_AVL_MAX_HEIGHT   (32)

The default maximum height of 32 allows for AVL trees having between 5,704,880 and 4,294,967,295 nodes, depending on order of insertion.

You may change this compile-time constant as you wish.

◆ RTEMS_BDBUF_CACHE_LOCK_ATTRIBS

#define RTEMS_BDBUF_CACHE_LOCK_ATTRIBS
Value:
RTEMS_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL)
#define RTEMS_BINARY_SEMAPHORE
This attribute constant indicates that the Classic API Semaphore instance created will be a proper bi...
Definition: attr.h:106
#define RTEMS_PRIORITY
This is the attribute constant which reflects that blocking tasks will be managed using task priority...
Definition: attr.h:70
#define RTEMS_NO_PRIORITY_CEILING
This attribute constant indicates that the Classic API Semaphore instance created will NOT use the Pr...
Definition: attr.h:132
#define RTEMS_LOCAL
This is the attribute constant to indicate local resource.
Definition: attr.h:53

Lock semaphore attributes.

This is used for locking type mutexes.

Warning
Priority inheritance is on.

◆ RTEMS_BDBUF_CACHE_WAITER_ATTRIBS

#define RTEMS_BDBUF_CACHE_WAITER_ATTRIBS
Value:
RTEMS_NO_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL)
#define RTEMS_SIMPLE_BINARY_SEMAPHORE
This attribute constant indicates that the Classic API Semaphore instance created will be a simple bi...
Definition: attr.h:112
#define RTEMS_PRIORITY
This is the attribute constant which reflects that blocking tasks will be managed using task priority...
Definition: attr.h:70
#define RTEMS_NO_PRIORITY_CEILING
This attribute constant indicates that the Classic API Semaphore instance created will NOT use the Pr...
Definition: attr.h:132
#define RTEMS_LOCAL
This is the attribute constant to indicate local resource.
Definition: attr.h:53

Waiter semaphore attributes.

Warning
Do not configure as inherit priority. If a driver is in the driver initialisation table this locked semaphore will have the IDLE task as the holder and a blocking task will raise the priority of the IDLE task which can cause unsual side effects.

◆ RTEMS_BDBUF_SWAPOUT_SYNC

#define RTEMS_BDBUF_SWAPOUT_SYNC   RTEMS_EVENT_2

The events used in this code.

These should be system events rather than application events.

◆ RTEMS_BDBUF_WAIT_TIMEOUT

#define RTEMS_BDBUF_WAIT_TIMEOUT   RTEMS_NO_TIMEOUT

Waiter timeout.

Set to non-zero to find some info on a waiter that is waiting too long.

Typedef Documentation

◆ rtems_bdbuf_swapout_transfer

A swapout transfer transaction data.

This data is passed to a worked thread to handle the write phase of the transfer.

◆ rtems_bdbuf_swapout_worker

Swapout worker thread.

These are available to take processing from the main swapout thread and handle the I/O operation.