Skip to content

Commit

Permalink
Removed a global and some other minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Piker-Alpha committed Jun 20, 2015
1 parent e7a2e66 commit 2aae3b4
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 30 deletions.
12 changes: 6 additions & 6 deletions i386/boot2/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void boot(int biosdev)
printf("\nModel: %s\n", gPlatform.ModelID);

#if ((MAKE_TARGET_OS & LION) != LION)
printf("\ngArchCPUType (CPU): %s\n", (gArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386");
printf("\nArchCPUType (CPU): %s\n", (gPlatform.ArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386");
sleep(3); // Silent sleep.
#endif
#endif
Expand Down Expand Up @@ -312,9 +312,9 @@ void boot(int biosdev)
// Is 'arch=<i386/x86_64>' specified as kernel flag?
if (getValueForBootKey(kernelFlags, "arch", &val, &length)) // && len >= 4)
{
gArchCPUType = (strncmp(val, "x86_64", 6) == 0) ? CPU_TYPE_X86_64 : CPU_TYPE_I386;
gPlatform.ArchCPUType = (strncmp(val, "x86_64", 6) == 0) ? CPU_TYPE_X86_64 : CPU_TYPE_I386;

_BOOT_DEBUG_DUMP("gArchCPUType (c.a.B.plist): %s\n", (gArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386");
_BOOT_DEBUG_DUMP("ArchCPUType (c.a.B.plist): %s\n", (gPlatform.ArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386");
}

// Check for -v (verbose) and -s (single user mode) flags.
Expand Down Expand Up @@ -655,7 +655,7 @@ void boot(int biosdev)

// Create path to pre-linked kernel.
sprintf(preLinkedKernelPath, "%s/%s_%s.%08lX", gPlatform.KernelCachePath, kKernelCache,
((gArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386"), adler32);
((gPlatform.ArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386"), adler32);

// Check if this file exists.
if ((GetFileInfo(NULL, preLinkedKernelPath, &flags, &cachetime) == 0) && ((flags & kFileTypeMask) == kFileTypeFlat))
Expand Down Expand Up @@ -694,11 +694,11 @@ void boot(int biosdev)
retStatus = LoadThinFatFile(bootFile, &fileLoadBuffer);

#if SUPPORT_32BIT_MODE
if (retStatus <= 0 && gArchCPUType == CPU_TYPE_X86_64)
if (retStatus <= 0 && gPlatform.ArchCPUType == CPU_TYPE_X86_64)
{
_BOOT_DEBUG_DUMP("Load failed for arch=x86_64, trying arch=i386 now.\n");

gArchCPUType = CPU_TYPE_I386;
gPlatform.ArchCPUType = CPU_TYPE_I386;

retStatus = LoadThinFatFile(bootFile, &fileLoadBuffer);
}
Expand Down
8 changes: 4 additions & 4 deletions i386/boot2/drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -969,17 +969,17 @@ long decodeKernel(void *fileLoadBuffer, entry_t *rentry, char **raddr, int *rsiz

ret = ThinFatFile(&fileLoadBuffer, &len);

if (ret == 0 && len == 0 && gArchCPUType == CPU_TYPE_X86_64)
if (ret == 0 && len == 0 && gPlatform.ArchCPUType == CPU_TYPE_X86_64)
{
gArchCPUType = CPU_TYPE_I386;
gPlatform.ArchCPUType = CPU_TYPE_I386;
ret = ThinFatFile(&fileLoadBuffer, &len);
}

ret = DecodeMachO(fileLoadBuffer, rentry, raddr, rsize);

if (ret < 0 && gArchCPUType == CPU_TYPE_X86_64)
if (ret < 0 && gPlatform.ArchCPUType == CPU_TYPE_X86_64)
{
gArchCPUType = CPU_TYPE_I386;
gPlatform.ArchCPUType = CPU_TYPE_I386;
ret = DecodeMachO(fileLoadBuffer, rentry, raddr, rsize);
}

Expand Down
10 changes: 8 additions & 2 deletions i386/config/settings-template.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@
// only to give us feedback for a future release of RevoBoot.
#endif

#define DISABLE_LEGACY_XHCI 0 // Set to 0 by default. Change this to 1 when you need to disable legacy XHCI.

#define DEBUG_BOOT 0 // Set to 0 by default. Change this to 1 when things don't seem to work for you.


Expand Down Expand Up @@ -359,17 +361,20 @@
#define STATIC_SCREEN_HEIGHT 1200 // Used (in RevoBoot v1.0.35 and greater) when USE_STATIC_DISPLAY_RESOLUTION is 1 and when
// USE_STATIC_DISPLAY_RESOLUTION is 0 but getResolutionFromEDID() isn't supported (failed).

#define BLACKMODE 1 // Show white Apple logo on a black background. Set to 0 for gray mode.

#define DEBUG_BOOT_GRAPHICS 0 // Set to 0 by default. Use 1 when to see debug info.


//------------------------------------------------------------ STRINGTABLE.H ----------------------------------------------------------------

#define INSTALL_ESD_SUPPORT 0 // Set to 0 by default. Setting this to 1 will make RevoBoot search in specific directories
// for com.apple.Boot.plist – required for Mac like Lion OS X installations.
// for com.apple.Boot.plist – required for Mac like installations of OS X.

#if (RECOVERY_HD_SUPPORT == 1 && INSTALL_ESD_SUPPORT == 0)
#define INSTALL_ESD_SUPPORT 1 // This setting is mandatory for RECOVERY_HD_SUPPORT
#endif

//-------------------------------------------------------------- SMBIOS.C ------------------------------------------------------------------


Expand Down Expand Up @@ -421,7 +426,8 @@

#if USE_STATIC_SMBIOS_DATA
// Do nothing.
#elif OVERRIDE_DYNAMIC_MEMORY_DETECTION
#elif OVERRIDE_DYNAMIC_MEMORY_DETECTION // See settings under SMBIOS.c

// Setup RAM module info. Please note that you may have to expand this when you have more RAM modules.
#define STATIC_RAM_SLOTS 4 // Number of RAM slots on mainboard.

Expand Down
14 changes: 6 additions & 8 deletions i386/libsaio/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ static long DecodeSymbolTable(long cmdBase);

static unsigned long gBinaryAddress;

cpu_type_t gArchCPUType = 0; // CPU_TYPE_I386;


//==============================================================================
// Public function.
Expand Down Expand Up @@ -115,7 +113,7 @@ long ThinFatFile(void **binary, unsigned long *length)
fapsize = fap->size;
}

if (fapcputype == gArchCPUType)
if (fapcputype == gPlatform.ArchCPUType)
{
*binary = (void *) ((unsigned long)*binary + fapoffset);
size = fapsize;
Expand Down Expand Up @@ -160,14 +158,14 @@ long DecodeMachO(void *binary, entry_t *rentry, char **raddr, int *rsize)
sleep(5);
#endif

/* if ((gArchCPUType == CPU_TYPE_I386 && mH->magic != MH_MAGIC) ||
(gArchCPUType == CPU_TYPE_X86_64 && mH->magic != MH_MAGIC_64))
/* if ((gPlatform.ArchCPUType == CPU_TYPE_I386 && mH->magic != MH_MAGIC) ||
(gPlatform.ArchCPUType == CPU_TYPE_X86_64 && mH->magic != MH_MAGIC_64))
{
error("Mach-O file has bad magic number\n");
return -1;
} */

switch (gArchCPUType)
switch (gPlatform.ArchCPUType)
{
case CPU_TYPE_I386:

Expand Down Expand Up @@ -202,7 +200,7 @@ long DecodeMachO(void *binary, entry_t *rentry, char **raddr, int *rsize)
return -1;
}

/* cmdstart = (unsigned long)gBinaryAddress + (gArchCPUType == CPU_TYPE_I386) ? sizeof(struct mach_header) :
/* cmdstart = (unsigned long)gBinaryAddress + (gPlatform.ArchCPUType == CPU_TYPE_I386) ? sizeof(struct mach_header) :
sizeof(struct mach_header_64); */
cmdBase = cmdstart;
ncmds = mH->ncmds;
Expand Down Expand Up @@ -564,7 +562,7 @@ static long DecodeSegment(long cmdBase, unsigned int *load_addr, unsigned int *l

static long DecodeUnixThread(long cmdBase, unsigned int *entry)
{
switch (gArchCPUType)
switch (gPlatform.ArchCPUType)
{
case CPU_TYPE_I386:
{
Expand Down
4 changes: 1 addition & 3 deletions i386/libsaio/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,9 @@ void initPlatform(int biosDevice, bool bootRecoveryHD)
* DHP: Booting with arch=i386 <i>and</i> setting this to CPU_TYPE_I386
* and setting the EFI_64_BIT directive in private_data to 0 allowed me
* to boot in EFI32 mode. Even with my 64 bit configuration. Pretty sweet.
*
* Note to self: Get rid of gArchCPUType (global alarm) fast.
*/

gPlatform.ArchCPUType = gArchCPUType = getArchCPUType();
gPlatform.ArchCPUType = getArchCPUType();

gPlatform.AddressWidth = (gPlatform.ArchCPUType == CPU_TYPE_X86_64) ? 8 : 4;

Expand Down
11 changes: 7 additions & 4 deletions i386/libsaio/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,13 @@

//------------------------------------------------------------------------------

#define kKernelCachePath "/System/Library/Caches/com.apple.kext.caches/Startup"
#define kKernelCache "kernelcache"
#if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // Yosemite and El Capitan.
#define kKernelCachePath "/System/Library/Prelinkedkernels"
#define kKernelCache "prelinkedkernel"
#else
#define kKernelCachePath "/System/Library/Caches/com.apple.kext.caches/Startup"
#define kKernelCache "kernelcache"
#endif

//------------------------------------------------------------------------------

Expand Down Expand Up @@ -366,8 +371,6 @@ typedef struct _PlatformInfo_t
extern void initCPUStruct(void);

/* platform.c */
extern cpu_type_t gArchCPUType; // DHP: Fix / remove me!

extern PlatformInfo_t gPlatform;

extern void initPlatform(int biosDevice, bool bootRecoveryHD);
Expand Down
3 changes: 0 additions & 3 deletions i386/libsaio/sl.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,4 @@ enum

extern void * gFSLoadAddress;

// Used in: boot/drivers/load.c
extern cpu_type_t gArchCPUType; // Formerly known as archCpuType.

#endif /* !__LIBSAIO_SL_H */

0 comments on commit 2aae3b4

Please sign in to comment.