Friday, November 27, 2009

on GfxLib and alpha-blending

GfxLib has seen some new code added to it. This is the general graphics library for the OS, providing basic drawing (like lines and rectangles), as well as advanced drawing (alpha-blended images). The alpha-blending code exists in multiple versions ,to take advantage of different processors. The "generic C" version can pull off 15 frames per second on alpha-blending a fullscreen image on 324x484 resolution. This version will run on any ARM processor ever used in Palm devices. The "fast" version requires a ARMv5 processor (like one in iQue, Zodiac) and can pull off 21 frames per second on the same fullscreen alpha-blended image. The "WMMX" version requires an XScale CPU (like one in LifeDrive, TX) and uses Intel's WMMX (their MMX for mobile) and is twice as fast as the "genereic C" version, managing a whopping 30 frames per second on fullscreen alpha-blending test.

These FPS numbers may seem low, but remember that (1) it is rare to redraw the fullscreen, generally only the changed area needs redrawing, (2) these might become faster as I optimize them more (3) comparing to more modern hardware is pointless, since almost all modern hardware has graphics acceleration chips and PalmOS devices do not (with the exception of the Zodiac, but I am not supporting it anyways for now)

For the technically curious: C version processes one pixel at a time. ARMv5 version processes two pixels at a time, using the "Enhanced DSP instructions" that this architecture provides (SMUL<x><y> and SMLA<x><y>) to do the parallel multiplication. The WMMX version processes four pixels at a time and makes heavy use of WMMX instructions (TBCST, WLDR, WSTR, WUNPACKEL, WSUB, WAND, WOR, WSLL, WSLR, WMUL, WMAC) to do parallel processing of al four pixels.

Also a rather large (9%) speedup was attained by strategically placed "PLD" instructions, that instruct the D-cache to pre-load data into the cache.

Sunday, November 22, 2009

PalmOS-based loader

PalmOS-based loader has been rewritten and now is finished. It loads DGOS as if it was just another PalmOS app. You tap it, it evicts PalmOS from ram and loads the DGOS kernel in under a second. It even has a [somewhat] cute icon:

Tuesday, November 17, 2009


Here is a simple kernel module, demonstrating how easy it is to write and build one.


#include <kernel.h>
#include <errors.h>
#include <timers.h>
#include <usrProcess.h>

Err kmod_main(UInt32 reason, void* data){

UInt64 time = timersGetTicks64();

if (reason == K_MOD_LOADED){

charsPrintF("Module loaded at 0x%08lx\n", time);
else if(reason == K_MOD_UNLOADED){

charsPrintF("Module unloaded at 0x%08lx\n", time);

charsPrintF("Module called with unknown command (0x%x,0x%08x)\n", reason, data);

return errNone;


LIBNAME = kmod.kmod
CC = arm-linux-elf-gcc
FLAGS = -O4 -fpic -fshort-wchar -mthumb-interwork
DLIBS = ../KernelLib/KernelLib.lib
CCFLAGS = $(FLAGS) -I../Src/public -I../Src
LDFLAGS = $(FLAGS) -nostartfiles -nodefaultlibs -nostdlib $(DLIBS) $(SLIBS) \
-Wl,-shared -Wl,-soname,$(LIBNAME)

kmod.kmod: kmod.o
$(CC) kmod.o -o kmod.kmod $(LDFLAGS) -e kmod_main

kmod.o: kmod.c
$(CC) $(CCFLAGS) -o kmod.o -c kmod.c

rm -rf *.o kmod.kmod

Monday, November 16, 2009

funny code fragments

Err elfUnload(Process* p, void* base){

if(p == taskGetKernelProcess()) {

Panic("ELF unload in kernel not implemented. why are you trying it anyways?");

Thursday, November 12, 2009


Wifi chipset in lifedrive and tx is not documented. i do not plan to reverse engineeer it. I plan to run the palmos driver in a palmos container layer, and use it to talk to the wifi chip. palmos supports one raw socket per interface, thus giving me all the network access i need, and the DGOS networking stack can then use that interface to talk to the wifi chip directly.