Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
storage.h File Reference
#include "ultibo/globaltypes.h"
#include "ultibo/globalconst.h"
#include "ultibo/system.h"
#include "ultibo/devices.h"

Go to the source code of this file.

Data Structures

struct  _STORAGE_DEVICE

Macros

#define STORAGE_NAME_PREFIX   "Storage"
 Name prefix for Storage Devices.
#define STORAGE_STATUS_TIMER_INTERVAL   1000
#define STORAGE_TYPE_NONE   0
#define STORAGE_TYPE_HDD   1
#define STORAGE_TYPE_FDD   2
#define STORAGE_TYPE_CDROM   3
#define STORAGE_TYPE_OPTICAL   4
#define STORAGE_TYPE_TAPE   5
#define STORAGE_TYPE_REMOVABLE   6
#define STORAGE_STATE_EJECTED   0
#define STORAGE_STATE_EJECTING   1
#define STORAGE_STATE_INSERTING   2
#define STORAGE_STATE_INSERTED   3
#define STORAGE_FLAG_NONE   0x00000000
#define STORAGE_FLAG_REMOVABLE   0x00000001
#define STORAGE_FLAG_LBA48   0x00000002
#define STORAGE_FLAG_NOT_READY   0x00000004
#define STORAGE_FLAG_NO_MEDIA   0x00000008
#define STORAGE_FLAG_READ_ONLY   0x00000010
#define STORAGE_FLAG_WRITE_ONLY   0x00000020
#define STORAGE_FLAG_ERASEABLE   0x00000040
#define STORAGE_FLAG_LOCKABLE   0x00000080
#define STORAGE_FLAG_LOCKED   0x00000100
#define STORAGE_FLAG_EJECTABLE   0x00000200
#define STORAGE_FLAG_CHANGABLE   0x00000400
#define STORAGE_CONTROL_TEST_READY   1
 Test Unit Ready.
#define STORAGE_CONTROL_RESET   2
 Reset Device.
#define STORAGE_CONTROL_TEST_MEDIA   3
 Test No Media.
#define STORAGE_CONTROL_LOCK   4
 Lock Media.
#define STORAGE_CONTROL_UNLOCK   5
 Unlock Media.
#define STORAGE_CONTROL_EJECT   6
 Eject Media.
#define STORAGE_CONTROL_TEST_LOCKED   7
 Test Media Locked.
#define STORAGE_CONTROL_TEST_CHANGED   8
 Test Media Changed.
#define STORAGE_CONTROL_GET_VENDORID   9
 Get Vendor ID.
#define STORAGE_CONTROL_GET_PRODUCTID   10
 Get Product ID.
#define STORAGE_CONTROL_GET_SERIAL   11
 Get Serial No.
#define STORAGE_CONTROL_GET_REVISION   12
 Get Revision No.
#define STORAGE_CONTROL_GET_PRODUCT   13
 Get Product Name.
#define STORAGE_CONTROL_GET_MANUFACTURER   14
 Get Manufacturer Name.

Typedefs

typedef struct _STORAGE_DEVICE STORAGE_DEVICE
typedef uint32_t STDCALL(* storage_enumerate_cb) (STORAGE_DEVICE *storage, void *data)
typedef uint32_t STDCALL(* storage_notification_cb) (DEVICE *device, void *data, uint32_t notification)
typedef uint32_t STDCALL(* storage_device_read_proc) (STORAGE_DEVICE *storage, int64_t start, int64_t count, void *buffer)
typedef uint32_t STDCALL(* storage_device_write_proc) (STORAGE_DEVICE *storage, int64_t start, int64_t count, void *buffer)
typedef uint32_t STDCALL(* storage_device_erase_proc) (STORAGE_DEVICE *storage, int64_t start, int64_t count)
typedef uint32_t STDCALL(* storage_device_control_proc) (STORAGE_DEVICE *storage, int request, size_t argument1, size_t *argument2)

Functions

uint32_t STDCALL storage_device_read (STORAGE_DEVICE *storage, int64_t start, int64_t count, void *buffer)
uint32_t STDCALL storage_device_write (STORAGE_DEVICE *storage, int64_t start, int64_t count, void *buffer)
uint32_t STDCALL storage_device_erase (STORAGE_DEVICE *storage, int64_t start, int64_t count)
uint32_t STDCALL storage_device_control (STORAGE_DEVICE *storage, int request, size_t argument1, size_t *argument2)
uint32_t STDCALL storage_device_set_state (STORAGE_DEVICE *storage, uint32_t state)
 Set the state of the specified storage and send a notification.
