<s>
The	O
Macintosh	B-Device
Toolbox	I-Device
implements	O
many	O
of	O
the	O
high-level	O
features	O
of	O
the	O
Classic	B-Application
Mac	I-Application
OS	I-Application
,	O
including	O
a	O
set	O
of	O
application	B-Application
programming	I-Application
interfaces	I-Application
for	O
software	O
development	O
on	O
the	O
platform	O
.	O
</s>
<s>
The	O
Toolbox	O
consists	O
of	O
a	O
number	O
of	O
"	O
managers	O
,	O
"	O
software	O
components	O
such	O
as	O
QuickDraw	B-Operating_System
,	O
responsible	O
for	O
drawing	O
onscreen	O
graphics	O
,	O
and	O
the	O
Menu	O
Manager	O
,	O
which	O
maintain	O
data	O
structures	O
describing	O
the	O
menu	O
bar	O
.	O
</s>
<s>
As	O
the	O
original	O
Macintosh	O
was	O
designed	O
without	O
virtual	B-Architecture
memory	I-Architecture
or	O
memory	B-General_Concept
protection	I-General_Concept
,	O
it	O
was	O
important	O
to	O
classify	O
code	O
according	O
to	O
when	O
it	O
should	O
be	O
loaded	O
into	O
memory	O
or	O
kept	O
on	O
disk	O
,	O
and	O
how	O
it	O
should	O
be	O
accessed	O
.	O
</s>
<s>
The	O
Toolbox	O
consists	O
of	O
subroutines	O
essential	O
enough	O
to	O
be	O
permanently	O
kept	O
in	O
memory	O
and	O
accessible	O
by	O
a	O
two-byte	O
machine	B-General_Concept
instruction	I-General_Concept
;	O
however	O
it	O
excludes	O
core	O
"	O
kernel	O
"	O
functionality	O
such	O
as	O
memory	B-General_Concept
management	I-General_Concept
and	O
the	O
file	B-Application
system	I-Application
.	O
</s>
<s>
Note	O
that	O
the	O
Toolbox	O
does	O
not	O
draw	O
the	O
menu	O
onscreen	O
:	O
menus	O
were	O
designed	O
to	O
have	O
a	O
customizable	O
appearance	O
,	O
so	O
the	O
drawing	O
code	O
was	O
stored	O
in	O
a	O
resource	B-Operating_System
,	O
which	O
could	O
be	O
on	O
a	O
disk	O
.	O
</s>
<s>
The	O
original	O
Motorola	B-Device
68000	I-Device
family	I-Device
implementation	O
of	O
the	O
Macintosh	O
operating	O
system	O
executes	O
system	B-Operating_System
calls	I-Operating_System
using	O
that	O
processor	O
's	O
illegal	B-Language
opcode	I-Language
exception	B-Application
handling	I-Application
mechanism	O
.	O
</s>
<s>
Motorola	O
specified	O
that	O
instructions	O
beginning	O
with	O
1111	O
and	O
1010	O
would	O
never	O
be	O
used	O
in	O
future	O
68000	B-Device
family	I-Device
processors	O
,	O
thus	O
freeing	O
them	O
for	O
use	O
as	O
such	O
by	O
an	O
operating	O
system	O
.	O
</s>
<s>
Further	O
,	O
they	O
each	O
had	O
their	O
own	O
dedicated	O
interrupt	B-General_Concept
vector	I-General_Concept
,	O
separate	O
from	O
the	O
generic	O
illegal	B-Language
opcode	I-Language
handler	O
.	O
</s>
<s>
As	O
1111	O
was	O
reserved	O
for	O
use	O
by	O
co-processors	O
such	O
as	O
the	O
68881	B-General_Concept
FPU	B-General_Concept
,	O
Apple	O
chose	O
1010	O
(	O
in	O
the	O
hexadecimal	O
representation	O
of	O
ASCII	B-Protocol
,	O
an	O
A	O
followed	O
by	O
a	O
control	O
character	O
)	O
as	O
the	O
prefix	O
for	O
operating	O
system	B-Operating_System
calls	I-Operating_System
.	O
</s>
<s>
Handling	O
illegal	B-Language
instructions	I-Language
is	O
known	O
as	O
trapping	O
,	O
so	O
these	O
special	O
instructions	O
were	O
called	O
A-traps	O
.	O
</s>
<s>
Only	O
two	O
bytes	B-Application
are	O
taken	O
by	O
every	O
operating	O
system	O
access	O
,	O
in	O
contrast	O
to	O
four	O
or	O
six	O
when	O
using	O
regular	O
jump	O
instructions	O
.	O
</s>
<s>
Then	O
,	O
even	O
if	O
the	O
underlying	O
code	O
was	O
stored	O
in	O
ROM	O
,	O
it	O
could	O
still	O
be	O
overridden	O
(	O
patched	O
)	O
by	O
replacing	O
the	O
ROM	O
memory	B-General_Concept
address	I-General_Concept
with	O
a	O
RAM	O
address	O
.	O
</s>
<s>
The	O
system	O
was	O
further	O
optimized	O
by	O
allotting	O
some	O
bits	O
of	O
the	O
A-trap	O
instruction	O
to	O
store	O
parameters	O
to	O
the	O
most	O
common	O
functions	O
.	O
</s>
<s>
For	O
example	O
,	O
memory	B-General_Concept
allocation	I-General_Concept
is	O
a	O
very	O
common	O
task	O
,	O
so	O
it	O
should	O
be	O
expressed	O
in	O
as	O
few	O
bytes	B-Application
of	O
code	O
as	O
possible	O
.	O
</s>
<s>
To	O
pass	O
a	O
parameter	O
would	O
require	O
an	O
additional	O
two-byte	O
instruction	O
,	O
which	O
would	O
be	O
inefficient	O
.	O
</s>
<s>
Having	O
two	O
functions	O
would	O
require	O
at	O
least	O
an	O
extra	O
four	O
bytes	B-Application
of	O
RAM	O
used	O
for	O
the	O
address	O
in	O
the	O
function	O
look-up	O
table	O
.	O
</s>
<s>
The	O
most	O
efficient	O
solution	O
is	O
to	O
map	O
multiple	O
A-traps	O
to	O
the	O
same	O
subroutine	O
,	O
which	O
then	O
uses	O
the	O
A-trap	O
as	O
a	O
parameter	O
.	O
</s>
<s>
The	O
Toolbox	O
was	O
defined	O
as	O
the	O
set	O
of	O
subroutines	O
which	O
took	O
no	O
parameters	O
within	O
the	O
A-trap	O
,	O
and	O
were	O
indexed	O
from	O
a	O
1024-entry	O
,	O
4-kilobyte	O
dispatch	O
table	O
.	O
</s>
<s>
In	O
1994	O
,	O
Apple	O
released	O
Macintoshes	O
using	O
the	O
PowerPC	B-Architecture
architecture	O
,	O
which	O
lacked	O
hardware	O
support	O
for	O
the	O
A-trap	O
mechanism	O
available	O
on	O
68k	B-Device
systems	O
.	O
</s>
<s>
The	O
API	B-Application
library	O
code	O
underlying	O
any	O
Toolbox	O
routine	O
then	O
does	O
nothing	O
except	O
reference	O
the	O
dispatch	O
table	O
.	O
</s>
<s>
The	O
dispatch	O
table	O
linked	O
only	O
to	O
emulated	O
68000	B-Device
family	I-Device
code	O
.	O
</s>
<s>
Toolbox	O
functions	O
implemented	O
in	O
native	O
PowerPC	B-Architecture
code	O
have	O
to	O
first	O
disable	O
the	O
emulator	O
using	O
the	O
Mixed	O
Mode	O
Manager	O
.	O
</s>
<s>
For	O
the	O
sake	O
of	O
uniformity	O
and	O
extensibility	O
,	O
new	O
function	O
entries	O
even	O
continued	O
to	O
be	O
added	O
to	O
the	O
Toolbox	O
after	O
the	O
PowerPC	B-Architecture
transition	O
.	O
</s>
<s>
An	O
alternative	O
mechanism	O
did	O
exist	O
,	O
however	O
,	O
in	O
the	O
Code	O
Fragment	O
Manager	O
,	O
which	O
was	O
used	O
to	O
load	O
and	O
dynamically	O
link	O
native	O
PowerPC	B-Architecture
programs	O
.	O
</s>
<s>
The	O
PowerPC	B-Architecture
system	B-Operating_System
call	I-Operating_System
facility	O
,	O
analogous	O
to	O
the	O
A-trap	O
mechanism	O
,	O
was	O
used	O
to	O
interface	O
with	O
the	O
Mac	B-Operating_System
OS	I-Operating_System
nanokernel	I-Operating_System
,	O
which	O
offered	O
few	O
services	O
directly	O
useful	O
to	O
applications	O
.	O
</s>
<s>
As	O
a	O
result	O
,	O
it	O
grew	O
into	O
a	O
hodgepodge	O
of	O
different	O
API	B-Application
libraries	B-Library
.	O
</s>
<s>
The	O
Toolbox	O
encompasses	O
most	O
of	O
the	O
basic	O
functionality	O
which	O
distinguished	O
the	O
Classic	B-Application
Mac	I-Application
OS	I-Application
.	O
</s>
<s>
Apple	O
's	O
references	O
“	O
Inside	O
Macintosh	O
:	O
Macintosh	B-Device
Toolbox	I-Device
Essentials	O
”	O
and	O
“	O
Inside	O
Macintosh	O
:	O
More	O
Macintosh	B-Device
Toolbox	I-Device
”	O
,	O
similarly	O
vague	O
in	O
scope	O
,	O
also	O
document	O
most	O
of	O
the	O
Toolbox	O
.	O
</s>
<s>
Because	O
much	O
of	O
the	O
Toolbox	O
is	O
implemented	O
in	O
ROM	O
,	O
alongside	O
the	O
computer	O
's	O
firmware	B-Application
,	O
it	O
was	O
convenient	O
to	O
use	O
as	O
a	O
bootloader	B-Application
environment	O
.	O
</s>
<s>
In	O
conjunction	O
with	O
resources	B-Operating_System
stored	O
on	O
the	O
ROM	O
chip	O
,	O
the	O
Toolbox	O
can	O
turn	O
the	O
screen	O
gray	O
,	O
show	O
a	O
dialog	O
box	O
with	O
the	O
signature	O
"	O
Welcome	O
to	O
Macintosh	O
"	O
greeting	O
,	O
and	O
display	O
the	O
mouse	O
cursor	O
.	O
</s>
<s>
By	O
using	O
Toolbox	O
to	O
help	O
boot	O
the	O
machine	O
,	O
a	O
rudimentary	O
Mac-like	O
environment	O
can	O
be	O
initialized	O
before	O
ever	O
loading	O
the	O
System	B-Application
suitcase	I-Application
from	O
disk	O
(	O
in	O
fact	O
before	O
ROMs	O
on	O
NuBus	O
cards	O
were	O
executed	O
)	O
,	O
which	O
is	O
when	O
the	O
decision	O
to	O
use	O
24-bit	O
or	O
32-bit	O
addressing	O
has	O
to	O
be	O
made	O
.	O
</s>
<s>
The	O
need	O
for	O
diagnostics	O
as	O
in	O
the	O
BIOS	B-Operating_System
resident	O
for	O
IBM	O
PC	O
compatibles	O
 '	O
