Hi all,

I wrote a (ugly) enhancement to the plan9 kernel that allows users using workstations

To press ^P and power off the machine, this is especially useful on (old) notebooks

That has a broken power switch…

 

I have added too some extra feature ^T^T 5 will turn off the screen

^T^T 6 will put it into a ready state

^T^T f confirms apm is present in the kernel

^T^T g is equivalent to ^P on workstations

There was too an options to poweroff disks, but it may hang the whole system…

 

Normally aux/apm disallows you to power off because you won’t be able to sync the fs

And if you halt the fs you won’t be able to power off using aux/apm … ;)

(Of course if you uncomment those two lines that allows suspending  the sys in the aux/apm code)

What is the solutions to this ? Place the power off sequence in the kernel as a key shortcut

We will use ^P because using it will power off workstations and reboot cpu’s , a nice behavior

(since we won’t need to power off cpu server)

 

VERY IMPORTANT !!! This thing won’t work if aux/apm isn’t working in the background…

                                  And if boot.ini don’t have the apm0= line added…

 

 

So how to install the code?

Copy the attached lib.h to /sys/src/9/port/lib.h

The devcons.c to /sys/src/9/port/devcons.c

The apm.c to /sys/src/9/pc/apm.c

And recompile the kernel and then install it…

 

This is a *extremely* dirty (and ugly) hack, don’t blame me for it please.

 

If you ever want to add some shorcuts for other devices (like net cards)

Then you’ll have to know that the poweroff_call functions

Takes too argument

-          Which device

-          What to do with it

 

So as an example poweroff_call(ALL_DEVICES,POWEROFF);

Will effectively power off all devices

The defines for the Devices are self explanatory:

#define BIOS          0x00

#define ALL_DEVICES   0x01

#define DISPLAY       0x1ff

#define SEC_STORAGE   0x2ff

#define PARALE_PORT   0x3ff

#define SERIAL_PORT   0x4ff

#define NET_ADAPTER   0x5ff

#define PCMCIA        0x6ff

#define BATTERY       0x80ff

Consider BIOS equivalent to ALL_DEVICES

The same for the action taken:

#define POWEROFF      0x03

#define SLEEP_DEEP    0x02

#define SLEEP_LIGHT   0x01

#define READY         0x00

 

Anyway HAVE FUN,

Maks

 

P.S: If you got some troubles just mail me

           I’m planning too to clean that stuff one of those days…