GNU Linux-libre 4.14.332-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / css_2401_csi2p_system / hrt / var.h
1 #ifndef ISP2401
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  */
15
16 #ifndef _HRT_VAR_H
17 #define _HRT_VAR_H
18
19 #include "version.h"
20 #include "system_api.h"
21 #include "hive_types.h"
22
23 #define hrt_int_type_of_char   char
24 #define hrt_int_type_of_uchar  unsigned char
25 #define hrt_int_type_of_short  short
26 #define hrt_int_type_of_ushort unsigned short
27 #define hrt_int_type_of_int    int
28 #define hrt_int_type_of_uint   unsigned int
29 #define hrt_int_type_of_long   long
30 #define hrt_int_type_of_ulong  unsigned long
31 #define hrt_int_type_of_ptr    unsigned int
32
33 #define hrt_host_type_of_char   char
34 #define hrt_host_type_of_uchar  unsigned char
35 #define hrt_host_type_of_short  short
36 #define hrt_host_type_of_ushort unsigned short
37 #define hrt_host_type_of_int    int
38 #define hrt_host_type_of_uint   unsigned int
39 #define hrt_host_type_of_long   long
40 #define hrt_host_type_of_ulong  unsigned long
41 #define hrt_host_type_of_ptr    void*
42
43 #define HRT_TYPE_BYTES(cell, type) (HRT_TYPE_BITS(cell, type)/8)
44 #define HRT_HOST_TYPE(cell_type)   HRTCAT(hrt_host_type_of_, cell_type)
45 #define HRT_INT_TYPE(type)         HRTCAT(hrt_int_type_of_, type)
46
47 #ifdef C_RUN
48
49 #ifdef C_RUN_DYNAMIC_LINK_PROGRAMS
50 extern void *csim_processor_get_crun_symbol(hive_proc_id p, const char *sym);
51 #define _hrt_cell_get_crun_symbol(cell,sym)          csim_processor_get_crun_symbol(cell,HRTSTR(sym))
52 #define _hrt_cell_get_crun_indexed_symbol(cell,sym)  csim_processor_get_crun_symbol(cell,HRTSTR(sym))
53 #else
54 #define _hrt_cell_get_crun_symbol(cell,sym)         (&sym)
55 #define _hrt_cell_get_crun_indexed_symbol(cell,sym) (sym)
56 #endif //  C_RUN_DYNAMIC_LINK_PROGRAMS
57
58 #define hrt_scalar_store(cell, type, var, data) \
59         ((*(HRT_HOST_TYPE(type)*)_hrt_cell_get_crun_symbol(cell,var)) = (data))
60 #define hrt_scalar_load(cell, type, var) \
61         ((*(HRT_HOST_TYPE(type)*)_hrt_cell_get_crun_symbol(cell,var)))
62
63 #define hrt_indexed_store(cell, type, array, index, data) \
64         ((((HRT_HOST_TYPE(type)*)_hrt_cell_get_crun_indexed_symbol(cell,array))[index]) = (data))
65 #define hrt_indexed_load(cell, type, array, index) \
66         (((HRT_HOST_TYPE(type)*)_hrt_cell_get_crun_indexed_symbol(cell,array))[index])
67
68 #else /* C_RUN */
69
70 #define hrt_scalar_store(cell, type, var, data) \
71   HRTCAT(hrt_mem_store_,HRT_TYPE_BITS(cell, type))(\
72                cell, \
73                HRTCAT(HIVE_MEM_,var), \
74                HRTCAT(HIVE_ADDR_,var), \
75                (HRT_INT_TYPE(type))(data))
76
77 #define hrt_scalar_load(cell, type, var) \
78   (HRT_HOST_TYPE(type))(HRTCAT4(_hrt_mem_load_,HRT_PROC_TYPE(cell),_,type) ( \
79                cell, \
80                HRTCAT(HIVE_MEM_,var), \
81                HRTCAT(HIVE_ADDR_,var)))
82
83 #define hrt_indexed_store(cell, type, array, index, data) \
84   HRTCAT(hrt_mem_store_,HRT_TYPE_BITS(cell, type))(\
85                cell, \
86                HRTCAT(HIVE_MEM_,array), \
87                (HRTCAT(HIVE_ADDR_,array))+((index)*HRT_TYPE_BYTES(cell, type)), \
88                (HRT_INT_TYPE(type))(data))
89
90 #define hrt_indexed_load(cell, type, array, index) \
91   (HRT_HOST_TYPE(type))(HRTCAT4(_hrt_mem_load_,HRT_PROC_TYPE(cell),_,type) ( \
92          cell, \
93                HRTCAT(HIVE_MEM_,array), \
94                (HRTCAT(HIVE_ADDR_,array))+((index)*HRT_TYPE_BYTES(cell, type))))
95
96 #endif /* C_RUN */
97
98 #endif /* _HRT_VAR_H */
99 #endif