uint32_t STDCALL storage_device_start_status (STORAGE_DEVICE *storage, uint32_t interval)
 Start status monitoring on the specified storage for insert/eject notifications.
uint32_t STDCALL storage_device_stop_status (STORAGE_DEVICE *storage)
 Stop status monitoring on the specified storage for insert/eject notifications.
STORAGE_DEVICE *STDCALL storage_device_create (void)
 Create a new Storage entry.
STORAGE_DEVICE *STDCALL storage_device_create_ex (uint32_t size)
 Create a new Storage entry.
uint32_t STDCALL storage_device_destroy (STORAGE_DEVICE *storage)
 Destroy an existing Storage entry.
uint32_t STDCALL storage_device_register (STORAGE_DEVICE *storage)
 Register a new Storage in the Storage table.
uint32_t STDCALL storage_device_deregister (STORAGE_DEVICE *storage)
 Deregister a Storage from the Storage table.
STORAGE_DEVICE *STDCALL storage_device_find (uint32_t storageid)
STORAGE_DEVICE *STDCALL storage_device_find_by_device (DEVICE *device)
 Find a Storage device by the matching DeviceData property.
STORAGE_DEVICE *STDCALL storage_device_find_by_name (const char *name)
STORAGE_DEVICE *STDCALL storage_device_find_by_description (const char *description)
uint32_t STDCALL storage_device_enumerate (storage_enumerate_cb callback, void *data)
uint32_t STDCALL storage_device_notification (STORAGE_DEVICE *storage, storage_notification_cb callback, void *data, uint32_t notification, uint32_t flags)
uint32_t STDCALL storage_get_count (void)
 Get the current storage count.
STORAGE_DEVICE *STDCALL storage_device_check (STORAGE_DEVICE *storage)
 Check if the supplied Storage is in the storage table.
uint32_t STDCALL storage_device_type_to_string (uint32_t storagetype, char *string, uint32_t len)
uint32_t STDCALL storage_device_state_to_string (uint32_t storagestate, char *string, uint32_t len)
uint32_t STDCALL storage_device_state_to_notification (uint32_t state)
 Convert a Storage state value into the notification code for device notifications.

Macro Definition Documentation

◆ STORAGE_NAME_PREFIX

#define STORAGE_NAME_PREFIX   "Storage"

Name prefix for Storage Devices.

Storage specific constants

◆ STORAGE_STATUS_TIMER_INTERVAL

#define STORAGE_STATUS_TIMER_INTERVAL   1000

◆ STORAGE_TYPE_NONE

#define STORAGE_TYPE_NONE   0

Storage Device Types

◆ STORAGE_TYPE_HDD

#define STORAGE_TYPE_HDD   1

◆ STORAGE_TYPE_FDD

#define STORAGE_TYPE_FDD   2

◆ STORAGE_TYPE_CDROM

#define STORAGE_TYPE_CDROM   3

◆ STORAGE_TYPE_OPTICAL

#define STORAGE_TYPE_OPTICAL   4

◆ STORAGE_TYPE_TAPE

#define STORAGE_TYPE_TAPE   5

◆ STORAGE_TYPE_REMOVABLE

#define STORAGE_TYPE_REMOVABLE   6

◆ STORAGE_STATE_EJECTED

#define STORAGE_STATE_EJECTED   0

Storage Device States

◆ STORAGE_STATE_EJECTING

#define STORAGE_STATE_EJECTING   1

◆ STORAGE_STATE_INSERTING

#define STORAGE_STATE_INSERTING   2

◆ STORAGE_STATE_INSERTED

#define STORAGE_STATE_INSERTED   3

◆ STORAGE_FLAG_NONE

#define STORAGE_FLAG_NONE   0x00000000

Storage Device Flags

◆ STORAGE_FLAG_REMOVABLE

#define STORAGE_FLAG_REMOVABLE   0x00000001

◆ STORAGE_FLAG_LBA48

#define STORAGE_FLAG_LBA48   0x00000002

