Macintosh Toolbox

Last updated

The Macintosh Toolbox implements many of the high-level features of the Classic Mac OS, including a set of application programming interfaces for software development on the platform. The Toolbox consists of a number of "managers," software components such as QuickDraw, responsible for drawing onscreen graphics, and the Menu Manager, which maintain data structures describing the menu bar. As the original Macintosh was designed without virtual memory or memory protection, it was important to classify code according to when it should be loaded into memory or kept on disk, and how it should be accessed. The Toolbox consists of subroutines essential enough to be permanently kept in memory and accessible by a two-byte machine instruction; however it excludes core "kernel" functionality such as memory management and the file system. Note that the Toolbox does not draw the menu onscreen: menus were designed to have a customizable appearance, so the drawing code was stored in a resource, which could be on a disk.

Contents

Advent and implementation

On 68k systems

The original Motorola 68000 family implementation of the Macintosh operating system executes system calls using that processor's illegal opcode exception handling mechanism. Motorola specified that instructions beginning with 1111 and 1010 would never be used in future 68000 family processors, thus freeing them for use as such by an operating system. Further, they each had their own dedicated interrupt vector, separate from the generic illegal opcode handler. As 1111 was reserved for use by co-processors such as the 68881 FPU, Apple chose 1010 (A in hexadecimal) as the prefix for operating system calls. Handling illegal instructions is known as trapping, so these special instructions were called A-traps. [1] When the processor encounters such an instruction, it transfers control to the operating system, which looks up the appropriate task and performs it. There were two advantages to this mechanism:

The system was further optimized by allotting some bits of the A-trap instruction to store parameters to the most common functions. For example, memory allocation is a very common task, so it should be expressed in as few bytes of code as possible. Sometimes the programmer wants to clear the memory block to zeros, so either the allocation function should take a boolean parameter, or there should be two allocation functions. To pass a parameter would require an additional two-byte instruction, which would be inefficient. Having two functions would require at least an extra four bytes of RAM used for the address in the function look-up table. The most efficient solution is to map multiple A-traps to the same subroutine, which then uses the A-trap as a parameter. This is true of the most commonly used subroutines. However, the Toolbox was composed of the less commonly used subroutines. The Toolbox was defined as the set of subroutines which took no parameters within the A-trap, and were indexed from a 1024-entry, 4-kilobyte dispatch table. [2] (Machines shipped with less than one megabyte of RAM use a single table of 512 entries, which corresponds to the 256-entry OS dispatch table of later ROM revisions. [3] )

On PowerPC systems

In 1994, Apple released Macintoshes using the PowerPC architecture, which lacked hardware support for the A-trap mechanism available on 68k systems. Because of their use in applying software patches, however, the dispatch tables were retained. The API library code underlying any Toolbox routine then does nothing except reference the dispatch table. The dispatch table linked only to emulated 68000 family code. Toolbox functions implemented in native PowerPC code have to first disable the emulator using the Mixed Mode Manager. For the sake of uniformity and extensibility, new function entries even continued to be added to the Toolbox after the PowerPC transition.

An alternative mechanism did exist, however, in the Code Fragment Manager, which was used to load and dynamically link native PowerPC programs. The PowerPC system call facility, analogous to the A-trap mechanism, was used to interface with the Mac OS nanokernel, which offered few services directly useful to applications.

Functionality

Programming interfaces

The Toolbox is composed of commonly used functions, but not the most commonly used functions. As a result, it grew into a hodgepodge of different API libraries. [3] The Toolbox encompasses most of the basic functionality which distinguished the Classic Mac OS. Apple's references “Inside Macintosh: Macintosh Toolbox Essentials” and “Inside Macintosh: More Macintosh Toolbox”, similarly vague in scope, also document most of the Toolbox.

Use in booting

Because much of the Toolbox is implemented in ROM, alongside the computer's firmware, it was convenient to use as a bootloader environment. In conjunction with resources stored on the ROM chip, the Toolbox can turn the screen gray, show a dialog box with the signature "Welcome to Macintosh" greeting, and display the mouse cursor. By using Toolbox to help boot the machine, a rudimentary Mac-like environment can be initialized before ever loading the System suitcase from disk (in fact before ROMs on NuBus cards were executed), which is when the decision to use 24-bit or 32-bit addressing has to be made. (System 7's support for 32-bit addressing requires 32-bit clean ROMs, as older Mac ROMs do not have support for this). The need for diagnostics as in the BIOS resident for IBM PC compatibles' boards is not necessary since the Macintosh has most of its diagnostics in POST and automatically reports errors via the "Sad Mac" codes.

