summaryrefslogtreecommitdiff
path: root/include/linux/wmt-mb.h
blob: 8c1a48d717c025ee43bce01c70b2db3b9324696d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*++
 * WonderMedia Memory Block driver
 *
 * Copyright c 2010  WonderMedia  Technologies, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * WonderMedia Technologies, Inc.
 * 10F, 529, Chung-Cheng Road, Hsin-Tien, Taipei 231, R.O.C
--*/
#ifndef MEMBLOCK_H
#define MEMBLOCK_H

#include <linux/types.h>

struct prdt_struct{
    unsigned int addr;
    unsigned short size;
    unsigned short reserve : 15;
    unsigned short EDT : 1;
}__attribute__((packed)) ;

struct mmu_table_info{
    unsigned int addr;
    unsigned int size;
    unsigned int offset;
}__attribute__((packed)) ;

// 1 presents the task init that would never be released
#define MB_DEF_TGID				0

#ifdef CONFIG_WMT_MB_RESERVE_FROM_IO
#define mb_virt_to_phys(v)    mb_do_virt_to_phys(v,MB_DEF_TGID,THE_MB_USER)
#define mb_phys_to_virt(p)    mb_do_phys_to_virt(p,MB_DEF_TGID,THE_MB_USER)
#else
#define mb_virt_to_phys(v)    virt_to_phys(v)
#define mb_phys_to_virt(p)    phys_to_virt(p)
#endif
#define mb_user_to_virt(u)    mb_do_user_to_virt(u,MB_DEF_TGID,THE_MB_USER)
#define mb_user_to_phys(u)    mb_do_user_to_phys(u,MB_DEF_TGID,THE_MB_USER)
/* all addresses are physical */
#define mb_alloc(s)           mb_do_alloc(s,MB_DEF_TGID,THE_MB_USER)
#define mb_free(p)            mb_do_free(p,MB_DEF_TGID,THE_MB_USER)
#define mb_get(p)             mb_do_get(p,MB_DEF_TGID,THE_MB_USER)
#define mb_put(p)             mb_do_put(p,MB_DEF_TGID,THE_MB_USER)
#define mb_counter(p)         mb_do_counter(p,THE_MB_USER)

void *mb_do_phys_to_virt(unsigned long phys, pid_t, char *);
unsigned long mb_do_virt_to_phys(void *virt, pid_t, char *);
unsigned long mb_do_user_to_virt(unsigned long, pid_t, char *);
unsigned long mb_do_user_to_phys(unsigned long, pid_t, char *);
unsigned long mb_do_alloc(unsigned long, pid_t, char *);
int mb_do_free(unsigned long, pid_t, char *);
int mb_do_get(unsigned long, pid_t, char *);
int mb_do_put(unsigned long, pid_t, char *);
int mb_do_counter(unsigned long, char *);

int user_to_prdt(
    unsigned long user,
    unsigned int size,
    struct prdt_struct *next,
    unsigned int items);

unsigned int wmt_mmu_table_size(unsigned int size);
void wmt_mmu_table_dump(struct mmu_table_info *info);
// To fix framebuffer build issue
#if 0
int wmt_mmu_table_check(
    unsigned int mmuPhys,
    unsigned int mmuSize,
    unsigned int size);
unsigned int wmt_mmu_table_from_phys(
    unsigned int mmuPhys,
    unsigned int mmuSize,
    unsigned int addr,
    unsigned int size);
unsigned int wmt_mmu_table_from_user(
    unsigned int mmuPhys,
    unsigned int mmuSize,
    unsigned int user,
    unsigned int size);
#endif
unsigned int wmt_mmu_table_create(
    unsigned int addr,
    unsigned int size,
    unsigned int addrType,
    struct mmu_table_info *info);
unsigned int wmt_mmu_table_destroy(struct mmu_table_info *info);

#endif