#ifndef _FSSH_DRIVERS_DRIVERS_H
#define _FSSH_DRIVERS_DRIVERS_H
#include "fssh_defs.h"
#include "fssh_fs_interface.h"
#ifdef __cplusplus
extern "C" {
#endif
these hooks are how the kernel accesses the device
--- */
typedef fssh_status_t (*fssh_device_open_hook) (const char *name,
uint32_t flags, void **cookie);
typedef fssh_status_t (*fssh_device_close_hook) (void *cookie);
typedef fssh_status_t (*fssh_device_free_hook) (void *cookie);
typedef fssh_status_t (*fssh_device_control_hook) (void *cookie, uint32_t op,
void *data, fssh_size_t len);
typedef fssh_status_t (*fssh_device_read_hook) (void *cookie,
fssh_off_t position, void *data,
fssh_size_t *numBytes);
typedef fssh_status_t (*fssh_device_write_hook) (void *cookie,
fssh_off_t position, const void *data,
fssh_size_t *numBytes);
typedef fssh_status_t (*fssh_device_select_hook) (void *cookie, uint8_t event,
uint32_t ref, fssh_selectsync *sync);
typedef fssh_status_t (*fssh_device_deselect_hook) (void *cookie, uint8_t event,
fssh_selectsync *sync);
typedef fssh_status_t (*fssh_device_read_pages_hook)(void *cookie,
fssh_off_t position, const fssh_iovec *vec,
fssh_size_t count, fssh_size_t *_numBytes);
typedef fssh_status_t (*fssh_device_write_pages_hook) (void *cookie,
fssh_off_t position, const fssh_iovec *vec,
fssh_size_t count, fssh_size_t *_numBytes);
#define FSSH_B_CUR_DRIVER_API_VERSION 2
the device_hooks structure is a descriptor for the device, giving its
entry points.
--- */
typedef struct {
fssh_device_open_hook open;
fssh_device_close_hook close;
fssh_device_free_hook free;
fssh_device_control_hook control;
fssh_device_read_hook read;
fssh_device_write_hook write;
fssh_device_select_hook select;
fssh_device_deselect_hook deselect;
fssh_device_read_pages_hook read_pages;
fssh_device_write_pages_hook write_pages;
} fssh_device_hooks;
fssh_status_t fssh_init_hardware(void);
const char **fssh_publish_devices(void);
fssh_device_hooks *fssh_find_device(const char *name);
fssh_status_t fssh_init_driver(void);
void fssh_uninit_driver(void);
extern int32_t fssh_api_version;
enum {
FSSH_B_GET_DEVICE_SIZE = 1,
FSSH_B_SET_DEVICE_SIZE,
FSSH_B_SET_NONBLOCKING_IO,
FSSH_B_SET_BLOCKING_IO,
FSSH_B_GET_READ_STATUS,
FSSH_B_GET_WRITE_STATUS,
FSSH_B_GET_GEOMETRY,
FSSH_B_GET_DRIVER_FOR_DEVICE,
FSSH_B_GET_PARTITION_INFO,
FSSH_B_SET_PARTITION,
FSSH_B_FORMAT_DEVICE,
FSSH_B_EJECT_DEVICE,
FSSH_B_GET_ICON,
FSSH_B_GET_BIOS_GEOMETRY,
FSSH_B_GET_MEDIA_STATUS,
FSSH_B_LOAD_MEDIA,
FSSH_B_GET_BIOS_DRIVE_ID,
FSSH_B_SET_UNINTERRUPTABLE_IO,
FSSH_B_SET_INTERRUPTABLE_IO,
FSSH_B_FLUSH_DRIVE_CACHE,
FSSH_B_GET_PATH_FOR_DEVICE,
FSSH_B_GET_ICON_NAME,
FSSH_B_GET_VECTOR_ICON,
FSSH_B_GET_DEVICE_NAME,
FSSH_B_TRIM_DEVICE,
FSSH_B_GET_NEXT_OPEN_DEVICE = 1000,
FSSH_B_ADD_FIXED_DRIVER,
FSSH_B_REMOVE_FIXED_DRIVER,
FSSH_B_AUDIO_DRIVER_BASE = 8000,
FSSH_B_MIDI_DRIVER_BASE = 8100,
FSSH_B_JOYSTICK_DRIVER_BASE = 8200,
FSSH_B_GRAPHIC_DRIVER_BASE = 8300,
FSSH_B_DEVICE_OP_CODES_END = 9999
};
geometry structure for the B_GET_GEOMETRY opcode
--- */
typedef struct {
uint32_t bytes_per_sector;
uint32_t sectors_per_track;
uint32_t cylinder_count;
uint32_t head_count;
uint8_t device_type;
bool removable;
bool read_only;
bool write_once;
} fssh_device_geometry;
Be-defined device types returned by B_GET_GEOMETRY. Use these if it makes
sense for your device.
--- */
enum {
FSSH_B_DISK = 0,
FSSH_B_TAPE,
FSSH_B_PRINTER,
FSSH_B_CPU,
FSSH_B_WORM,
FSSH_B_CD,
FSSH_B_SCANNER,
FSSH_B_OPTICAL,
FSSH_B_JUKEBOX,
FSSH_B_NETWORK
};
partition_info structure used by B_GET_PARTITION_INFO and B_SET_PARTITION
--- */
typedef struct {
fssh_off_t offset;
fssh_off_t size;
int32_t logical_block_size;
int32_t session;
int32_t partition;
char device[256];
} fssh_partition_info;
driver_path structure returned by the B_GET_DRIVER_FOR_DEVICE
--- */
typedef char fssh_driver_path[256];
open_device_iterator structure used by the B_GET_NEXT_OPEN_DEVICE opcode
--- */
typedef struct {
uint32_t cookie;
char device[256];
} fssh_open_device_iterator;
icon structure for the B_GET_ICON opcode
--- */
typedef struct {
int32_t icon_size;
void *icon_data;
} fssh_device_icon;
typedef struct {
uint32_t range_count;
uint64_t trimmed_size;
struct range {
uint64_t offset;
uint64_t size;
} ranges[1];
} fssh_fs_trim_data;
#ifdef __cplusplus
}
#endif
#endif