Sign in Join
Wiki copytemporary

PalmOS port: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11Currently, the PalmOS port is a retro, "just for fun" port of the compiler and runtime libraries, based on an earlier, incomplete effort from over a decade ago. The port was originally started by Mazen Neifer. Peter Vreman ported PalmOS API headers. m68k port and 3.1.x+ compiler support and maintenance by Károly Balogh. The PalmOS port is a crosscompiler-only target.
22
33## Status
44
55- The 3.1.x compiler has compiler support (very experimental) for PalmOS.
66- [[m68k]] CPU is supported, including syscall generation support. Only small code is supported at the moment.
77- [[ARM]] CPU is not yet supported
88- Base RTL units are buildable but functionality is minimal.
99- There's a **palmunits** package, basic functionality was tested successfully.
1010- Resource compilation is broken at the moment.
1111
1212## CPU Defaults
1313
1414The [[m68k]] PalmOS port defaults to 68000 CPU subarchitecture and no FPU. Note that by default, the PalmOS port doesn't include the RTL's SoftFPU. For floating point calculations, one can use the OS supplied floating point unit helper API, or recompile the RTL with the SoftFPU included, using argument **-CfSOFT**.
1515
1616## Identification
1717
1818To identify PalmOS exclusively during compile-time, use **{\$IFDEF PALMOS}**.
1919
2020## Calling conventions
2121
2222### Registers
2323
2424As a difference to the standard [[m68k|m68k register layout]], on PalmOS also **d2** and **a2** registers are used as scratch registers, and their contents are not preserved. This is dictated by the ABI used by the C compilers and the syscall convention of the platform. Additionally, register **a5** is used as a pointer to the global data. On PalmOS, register **a5** points to the end of the global data.
2525
2626### SysCalls
2727
2828It's not required to use inline assembly to do system calls. Any trap function can be defined the following way:
2929
3030``` pascal
3131function MemPtrNew(size: UInt32): MemPtr; syscall $A013;
3232```
3333
3434Note the syscall modifier in the function declaration. The argument to the syscall modifier is the trap number to call. The arguments to a syscall function are always passed on the stack and they're word (2 byte) aligned. Optionally, the numerical trap ID (here shown in hexadecimal) can be defined by a constant. For further examples, see the file *rtl/palmos/palmos.inc* in the RTL source or the **palmunits** package.
3535
3636## Building Tutorial
3737
3838The section below details building an m68k-palmos Free Pascal cross compiler. The ARM building process is the same with the different CPU name. Note that the ARM PalmOS support is non functional at the moment. The tutorial below uses PATHs tuned for Linux and macOS systems. The FPC directory structure on Windows can be slightly different to these.
3939
4040### Cross binutils
4141
4242The older version of GNU binutils included in [prc-tools](http://prc-tools.sourceforge.net) is difficult to build on modern systems, like macOS/Darwin 10.12+ or any 64-bit Linux. It is recommended to use the [prc-tools-remix](https://github.com/chainq/prc-tools-remix) repository instead. This supports both m68k and ARM prc tools, and it is fixed to build and work on current systems. It also provides up to date installation instructions, see there.
4343
4444From prc-tools, Free Pascal uses the followings:
4545
4646- as
4747- ld
4848- ar
4949- build-prc
5050
5151Make sure they're all on the path or in the specified tools directory, and they all share the same prefix, like **m68k-palmos-**.
5252
5353### Cross compiler
5454
5555PalmOS is a cross-compiler only target. The following steps can be used build a PalmOS cross-compiler:
5656
57571. Install the latest stable Free Pascal Compiler. This will be used as the startup compiler.
58582. Check out FPC SVN trunk into a directory.
59593. Make sure the cross-binutils are properly built, and its binaries are actually in the **PATH**.
60604. Go to the SVN trunk root directory and use the following command to build an m68k-palmos cross-compiler:
6161
6262``` bash
6363 make clean crossall crossinstall OS_TARGET=palmos CPU_TARGET=m68k CROSSOPT="-XX -CX" INSTALL_PREFIX="<path/to/install>"
6464```
6565
6666If everything went correctly, you should find a working PalmOS cross-compiler at the install path you specified.
6767
6868Now, lets create a default fpc.cfg for PalmOS cross compiling. Create a file called **\<path/to/install\>/lib/fpc/etc/fpc.cfg**. Put the following lines into that file, and fix up the paths:
6969
7070`#IFDEF CPUM68K`\
7171`-Fu<path/to/install>/lib/fpc/$fpcversion/units/$FPCTARGET`\
7272`-Fu<path/to/install>/lib/fpc/$fpcversion/units/$FPCTARGET/*`\
7373`#IFDEF PALMOS`\
7474`-FD</path/to/m68k-palmos-binutils>`\
7575`-XPm68k-palmos-`\
7676`-XX`\
7777`-CX`\
7878`#ENDIF`\
7979`#ENDIF`
8080
8181Note the **-CX** and **-XX** options used for both the build and the config file. They enable smartlinking by default.
8282
83-**<font color="red">Due to the size constraints PalmOS puts on the executables, and the limitations of the old prc-tools binutils, building and compiling without smartlinking is not supported.</font>**
83+**Due to the size constraints PalmOS puts on the executables, and the limitations of the old prc-tools binutils, building and compiling without smartlinking is not supported.**
8484
8585Optionally add **\<path/to/install\>/lib/fpc/3.1.1/** directory to the PATH, so you'll have direct access to the cross compiler. If you've done everything right, you now should be able to build PalmOS executables from a Pascal source the following way:
8686
8787`ppcross68k -Tpalmos <source.pas>`
8888
8989Copy the resulting **.prc** executable to your PalmOS device using HotSync or your preferred method.
9090
9191## Examples
9292
9393The *'palmunits* package contains a few examples, which are a good starting point. They should be directly buildable from the command line. They're all GUI applications. Console applications are not supported at this moment.
9494
9595## Running binaries
9696
9797### Emulator
9898
9999The old POSE Emulator of 68k-based Palm devices is Windows only, but works great with WINE on macOS and Linux. You will also need a set of Palm ROMs and skins for the emulator. These are available from various locations over the internet, preserving old Palm software and developer tools. Due to the uncertain nature of these redistributions, we cannot directly link these here, sadly.
100100
101-<figure>
102101<img src="fpc_cube_on_pose.png" title="FPC Cube! example program running on POSE" width="240" />
103-<figcaption>FPC Cube! example program running on POSE</figcaption>
104-</figure>
105102
106103### Real Device
107104
108105On Linux and macOS, the open source command line **pilot-link** was tested and works for uploading FPC generated binaries. **pilot-link** is still available from most distributions' package manager, [or in source from here](https://github.com/jichu4n/pilot-link). There are also various GUI front-ends for **pilot-link**, like [JPilot](http://jpilot.org).
109106
110107On Windows or macOS, the original Palm Desktop software should work as well.
111108
112109## Debugging PalmOS applications
113110
114111This section is not yet available
115112
116113## Links
117114
118115- [Buildfaq](http://www.stack.nl/~marcov/buildfaq.pdf) is a general FAQ about how to build and configure FPC.
119116
120117Various Palm related information sources
121118
122119- [PRC format](http://web.mit.edu/tytso/www/pilot/prc-format.html) describes the Palm executable and resource format
123120- [pilot-link howto](http://www.tldp.org/HOWTO/PalmOS-HOWTO/pilotlink.html) describes the usage of pilot-link and transferring files and data to/from the device
124121
125122Here are some links related to ARM CPU Architecture
126123
127124- [GCC ARM Improvement Project](http://www.inf.u-szeged.hu/gcc-arm/)
128125- [ARM ASSEMBLER](http://www.heyrick.co.uk/assembler/index.html) Good information and codes related to arm assembly language.
129126- [ARM Instruction Sets & Programs](http://soc.csie.ndhu.edu.tw/source/intro_embedded/ch2-arm-2.ppt) Very good and consice information about arm architecture
130127- [The ARM Instruction Set](http://web.njit.edu/~baltrush/arm_stuff/ARMInst.ppt) Another fine power point file about arm
131128
132129## Contacts
133130
134131Current maintainer: Károly Balogh
135132
136133Original author: [Mazen NEIFER](mailto:mazen@freepascal.org)
137134
138135---
139136*From the Free Pascal wiki, page "PalmOS port", as it stood on 2018-01-13 after a change by Chain-Q, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
140137Category: Palm OS and Garnet OS

Back to history