boards	O
is	O
not	O
necessary	O
since	O
the	O
Macintosh	O
has	O
most	O
of	O
its	O
diagnostics	O
in	O
POST	B-Device
and	O
automatically	O
reports	O
errors	O
via	O
the	O
"	O
Sad	O
Mac	O
"	O
codes	O
.	O
</s>
<s>
Although	O
the	O
"	O
Classic	B-Application
Mac	I-Application
OS	I-Application
"	O
boot	O
process	O
is	O
convoluted	O
and	O
largely	O
undocumented	O
,	O
it	O
is	O
not	O
more	O
limited	O
than	O
an	O
IBM	O
PC	O
compatible	O
BIOS	B-Operating_System
.	O
</s>
<s>
Like	O
a	O
PC	O
's	O
master	B-Device
boot	I-Device
record	I-Device
,	O
a	O
ROM-based	O
Mac	O
reads	O
and	O
executes	O
code	O
from	O
the	O
first	O
blocks	O
(	O
"	O
boot	O
blocks	O
"	O
)	O
of	O
the	O
disk	B-Application
partition	I-Application
selected	O
as	O
the	O
boot	O
device	O
.	O
</s>
<s>
The	O
boot	O
blocks	O
then	O
verify	O
that	O
a	O
suitable	O
rudimentary	O
environment	O
exists	O
,	O
and	O
use	O
it	O
to	O
load	O
the	O
System	B-Application
suitcase	I-Application
.	O
</s>
<s>
A	O
different	O
operating	O
system	O
with	O
a	O
different	O
file	B-Application
system	I-Application
can	O
boot	O
by	O
simply	O
using	O
its	O
own	O
code	O
in	O
the	O
boot	O
blocks	O
.	O
</s>
<s>
This	O
system	O
was	O
not	O
used	O
for	O
PowerPC	B-Architecture
Linux	O
,	O
however	O
,	O
because	O
Open	B-Architecture
Firmware	I-Architecture
in	O
New	B-Device
World	I-Device
ROM	I-Device
machines	O
requires	O
a	O
bootloader	B-Application
within	O
an	O
HFS	O
filesystem	B-Application
—	O
a	O
reason	O
having	O
nothing	O
to	O
do	O
with	O
the	O
Toolbox	O
or	O
"	O
old-fashioned	O
"	O
Macs	O
in	O
general	O
.	O
</s>
<s>
More	O
narrowly	O
,	O
the	O
Startup	O
Disk	O
control	O
panel	O
in	O
the	O
Classic	B-Application
Mac	I-Application
OS	I-Application
and	O
macOS	B-Application
only	O
allows	O
the	O
user	O
to	O
select	O
a	O
mounted	O
filesystem	B-Application
with	O
very	O
particular	O
constraints	O
.	O
</s>
<s>
In	O
Mac	B-Application
OS	I-Application
X	I-Application
,	O
the	O
Toolbox	O
is	O
not	O
used	O
at	O
all	O
,	O
though	O
the	O
Classic	O
Environment	O
loads	O
the	O
Toolbox	O
ROM	O
file	O
into	O
its	O
virtual	O
machine	O
.	O
</s>
<s>
Much	O
of	O
the	O
Toolbox	O
was	O
restructured	O
and	O
implemented	O
as	O
part	O
of	O
Apple	O
's	O
Carbon	B-Operating_System
programming	O
API	B-Application
,	O
allowing	O
programmers	O
familiar	O
with	O
the	O
Toolbox	O
to	O
port	O
their	O
program	O
code	O
more	O
easily	O
to	O
Mac	B-Application
OS	I-Application
X	I-Application
.	O
</s>
