On Sun, Oct 27, 2024 at 11:46 AM Zhaoming Luo <zhaoming1...@qq.com> wrote:
> Hi,

Hi Zhaoming,

> I did the following things in a Debian/Hurd virtual machine.
>
> I was following this link
> <https://darnassus.sceen.net/~hurd-web/hurd/translator/writing/example/>
> to implement a rtc server. My idea is that I should implement a working
> rtc server in user space before adding the source code into the repo
> because I don't want to get stuck in Makefile system before I have a
> working rtc server.

Sure, that makes sense. And it's a great property of the Hurd that you
can in fact develop out-of-tree translators with ease. Though in the
case of rtc, we'd probably want it in-tree eventually.

> I wrote the pioctl.defs (I paste it below), used mig
> to resolve it, and mig told me 'tm_t' is not defined. Then I added the
> following lines in /usr/include/i386-gnu/hurd/ioctl_types.h

If it's MIG itself that complained about a missing type, adding a
definition to a C header won't change anything.

> It still didn't work. How can I use `struct tm` in a user space defs file?

To use tm_t, it would have to be defined in some MIG .defs header (in
a way that matches the C definition). See how timespec_t is defined in
hurd_types.defs for example.

But also, tm_t seems to be a weird type to be used in RPCs. I see that
Linux RTC device ioctls actually operate on a 'struct rtc_time', which
is only similar to a 'struct tm', but not the same thing. I would
presume the RTC actually deals with broken-down tm-like time
representation internally, rather than a timestamp?

If so, it would make sense to me if you defined a type that represents
RTC's time representation right in your .defs file, and used that in
your RPCs. Perhaps like this:

type rtc_time_t = struct {
  int tm_sec;
  ...
};

with a matching definition in C.

> /* TODO: adding other ioctl calls for /dev/rtc in mc146818rtc.h */
> skip; skip; skip; skip; /* 0 1 2 3 */
> skip; skip; skip; skip; /* 4 5 6 7 */
> skip;                   /* 8 */
>
> /* 9 RTC_RD_TIME */
> routine pioctl_rtc_rd_time (
>      reqport: io_t;
>      inout time: tm_t);

Shouldn't this be 'out' rather than 'inout'?

> /* 10 RTC_SET_TIME */
> routine pioctl_rtc_set_time (
>      reqport: io_t;
>      time: tm_t);

Do I understand it right that this would be more privileged than
reading the time?

Sergey

Reply via email to