◆ STORAGE_FLAG_NOT_READY

#define STORAGE_FLAG_NOT_READY   0x00000004

◆ STORAGE_FLAG_NO_MEDIA

#define STORAGE_FLAG_NO_MEDIA   0x00000008

◆ STORAGE_FLAG_READ_ONLY

#define STORAGE_FLAG_READ_ONLY   0x00000010

◆ STORAGE_FLAG_WRITE_ONLY

#define STORAGE_FLAG_WRITE_ONLY   0x00000020

◆ STORAGE_FLAG_ERASEABLE

#define STORAGE_FLAG_ERASEABLE   0x00000040

◆ STORAGE_FLAG_LOCKABLE

#define STORAGE_FLAG_LOCKABLE   0x00000080

◆ STORAGE_FLAG_LOCKED

#define STORAGE_FLAG_LOCKED   0x00000100

◆ STORAGE_FLAG_EJECTABLE

#define STORAGE_FLAG_EJECTABLE   0x00000200

◆ STORAGE_FLAG_CHANGABLE

#define STORAGE_FLAG_CHANGABLE   0x00000400

◆ STORAGE_CONTROL_TEST_READY

#define STORAGE_CONTROL_TEST_READY   1

Test Unit Ready.

Storage Device Control Codes

◆ STORAGE_CONTROL_RESET

#define STORAGE_CONTROL_RESET   2

Reset Device.

◆ STORAGE_CONTROL_TEST_MEDIA

#define STORAGE_CONTROL_TEST_MEDIA   3

Test No Media.

◆ STORAGE_CONTROL_LOCK

#define STORAGE_CONTROL_LOCK   4

Lock Media.

◆ STORAGE_CONTROL_UNLOCK

#define STORAGE_CONTROL_UNLOCK   5

Unlock Media.

◆ STORAGE_CONTROL_EJECT

#define STORAGE_CONTROL_EJECT   6

Eject Media.

◆ STORAGE_CONTROL_TEST_LOCKED

#define STORAGE_CONTROL_TEST_LOCKED   7

Test Media Locked.

◆ STORAGE_CONTROL_TEST_CHANGED

#define STORAGE_CONTROL_TEST_CHANGED   8

Test Media Changed.

◆ STORAGE_CONTROL_GET_VENDORID

#define STORAGE_CONTROL_GET_VENDORID   9

Get Vendor ID.

◆ STORAGE_CONTROL_GET_PRODUCTID

#define STORAGE_CONTROL_GET_PRODUCTID   10

Get Product ID.

◆ STORAGE_CONTROL_GET_SERIAL

#define STORAGE_CONTROL_GET_SERIAL   11

Get Serial No.

◆ STORAGE_CONTROL_GET_REVISION

#define STORAGE_CONTROL_GET_REVISION   12

Get Revision No.

◆ STORAGE_CONTROL_GET_PRODUCT

#define STORAGE_CONTROL_GET_PRODUCT   13

Get Product Name.

◆ STORAGE_CONTROL_GET_MANUFACTURER

#define STORAGE_CONTROL_GET_MANUFACTURER   14

Get Manufacturer Name.

Typedef Documentation

◆ STORAGE_DEVICE

Storage specific types Storage Device

◆ storage_enumerate_cb

typedef uint32_t STDCALL(* storage_enumerate_cb) (STORAGE_DEVICE *storage, void *data)

Storage Enumeration Callback

◆ storage_notification_cb

typedef uint32_t STDCALL(* storage_notification_cb) (DEVICE *device, void *data, uint32_t notification)

Storage Notification Callback

◆ storage_device_read_proc

typedef uint32_t STDCALL(* storage_device_read_proc) (STORAGE_DEVICE *storage, int64_t start, int64_t count, void *buffer)

Storage Device Methods

◆ storage_device_write_proc

typedef uint32_t STDCALL(* storage_device_write_proc) (STORAGE_DEVICE *storage, int64_t start, int64_t count, void *buffer)

◆ storage_device_erase_proc

typedef uint32_t STDCALL(* storage_device_erase_proc) (STORAGE_DEVICE *storage, int64_t start, int64_t count)

◆ storage_device_control_proc

typedef uint32_t STDCALL(* storage_device_control_proc) (STORAGE_DEVICE *storage, int request, size_t argument1, size_t *argument2)

