openbsd-ports
[Top] [All Lists]

Re: The Right Way... ?

To: Ian Darwin <ian@daroad.darwinsys.com>
Subject: Re: The Right Way... ?
From: "J.C. Roberts" <unknown@abac.com>
Date: Thu, 16 Aug 2001 02:37:42 -0700
Cc: ports@openbsd.org
In-reply-to: <20010814190802.A29629@daroad.darwinsys.com>
Organization: None
References: <51iinto5hdrr7a2njbc3t5p1v79hpneesq@4ax.com> <20010814190802.A29629@daroad.darwinsys.com>
Reply-to: unknown@abac.com
Sender: owner-ports@openbsd.org
On Tue, 14 Aug 2001 19:08:02 -0400, you wrote:

>I think I can make it work without those files, using the apm device
>directly.
>
>I am writing my own "kapm" (as an exercise in learning KDE programming)
>and think I can make it work with just apm_vars.h which is in /usr/include.
>
>I'll let you know in a few days; right now I'm wresting with C++ (having
>been a C and Java junkie for years, there are always nits and obstacles
>when moving among similar languages).
>
>Ian

I'll bet you make something better than klaptopdaemon and all my
porting effort will be for not. ;-) 

Most of the stuff you'll to make a great "kapm" seems to be in
apmvars.h  apm-proto.h and apm.c

The main problem I'm having is figuring out how to use ioctl and the
right way to talk to apmd. For example, at the end of apmvar.h we have
a couple useful defines like

#define APM_IOC_REJECT _IOW('A', 0, struct apm_event_info)
#define APM_IOC_STANDBY _IO('A', 1)
#define APM_IOC_SUSPEND _IO('A', 2)
#define APM_IOC_GETPOWER _IOR('A', 3, struct apm_power_info)
...

I'm yet to figure out what the 0, 1, 2 and 3 (to 6) arguments really
do but these defines seem to use ioccom.h to create the "request" part
of an ioctl call. You'll notice these correspond to the apm_action
enum in apm-proto.h

What I need to be able to get is APM_GET_CAPABILITIES so I test to see
what are the available capabilities of the system and either
APM_PWR_MGT_ENABLE or APM_MGT_ENGAGE (not sure which) to test if apm
is available and working.

What I'd like to do is create an amp_status structure like:

struct apm_able_info {
        u_int apm_status        /* whether or not APM is working */
                                /* 0 = disabled, 1 = enabled */
        u_int apm_abilities     /* int holding APM_GET_CAPIBILITIES */
};

and a corresponding define like the ones in apmvar.h

#define APM_IOC_GETABLE _IOR('A', 7, struct amp_able_info)

Since I don't know what or where the 0-6 are, I've got no way to
understand how to code my #7... Someplace there has got to be an enum
or something with 0-6 that ioctl reads

I only need to read the info so a direct call to /dev/apm (read only)
would be alright if I can't figure out how to get the apmd daemon to
do it through a socket call. If you know how to code this (either way
or preferably both) a couple lines of sample code would do me a world
of good.

Thanks,

JCR


<Prev in Thread] Current Thread [Next in Thread>