Additional GDriver call
This commit is contained in:
parent
6b9ff5de2a
commit
33200c1a97
2 changed files with 27 additions and 9 deletions
|
@ -11,19 +11,13 @@
|
||||||
|
|
||||||
#include "sys_defs.h"
|
#include "sys_defs.h"
|
||||||
|
|
||||||
|
#include <string.h> // For memset
|
||||||
|
|
||||||
// Define the tables to hold the driver instances.
|
// Define the tables to hold the driver instances.
|
||||||
static GDriver *dhead;
|
static GDriver *dhead;
|
||||||
|
|
||||||
// The system initialization.
|
// The system initialization.
|
||||||
void _gdriverInit(void) {
|
void _gdriverInit(void) {
|
||||||
|
|
||||||
// Drivers not loaded yet
|
|
||||||
// GINPUT_NEED_MOUSE
|
|
||||||
// GINPUT_NEED_DIAL
|
|
||||||
// GINPUT_NEED_TOGGLE
|
|
||||||
// GINPUT_NEED_KEYBOARD
|
|
||||||
// GINPUT_NEED_STRING
|
|
||||||
// GFX_USE_GBLOCK
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The system de-initialization.
|
// The system de-initialization.
|
||||||
|
@ -51,7 +45,7 @@ GDriver *gdriverRegister(const GDriverVMT *vmt) {
|
||||||
pd = gfxAlloc(vmt->objsize);
|
pd = gfxAlloc(vmt->objsize);
|
||||||
if (!pd)
|
if (!pd)
|
||||||
return 0;
|
return 0;
|
||||||
pd->driverchain = 0;
|
memset(pd, 0, vmt->objsize);
|
||||||
pd->vmt = vmt;
|
pd->vmt = vmt;
|
||||||
if (vmt->init && !vmt->init(pd, dinstance, sinstance)) {
|
if (vmt->init && !vmt->init(pd, dinstance, sinstance)) {
|
||||||
gfxFree(pd);
|
gfxFree(pd);
|
||||||
|
@ -136,4 +130,19 @@ GDriver *gdriverGetNext(uint16_t type, GDriver *driver) {
|
||||||
return driver;
|
return driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned gdriverGetDriverInstanceNumber(GDriver *driver) {
|
||||||
|
GDriver *pd;
|
||||||
|
unsigned instance;
|
||||||
|
|
||||||
|
// Loop to find the system instance
|
||||||
|
instance = 0;
|
||||||
|
for(pd = dhead; pd; pd = pd->driverchain) {
|
||||||
|
if (pd == driver)
|
||||||
|
return instance;
|
||||||
|
if (pd->vmt->type == driver->vmt->type)
|
||||||
|
instance++;
|
||||||
|
}
|
||||||
|
return (unsigned)-1;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* GFX_USE_GDRIVER */
|
#endif /* GFX_USE_GDRIVER */
|
||||||
|
|
|
@ -70,6 +70,7 @@ typedef struct GDriverVMT {
|
||||||
bool_t (*init)(GDriver *driver, unsigned driverinstance, unsigned systeminstance); // @< Initialise the driver. Returns TRUE if OK.
|
bool_t (*init)(GDriver *driver, unsigned driverinstance, unsigned systeminstance); // @< Initialise the driver. Returns TRUE if OK.
|
||||||
// driverinstance is the instance 0..n of this driver.
|
// driverinstance is the instance 0..n of this driver.
|
||||||
// systeminstance is the instance 0..n of this type of device.
|
// systeminstance is the instance 0..n of this type of device.
|
||||||
|
// The memory allocated is cleared before this call.
|
||||||
void (*postinit)(GDriver *driver); // @< Called once the driver is registered.
|
void (*postinit)(GDriver *driver); // @< Called once the driver is registered.
|
||||||
void (*deinit)(GDriver *driver); // @< De-initialise the driver
|
void (*deinit)(GDriver *driver); // @< De-initialise the driver
|
||||||
} GDriverVMT;
|
} GDriverVMT;
|
||||||
|
@ -130,6 +131,14 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
unsigned gdriverInstanceCount(uint16_t type);
|
unsigned gdriverInstanceCount(uint16_t type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the instance number for a device
|
||||||
|
* @return The instance number or (unsigned)-1 if it fails.
|
||||||
|
*
|
||||||
|
* @param[in] driver The driver to find the instance number for
|
||||||
|
*/
|
||||||
|
unsigned gdriverGetDriverInstanceNumber(GDriver *driver);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the next driver for a type of device
|
* @brief Get the next driver for a type of device
|
||||||
* @return The runtime driver structure or NULL if there are no more.
|
* @return The runtime driver structure or NULL if there are no more.
|
||||||
|
|
Loading…
Add table
Reference in a new issue