Function Documentation

◆ storage_device_read()

uint32_t STDCALL storage_device_read ( STORAGE_DEVICE * storage,
int64_t start,
int64_t count,
void * buffer )

Storage Functions

◆ storage_device_write()

uint32_t STDCALL storage_device_write ( STORAGE_DEVICE * storage,
int64_t start,
int64_t count,
void * buffer )

◆ storage_device_erase()

uint32_t STDCALL storage_device_erase ( STORAGE_DEVICE * storage,
int64_t start,
int64_t count )

◆ storage_device_control()

uint32_t STDCALL storage_device_control ( STORAGE_DEVICE * storage,
int request,
size_t argument1,
size_t * argument2 )

◆ storage_device_set_state()

uint32_t STDCALL storage_device_set_state ( STORAGE_DEVICE * storage,
uint32_t state )

Set the state of the specified storage and send a notification.

Parameters
StorageThe storage to set the state for
StateThe new state to set and notify
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ storage_device_start_status()

uint32_t STDCALL storage_device_start_status ( STORAGE_DEVICE * storage,
uint32_t interval )

Start status monitoring on the specified storage for insert/eject notifications.

Parameters
StorageThe storage to start status monitoring for
IntervalThe status monitoring interval in milliseconds
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ storage_device_stop_status()

uint32_t STDCALL storage_device_stop_status ( STORAGE_DEVICE * storage)

Stop status monitoring on the specified storage for insert/eject notifications.

Parameters
StorageThe storage to stop status monitoring for
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ storage_device_create()

STORAGE_DEVICE *STDCALL storage_device_create ( void )

Create a new Storage entry.

Returns
Pointer to new Storage entry or nil if storage could not be created

◆ storage_device_create_ex()

STORAGE_DEVICE *STDCALL storage_device_create_ex ( uint32_t size)

Create a new Storage entry.

Parameters
SizeSize in bytes to allocate for new storage (Including the storage entry)
Returns
Pointer to new Storage entry or nil if storage could not be created

◆ storage_device_destroy()

uint32_t STDCALL storage_device_destroy ( STORAGE_DEVICE * storage)

Destroy an existing Storage entry.

◆ storage_device_register()

uint32_t STDCALL storage_device_register ( STORAGE_DEVICE * storage)

Register a new Storage in the Storage table.

◆ storage_device_deregister()

uint32_t STDCALL storage_device_deregister ( STORAGE_DEVICE * storage)

Deregister a Storage from the Storage table.

◆ storage_device_find()

STORAGE_DEVICE *STDCALL storage_device_find ( uint32_t storageid)

◆ storage_device_find_by_device()

STORAGE_DEVICE *STDCALL storage_device_find_by_device ( DEVICE * device)

Find a Storage device by the matching DeviceData property.

Parameters
DeviceThe device entry to match with the DeviceData value
Returns
The Storage device matched or nil if none found

◆ storage_device_find_by_name()

STORAGE_DEVICE *STDCALL storage_device_find_by_name ( const char * name)

◆ storage_device_find_by_description()

STORAGE_DEVICE *STDCALL storage_device_find_by_description ( const char * description)

◆ storage_device_enumerate()

uint32_t STDCALL storage_device_enumerate ( storage_enumerate_cb callback,
void * data )

◆ storage_device_notification()

uint32_t STDCALL storage_device_notification ( STORAGE_DEVICE * storage,
storage_notification_cb callback,
void * data,
uint32_t notification,
uint32_t flags )

◆ storage_get_count()

uint32_t STDCALL storage_get_count ( void )

Get the current storage count.

Storage Helper Functions

◆ storage_device_check()

STORAGE_DEVICE *STDCALL storage_device_check ( STORAGE_DEVICE * storage)

Check if the supplied Storage is in the storage table.

◆ storage_device_type_to_string()

uint32_t STDCALL storage_device_type_to_string ( uint32_t storagetype,
char * string,
uint32_t len )

◆ storage_device_state_to_string()

uint32_t STDCALL storage_device_state_to_string ( uint32_t storagestate,
char * string,
uint32_t len )

◆ storage_device_state_to_notification()

uint32_t STDCALL storage_device_state_to_notification ( uint32_t state)

Convert a Storage state value into the notification code for device notifications.