Index: trunk/i386/libsaio/bootstruct.c =================================================================== --- trunk/i386/libsaio/bootstruct.c (revision 2732) +++ trunk/i386/libsaio/bootstruct.c (revision 2733) @@ -31,13 +31,13 @@ #include "bootstruct.h" #ifndef DEBUG_BOOTSTRUCT -#define DEBUG_BOOTSTRUCT 0 + #define DEBUG_BOOTSTRUCT 0 #endif #if DEBUG_BOOTSTRUCT -#define DBG(x...) printf(x) + #define DBG(x...) printf(x) #else -#define DBG(x...) msglog(x) + #define DBG(x...) msglog(x) #endif /*========================================================================== @@ -45,10 +45,10 @@ * the kernel by the booter. */ -boot_args *bootArgs; -boot_args_pre_lion *bootArgsPreLion; +boot_args *bootArgs = NULL; +boot_args_legacy *bootArgsLegacy = NULL; -PrivateBootInfo_t *bootInfo; +PrivateBootInfo_t *bootInfo = NULL; Node *gMemoryMapNode; static char platformName[64]; @@ -57,18 +57,22 @@ { Node *node; int nameLen; + static int init_done = 0; if ( !init_done ) { bootArgs = (boot_args *)malloc(sizeof(boot_args)); - bootArgsPreLion = (boot_args_pre_lion *)malloc(sizeof(boot_args_pre_lion)); + bootArgsLegacy = (boot_args_legacy *)malloc(sizeof(boot_args_legacy)); bootInfo = (PrivateBootInfo_t *)malloc(sizeof(PrivateBootInfo_t)); - if (bootArgs == 0 || bootArgsPreLion == 0 || bootInfo == 0) + + if (bootArgs == 0 || bootArgsLegacy == 0 || bootInfo == 0) + { stop("Couldn't allocate boot info\n"); + } bzero(bootArgs, sizeof(boot_args)); - bzero(bootArgsPreLion, sizeof(boot_args_pre_lion)); + bzero(bootArgsLegacy, sizeof(boot_args_legacy)); bzero(bootInfo, sizeof(PrivateBootInfo_t)); // Get system memory map. Also update the size of the @@ -95,11 +99,13 @@ DT__Initialize(); node = DT__FindNode("/", true); - if (node == 0) { + if (node == 0) + { stop("Couldn't create root node"); } getPlatformName(platformName, sizeof(platformName)); + nameLen = strlen(platformName) + 1; DT__AddProperty(node, "compatible", nameLen, platformName); DT__AddProperty(node, "model", nameLen, platformName); @@ -109,8 +115,8 @@ bootArgs->Version = kBootArgsVersion; bootArgs->Revision = kBootArgsRevision; - bootArgsPreLion->Version = kBootArgsPreLionVersion; - bootArgsPreLion->Revision = kBootArgsPreLionRevision; + bootArgsLegacy->Version = kBootArgsLegacyVersion; + bootArgsLegacy->Revision = kBootArgsLegacyRevision; init_done = 1; } @@ -123,9 +129,9 @@ if ( TIGER || LEOPARD || SNOW_LEOPARD ) { // for 10.4 10.5 10.6 - void *oldAddr = bootArgsPreLion; - bootArgsPreLion = (boot_args_pre_lion *)AllocateKernelMemory(sizeof(boot_args_pre_lion)); - bcopy(oldAddr, bootArgsPreLion, sizeof(boot_args_pre_lion)); + void *oldAddr = bootArgsLegacy; + bootArgsLegacy = (boot_args_legacy *)AllocateKernelMemory(sizeof(boot_args_legacy)); + bcopy(oldAddr, bootArgsLegacy, sizeof(boot_args_legacy)); } else { @@ -143,8 +149,9 @@ uint32_t size; void *addr; int i; - EfiMemoryRange *memoryMap; - MemoryRange *range; + + EfiMemoryRange *memoryMap = NULL; + MemoryRange *range = NULL; int memoryMapCount = bootInfo->memoryMapCount; if (memoryMapCount == 0) @@ -156,10 +163,10 @@ // convert memory map to boot_args memory map memoryMap = (EfiMemoryRange *)AllocateKernelMemory(sizeof(EfiMemoryRange) * memoryMapCount); - bootArgs->MemoryMap = (uint32_t)memoryMap; - bootArgs->MemoryMapSize = sizeof(EfiMemoryRange) * memoryMapCount; - bootArgs->MemoryMapDescriptorSize = sizeof(EfiMemoryRange); - bootArgs->MemoryMapDescriptorVersion = 0; + bootArgs->MemoryMap = (uint32_t)memoryMap; + bootArgs->MemoryMapSize = sizeof(EfiMemoryRange) * memoryMapCount; + bootArgs->MemoryMapDescriptorSize = sizeof(EfiMemoryRange); + bootArgs->MemoryMapDescriptorVersion = 0; for (i = 0; i < memoryMapCount; i++, memoryMap++) { @@ -201,7 +208,6 @@ // Flatten device tree DT__FlattenDeviceTree(0, &size); addr = (void *)AllocateKernelMemory(size); - if (addr == 0) { stop("Couldn't allocate device tree\n"); @@ -213,27 +219,27 @@ // Copy BootArgs values to older structure - memcpy(&bootArgsPreLion->CommandLine, &bootArgs->CommandLine, BOOT_LINE_LENGTH); - memcpy(&bootArgsPreLion->Video, &bootArgs->Video, sizeof(Boot_Video)); + memcpy(&bootArgsLegacy->CommandLine, &bootArgs->CommandLine, BOOT_LINE_LENGTH); + memcpy(&bootArgsLegacy->Video, &bootArgs->Video, sizeof(Boot_Video)); - bootArgsPreLion->MemoryMap = bootArgs->MemoryMap; - bootArgsPreLion->MemoryMapSize = bootArgs->MemoryMapSize; - bootArgsPreLion->MemoryMapDescriptorSize = bootArgs->MemoryMapDescriptorSize; - bootArgsPreLion->MemoryMapDescriptorVersion = bootArgs->MemoryMapDescriptorVersion; + bootArgsLegacy->MemoryMap = bootArgs->MemoryMap; + bootArgsLegacy->MemoryMapSize = bootArgs->MemoryMapSize; + bootArgsLegacy->MemoryMapDescriptorSize = bootArgs->MemoryMapDescriptorSize; + bootArgsLegacy->MemoryMapDescriptorVersion = bootArgs->MemoryMapDescriptorVersion; - bootArgsPreLion->deviceTreeP = bootArgs->deviceTreeP; - bootArgsPreLion->deviceTreeLength = bootArgs->deviceTreeLength; + bootArgsLegacy->deviceTreeP = bootArgs->deviceTreeP; + bootArgsLegacy->deviceTreeLength = bootArgs->deviceTreeLength; - bootArgsPreLion->kaddr = bootArgs->kaddr; - bootArgsPreLion->ksize = bootArgs->ksize; + bootArgsLegacy->kaddr = bootArgs->kaddr; + bootArgsLegacy->ksize = bootArgs->ksize; - bootArgsPreLion->efiRuntimeServicesPageStart = bootArgs->efiRuntimeServicesPageStart; - bootArgsPreLion->efiRuntimeServicesPageCount = bootArgs->efiRuntimeServicesPageCount; - bootArgsPreLion->efiSystemTable = bootArgs->efiSystemTable; + bootArgsLegacy->efiRuntimeServicesPageStart = bootArgs->efiRuntimeServicesPageStart; + bootArgsLegacy->efiRuntimeServicesPageCount = bootArgs->efiRuntimeServicesPageCount; + bootArgsLegacy->efiSystemTable = bootArgs->efiSystemTable; - bootArgsPreLion->efiMode = bootArgs->efiMode; + bootArgsLegacy->efiMode = bootArgs->efiMode; - bootArgsPreLion->performanceDataStart = bootArgs->performanceDataStart; - bootArgsPreLion->performanceDataSize = bootArgs->performanceDataSize; - bootArgsPreLion->efiRuntimeServicesVirtualPageStart = bootArgs->efiRuntimeServicesVirtualPageStart; + bootArgsLegacy->performanceDataStart = bootArgs->performanceDataStart; + bootArgsLegacy->performanceDataSize = bootArgs->performanceDataSize; + bootArgsLegacy->efiRuntimeServicesVirtualPageStart = bootArgs->efiRuntimeServicesVirtualPageStart; } Index: trunk/i386/libsaio/bootstruct.h =================================================================== --- trunk/i386/libsaio/bootstruct.h (revision 2732) +++ trunk/i386/libsaio/bootstruct.h (revision 2733) @@ -33,8 +33,8 @@ /* * Kernel boot args global also used by booter for its own data. */ -extern boot_args *bootArgs; -extern boot_args_pre_lion *bootArgsPreLion; +extern boot_args *bootArgs; +extern boot_args_legacy *bootArgsLegacy; extern Node *gMemoryMapNode; #define VGA_TEXT_MODE 0 Index: trunk/i386/libsaio/bootargs.h =================================================================== --- trunk/i386/libsaio/bootargs.h (revision 2732) +++ trunk/i386/libsaio/bootargs.h (revision 2733) @@ -116,8 +116,8 @@ #define kBootArgsVersion 2 // Snow Leopard and older -#define kBootArgsPreLionRevision 6 -#define kBootArgsPreLionVersion 1 +#define kBootArgsLegacyVersion 1 +#define kBootArgsLegacyRevision 6 /* Snapshot constants of previous revisions that are supported */ #define kBootArgsVersion1 1 @@ -187,7 +187,7 @@ } boot_args; -typedef struct boot_args_pre_lion +typedef struct boot_args_legacy { uint16_t Revision; /* Revision of boot_args structure */ uint16_t Version; /* Version of boot_args structure */ @@ -220,6 +220,6 @@ uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */ uint32_t __reserved3[2]; -} boot_args_pre_lion; +} boot_args_legacy; #endif /* _PEXPERT_I386_BOOT_H */ Index: trunk/i386/boot2/boot.c =================================================================== --- trunk/i386/boot2/boot.c (revision 2732) +++ trunk/i386/boot2/boot.c (revision 2733) @@ -236,9 +236,9 @@ if ( TIGER || LEOPARD || SNOW_LEOPARD ) { // Notify modules that the kernel is about to be started - execute_hook("Kernel Start", (void *)kernelEntry, (void *)bootArgsPreLion, NULL, NULL); + execute_hook("Kernel Start", (void *)kernelEntry, (void *)bootArgsLegacy, NULL, NULL); - startprog( kernelEntry, bootArgsPreLion ); + startprog( kernelEntry, bootArgsLegacy ); } else {