Exemple #1
0
long LoadDrivers( char * dirSpec )
{
    if ( InitDriverSupport() != 0 )
        return 0;

    if ( gBootFileType == kNetworkDeviceType )
    {
        if (NetLoadDrivers(dirSpec) != 0) {
            error("Could not load drivers from the network\n");
            return -1;
        }
    }
    else if ( gBootFileType == kBlockDeviceType )
    {
        if (gMKextName[0] != '\0')
        {
            verbose("LoadDrivers: Loading from [%s]\n", gMKextName);
            if ( LoadDriverMKext(gMKextName) != 0 )
            {
                error("Could not load %s\n", gMKextName);
                return -1;
            }
        }
        else
        {
            strcpy(gExtensionsSpec, dirSpec);
            strcat(gExtensionsSpec, "System/Library/");
            FileLoadDrivers(gExtensionsSpec, 0);
        }
    }
    else
    {
        return 0;
    }

    MatchPersonalities();

    MatchLibraries();

    LoadMatchedModules();

    return 0;
}
Exemple #2
0
long NBI_LoadDrivers( char * dirSpec )
{
	
    char dirSpecExtra[1024];
	
    if ( InitDriverSupport() != 0 )
        return 0;
	
	int step = 0;
	execute_hook("ramDiskLoadDrivers", &step, NULL, NULL, NULL, NULL, NULL);
#ifdef NBP_SUPPORT	
    if ( get_env(envgBootFileType) == kNetworkDeviceType )
    {
        if (NetLoadDrivers(dirSpec) != 0)
		{
            error("Could not load drivers from the network\n");
            return -1;
        }
    }
    else
#endif
		if ( get_env(envgBootFileType) == kBlockDeviceType )
		{
			verbose("Loading Recovery Extensions\n");
			strlcpy(dirSpecExtra, "/Extra/RecoveryExtensions/", sizeof(dirSpecExtra));
			FileLoadDrivers(dirSpecExtra, sizeof(dirSpecExtra), 0);
			
#ifdef BOOT_HELPER_SUPPORT			
			// TODO: fix this, the order does matter, and it's not correct now.
			// Also try to load Extensions from boot helper partitions.
			if (((BVRef)(uint32_t)get_env(envgBootVolume))->flags & kBVFlagBooter)
			{
				strlcpy(dirSpecExtra, "/com.apple.boot.P/System/Library/", sizeof(dirSpecExtra));
				if (FileLoadDrivers(dirSpecExtra, sizeof(dirSpecExtra), 0) != 0)
				{
					strlcpy(dirSpecExtra, "/com.apple.boot.R/System/Library/", sizeof(dirSpecExtra));
					if (FileLoadDrivers(dirSpecExtra, sizeof(dirSpecExtra), 0) != 0)
					{
						strlcpy(dirSpecExtra, "/com.apple.boot.S/System/Library/", sizeof(dirSpecExtra));
						FileLoadDrivers(dirSpecExtra, sizeof(dirSpecExtra), 0);
					}
				}
			}
#endif
            char * MKextName = (char*)(uint32_t)get_env(envMKextName);
			
			if (MKextName[0] != '\0')
			{
				verbose("LoadDrivers: Loading from [%s]\n", MKextName);
				if ( LoadDriverMKext(MKextName) != 0 )
				{
					error("Could not load %s\n", MKextName);
					return -1;
				}
			}
			else
			{
				char * ExtensionsSpec = (char*)(uint32_t)get_env(envDriverExtSpec);
				
				strlcpy(ExtensionsSpec, dirSpec, DEFAULT_DRIVER_SPEC_SIZE);
				strlcat(ExtensionsSpec, "System/Library/", DEFAULT_DRIVER_SPEC_SIZE);
				FileLoadDrivers(ExtensionsSpec,DEFAULT_DRIVER_SPEC_SIZE, 0);
			}
		}
		else
		{
			return 0;
		}
#if UNUSED
    MatchPersonalities();
#endif
    MatchLibraries();
	
    LoadMatchedModules();
	
    return 0;
}
Exemple #3
0
long LoadDrivers( char * dirSpec )
{
	char dirSpecExtra[1024];

	if ( InitDriverSupport() != 0 ) {
		return 0;
	}

	// Load extra drivers if a hook has been installed.
	if (LoadExtraDrivers_p != NULL)
	{
		(*LoadExtraDrivers_p)(&FileLoadDrivers);
	}

	if ( gBootFileType == kNetworkDeviceType )
	{
		if (NetLoadDrivers(dirSpec) != 0)
		{
			error("Could not load drivers from the network\n");
			return -1;
		}
	}
	else if ( gBootFileType == kBlockDeviceType )
	{
		// First try to load Extra extensions from the ramdisk if isn't aliased as bt(0,0).
		if (gRAMDiskVolume && !gRAMDiskBTAliased)
		{
			strcpy(dirSpecExtra, "rd(0,0)/Extra/");
			FileLoadDrivers(dirSpecExtra, 0);
		}

		// Next try to load Extra extensions from the selected root partition.
		strcpy(dirSpecExtra, "/Extra/");
		if (FileLoadDrivers(dirSpecExtra, 0) != 0) {
			// If failed, then try to load Extra extensions from the boot partition
			// in case we have a separate booter partition or a bt(0,0) aliased ramdisk.
			if ( !(gBIOSBootVolume->biosdev == gBootVolume->biosdev  && gBIOSBootVolume->part_no == gBootVolume->part_no)
				|| (gRAMDiskVolume && gRAMDiskBTAliased) ) {
				// Next try a specfic OS version folder ie 10.5
				sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gMacOSVersion);
				if (FileLoadDrivers(dirSpecExtra, 0) != 0) {
					// Next we'll try the base
					strcpy(dirSpecExtra, "bt(0,0)/Extra/");
					FileLoadDrivers(dirSpecExtra, 0);
				}
			}
		}
		if(!gHaveKernelCache) {
			// Don't load main driver (from /System/Library/Extentions) if gHaveKernelCache is set.
			// since these drivers will already be in the kernel cache.
			// NOTE: when gHaveKernelCache, xnu cannot (by default) load *any* extra kexts from the bootloader.
			// The /Extra code is not disabled in this case due to a kernel patch that allows for this to happen.

			// Also try to load Extensions from boot helper partitions.
			if (gBootVolume->flags & kBVFlagBooter) {
				strcpy(dirSpecExtra, "/com.apple.boot.P/System/Library/");
				if (FileLoadDrivers(dirSpecExtra, 0) != 0) {
					strcpy(dirSpecExtra, "/com.apple.boot.R/System/Library/");
					if (FileLoadDrivers(dirSpecExtra, 0) != 0) {
						strcpy(dirSpecExtra, "/com.apple.boot.S/System/Library/");
						FileLoadDrivers(dirSpecExtra, 0);
					}
				}
			}

			if (gMKextName[0] != '\0') {
				verbose("LoadDrivers: Loading from [%s]\n", gMKextName);
				if ( LoadDriverMKext(gMKextName) != 0 ) {
					error("Could not load %s\n", gMKextName);
					return -1;
				}
			}
			else
			{
				if ( MAVERICKS || YOSEMITE ) // issue 352
				{
					strlcpy(gExtensionsSpec, dirSpec, 4087); /* 4096 - sizeof("Library/") */
					strcat(gExtensionsSpec, "Library/");
					FileLoadDrivers(gExtensionsSpec, 0);
				}
				strlcpy(gExtensionsSpec, dirSpec, 4080); /* 4096 - sizeof("System/Library/") */
				strcat(gExtensionsSpec, "System/Library/");
				FileLoadDrivers(gExtensionsSpec, 0);
			}

		}
	} else {
		return 0;
	}

	MatchPersonalities();

	MatchLibraries();

	LoadMatchedModules();

	return 0;
}
Exemple #4
0
long LoadDrivers( char * dirSpec )
{	
	const char * sLoadExtra = "LoadDrivers: Loading Extra drivers %s...\n";
    char dirSpecExtra[1024];
	
    if ( InitDriverSupport() != 0 )
        return 0;
	
#ifndef OPTION_ROM
    // Load extra drivers if a hook has been installed.
    if (LoadExtraDrivers_p != NULL)
    {
        (*LoadExtraDrivers_p)(&FileLoadDrivers);
    }
	
    if ( gBootFileType == kNetworkDeviceType )
    {
        if (NetLoadDrivers(dirSpec) != 0) {
            error("Could not load drivers from the network\n");
            return -1;
        }
    }
    else
#endif
		if ( gBootFileType == kBlockDeviceType )
		{
			// First try to load Extra extensions from the ramdisk if isn't aliased as bt(0,0).
#ifndef OPTION_ROM
			// First try a specfic OS version folder ie 10.5
			sprintf(dirSpecExtra, "rd(0,0)/Extra/%s/", &gMacOSVersion);
			if (FileLoadDrivers(dirSpecExtra, 0) != 0)
			{	
				// Next we'll try the base
				strcpy(dirSpecExtra, "rd(0,0)/Extra/");
				FileLoadDrivers(dirSpecExtra, 0);
			}
#endif
			
			// First try a specfic OS version folder ie 10.5
			sprintf(dirSpecExtra, "/Extra/%s/", &gMacOSVersion);
			if (FileLoadDrivers(dirSpecExtra, 0) != 0)
			{	
				// Next try to load Extra extensions from the selected root partition.
				strcpy(dirSpecExtra, "/Extra/");
				if (FileLoadDrivers(dirSpecExtra, 0) != 0)
				{
					// If failed, then try to load Extra extensions from the boot partition
					// in case we have a separate booter partition or a bt(0,0) aliased ramdisk.
					if ( !(gBIOSBootVolume->biosdev == gBootVolume->biosdev  && gBIOSBootVolume->part_no == gBootVolume->part_no)
#ifndef OPTION_ROM
						|| (gRAMDiskVolume && gRAMDiskBTAliased) )
#else
						)
#endif
					{
						// First try a specfic OS version folder ie 10.5
						sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gMacOSVersion);
						if (FileLoadDrivers(dirSpecExtra, 0) != 0)
						{	
							// Next we'll try the base
							strcpy(dirSpecExtra, "bt(0,0)/Extra/");
							verbose(sLoadExtra, dirSpecExtra);
							FileLoadDrivers(dirSpecExtra, 0);
						}
					}
				}
				
			}