~aleteoryx/muditaos

ref: 7fbaf735ed99f5b0d26adb686cfa6ed2bb4267d5 muditaos/module-os/board/linux/macros.h -rw-r--r-- 1.8 KiB
7fbaf735 — Przemyslaw Brudny [EGD-7813] Option Window titles localizations fix 4 years ago
                                                                                
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
/*
 *  @file macros.h
 *  @author Mateusz Piesta (mateusz.piesta@mudita.com)
 *  @date 31 lip 2018
 *  @brief Handy macros
 *  @copyright Copyright (C) 2018 mudita.com
 *  @details
 */

#ifndef MACROS_H_
#define MACROS_H_


#include <stdbool.h>
#include <assert.h>
#include <stdint.h>

#define _STRINGIFY(s) #s
#define STRINGIFY(s) _STRINGIFY(s)

#define UNUSED(x) ((void)(x))

#define ALIGN_(n) 							__attribute__((aligned(n)))

#define CACHEABLE_SECTION_SDRAM(var)	    var

#define CACHEABLE_SECTION_SDRAM_ALIGN(var,alignbytes) var

#define NONCACHEABLE_SECTION_SDRAM(var)	 var

#define NONCACHEABLE_SECTION_SDRAM_ALIGN(var,alignbytes)    var

#define NONCACHEABLE_SECTION_INIT(var) 	 var

#define NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes)  var

#define NONCACHEABLE_SECTION(var) var

#define NONCACHEABLE_SECTION_ALIGN(var, alignbytes)  var

static inline uint32_t IS_MEM_ADDR_CACHED(void* addr)
{
	extern uint32_t __sdram_non_cached_start[];
	extern uint32_t __sdram_non_cached_end[];
	extern uint32_t __ocram_cached_start[];
	extern uint32_t __ocram_cached_end[];
	extern uint32_t __dtcm_ram_start[];
	extern uint32_t __dtcm_ram_end[];
	extern uint32_t __sdram_cached_start[];
	extern uint32_t __sdram_cached_end[];


	if(((uint32_t*)addr >= (uint32_t*)__sdram_non_cached_start) && ((uint32_t*)addr < (uint32_t*)__sdram_non_cached_end)){
		return 0;
	}
	if(((uint32_t*)addr >= (uint32_t*)__ocram_cached_start) && ((uint32_t*)addr < (uint32_t*)__ocram_cached_end)){
		return 1;
	}
	if(((uint32_t*)addr >= (uint32_t*)__dtcm_ram_start) && ((uint32_t*)addr < (uint32_t*)__dtcm_ram_end)){
		return 0;
	}
	if(((uint32_t*)addr >= (uint32_t*)__sdram_cached_start) && ((uint32_t*)addr < (uint32_t*)__sdram_cached_end)){
		return 1;
	}

	assert(0);
}

//! Test if in interrupt mode
static inline bool isIRQ()
{
    return false;
}


#endif /* MACROS_H_ */