diskdevs.h
来自「AMLOGIC DPF source code」· C头文件 代码 · 共 283 行
H
283 行
/*******************************************************************
*
* Copyright C 2005 by Amlogic, Inc. All Rights Reserved.
*
* Description:
*
* Author: Amlogic Software
* Created: Fri Nov 11 01:07:03 2005
*
*******************************************************************/
/*
* logdisk.h - Physical and logical block devices (disks) support
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Victor V. Vengerov <vvv@oktet.ru>
*
* @(#) diskdevs.h,v 1.1 2002/02/28 20:39:54 joel Exp
*/
#ifndef __AVFS_LIBBLOCK_LOGDISK_H__
#define __AVFS_LIBBLOCK_LOGDISK_H__
#ifdef __cplusplus
extern "C" {
#endif
#if 0
//porting
#include <avfs.h>
#include <avfs/libio.h>
#include <stdlib.h>
#else
#if 1
//porting
typedef void avfs_task;
typedef unsigned32 avfs_task_argument;
#define AVFS_NO_TIMEOUT WATCHDOG_NO_TIMEOUT
#define WATCHDOG_NO_TIMEOUT 0
#define AVFS_WAIT 0x00000000 /* wait on resource */
#define AVFS_NO_WAIT 0x00000001 /* do not wait on resource */
#define AVFS_BINARY_SEMAPHORE 0x00000010
#define AVFS_FIFO 0x00000000 /* process AVFS_FIFO */
#define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */
#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
#define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << 16))
#define IOCGROUP(x) (((x) >> 8) & 0xff)
//#define IOCPARM_MAX PAGE_SIZE /* max size of ioctl, mult. of PAGE_SIZE */
#define IOC_VOID 0x20000000 /* no parameters */
#define IOC_OUT 0x40000000 /* copy out parameters */
#define IOC_IN 0x80000000 /* copy in parameters */
#define IOC_INOUT (IOC_IN|IOC_OUT)
#define IOC_DIRMASK 0xe0000000 /* mask for IN/OUT/VOID */
#define _IOC(inout,group,num,len) \
((u_int32_t)inout | \
(u_int32_t) ((u_int32_t)((u_int32_t)len & IOCPARM_MASK) << 16) | \
(u_int32_t)((group) << 8) | \
(u_int32_t)(num))
#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0)
#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t))
#define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t))
/* this should be _IORW, but stdio got there first */
#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
#endif
#endif
#include "./blkdev.h"
/* Buffer pool identifier */
typedef int avfs_bdpool_id;
/* Block device ioctl handler */
typedef int (* block_device_ioctl) (dev_t dev, int req, void *argp);
/* disk_device: Entry of this type created for every disk device (both for
* logical and physical disks).
* Array of arrays of pointers to disk_device structures maintained. First
* table indexed by major number and second table indexed by minor number.
* Such data organization allow quick lookup using data structure of
* moderated size.
*/
typedef struct disk_device {
dev_t dev; /* Device ID (major + minor) */
struct disk_device *phys_dev; /* Physical device ID (the same
as dev if this entry specifies
the physical device) */
char *name; /* Disk device name */
int uses; /* Use counter. Device couldn't be
removed if it is in use. */
int start; /* Starting block number (0 for
physical devices, block offset
on the related physical device
for logical device) */
int size; /* Size of physical or logical disk
in disk blocks */
int block_size; /* Size of device block (minimum
transfer unit) in bytes
(must be power of 2) */
int block_size_log2; /* log2 of block_size */
avfs_bdpool_id pool; /* Buffer pool assigned to this
device */
block_device_ioctl ioctl; /* ioctl handler for this block
device */
} disk_device;
/* avfs_disk_create_phys --
* Create physical disk entry. This function usually invoked from
* block device driver initialization code when physical device
* detected in the system. Device driver should provide ioctl handler
* to allow block device access operations. This primitive will register
* device in avfs (invoke avfs_io_register_name).
*
* PARAMETERS:
* dev - device identifier (major, minor numbers)
* block_size - size of disk block (minimum data transfer unit); must be
* power of 2
* disk_size - number of blocks on device
* handler - IOCTL handler (function providing basic block input/output
* request handling BIOREQUEST and other device management
* operations)
* name - character name of device (e.g. /dev/hda)
*
* RETURNS:
* AVFS_SUCCESSFUL if information about new physical disk added, or
* error code if error occured (device already registered, wrong block
* size value, no memory available).
*/
avfs_status_code
avfs_disk_create_phys(dev_t dev, int block_size, int disk_size,
block_device_ioctl handler,
char *name);
/* avfs_disk_create_log --
* Create logical disk entry. Logical disk is contiguous area on physical
* disk. Disk may be splitted to several logical disks in several ways:
* manually or using information stored in blocks on physical disk
* (DOS-like partition table, BSD disk label, etc). This function usually
* invoked from application when application-specific splitting are in use,
* or from generic code which handle different logical disk organizations.
* This primitive will register device in avfs (invoke
* avfs_io_register_name).
*
* PARAMETERS:
* dev - logical device identifier (major, minor numbers)
* phys - physical device (block device which holds this logical disk)
* identifier
* start - starting block number on the physical device
* size - logical disk size in blocks
* name - logical disk name
*
* RETURNS:
* AVFS_SUCCESSFUL if logical device successfully added, or error code
* if error occured (device already registered, no physical device
* exists, logical disk is out of physical disk boundaries, no memory
* available).
*/
avfs_status_code
avfs_disk_create_log(dev_t dev, dev_t phys, int start, int size, char *name);
/* avfs_disk_delete --
* Delete physical or logical disk device. Device may be deleted if its
* use counter (and use counters of all logical devices - if it is
* physical device) equal to 0. When physical device deleted,
* all logical devices deleted inherently. Appropriate devices removed
* from "/dev" filesystem.
*
* PARAMETERS:
* dev - device identifier (major, minor numbers)
*
* RETURNS:
* AVFS_SUCCESSFUL if block device successfully deleted, or error code
* if error occured (device is not defined, device is in use).
*/
avfs_status_code
avfs_disk_delete(dev_t dev);
/* avfs_disk_lookup --
* Find block device descriptor by its device identifier. This function
* increment usage counter to 1. User should release disk_device structure
* by invoking avfs_disk_release primitive.
*
* PARAMETERS:
* dev - device identifier (major, minor numbers)
*
* RETURNS:
* pointer to the block device descriptor, or NULL if no such device
* exists.
*/
disk_device *
avfs_disk_lookup(dev_t dev);
/* avfs_disk_release --
* Release disk_device structure (decrement usage counter to 1).
*
* PARAMETERS:
* dd - pointer to disk device structure
*
* RETURNS:
* AVFS_SUCCESSFUL
*
* NOTE:
* It should be implemented as inline function.
*/
avfs_status_code
avfs_disk_release(disk_device *dd);
/* avfs_disk_next --
* Disk device enumerator. Looking for device having device number larger
* than dev and return disk device descriptor for it. If there are no
* such device, NULL value returned.
*
* PARAMETERS:
* dev - device number (use -1 to start search)
*
* RETURNS:
* Pointer to the disk descriptor for next disk device, or NULL if all
* devices enumerated. */
disk_device *
avfs_disk_next(dev_t dev);
/* avfs_set_diskbuf_invalid
*set all bdbufs of one disk invalid
*
*PARAMETERS:
*dbdev: device id
*
* RETURNS:
* AVFS_SUCCESSFUL if all resources released, or error code if error
* occured.
*/
avfs_status_code
avfs_set_diskbuf_invalid(dev_t bddev);
/* avfs_diskio_initialize --
* Initialization of disk device library (initialize all data structures,
* etc.)
*
* PARAMETERS:
* none
*
* RETURNS:
* AVFS_SUCCESSFUL if library initialized, or error code if error
* occured.
*/
avfs_status_code
avfs_disk_io_initialize(void);
/* avfs_diskio_done --
* Release all resources allocated for disk device interface.
*
* PARAMETERS:
* none
*
* RETURNS:
* AVFS_SUCCESSFUL if all resources released, or error code if error
* occured.
*/
avfs_status_code
avfs_disk_io_done(void);
//add by Andrew to support Plug&Play
avfs_status_code AV_Disk_Dev_Register(avfs_device_major_number major,
avfs_device_minor_number minor, int block_size, int disk_size,
block_device_ioctl handler,char *name);
/* unregister a block device, called by physical layer such as ms devices
*/
avfs_status_code AV_Disk_Unregister(avfs_device_major_number major,
avfs_device_minor_number minor);
avfs_status_code
avfs_disk_del_log(dev_t dev);
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?