-
Notifications
You must be signed in to change notification settings - Fork 1
/
INIT.c
71 lines (56 loc) · 1.51 KB
/
INIT.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "A4Stuff.h"
#include "SetupA4.h"
#include "ShowInitIcon.h"
#include "xpram.h"
#include <Gestalt.h>
const int kInitIcon = 128;
const int kYesIcon = 129;
const int kNoIcon = 130;
const int kBadMachineIcon = 131;
// weAre32Bit reads the 32-bit addressing status out of the xPRAM of the machine
// and returns true if we're currently set up for 32-bit addressing or false if not.
int weAre32Bit() {
char membyte;
read_xpram(&membyte, 0x8A, 1);
if ((membyte & 5) != 5) {
return false;
}
return true;
}
// force32On turns on the two bits that control 32-bit addressing in the xPRAM.
// Note, it dos not sanity check whether this will work or not...
void force32On() {
char membyte;
read_xpram(&membyte, 0x8A, 1);
// clear bits 1 and 3
membyte = (membyte | 5);
write_xpram(&membyte, 0x8A, 1);
}
// restart restarts by jumping to the ROM entry point. See Inside
// Macintosh II, p. 386. Obviously, this never returns.
asm void restart() {
move.l 0x02AE, A0
jmp 0x0A(A0)
}
void main(void)
{
long oldA4;
long processorType;
oldA4 = SetCurrentA4();
RememberA4();
ShowInitIcon(kInitIcon, false);
// First, check whether we're a 68000: in this case, bail out early, because
// we're doomed regardless.
Gestalt('proc', &processorType);
if (processorType < 3) { // 3 -> 68020, confusingly
ShowInitIcon(kBadMachineIcon, true);
} else if (weAre32Bit()) {
ShowInitIcon(kYesIcon, true);
} else {
ShowInitIcon(kNoIcon, true);
force32On();
restart();
}
/* restore the a4 world */
SetA4(oldA4);
}