-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Description
tl;dr: we have not fully solved #11993.
PR #18186 documents an approach to driver-specific APIs based on extended a standard driver API with additional methods only supported by a specific driver API. The requirements derive from #11993.
#12056 provided a macro to be used in system call verification to confirm that a driver-specific API call could be correctly called for a given device instance. This approach lacked documentation and tests, but was merged.
Since it was never used in-tree, #23407 proposes removing it, in part because the solution is based on comparing the device's init function against an available symbol, and #23407 eliminates the init function from the device structure.
In attempting to assess whether the API can be removed, I've attempted to update #17631 to work correctly with user mode, which requires adding syscall implementations for its specific API. This fails, because the syscall infrastructure doesn't support the architectural solution accepted in #18186.
To summarize the context:
- The DS3231 driver is a specialized counter, conforming to the counter API but using an API table that includes additional functions. A
counter_driver_apiinstance appears at the start of theds3231_driver_api. - While
counter_driver_apiis a top-level driver API and so is declared with__subsystemwhich triggers synthesis ofK_OBJ_DRIVER_COUNTERds3231_driver_apiis not a top-level API, and does not have its ownK_OBJ_DRIVER_DS3231object type. It cannot have such a type type, because thecounter_foo()API is expected to work on devices that haveds3231_driver_apiAPI tables. - We need some way to validate the system calls that are specific to the driver, which requires a change to
Z_SYSCALL_SPECIFIC_API()to verify that the device is associated with the base API (so that the base API functions validate) and it must use the API table that provides the extended functions.
A proposed solution is presented in #24537. I am not happy with it, particularly the dirty trick required to associate the base with extended API structures.
#17631 has been updated with a draft of what this would look like in a real driver. Initial testing is promising, but the test application requires a lot of work to become fully userspace compatible.