Linux for Macintosh 68K Port
The next stage in the operation was to figure out how to boot a Linux kernel image on the Macintosh. NetBSD and OpenBSD use a boot loader which loads a.out format executables into the memory of the Macintosh, shuts the Macintosh down, moves it to address 0 and jumps to it. I quickly decided I didn't want to write a boot loader. The OpenBSD loader was almost pure MacOS wizardry at a level far beyond my abilities. Not to worry—it soon became apparent that the OpenBSD loader could be persuaded to load Linux too. A true loader could wait.
The next problem was building a Linux kernel image that would link and (while most likely not doing anything useful) at least serve as something to feed the OpenBSD booter. Linux is built using the GNU tool chain, which supports the building of cross compilers. It is thus possible to compile and build 680x0 binaries on an ordinary Intel-based PC. It took a couple of builds to get gcc and the GNU binutils generating almost the right code. Linux a.out executables have a two-byte header different from the OpenBSD ones, and the OpenBSD boot loader checked those bytes. Rather than rebuild the entire tool chain again, I wrote a simple tool to fix the headers.
Most of Linux/M68K was quite content to build for a Macintosh target. I filled in everything that complained with dummy routines—for Mac keyboards, mice, display, etc. until it all compiled. Because of the well-designed abstraction layers in the Linux/M68K kernel, this was quite easy to do. I now had a completely useless, do-nothing, Macintosh kernel that the OpenBSD loader would load and which then promptly crashed the machine as I expected.
The Linux/M68K project had faced up to the challenges of supporting multiple types of 680x0-based computers within the same port, well before I got involved. As a result of the need to support both the Amiga and Atari systems, clear layers of abstractions are present. Adding an additional M68K target consists mostly of filling in platform-specific blank fields. A port to a completely new processor would have been far more challenging than this one.
For the Macintosh case, I filled in various, mostly blank function handlers. After finally getting the thing to link, I ended up with a kernel that was hard-coded for a 5MB 68020-based Macintosh with FPU and a display at 0xF9000000. It had no interrupt controllers, no disk controllers, no keyboard and no mouse. Anything else I could find was also hard coded. However, it linked and that was the important thing. Having done a bit of reading up on the innards of the console drivers (and much interrogation of Jes), I wrote a fairly simplistic back end for the generic console driver on the Macintosh. As it turned out, the very simplistic approach reflected the Macintosh hardware I had, which was a completely unaccelerated bitmapped display supporting 640x480 in 4-bit colour.
A Linux 68K kernel starts with a partially shared piece of initialisation code written in 680x0 assembler and using almost all the most Gothic and peculiar features of the architecture. This initialisation code also sets up the memory management and caching, and touches everything no one normally knows about. The 68020, 68851, 68881 combination of chips used in the Macintosh II is obsolete and Motorola didn't carry documentation on this device. I did know two things which, in theory, were enough to debug and figure out what was going on. First, I knew the base address of the screen memory; second, I knew the address that the code would begin executing. The very first routine I put in the startup code painted the screen a revolting blue colour. After about 15 boots and some staring at the source code, I had a Macintosh that booted to a blue screen, waited a short while, then crashed.
In many ways, this was the single hardest item to get going. When dealing with a completely unknown system environment with no idea what is around the code, debugging is extremely tricky. Real commercial hardware people use logic analysers—I didn't have that option. I learned several things in the process; notably, that Macintosh screen memory is not located where the hardware claims it is until the MMU is set up. I also made the amazing discovery that the rounded corners on the Macintosh display are drawn in software.
Over the next few weeks, the Macintosh went through an assortment of debugging stripes and coloured patterns as I inched a few lines at a time through the initialisation assembler code, fixing it bit by bit and gradually mapping in the needed hardware. Eventually, the kernel hit the magic start_kernel function in the C code without crashing on the way.
Practical Task Scheduling Deployment
July 20, 2016 12:00 pm CDT
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.Register Now!
- SUSE LLC's SUSE Manager
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- My +1 Sword of Productivity
- Non-Linux FOSS: Caffeine!
- Managing Linux Using Puppet
- Doing for User Space What We Did for Kernel Space
- SuperTuxKart 0.9.2 Released
- Parsing an RSS News Feed with a Bash Script
- Google's SwiftShader Released
- Rogue Wave Software's Zend Server
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide