/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
- *
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
+ * Reserved. This file contains Original Code and/or Modifications of
+ * Original Code as defined in and that are subject to the Apple Public
+ * Source License Version 2.0 (the 'License'). You may not use this file
+ * except in compliance with the License. Please obtain a copy of the
+ * License at http://www.apple.com/publicsource and read it before using
+ * this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
if ( gBootFileType == kNetworkDeviceType )
{
- NetLoadDrivers(dirSpec);
+ if (NetLoadDrivers(dirSpec) != 0) {
+ error("Could not load drivers from the network\n");
+ return -1;
+ }
}
else if ( gBootFileType == kBlockDeviceType )
{
- strcpy(gExtensionsSpec, dirSpec);
- strcat(gExtensionsSpec, "System/Library/");
- FileLoadDrivers(gExtensionsSpec, 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
+ {
+ strcpy(gExtensionsSpec, dirSpec);
+ strcat(gExtensionsSpec, "System/Library/");
+ FileLoadDrivers(gExtensionsSpec, 0);
+ }
}
else
{
{
ret = GetFileInfo(dirSpec, "Extensions", &flags, &time2);
if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeDirectory) ||
- (((gBootMode & kBootModeSafe) == 0) && (time > time2)))
+ (((gBootMode & kBootModeSafe) == 0) && (time == (time2 + 1))))
{
sprintf(gDriverSpec, "%sExtensions.mkext", dirSpec);
verbose("LoadDrivers: Loading from [%s]\n", gDriverSpec);
#endif
// INTEL modification
- sprintf(gDriverSpec, "%s%s.mkext", dirSpec, bootArgs->bootFile);
+ sprintf(gDriverSpec, "%s%s.mkext", dirSpec, bootInfo->bootFile);
verbose("NetLoadDrivers: Loading from [%s]\n", gDriverSpec);
unsigned long driversAddr, driversLength;
long length;
char segName[32];
- DriversPackage * package = (DriversPackage *)kLoadAddr;
+ DriversPackage * package;
#define GetPackageElement(e) OSSwapBigToHostInt32(package->e)
// Load the MKext.
- length = LoadFile(fileSpec);
+ length = LoadThinFatFile(fileSpec, (void **)&package);
if (length == -1) return -1;
- ThinFatFile((void **)&package, &length);
-
// Verify the MKext.
if (( GetPackageElement(signature1) != kDriverPackageSignature1) ||
( GetPackageElement(signature2) != kDriverPackageSignature2) ||
( GetPackageElement(length) > kLoadSize ) ||
( GetPackageElement(alder32) !=
- Alder32((char *)&package->version, GetPackageElement(length) - 0x10) ) )
+ Alder32((unsigned char *)&package->version, GetPackageElement(length) - 0x10) ) )
{
return -1;
}
return ret;
}
-#if 0
-//==========================================================================
-// ThinFatFile
-// Checks the loaded file for a fat header; if present, updates
-// loadAddr and length to be the portion of the fat file relevant
-// to the current architecture; otherwise leaves them unchanged.
-
-static void
-ThinFatFile(void **loadAddrP, unsigned long *lengthP)
-{
- // Check for fat files.
- struct fat_header *fhp = (struct fat_header *)kLoadAddr;
- struct fat_arch *fap = (struct fat_arch *)((void *)kLoadAddr +
- sizeof(struct fat_header));
- int nfat, swapped;
- void *loadAddr = 0;
- unsigned long length = 0;
-
- if (fhp->magic == FAT_MAGIC) {
- nfat = fhp->nfat_arch;
- swapped = 0;
- } else if (fhp->magic == FAT_CIGAM) {
- nfat = OSSwapInt32(fhp->nfat_arch);
- swapped = 1;
- } else {
- nfat = 0;
- swapped = 0;
- }
-
- for (; nfat > 0; nfat--, fap++) {
- if (swapped) {
- fap->cputype = OSSwapInt32(fap->cputype);
- fap->offset = OSSwapInt32(fap->offset);
- fap->size = OSSwapInt32(fap->size);
- }
- if (fap->cputype == CPU_TYPE_I386) {
- loadAddr = (void *)kLoadAddr + fap->offset;
- length = fap->size;
- break;
- }
- }
- if (loadAddr)
- *loadAddrP = loadAddr;
- if (length)
- *lengthP = length;
-}
-#endif
//==========================================================================
// LoadMatchedModules
char *fileName, segName[32];
DriverInfoPtr driver;
long length, driverAddr, driverLength;
+ void *driverModuleAddr = 0;
+
module = gModuleHead;
{
fileName = prop->string;
sprintf(gFileSpec, "%s%s", module->driverPath, fileName);
- length = LoadFile(gFileSpec);
+ length = LoadThinFatFile(gFileSpec, &driverModuleAddr);
+ //length = LoadFile(gFileSpec);
+ //driverModuleAddr = (void *)kLoadAddr;
+ //printf("%s length = %d addr = 0x%x\n", gFileSpec, length, driverModuleAddr); getc();
}
else
length = 0;
if (length != -1)
{
- void *driverModuleAddr = (void *)kLoadAddr;
- if (length != 0)
- {
- ThinFatFile(&driverModuleAddr, &length);
- }
+ //driverModuleAddr = (void *)kLoadAddr;
+ //if (length != 0)
+ //{
+ // ThinFatFile(&driverModuleAddr, &length);
+ //}
// Make make in the image area.
driverLength = sizeof(DriverInfo) + module->plistLength + length;