Files
tactility/TactilityKernel/Include/Tactility/Driver.h
T
2026-01-25 23:54:33 +01:00

54 lines
1.3 KiB
C

// SPDX-License-Identifier: Apache-2.0
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include "Error.h"
struct Device;
struct DeviceType;
struct Driver {
/** The driver name */
const char* name;
/** Array of const char*, terminated by NULL */
const char**compatible;
/** Function to initialize the driver for a device */
error_t (*startDevice)(struct Device* dev);
/** Function to deinitialize the driver for a device */
error_t (*stopDevice)(struct Device* dev);
/** Contains the driver's functions */
const void* api;
/** Which type of devices this driver creates (can be NULL) */
const struct DeviceType* deviceType;
/** Internal data */
struct {
/** Contains private data */
void* data;
} internal;
};
error_t driver_construct(struct Driver* driver);
error_t driver_destruct(struct Driver* driver);
error_t driver_bind(struct Driver* driver, struct Device* device);
error_t driver_unbind(struct Driver* driver, struct Device* device);
bool driver_is_compatible(struct Driver* driver, const char* compatible);
struct Driver* driver_find_compatible(const char* compatible);
static inline const struct DeviceType* driver_get_device_type(struct Driver* driver) {
return driver->deviceType;
}
#ifdef __cplusplus
}
#endif