root / prex-0.9.0 / include / sys / ioctl.h @ 03e9c04a
History | View | Annotate | Download (3.98 KB)
1 |
/*
|
---|---|
2 |
* Copyright (c) 2005-2008, Kohsuke Ohtani
|
3 |
* All rights reserved.
|
4 |
*
|
5 |
* Redistribution and use in source and binary forms, with or without
|
6 |
* modification, are permitted provided that the following conditions
|
7 |
* are met:
|
8 |
* 1. Redistributions of source code must retain the above copyright
|
9 |
* notice, this list of conditions and the following disclaimer.
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright
|
11 |
* notice, this list of conditions and the following disclaimer in the
|
12 |
* documentation and/or other materials provided with the distribution.
|
13 |
* 3. Neither the name of the author nor the names of any co-contibutors
|
14 |
* may be used to endorse or promote products derived from this software
|
15 |
* without specific prior written permission.
|
16 |
*
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
27 |
* SUCH DAMAGE.
|
28 |
*/
|
29 |
|
30 |
#ifndef _SYS_IOCTL_H_
|
31 |
#define _SYS_IOCTL_H_
|
32 |
|
33 |
#include <sys/cdefs.h> |
34 |
#include <sys/time.h> |
35 |
#include <sys/power.h> |
36 |
|
37 |
/*
|
38 |
* Ioctl's have the command encoded in the lower word, and the size of
|
39 |
* any in or out parameters in the upper word. The high 3 bits of the
|
40 |
* upper word are used to encode the in/out status of the parameter.
|
41 |
*/
|
42 |
#define IOCPARM_MASK 0xff /* parameter length, at most 13 bits */ |
43 |
#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK) |
44 |
#define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << 16)) |
45 |
#define IOCGROUP(x) (((x) >> 8) & 0xff) |
46 |
|
47 |
#define IOCPARM_MAX 256 |
48 |
|
49 |
#define IOC_VOID 0x20000000 /* no parameters */ |
50 |
#define IOC_OUT 0x40000000 /* copy out parameters */ |
51 |
#define IOC_IN 0x80000000U /* copy in parameters */ |
52 |
#define IOC_INOUT (IOC_IN|IOC_OUT)
|
53 |
#define IOC_DIRMASK 0xe0000000 |
54 |
|
55 |
/* Prex */
|
56 |
#define IOC_IVAL 0x10000000 /* input argument is immediate value */ |
57 |
#define IOC_OVAL 0x08000000 /* return value as output */ |
58 |
|
59 |
#define _IOC(inout,group,num,len) \
|
60 |
(u_long)(inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)) |
61 |
#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0) |
62 |
#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t)) |
63 |
#define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t)) |
64 |
/* this should be _IORW, but stdio got there first */
|
65 |
#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t)) |
66 |
|
67 |
#define _IORN(g,n,t) _IOC((IOC_OVAL|IOC_OUT), (g), (n), sizeof(t)) |
68 |
#define _IOWN(g,n,t) _IOC((IOC_IVAL|IOC_IN), (g), (n), sizeof(t)) |
69 |
|
70 |
|
71 |
/*
|
72 |
* CPU frequency I/O control code
|
73 |
*/
|
74 |
#define CFIOC_GET_INFO _IOR('6', 0, struct cpufreqinfo) |
75 |
|
76 |
/*
|
77 |
* CPU frequency information
|
78 |
*/
|
79 |
struct cpufreqinfo {
|
80 |
int maxfreq; /* max speed in MHz */ |
81 |
int maxvolts; /* max power in mV */ |
82 |
int freq; /* current speed in MHz */ |
83 |
int volts; /* current power in mV */ |
84 |
}; |
85 |
|
86 |
/*
|
87 |
* Power management I/O control code
|
88 |
*/
|
89 |
#define PMIOC_CONNECT _IOW('P', 0, int) |
90 |
#define PMIOC_QUERY_EVENT _IOW('P', 1, int) |
91 |
#define PMIOC_SET_POWER _IOW('P', 2, int) |
92 |
#define PMIOC_GET_SUSTMR _IOR('P', 3, int) |
93 |
#define PMIOC_SET_SUSTMR _IOW('P', 4, int) |
94 |
#define PMIOC_GET_DIMTMR _IOR('P', 5, int) |
95 |
#define PMIOC_SET_DIMTMR _IOW('P', 6, int) |
96 |
#define PMIOC_GET_POLICY _IOR('P', 7, int) |
97 |
#define PMIOC_SET_POLICY _IOW('P', 8, int) |
98 |
|
99 |
/*
|
100 |
* RTC I/O control code
|
101 |
*/
|
102 |
#define RTCIOC_GET_TIME _IOR('R', 0, struct __timeval) |
103 |
#define RTCIOC_SET_TIME _IOW('R', 1, struct __timeval) |
104 |
|
105 |
struct __timeval {
|
106 |
long tv_sec; /* seconds */ |
107 |
long tv_usec; /* and microseconds */ |
108 |
}; |
109 |
|
110 |
__BEGIN_DECLS |
111 |
int ioctl(int, unsigned long, ...); |
112 |
__END_DECLS |
113 |
|
114 |
#endif /* !_SYS_IOCTL_H_ */ |