bugfix
[picodrive.git] / platform / gp2x / warm.h
CommitLineData
0d9bf4fc 1/*
2 * wARM - exporting ARM processor specific privileged services to userspace
3 * library functions
4 *
5 * Copyright (c) GraÅžvydas "notaz" Ignotas, 2009
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the organization nor the
15 * names of its contributors may be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29#ifndef __WARM_H__
30#define __WARM_H__ 1
31
32/* cache operations (warm_cache_op_*):
33 * o clean - write dirty data to memory, but also leave in cache.
34 * o invalidate - throw away everything in cache, losing dirty data.
35 *
36 * Write buffer is always drained, no ops will only drain WB
37 */
38#define WOP_D_CLEAN (1 << 0)
39#define WOP_D_INVALIDATE (1 << 1)
40#define WOP_I_INVALIDATE (1 << 2)
41
42/* change C and B bits (warm_change_cb_*)
43 * if is_set in not zero, bits are set, else cleared.
44 * the address for range function is virtual address.
45 */
46#define WCB_C_BIT (1 << 0)
47#define WCB_B_BIT (1 << 1)
48
49#ifndef __ASSEMBLER__
50
51#ifdef __cplusplus
52extern "C"
53{
54#endif
55
56int warm_init(void);
57
58int warm_cache_op_range(int ops, void *virt_addr, unsigned long size);
59int warm_cache_op_all(int ops);
60
61int warm_change_cb_upper(int cb, int is_set);
62int warm_change_cb_range(int cb, int is_set, void *virt_addr, unsigned long size);
63
64unsigned long warm_virt2phys(const void *ptr);
65
66void warm_finish(void);
67
68#ifdef __cplusplus
69}
70#endif
71
72/* internal */
73#ifdef WARM_CODE
74
75#include <linux/ioctl.h>
76
77#define WARM_IOCTL_BASE 'A'
78
79struct warm_cache_op
80{
81 unsigned long addr;
82 unsigned long size;
83 int ops;
84};
85
86struct warm_change_cb
87{
88 unsigned long addr;
89 unsigned long size;
90 int cb;
91 int is_set;
92};
93
94#define WARMC_CACHE_OP _IOW(WARM_IOCTL_BASE, 0, struct warm_cache_op)
95#define WARMC_CHANGE_CB _IOW(WARM_IOCTL_BASE, 1, struct warm_change_cb)
96#define WARMC_VIRT2PHYS _IOWR(WARM_IOCTL_BASE, 2, unsigned long)
97
98#endif /* WARM_CODE */
99#endif /* !__ASSEMBLER__ */
100#endif /* __WARM_H__ */