Zhaoming Luo, le lun. 21 oct. 2024 20:51:21 +0800, a ecrit:
> On 10/21/24 8:12 PM, Samuel Thibault wrote:
> > I mean that it probably doesn't have to be in kernelland, and rather be
> > a userland translator.
>
> Do you mean we can implement an userland translator (it is also a rtc device
> driver, something like /hurd/rtc?) without using the device interface (e.g.
> device_open("rtc",...) to open rtc) provided by gnumach? If the answer is yes.
Yes.
> How?
Thanks to the trivfs library. You can use devnode as a simple
trivfs-based translator, drop the device_* parts, and add the ioctl
parts.
> Userland can implement device_open etc. Actually we would rather make
> /dev/rtc expose the usual ioctls that applications expect to be able to
> use, we don't necessarily want to implement the device_* interface.
>
> How do we expose the usual ioctls?
By implementing the corresponding RPC, whose msgid is given by the
IOC_MSGID macro. For instance for
RTC_RD_TIME. _IOR('p', 0x09, struct rtc_time)
the group is 'p' and the command is 0x9, so the subsystem would be
140000, and the exact RPC would be 140009. You'd probably want to create
a pioctl.defs file just like the existing hurd/rioctl.defs file, and
thus immediately get all the RPC stubs built to plug the RTC RPC
implementations.
Samuel