Re: [Gems-users] accessing ruby methods


Date: Thu, 28 Sep 2006 20:55:14 +0200
From: "Mladen Nikitovic" <mladen@xxxxxxxxxxx>
Subject: Re: [Gems-users] accessing ruby methods
Hi,

Thank you for your answer. I think I was too unclear about what I wanted.

My goal is twofold. First, I would like to add new functionality to ruby
such as new statistics functions. I see that the current (e.g dump-stats)
are registered as attributes. I tried to register my own function
(start-measurement) and my idea was to somehow call it from my SimICS
device. In function start-measurement the return value is of type
attr_value_t with u.integer = 42, and .kind = Sim_Val_Integer. Still,
val.kind (see below) tells me that the return value is 0, Sim_Val_Invalid.

  conf_object_t *ruby;
  attr_value_t val;

	ruby = SIM_get_object("ruby0");
	if(!ruby)
	  SIM_log_info(1, &empty->log, 0, "Ruby object not found");

	val = SIM_get_attribute(ruby, "start-measurement");

	SIM_log_info(1, &empty->log, 0, "attribute value: %d", (int)
val.kind);


I added my function in the necessary places (ruby.c, commands.C and
commands.py so the compiler does not report any faults.

The second goal was to register simple variables (not functions) as
attributes that i could access through the ruby0 object  via
SIM_get/set_attribute. Seems that the attribute approach should work, at
least in theory. But I don't see how the macro RUBY_COMMAND can be applied
to this case. Can I treat functions and simple variables the same way when
registering them as atributes?

I hope that my approach is on the right track, or that you can point me to
the correct one. I did not get any new insights from watching the
OpalInterface.[Ch].

Regards,
Mladen

-----Original Message-----
From: gems-users-bounces@xxxxxxxxxxx [mailto:gems-users-bounces@xxxxxxxxxxx]
On Behalf Of Dan Gibson
Sent: den 28 september 2006 14:58
To: Gems Users
Subject: Re: [Gems-users] accessing ruby methods


You might want to study the interface between ruby and opal in detail.

Essentially, Ruby provides a struct, its "interface" in simics lingo, 
that contains a set of function pointers to the various ruby functions. 
These functions and the struct are defined in mf_api.h. At init-time, 
these function pointers are initialized and stored in various locations 
(see OpalInterface.[Ch] for examples).

If you only need "numberOfProcessors" functionality, I would recommend 
you use the Simics API instead -- it should be much easier. See the 
Simics Reference Manual for the available API calls.

Regards,
Dan Gibson

Mladen Nikitovic wrote:
> Hi,
>
> I'm writing on a simics device, and inside it I would like to access 
> ruby methods such as numberOfProcessors, but It seems I'm doing 
> something wrong. The compiler complains and reports that the 
> "structure has no member named `numberOfProcessors'". I tried to 
> include some header files but it failed also. Does anyone have a hint?
>
>
> This is the piece of code I'm trying to run in my "empty-device". 
> Seems that SIM_get_object returns a valid ruby object..
>
> conf_object_t *ruby;
>
> ruby = SIM_get_object("ruby0");
> 	if(!ruby)
> 	  SIM_log_info(1, &empty->log, 0, "Ruby object not found");
>
> SIM_log_info(1, &empty->log, 0, "ruby->numberOfProcessors(): %d",
> ruby->numberOfProcessors());
>
> Regards,
> Mladen
>
>
> _______________________________________________
> Gems-users mailing list
> Gems-users@xxxxxxxxxxx 
> https://lists.cs.wisc.edu/mailman/listinfo/gems-users
> Use Google to search the GEMS Users mailing list by adding 
> "site:https://lists.cs.wisc.edu/archive/gems-users/"; to your search.
>
>
>   
_______________________________________________
Gems-users mailing list
Gems-users@xxxxxxxxxxx https://lists.cs.wisc.edu/mailman/listinfo/gems-users
Use Google to search the GEMS Users mailing list by adding
"site:https://lists.cs.wisc.edu/archive/gems-users/"; to your search.



[← Prev in Thread] Current Thread [Next in Thread→]