The similarity between the boot-up environment and the actual operating system should not be confused with being identical, however. Although the "Classic Mac OS" boot process is convoluted and largely undocumented, it is not more limited than an IBM PC compatible BIOS. Like a PC's master boot record, a ROM-based Mac reads and executes code from the first blocks ("boot blocks") of the disk partition selected as the boot device. The boot blocks then verify that a suitable rudimentary environment exists, and use it to load the System suitcase. A different operating system with a different file system can boot by simply using its own code in the boot blocks. [4] This system was not used for PowerPC Linux, however, because Open Firmware in New World ROM machines requires a bootloader within an HFS filesystem—a reason having nothing to do with the Toolbox or "old-fashioned" Macs in general. More narrowly, the Startup Disk control panel in the Classic Mac OS and later macOS only allows the user to select a mounted filesystem with very particular constraints.

Legacy

In Mac OS X, the Toolbox is not used at all, though the Classic Environment loads the Toolbox ROM file into its virtual machine. Much of the Toolbox was restructured and implemented as part of Apple's Carbon programming API, allowing programmers familiar with the Toolbox to port their program code more easily to Mac OS X.

See also

Related Research Articles

<span class="mw-page-title-main">ISO 9660</span> File system for CD-R and CD-ROM optical discs

ISO 9660 is a file system for optical disc media. The file system is an international standard available from the International Organization for Standardization (ISO). Since the specification is available for anybody to purchase, implementations have been written for many operating systems.

<span class="mw-page-title-main">Motorola 68000</span> Microprocessor

The Motorola 68000 is a 16/32-bit complex instruction set computer (CISC) microprocessor, introduced in 1979 by Motorola Semiconductor Products Sector.

<span class="mw-page-title-main">Booting</span> Process of starting a computer

In computing, booting is the process of starting a computer as initiated via hardware such as a button on the computer or by a software command. After it is switched on, a computer's central processing unit (CPU) has no software in its main memory, so some process must load software into memory before it can be executed. This may be done by hardware or firmware in the CPU, or by a separate processor in the computer system.

<span class="mw-page-title-main">Apple Lisa</span> Personal computer by Apple Inc.

Lisa is a desktop computer developed by Apple, released on January 19, 1983. It is generally considered the first mass-market personal computer operable through a graphical user interface (GUI). In 1983, a machine like the Lisa was still so expensive that it was primarily marketed to individual and small and medium-sized businesses as a groundbreaking new alternative to much bigger and more expensive mainframes or minicomputers such as from IBM, that either require additional, expensive consultancy from the supplier, hiring specially trained personnel, or at least, a much steeper learning curve to maintain and operate. Earlier GUI-controlled personal computers were not mass-marketed; for example, the Xerox Alto was manufactured only for Xerox and select partners through Xerox PARC from the early to mid-1970s.

In computer science, self-modifying code is code that alters its own instructions while it is executing – usually to reduce the instruction path length and improve performance or simply to reduce otherwise repetitively similar code, thus simplifying maintenance. The term is usually only applied to code where the self-modification is intentional, not in situations where code accidentally modifies itself due to an error such as a buffer overflow.

<span class="mw-page-title-main">Classic Mac OS memory management</span>

Historically, the classic Mac OS used a form of memory management that has fallen out of favor in modern systems. Criticism of this approach was one of the key areas addressed by the change to Mac OS X.

<span class="mw-page-title-main">MacsBug</span> Low-level debugger, originally for Motorola 68000

MacsBug is a low-level debugger for the classic Mac OS operating system. MacsBug is an acronym for Motorola Advanced Computer Systems Debugger, as opposed to Macintosh debugger. The original version was developed by Motorola as a general debugger for its 68000 systems. — it was ported to the Mac as a programmer's tool early in the project's development.

<span class="mw-page-title-main">Macintosh 512K</span> Revised version of the Macintosh 128K by Apple Computer

The Macintosh 512K is a personal computer that was designed, manufactured and sold by Apple Computer from September 1984 to April 1986. It is the first update to the original Macintosh 128K. It was virtually identical to the previous Macintosh, differing primarily in the amount of built-in random-access memory. The increased memory turned the Macintosh into a more business-capable computer and gained the ability to run more software. It is the earliest Macintosh model that can be used as an AppleShare server and, with a bridge Mac, communicate with modern devices.

New World ROM computers are Macintosh models that do not use a Macintosh Toolbox ROM on the logic board. Due to Mac OS X not requiring the availability of the Toolbox, this allowed ROM sizes to shrink dramatically, and facilitated the use of flash memory for system firmware instead of the now more expensive and less flexible Mask ROM that most previous Macs used. A facility for loading the Toolbox from the startup device was, however, made available, allowing the use of Mac OS 8 and Mac OS 9 on New World machines.

<span class="mw-page-title-main">Old World ROM</span>

