Jump to content
13 posts in this topic

Recommended Posts

Hi guys, I ask to the developers of this community, I'm am developing a kext for a pci device for Mac OS and I want to add custom boot args to it to enable a diagnostic mode (it just defines a particular macro when the boot arg is detected) or to add other stuff in the future, can you help me? I'd like to add a boot arg that I want to call -kx_diagnose

 Instead of doing that you could use the sysctl interfaces to set an integer in your driver.

i cant't because that system i implemented has to be loaded at driver startup

perhaps look at the source for other kexts that have args to give you a hint ?

if you can it will be great, I just to want to see how to do that because I don't know

Hi. What about "pe_parse_boot_argn" interface? Well, can't explain that in short words...

 

I guess @vit9696's Lilu may give you a few hints. :)

thank you, i have seen that it's very simple, just include 

#include <IOKit/IOLib.h>
#include <IOKit/IORegistryEntry.h>
#include <mach/mach_types.h>

in the module in witch there is the startup function and then inside that function i have just to call the function you mentioned 

    if (PE_parse_boot_argn("-kx_debug", tmp, sizeof(tmp))){
        #define GENERAL_DEBUG
        debug(DBGCLASS"[%p]::initHardware: debug mode enabled by boot arg -kx_debug\n",this);
    }else{
        #ifdef GENERAL_DEBUG
            #undef GENERAL_DEBUG
        #endif
    }
  • Like 1

 

thank you, i have seen that it's very simple, just include 

#include <IOKit/IOLib.h>
#include <IOKit/IORegistryEntry.h>
#include <mach/mach_types.h>

in the module in witch there is the startup function and then inside that function i have just to call the function you mentioned 

    if (PE_parse_boot_argn("-kx_debug", tmp, sizeof(tmp))){
        #define GENERAL_DEBUG
        debug(DBGCLASS"[%p]::initHardware: debug mode enabled by boot arg -kx_debug\n",this);
    }else{
        #ifdef GENERAL_DEBUG
            #undef GENERAL_DEBUG
        #endif
    }

Congratulations! Glad to hear that. :)

 

BTW, I think your code is somewhat complicated, introduce a global macro and define debug logging can be a better solution. :)

(Like Lilu's DBGLOG() )

Congratulations! Glad to hear that. :)

 

BTW, I think your code is somewhat complicated, introduce a global macro and define debug logging can be a better solution. :)

(Like Lilu's DBGLOG() )

if you mean 

debug(DBGCLASS"[%p]::initHardware: debug mode enabled by boot arg -kx_debug\n",this);

it is  a replacement of iolog , that uses also serial and network debugging too, it is custom made

  • Like 2
  • 2 weeks later...

just a quick update, i have seen that using macros does not work that well, so i used some booleans

 

i decided to put more boot args for various stuff.

 

if you ask hw is an instance of a custom class that represents the device that the driver is using and his characteristics

 

and debug stil is what i told before if you are asking and also arg is to count the boot args found only for testing reasons

debug(DBGCLASS"[%p]::initHardware: boot args detection started\n",this);
    //boot args checking
    
    char tmp[16];
    int arg;
    arg = 0;
    
    if (PE_parse_boot_argn("-kx_debug", tmp, sizeof(tmp))){
        hw->nameDebug = true;
        hw->showBusInName = true;
        arg++;
        debug(DBGCLASS"[%p]::initHardware: debug mode enabled by boot arg -kx_debug\n",this);
    }else{
        hw->nameDebug = false;
        hw->showBusInName = false;
    }
    
    
     if (PE_parse_boot_argn("-kx_exp_deb", tmp, sizeof(tmp))){
         hw->testImputs = true;
         arg++;
         debug(DBGCLASS"[%p]::initHardware: debug of experimental features enbled by -kx_exp_deb\n",this);
     }else{
         hw->testImputs = false;
     }
     
     if (PE_parse_boot_argn("-kx_original", tmp, sizeof(tmp))){
         hw->disableFixes = true;
         arg++;
         debug(DBGCLASS"[%p]::initHardware: fixes of the mod disabled by -kx_original\n",this);
     }else{
         hw->disableFixes = false;
     }
    
    if (arg == 0){
        debug(DBGCLASS"[%p]::initHardware: boot args detecting finished, none found\n",this);
    }else{
        debug(DBGCLASS"[%p]::initHardware: boot args detecting finished, [%i] found\n",this, arg);
    }

 

thank you, i have seen that it's very simple, just include 

#include <IOKit/IOLib.h>
#include <IOKit/IORegistryEntry.h>
#include <mach/mach_types.h>

in the module in witch there is the startup function and then inside that function i have just to call the function you mentioned 

    if (PE_parse_boot_argn("-kx_debug", tmp, sizeof(tmp))){
        #define GENERAL_DEBUG
        debug(DBGCLASS"[%p]::initHardware: debug mode enabled by boot arg -kx_debug\n",this);
    }else{
        #ifdef GENERAL_DEBUG
            #undef GENERAL_DEBUG
        #endif
    }

 

I think that you have misunderstood macros. They are evaluated at compile time, not runtime.

I think that you have misunderstood macros. They are evaluated at compile time, not runtime.

yes i have seen it, that's why i decided to use some booleans instead

  • Like 1
×
×
  • Create New...