Subject: Re: Making a common API for cpu frequency drivers
To: Jason Thorpe <thorpej@shagadelic.org>
From: Juan RP <juan@xtrarom.org>
List: tech-kern
Date: 09/01/2006 23:19:10
This is a multi-part message in MIME format.
--Multipart=_Fri__1_Sep_2006_23_19_10_+0200_32dz=.l+s6pQPqO0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
On Fri, 1 Sep 2006 09:19:16 -0700
Jason Thorpe <thorpej@shagadelic.org> wrote:
> ...instead have something like:
>
> <dict>
> <key>cpu-supported-clock-frequencies</key>
> <array>
> <integer>1300</integer>
> <integer>1800</integer>
> <integer>2000</integer>
> <integer>2200</integer>
> </array>
> </dict>
>
> That makes it more extensible if you find you need to add more
> properties later.
>
> In fact, I would suggest registering the frequency array as a property
> in the device_properties() dictionary corresponding to that CPU's
> device_t ... that way these properties can be visible via generic "get
> device properties" calls, as well. sysmon can simply fetch the array
> from there.
Ok, now that I know how to make the skeleton I can work in other things.
Example:
[juan@nocturno][~]> ./prop_dictionary
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>cpu0</key>
<array>
<integer>0x3e8</integer>
<integer>0x4b0</integer>
<integer>0x578</integer>
<integer>0x640</integer>
</array>
<key>cpu1</key>
<array>
<integer>0x4b0</integer>
<integer>0x578</integer>
<integer>0x708</integer>
<integer>0x898</integer>
</array>
<key>cpu2</key>
<array>
<integer>0x578</integer>
<integer>0x4b0</integer>
<integer>0x7d0</integer>
</array>
<key>cpu3</key>
<array>
<integer>0x258</integer>
<integer>0x320</integer>
<integer>0x3e8</integer>
<integer>0x4b0</integer>
</array>
</dict>
</plist>
[juan@nocturno][~]>
> Please make sure the dictionary key names have meaningful namespace
> prefixes to them.
Does that mean that the key of the dictionary must not have names like
cpu0?
> Glad someone is taking in interest in cleaning this all up! Yay
> sysmon! Yay proplib! :-)
I'm starting to love it... I've attached the test code to create the template.
--Multipart=_Fri__1_Sep_2006_23_19_10_+0200_32dz=.l+s6pQPqO0
Content-Type: application/octet-stream;
name="prop_dictionary.c"
Content-Disposition: attachment;
filename="prop_dictionary.c"
Content-Transfer-Encoding: base64
I2luY2x1ZGUgPHByb3AvcHJvcGxpYi5oPgoKI2luY2x1ZGUgPGVyci5oPgojaW5jbHVkZSA8ZmNu
dGwuaD4KI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0
cmluZy5oPgojaW5jbHVkZSA8dW5pc3RkLmg+CgojZGVmaW5lIE1BWF9GUkVRUwkxNgoKc3RydWN0
IHRhYmxlIHsKCWNvbnN0IGNoYXIgKmRldmljZTsKCXVuc2lnbmVkIGludCBmcmVxW01BWF9GUkVR
U107Cn0gdGFibGVbXSA9IHsKCXsgImNwdTAiLCB7IDEwMDAsIDEyMDAsIDE0MDAsIDE2MDAgfSB9
LAoJeyAiY3B1MSIsIHsgMTIwMCwgMTQwMCwgMTgwMCwgMjIwMCB9IH0sCgl7ICJjcHUyIiwgeyAx
NDAwLCAxMjAwLCAyMDAwIH0gfSwKCXsgImNwdTMiLCB7IDYwMCwgODAwLCAxMDAwLCAxMjAwIH0g
fSwKCXsgTlVMTCwgeyAwIH0gfQp9OwoKaW50Cm1haW4odm9pZCkKewoJcHJvcF9kaWN0aW9uYXJ5
X3QgZGljdDsKCXN0cnVjdCB0YWJsZSAqdG07CglpbnQgaSA9IDA7CgoJLyogY3JlYW1vcyBkaWNj
aW9uYXJpbyAqLwoJZGljdCA9IHByb3BfZGljdGlvbmFyeV9jcmVhdGUoKTsKCWlmIChkaWN0ID09
IEZBTFNFKQoJCXJldHVybiAtMTsKCgoJLyogaXRlcmFtb3Mgc29icmUgdG9kYXMgbGFzIHN0cnVj
dHMuLi4gKi8KCWZvciAodG0gPSB0YWJsZTsgdG0tPmRldmljZSAhPSBOVUxMOyB0bSsrKSB7C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