Old World ROM computers are the Macintosh (Mac) models that use a Macintosh Toolbox read-only memory (ROM) chip, usually in a socket. All Macs prior to the iMac, the iBook, the Blue and White Power Mac G3 and the Bronze Keyboard (Lombard) PowerBook G3 use Old World ROM, while said models, as well as all subsequent models until the introduction of the Intel-based EFI Models, are New World ROM machines. In particular, the Beige Power Mac G3 and all other beige and platinum-colored Power Macs are Old World ROM machines. In common use, the "Old World" designation usually applies to the early generations of PCI-based "beige" Power Macs, but not the older Motorola 68000-based Macs; however, the Toolbox runs the same way on all three types of machines.

The National Semiconductor COP8 is an 8-bit CISC core microcontroller. COP8 is an enhancement to the earlier COP400 4-bit microcontroller family. COP8 main features are:

BIOS implementations provide interrupts that can be invoked by operating systems and application programs to use the facilities of the firmware on IBM PC compatible computers. Traditionally, BIOS calls are mainly used by DOS programs and some other software such as boot loaders. BIOS runs in the real address mode of the x86 CPU, so programs that call BIOS either must also run in real mode or must switch from protected mode to real mode before calling BIOS and then switching back again. For this reason, modern operating systems that use the CPU in Protected mode or Long mode generally do not use the BIOS interrupt calls to support system functions, although they use the BIOS interrupt calls to probe and initialize hardware during booting. Real mode has the 1MB memory limitation, modern boot loaders use the unreal mode or protected mode to access up to 4GB memory.

Apple Partition Map (APM) is a partition scheme used to define the low-level organization of data on disks formatted for use with 68k and PowerPC Macintosh computers. It was introduced with the Macintosh II.

The original Macintosh was a relatively simple machine, now of interest for its simplicity and for the fact that it was the first computer produced by Apple under the name Macintosh. The Macintosh used standard off-the-shelf components to the greatest extent possible, achieving a moderate price point by mixing complex LSI chips, readily customizable programmable array logic, and off-the-shelf components.

The Amiga computer can be used to emulate several other computer platforms, including legacy platforms such as the Commodore 64, and its contemporary rivals such as the IBM PC and the Macintosh.

MacWorks Plus was a complete implementation (port) of the Macintosh Plus 128K ROM on the Apple Lisa and Macintosh XL computer systems, and introduced in August 1988. It was developed for Sun Remarketing of Cache Valley, Utah, under license from Apple Inc., by a contract developer named Chuck Lukaszewski, who was responsible for versions up through 1.1(h), which supported up to Macintosh System 6.0.3. Dafax Processing Corp. with the assistance of Query Engineering, Inc. then further developed the environment to MacWorks Plus II, which continued Macintosh system support up to System 6.0.8 with the Basic version, and introduced a Pro version to extend support to the maximum possible for any 68000 processor: System 7.5.5. Prior to MacWorks Plus, the maximum system supported by its predecessor MacWorks XL was System 3.2.

<span class="mw-page-title-main">FutureBASIC</span>

FutureBasic is a free BASIC compiler for Apple Inc.'s Macintosh.

<span class="mw-page-title-main">BootX (Apple)</span> Boot loader developed by Apple Inc.

BootX is a software-based bootloader designed and developed by Apple Inc. for use on the company's Macintosh computer range. BootX is used to prepare the computer for use, by loading all required device drivers and then starting-up Mac OS X by booting the kernel on all PowerPC Macintoshes running the Mac OS X 10.2 operating system or later versions.

A master boot record (MBR) is a type of boot sector in the first few blocks of partitioned computer mass storage devices like fixed disks or removable drives intended for use with IBM PC-compatible systems and beyond. The concept of MBRs was publicly introduced in 1983 with PC DOS 2.0.

<span class="mw-page-title-main">Classic Mac OS</span> Original operating system of Apple Mac (1984–2001)

Mac OS is the series of operating systems developed for the Macintosh family of personal computers by Apple Computer, Inc. from 1984 to 2001, starting with System 1 and ending with Mac OS 9. The Macintosh operating system is credited with having popularized the graphical user interface concept. It was included with every Macintosh that was sold during the era in which it was developed, and many updates to the system software were done in conjunction with the introduction of new Macintosh systems.

References

  1. Apple Inc. (6 July 1996). "A-Line Instructions". Archived from the original on 2004-07-02. Alt URL
  2. Apple Inc. (6 July 1996). "About the Trap Manager". Archived from the original on 2004-07-02. Alt URL
  3. 1 2 Olson, James H. (4 September 1997). "Mac Alamanac II". Linux/m68k for Macintosh.
  4. Apple Inc. (6 July 1996). "Boot Blocks". Archived from the original on 2004-03-12. Alt URL