Re: How to read hw.clockrate from a kernel module?
--0016e64f829cf254c404b00d999c
Content-Type: text/plain; charset=ISO-8859-1
Hi Maurizio,
Yeah, I would suppose you can use either kernel_sysctl() or
kernel_sysctlbyname() to get it.
An example of kernel_sysctl(), which is used in more places than
kernel_sysctlbyname() AFAICS:
http://pkgbox64.dragonflybsd.org/xref/DragonFly-master/sys/vfs/nwfs/nwfs_vfsops.c#360
Cheers,
Antonio Huete
2011/10/24 Maurizio Lombardi <m.lombardi85@gmail.com>
> Hi all,
>
> I've a little question:
> In platform/pc32/i386/identcpu.c there is the following variable defined:
>
> ------------------
> static int hw_clockrate;
> SYSCTL_INT(_hw, OID_AUTO, clockrate, CTLFLAG_RD,
> &hw_clockrate, 0, "CPU instruction clock rate");
> ------------------
>
> I suppose it contains the current cpu speed in Mhz.
> How can I properly read it's content from a kernel module?
> Is it correct to do that?
>
> --------------
> const size_t var_size = sizeof(int);
> int cpu_mhz;
>
> kernel_sysctlbyname("hw.clockrate", &cpu_mhz, &var_size, NULL, 0, NULL);
> --------------
>
> Thanks for the help,
>
> --
> --------------------
> Maurizio Lombardi
>
--0016e64f829cf254c404b00d999c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hi Maurizio,<div><br></div><div>Yeah, I would suppose you can use either ke=
rnel_sysctl() or kernel_sysctlbyname() to get it.</div><div><br></div><div>=
An example of kernel_sysctl(), which is used in more places than kernel_sys=
ctlbyname() AFAICS:</div>
<div><br></div><div><a href=3D"http://pkgbox64.dragonflybsd.org/xref/Dragon=
Fly-master/sys/vfs/nwfs/nwfs_vfsops.c#360">http://pkgbox64.dragonflybsd.org=
/xref/DragonFly-master/sys/vfs/nwfs/nwfs_vfsops.c#360</a></div><div><br></d=
iv>
<div>Cheers,</div><div>Antonio Huete<br><br><div class=3D"gmail_quote">2011=
/10/24 Maurizio Lombardi <span dir=3D"ltr"><<a href=3D"mailto:m.lombardi=
85@gmail.com">m.lombardi85@gmail.com</a>></span><br><blockquote class=3D=
"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding=
-left:1ex;">
Hi all,<br>
<br>
I've a little question:<br>
In platform/pc32/i386/identcpu.c there is the following variable defined:<b=
r>
<br>
------------------<br>
static int hw_clockrate;<br>
SYSCTL_INT(_hw, OID_AUTO, clockrate, CTLFLAG_RD,<br>
=A0&hw_clockrate, 0, "CPU instruction clock rate");<br>
------------------<br>
<br>
I suppose it contains the current cpu speed in Mhz.<br>
How can I properly read it's content from a kernel module?<br>
Is it correct to do that?<br>
<br>
--------------<br>
const size_t var_size =3D sizeof(int);<br>
int cpu_mhz;<br>
<br>
kernel_sysctlbyname("hw.clockrate", &cpu_mhz, &var_size, =
NULL, 0, NULL);<br>
--------------<br>
<br>
Thanks for the help,<br>
<font color=3D"#888888"><br>
--<br>
--------------------<br>
Maurizio Lombardi<br>
</font></blockquote></div><br></div>
--0016e64f829cf254c404b00d999c--
討論串 (同標題文章)