r3 release
[warm.git] / warm.h
CommitLineData
198a1649 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
87956811 66int warm_mmap_section(void *virt_addr, unsigned long phys_addr,
67 unsigned long size, int cb);
68int warm_munmap_section(void *virt_addr, unsigned long size);
69
198a1649 70void warm_finish(void);
71
72#ifdef __cplusplus
73}
74#endif
75
76/* internal */
77#ifdef WARM_CODE
78
79#include <linux/ioctl.h>
80
81#define WARM_IOCTL_BASE 'A'
82
83struct warm_cache_op
84{
85 unsigned long addr;
86 unsigned long size;
87 int ops;
88};
89
90struct warm_change_cb
91{
92 unsigned long addr;
93 unsigned long size;
94 int cb;
bee2f7fb 95 int is_set; /* set (1) or clear (0) */
198a1649 96};
97
87956811 98struct warm_map_op
99{
100 unsigned long virt_addr;
101 unsigned long phys_addr;
102 unsigned long size;
103 int cb;
104 int is_unmap;
105};
106
198a1649 107#define WARMC_CACHE_OP _IOW(WARM_IOCTL_BASE, 0, struct warm_cache_op)
108#define WARMC_CHANGE_CB _IOW(WARM_IOCTL_BASE, 1, struct warm_change_cb)
109#define WARMC_VIRT2PHYS _IOWR(WARM_IOCTL_BASE, 2, unsigned long)
87956811 110#define WARMC_MMAP _IOW(WARM_IOCTL_BASE, 3, struct warm_map_op)
198a1649 111
112#endif /* WARM_CODE */
113#endif /* !__ASSEMBLER__ */
114#endif /* __WARM_H__ */