2004-02-26 22:29:31 +00:00
|
|
|
/*
|
|
|
|
*
|
2006-09-15 14:55:39 +00:00
|
|
|
* (c) 2004 Laurent Vivier <Laurent@lvivier.info>
|
2004-02-26 22:29:31 +00:00
|
|
|
*
|
2004-02-26 23:38:05 +00:00
|
|
|
* some parts from BootX, (c) Benjamin Herrenschmidt
|
|
|
|
*
|
2004-02-26 22:29:31 +00:00
|
|
|
*/
|
|
|
|
|
2005-11-08 02:06:40 +00:00
|
|
|
#include <macos/lowmem.h>
|
|
|
|
#include <macos/gestalt.h>
|
|
|
|
#include <macos/errors.h>
|
|
|
|
|
2004-06-02 17:38:24 +00:00
|
|
|
#include "misc.h"
|
2004-02-26 20:10:41 +00:00
|
|
|
#include "arch.h"
|
2005-05-12 21:07:11 +00:00
|
|
|
#ifdef ARCH_PPC
|
|
|
|
#include "bootx.h"
|
|
|
|
#endif
|
2004-02-26 20:10:41 +00:00
|
|
|
|
2004-05-25 23:30:31 +00:00
|
|
|
unsigned long cpu_type;
|
|
|
|
unsigned long mmu_type;
|
|
|
|
unsigned long fpu_type;
|
|
|
|
unsigned long machine_id;
|
|
|
|
unsigned long arch_type;
|
2005-06-13 18:49:38 +00:00
|
|
|
unsigned long ram_size;
|
2005-09-19 22:01:53 +00:00
|
|
|
unsigned long gmt_bias;
|
2005-05-12 21:07:11 +00:00
|
|
|
#ifdef ARCH_PPC
|
2004-05-25 23:30:31 +00:00
|
|
|
unsigned long bus_type;
|
2005-05-12 21:07:11 +00:00
|
|
|
#endif
|
2004-02-26 20:10:41 +00:00
|
|
|
|
2005-05-23 22:23:34 +00:00
|
|
|
struct older_macintosh_info {
|
|
|
|
char *name;
|
|
|
|
unsigned short ROMID;
|
|
|
|
unsigned short SSW;
|
|
|
|
unsigned long cpu_type;
|
|
|
|
unsigned long mmu_type;
|
|
|
|
unsigned long fpu_type;
|
|
|
|
unsigned long machine_id;
|
|
|
|
unsigned long arch_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct older_macintosh_info older_macintosh[] = {
|
|
|
|
{ "Macintosh SE/30", 0x0178, 0x0603,
|
|
|
|
gestalt68030, gestalt68030MMU, gestalt68882,
|
|
|
|
gestaltMacSE030, gestalt68k },
|
|
|
|
{ "Macintosh Classic", 0x0276, 0x0607,
|
|
|
|
gestalt68000, gestaltNoMMU, gestaltNoFPU,
|
|
|
|
gestaltClassic, gestalt68k },
|
2005-05-23 22:27:03 +00:00
|
|
|
{ 0 }
|
2005-05-23 22:23:34 +00:00
|
|
|
};
|
|
|
|
|
2004-02-26 20:10:41 +00:00
|
|
|
void arch_init()
|
|
|
|
{
|
2005-09-19 22:01:53 +00:00
|
|
|
MachineLocation where;
|
2005-05-23 22:23:34 +00:00
|
|
|
int i = 0;
|
2004-07-10 01:28:27 +00:00
|
|
|
|
2005-05-23 22:23:34 +00:00
|
|
|
/* Some systems don't support Gestalt() */
|
2004-07-10 01:28:27 +00:00
|
|
|
|
2005-05-23 22:27:03 +00:00
|
|
|
while (older_macintosh[i].name != 0 )
|
2005-05-23 22:23:34 +00:00
|
|
|
{
|
|
|
|
if (ROMBase[4] == older_macintosh[i].ROMID)
|
|
|
|
{
|
|
|
|
/* Doesn't support Gestalt(), nor SysEnvirons() */
|
2004-07-10 01:28:27 +00:00
|
|
|
|
2005-05-23 22:23:34 +00:00
|
|
|
cpu_type = older_macintosh[i].cpu_type;
|
|
|
|
mmu_type = older_macintosh[i].mmu_type;
|
|
|
|
fpu_type = older_macintosh[i].fpu_type;
|
|
|
|
machine_id = older_macintosh[i].machine_id;
|
|
|
|
arch_type = older_macintosh[i].arch_type;
|
2005-06-13 18:49:38 +00:00
|
|
|
ram_size = MemTop;
|
2004-07-10 01:28:27 +00:00
|
|
|
|
2005-05-23 22:23:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
i++;
|
2004-07-10 01:28:27 +00:00
|
|
|
}
|
2005-05-23 22:23:34 +00:00
|
|
|
|
2005-06-13 18:49:38 +00:00
|
|
|
/* get RAM size */
|
|
|
|
|
2007-03-22 16:27:34 +00:00
|
|
|
Gestalt('ram ', (long*)&ram_size);
|
2005-06-13 18:49:38 +00:00
|
|
|
|
2004-02-26 20:10:41 +00:00
|
|
|
/* get processor type */
|
|
|
|
|
2007-03-22 16:27:34 +00:00
|
|
|
Gestalt(gestaltProcessorType, (long*)&cpu_type);
|
2004-02-26 20:10:41 +00:00
|
|
|
|
|
|
|
/* check FPU */
|
|
|
|
|
2007-03-22 16:27:34 +00:00
|
|
|
if (Gestalt('FPUE', (long*)&fpu_type) == noErr)
|
2004-02-26 20:10:41 +00:00
|
|
|
fpu_type = 0;
|
|
|
|
else
|
2007-03-22 16:27:34 +00:00
|
|
|
Gestalt(gestaltFPUType, (long*)&fpu_type);
|
2004-02-26 20:10:41 +00:00
|
|
|
|
|
|
|
/* check MMU */
|
|
|
|
|
2007-03-22 16:27:34 +00:00
|
|
|
Gestalt(gestaltMMUType, (long*)&mmu_type);
|
2004-02-26 20:10:41 +00:00
|
|
|
|
2004-06-02 21:11:21 +00:00
|
|
|
/* I'v got a 'noMMU' with my 68030, not cool... */
|
|
|
|
|
|
|
|
if (mmu_type == gestaltNoMMU)
|
|
|
|
{
|
|
|
|
switch(cpu_type)
|
|
|
|
{
|
|
|
|
case gestalt68030:
|
|
|
|
mmu_type = gestalt68030MMU;
|
|
|
|
break;
|
|
|
|
case gestalt68040:
|
|
|
|
mmu_type = gestalt68040MMU;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-26 23:38:05 +00:00
|
|
|
/* get architecture type: powerPC or m68k */
|
2004-02-26 20:10:41 +00:00
|
|
|
|
2007-03-22 16:27:34 +00:00
|
|
|
if (Gestalt(gestaltSysArchitecture, (long*)&arch_type) != noErr)
|
2004-02-26 23:38:05 +00:00
|
|
|
arch_type = gestalt68k;
|
2004-02-26 20:10:41 +00:00
|
|
|
|
2004-02-26 23:38:05 +00:00
|
|
|
/* check machine type */
|
2004-02-26 20:10:41 +00:00
|
|
|
|
2007-03-22 16:27:34 +00:00
|
|
|
Gestalt(gestaltMachineType, (long*)&machine_id);
|
2004-02-26 22:29:31 +00:00
|
|
|
|
2005-09-19 22:01:53 +00:00
|
|
|
/* GMT bias */
|
|
|
|
|
|
|
|
ReadLocation(&where);
|
|
|
|
gmt_bias = where.u.gmtDelta & 0x00FFFFFF;
|
|
|
|
if (gmt_bias & 0x00800000)
|
|
|
|
gmt_bias |= 0xFF000000; /* sign-extend to 32 bits */
|
|
|
|
gmt_bias = (long)gmt_bias / 60; /* convert to whole minutes, remember sign */
|
|
|
|
|
2005-05-12 21:07:11 +00:00
|
|
|
#ifdef ARCH_PPC
|
2004-02-26 22:29:31 +00:00
|
|
|
/* check bus type */
|
|
|
|
|
2005-05-12 21:07:11 +00:00
|
|
|
if (arch_type == gestaltPowerPC)
|
2004-02-26 23:38:05 +00:00
|
|
|
{
|
|
|
|
unsigned long response;
|
|
|
|
|
|
|
|
/* OpenFirmware implies PCI */
|
|
|
|
|
|
|
|
if ( (Gestalt('opfw', &response) == noErr) &&
|
|
|
|
(Gestalt('nreg', &response) == noErr) )
|
2005-05-12 21:07:11 +00:00
|
|
|
bus_type = BOOT_ARCH_PCI;
|
2004-02-26 23:38:05 +00:00
|
|
|
else
|
2005-05-12 21:07:11 +00:00
|
|
|
bus_type = BOOT_ARCH_NUBUS;
|
2004-02-26 23:38:05 +00:00
|
|
|
|
|
|
|
switch(machine_id)
|
|
|
|
{
|
|
|
|
case gestaltPowerMac6100_60:
|
|
|
|
case gestaltPowerMac6100_66:
|
|
|
|
case gestaltPowerMac6100_80:
|
|
|
|
case gestaltPowerMac7100_66:
|
|
|
|
case gestaltPowerMac7100_80:
|
|
|
|
case gestaltPowerMac7100_80_chipped:
|
|
|
|
case gestaltPowerMac8100_80:
|
|
|
|
case gestaltPowerMac8100_100:
|
|
|
|
case gestaltPowerMac8100_110:
|
|
|
|
case gestaltPowerMac8100_120:
|
|
|
|
case gestaltAWS9150_80:
|
|
|
|
case gestaltAWS9150_120:
|
2005-05-12 21:07:11 +00:00
|
|
|
bus_type |= BOOT_ARCH_NUBUS_PDM;
|
2004-02-26 23:38:05 +00:00
|
|
|
break;
|
|
|
|
case gestaltPowerMac5200:
|
|
|
|
case gestaltPowerMac6200:
|
2005-05-12 21:07:11 +00:00
|
|
|
bus_type |= BOOT_ARCH_NUBUS_PERFORMA;
|
2004-02-26 23:38:05 +00:00
|
|
|
break;
|
|
|
|
case gestaltPowerBook1400:
|
|
|
|
case gestaltPowerBook5300:
|
|
|
|
case gestaltPowerBookDuo2300:
|
2005-05-12 21:07:11 +00:00
|
|
|
bus_type |= BOOT_ARCH_NUBUS_POWERBOOK;
|
2004-02-26 23:38:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-05-12 21:07:11 +00:00
|
|
|
#endif
|
2004-02-26 20:10:41 +00:00
|
|
|
}
|