Chapter 1: The Palm OS Mental Model and Architecture

This is an LLM ass-isted document, as are all in the ass/ subdirectory.
Of these, here in the dump/ subdirectory I keep the sloppy & doubtful ones.
I keep these as learning materials for myself, yet to be went thru.

Return to index

1. The Machine in Your Hand

To write reliable software for Palm OS, you must abandon modern operating system assumptions: there is no virtual memory, no memory protection unit (MPU/MMU), no multi-threaded preemptive scheduler, no files in a POSIX filesystem tree, and no gigabytes of swap space.

Instead, a classic Palm device is a lean, battery-conserving appliance designed around instant-on operation and 160x160 pixel resistive touchscreen interaction.

1.1. Motorola 68000 & DragonBall Architecture

Classic Palm devices run on the Freescale/Motorola DragonBall family of microcontrollers, built around a Motorola 68EC000 core:

Device Family Processor Clock Speed Architecture RAM / Flash Typical OS
PalmPilot Pro MC68328 16 MHz 68EC000 1 MB / 512K 2.0
Palm III / V MC68328 16 MHz 68EC000 2-8 MB 3.0 - 3.5
Palm m100 MC68VZ328 20 MHz 68EC000 2 MB 3.5
Palm IIIc MC68VZ328 33 MHz 68EC000 8 MB (Color) 3.5
Palm m515 MC68VZ328 33 MHz 68EC000 16 MB (Color) 4.1
Tungsten T OMAP 1510 144 MHz ARM925T 16 MB 5.0 (PACE)

The 68EC000 CPU features:

  • 32-bit internal registers (8 data registers d0-d7, 8 address registers a0-a7).
  • 24-bit external address bus (addressing up to 16 MB of physical memory).
  • Big-endian byte order: the high byte is stored at the lowest memory address. Word and long-word access must be aligned to even addresses, or an Address Error (bus exception) crashes the system!

1.2. The Palm OS Memory Architecture: Dynamic Heap vs. Storage Heap

RAM on a Palm OS device is partitioned into two distinct physical cards or heaps:

  1. Dynamic Heap (RAM in the Unix sense):
    • Used for the operating system state, active application stack, global variables, and dynamic allocations (MemPtrNew).
    • Extremely constrained! On Palm OS 1.0-2.0, it was only 32 KB. On Palm OS 3.0-4.x, it ranges between 96 KB and 256 KB (rarely up to 512 KB on OS 4.1 devices like the m515).
    • Any allocation from the Dynamic Heap is cleared on soft reset.
  2. Storage Heap (Filesystem / Disk in the Unix sense):
    • All databases, application files, memo records, and calendar entries live here.
    • Non-volatile: battery-backed static RAM preserves the Storage Heap continuously even when the screen is powered down.
    • You do not read or write files using byte-stream file descriptors (open/read/write). Instead, you access records directly in RAM via the Data Manager.

1.3. The A5 World and Small-Data Model

The 68000 architecture uses address register a5 as a base pointer to locate an application's global variables and jump tables. This is known as the A5 World:

  • Offsets from a5 use 16-bit signed displacements, restricting total global data (and single code sections) to ±32 KB.
  • When an application launches in normal mode (sysAppLaunchCmdNormalLaunch), the OS sets up a5.
  • If your application is invoked by an action code (like a system alarm or search query) without a full launch, a5 is not initialized! Accessing global variables in that state crashes immediately.
  • Modern C++ programming on Palm OS eliminates global variables in favor of stack allocations or explicit context pointers.

1.4. The PRC Container File Format

A Palm executable is not an ELF or PE binary. It is a Palm Resource Database file with the extension .prc:

  • Database Header: Contains the 32-character application database name, flags, version, creation/modification dates, type ('appl' for applications, 'libr' for shared libraries), and a 4-character Creator ID (e.g., 'GP14').
  • Resource List: A directory of resource entries. Each entry specifies a 4-byte Resource Type (e.g., 'code', 'data', 'tFRM', 'tAbt'), a 2-byte Resource ID, and an offset into the file.
  • code #1: The primary executable code resource containing PilotMain.
  • data #0: Initialized global data.
  • rloc #0: Relocation fixups generated by the linker.

1.5. System Call Dispatch: Trap #15

How does application code invoke the hundreds of operating system APIs without a dynamic linker like ld.so?

Palm OS uses the 68000's hardware software-interrupt instruction: trap #15. Each system function has a unique 16-bit trap vector number (e.g., sysTrapMemPtrNew = 0xA013, sysTrapFrmAlert = 0xA188, sysTrapEvtGetEvent = 0xA006).

To call a function:

  1. Arguments are pushed onto the 68000 stack in Pascal/C calling order.
  2. The trap number (or inline trap word) is dispatched via trap #15.
  3. The Palm OS trap dispatcher intercepts the exception, locates the API in ROM via a system jump table, executes it, and returns results in register d0.

2. Further Reading & Reference Resources