Jump to content
ITzTravelInTime

Create a new kext that uses boot args

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

Share this post


Link to post
Share on other sites
Advertisement

 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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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
    }

Share this post


Link to post
Share on other sites

 

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() )

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Great. I see.

Share this post


Link to post
Share on other sites

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);
    }

Share this post


Link to post
Share on other sites

 

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Frywyn10
      Hello, i installed Os X El Capitan on this pc : Dell Optiplex 3020, I3 4130, 6Gb RAM and a GT 220. Everything installed without problem (just usb injection needed). But now i want to update to sierra and/or high sierra . I downloaded the installer for both of them (5Gb each) on my hackintosh and tried to install the Os but when rebooting the boot loader don’t propose to boot onto install disk. El Capitan come from my old iMac (genuine system) and it can’t be update to newer Os. I would like to know if anybody have a solution to upgrade from El Capitan to a newer version of the Apple system. Thanks
    • By moman2000
      Hi,
       
      Here it is (attached) for anyone who needs it for patching or restoring!
       
      Taken from macOS 10.14 Beta 1 18A293u
       
      Regards,
      Mohamed
      AppleHDA_282.5.kext.zip
    • By Wallfacer
      hi there, 
      when attempting install 10.10 to my old PC, it reboots everytime when attached pic shows up. my hardware is:
      mb - unika p35 (with ich9) 775pin
      cpu - intel xeon x3210
      video card - nv geforce 8600gt
       
      could anybody know what was wrong? or is it possibly because of the video card, or the powermanagement?
       
      thank you so much for help!

    • By JDizz
      #UPDATE AS OF APRIL 27, 2018 Thursday, 3:53 PM EST

      SIMPLE INSTRUCTIONS
      After you figure out how to get High Sierra 10.13 or 10.13.4 installed to a USB with Clover Bootloader, and you're loaded onto MacOS High Sierra:

      Download Clover Configurator and MOUNT your partition and OPEN it to reveal your EFI folder. Delete it.
      Simply download the attached ZIP and unzip it by double clicking it. Then copy and paste the EFI folder you unzipped to the location of your mounted partition.

      Done. Enjoy. Special thanks to Jake Lo !


      WORKING [Dell M6800 - High Sierra 10.13.4]
      Sleep/Wake WHILE THE POWER CORD IS PLUGGED IN (Not from closing the screen down, but from clicking the Apple logo and sleep or by timer).
      Wi-Fi (AirPort Extreme) via Broadcom BCM43xx.
      2 USB ports on the LEFT side as USB 2.0/3.0 and the 1 USB 2.0/eSATA on the back.
      KeyBoard.
      TouchPad (With MultiTouch - Fully functional)
      iMessage, iCloud, FaceTime, AppStore work perfectly.
      NVIDIA Graphics work perfectly thanks to the Lilu and NvidiaGraphicsFixUp kext. THIS FIXES THE BLACK OR BLANK SCREEN PROBLEM.
      DVD-Drive/Burning if you even care to use CD, DVD disk.
      Bluetooth (Works even with Apple HomePod =] )
      Ethernet/RJ-45
      2 USBs on right side as USB 2.0/3.0
      Native Sound (On board Speakers and can adjust sound with buttons)
      SD Card Readers
      Adjusting Brightness (Download an app from the AppStore called Brightness Slider -OR- use Night Shift [will not adjust brightness, but will be bearable]).


      NOT WORKING [Dell M6800 - High Sierra 10.13.4]
      Headphone Jack (Excessive Static)
    • By partha.slg123
      Hackintosh High Sierra 10.13.3 USB Installer Boot Into USB DIrectly Enter Exit Option Menu. Clover Boot Menu Not Showing. Plz Help .................
       

       
      My System Specification :

      CPU : Core i5 6400
      MB : Asus H110M-CS
      RAM : 8GB DDR 4
      HDD : WD 1TB For Windows And WD 500 GB For Hackintosh
      Bootloader : Clover
×