Subject: power management
To: None <port-hpcarm@NetBSD.org>
From: Lorant Toth <LorantToth@gmx.net>
List: port-hpcarm
Date: 10/26/2004 14:02:56
hi,

on another note.

I've been thinking on how to get around the Jornadas ROM limitation in 
conjunction with WinCE and PM. AFAIK there's no way to implement proper 
PM for now b/c if the CPU is suspended it will transfer control to WinCE 
after being powered on again, that in turn will erase the system and 
video memory and display the welcome dialog. Currently I usually shut 
down the system to WinCE power it off, hit Win+E, and boot the kernel 
again from the Explorer right away...

This takes quite some time, especially the bootup and initialization 
process. Naive and unknowing as I am I would like to propose a simple 
suspend to disk scheme for PM to get a few suggestions from more 
experienced ppl on this. This would be a hack but afaik there seems to 
be no better except for a flashboard replacement.

My idea would be to do about the same thing as with booting, to abuse 
Wince as a big loader, but to skip the bootup process by saving memory 
and video and registers to disk. that simple?

To suspend I'd suggest to do the following:
* dump the whole memory including kernel and video-mem (and possibly 
registers and mmapped io-ports?) to a WinCE-readable CF-card. The 720 
has 32 MB of RAM so a 64MB CF card should suffice, quite cheap these 
days. Or dump to the hpcboot partition on the "boot" CF/MicroDrive.
* suspend the CPU and devices, screen, ...

To power up again:
* create a modified hpcboot that runs under Wince and will specifically 
look for a memory dump file, to restore everything and jump to the last 
routine before suspend - if the state was correctly saved this could 
work... afaik WinCE looks for certain named directories on storage cards 
and autoruns files in those - hpcboot could reside there.

I am not sure what WinCE does besides erasing RAM when booting, if it 
would not change too much or if everything could be restored to the 
original state, this might work. Generally the system should be in a 
safe state before suspend I assume (i.e. hard disk heads parked, pcmcia 
devices suspended and so on) so that most devices would need 
reinitialization even it were for a normal suspend and thus WinCE should 
not interfere with this? Therefore we could just pop Wince in between as 
a loader and just pretend nothing happened? On a PC the BIOS would do 
the save to disk part, not the kernel or a module I assume.

This is just a suggestion and I am new to NetBSD, I've never done any 
*nix kernel hacking and probably have no clue what I talk about:)
I don't know how difficult it is to save the current system state to 
disk - but a kernel module or driver should be able to access and store 
all phys mem to dump, as well as registers and video mem I presume.

Personally I think that working PM is the last piece to make the Jornada 
7xx a really usable portable machine... sorry if this post is useless.

just my 0.02$...
-Lorant