Author Topic: adding kFixFSB & kbusratio to chameleon  (Read 2700 times)

0 Members and 1 Guest are viewing this topic.

valv

  • VoodooLabs
  • Posts: 72
    • The AnVAL Forum (fr)
adding kFixFSB & kbusratio to chameleon
« on: June 26, 2010, 06:59:03 PM »
hello all,

Lastly I was adding an FSB detection alternative to the actual algo. that's not the point as the new part detects it well. In an attempt to give user a choice of new or old algo, I got stack at a crucial point: the key to add. I explain: the user can specify FixFSB=Yes into the boot.plist, this way the boot-loader gets him inn the new algo. Else the old one is used. What I did:
Quote
defined the new key onto boot2/boot.h like this
Code: [Select]
#define kFixFSB "FixFSB" /* cpu.c */
declared "fix_fsb" into
Code: [Select]
void scan_cpu(PlatformInfo_t *p) like this
Code: [Select]
bool fix_fsb;
then I 've put it altogether in a point I need the transition to occur, like this
Code: [Select]
fix_fsb = false;
getBoolForKey(kFixFSB, &fix_fsb, &bootInfo->bootConfig);
if (fix_fsb) {
....
verbose("CPU: FSB Fix applied !\n");
}

I then added

#include "boot.h"
#include "bootstruct.h"

into cpu.c
Any idea why is this not going to work? Help appreciated!

Kabyl

  • VoodooLabs
  • Posts: 158
Re: adding kFixFSB & kbusratio to chameleon
« Reply #1 on: June 26, 2010, 07:13:12 PM »
Any idea with is this not going to work? Help appreciated!

That should work just fine, however, your question doesn't :P

valv

  • VoodooLabs
  • Posts: 72
    • The AnVAL Forum (fr)
Re: adding kFixFSB & kbusratio to chameleon
« Reply #2 on: June 26, 2010, 07:16:28 PM »
thank u for the feedback :o sorry for the typo :-[

valv

  • VoodooLabs
  • Posts: 72
    • The AnVAL Forum (fr)
Re: adding kFixFSB & kbusratio to chameleon
« Reply #3 on: June 28, 2010, 07:03:27 PM »
Thanks to Kabyl and cparm, I got FixFSB correctly implemented. But, too good to be true, am now stack at making the same happen to busratio. The whole problem here is the float type (and more specifically declaring getFloatForKey into stringTable.c).
This is what I 've done so far:
Inside of saio_internal.h, I added the following line:
Quote
extern bool   getFloatForKey(const char *key, float *val, config_file_t *configBuff);

then I declared it into stringTable. This is where I get blocked
Quote
bool getFloatForKey( const char *key, float *value, config_file_t *config )
{
    const char *val;
    int size;
    float sum;
   
    if (getValueForKey(key, &val, &size, config))
   {
      if ( size )
      {
         if (*val == '-')
         {
            return false;
         }
         
         for (sum = 0; size > 0; size--)
         {
            if (*val < '2.5' || *val > '19.5')
               return false;
            
            sum = strtof(*val++ - '0'); // Here I was already playing with atof, strtod...
         }
         
         *value = sum;
         return true;
      }
   }
    return false;
}
I also added strtod.c inside of i386/libsa/
I used to "float" on the net, and found out some harsh issues related to this file on 10.5/10.6.
So my question is: how to go from here ? I know am wrongly editing stringTable. But could someone please give me a hand on this? Thanks.
Also if u have any alternative to strtod, atol or strtof, please tell me.

Azimutz

  • VoodooLabs
  • Posts: 420
  • Paranoid Android
Re: adding kFixFSB & kbusratio to chameleon
« Reply #4 on: June 29, 2010, 12:19:36 AM »
I don't think you need to create a new function on stringTable.c just to do that, valv!?
I'd try to use just getValueForKey, then "cast" val (const char) into "float something;" or the other way around as needed; and use arrays. Anyway, it doesn't hurt creating it since most "getSomething" functions end up using getValueForKey in some form.
Most probably i should just shut up and read more :P right away...
« Last Edit: June 29, 2010, 01:43:16 AM by Azimutz »
 System & Patches: http://goo.gl/i961
 Chameleon:
- trunk builds: http://goo.gl/9G1Hq
- pref pane: http://goo.gl/OL2UT

valv

  • VoodooLabs
  • Posts: 72
    • The AnVAL Forum (fr)
Re: adding kFixFSB & kbusratio to chameleon
« Reply #5 on: June 29, 2010, 11:34:50 AM »
u 're right!
I don't know why I was trying to do it the hard way. Maybe for sanity. Casting would help forcing the code to compile, but would it have side effects afterwards? Thank u Azi. your thoughts are always welcome dear friend :)

Azimutz

  • VoodooLabs
  • Posts: 420
  • Paranoid Android
Re: adding kFixFSB & kbusratio to chameleon
« Reply #6 on: June 30, 2010, 02:26:09 AM »
Hey man,
i don't know if i'm right... i mean, right now i'm pretty confused with all these functions, datatypes, etc, etc, etc...
i'm up to the ears with code  :confused:
One thing i'm sure, you can cast from char to float! How to return the float value back is another matter so, i'm maybe not that right on using just getValueForKey?! And i'm not sure if casting is enough or you need something like strtof??
I was going through this stuff (casting, datatypes, arrays, etc...) when i read your post and kept on reading and finding stuff to review on my code.. and fixing stuff :P so, let me read a bit more before i say bs... i'm keeping an eye on you :)
« Last Edit: June 30, 2010, 02:28:06 AM by Azimutz »
 System & Patches: http://goo.gl/i961
 Chameleon:
- trunk builds: http://goo.gl/9G1Hq
- pref pane: http://goo.gl/OL2UT