• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 Amlogic Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef IONMEM_H
18 #define IONMEM_H
19 #include <ion/ion.h>
20 #if defined (__cplusplus)
21 extern "C" {
22 #endif
23 
24 #define ION_IOC_MESON_PHYS_ADDR 8
25 
26 
27 struct meson_phys_data{
28     int handle;
29     unsigned int phys_addr;
30     unsigned int size;
31 };
32 
33 typedef struct IONMEM_AllocParams {
34     int                 mIonHnd;
35     size_t              size;
36     unsigned char       *vaddr;
37     size_t              map_len;
38 } IONMEM_AllocParams;
39 
40 
41 #define ION_IOC_MAGIC       'I'
42 
43 #define ION_IOC_CUSTOM      _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data)
44 
45 #ifdef __DEBUG
46 #define __D(fmt, args...) fprintf(stderr, "CMEM Debug: " fmt, ## args)
47 #else
48 #define __D(fmt, args...)
49 #endif
50 
51 #define __E(fmt, args...) fprintf(stderr, "CMEM Error: " fmt, ## args)
52 
53 
54 int CMEM_init(void);
55 unsigned long CMEM_alloc(size_t size, IONMEM_AllocParams *params);
56 int CMEM_getPhyPtr(IONMEM_AllocParams *params, unsigned long *PhyAdrr);
57 /*void* CMEM_getUsrPtr(unsigned long PhyAdr, int size);*/
58 int CMEM_free(IONMEM_AllocParams *params);
59 int CMEM_exit(void);
60 
61 #if defined (__cplusplus)
62 }
63 #endif
64 
65 #endif
66 
67