1 | #ifndef SRL_HW_HELPERS_H |
---|
2 | #define SRL_HW_HELPERS_H |
---|
3 | |
---|
4 | /** |
---|
5 | * @file |
---|
6 | * @module{SRL} |
---|
7 | * @short Miscellaneous APIs |
---|
8 | */ |
---|
9 | |
---|
10 | #include "stdio.h" |
---|
11 | |
---|
12 | typedef struct __ldscript_symbol_s __ldscript_symbol_t; |
---|
13 | |
---|
14 | #define BASE_ADDR_OF(id) \ |
---|
15 | ({ \ |
---|
16 | extern __ldscript_symbol_t _dsx_##id##_region_begin; \ |
---|
17 | (void*)&_dsx_##id##_region_begin; \ |
---|
18 | }) |
---|
19 | |
---|
20 | |
---|
21 | /** |
---|
22 | Standard API call, expands to nothing for this implementation. |
---|
23 | */ |
---|
24 | #define srl_busy_cycles(n) do{}while(0) |
---|
25 | |
---|
26 | //void useless(void *pointless,...){} |
---|
27 | /** |
---|
28 | @this flushes the cache line containing the address. |
---|
29 | */ |
---|
30 | //TODO |
---|
31 | #define srl_dcache_flush_addr 0 |
---|
32 | |
---|
33 | /* |
---|
34 | static inline cpu_dcache_invld(void *ptr){ |
---|
35 | asm volatile ( |
---|
36 | " cache %0, %1" |
---|
37 | : : "i" (0x11) , "R" (*(uint8_t*)(ptr)) |
---|
38 | : "memory" |
---|
39 | ); |
---|
40 | } |
---|
41 | */ |
---|
42 | |
---|
43 | /** |
---|
44 | @this flushes a memory zone from cache. |
---|
45 | */ |
---|
46 | //TODO |
---|
47 | //void dcache_flush(const void * addr, size_t size) |
---|
48 | #define srl_dcache_flush_zone dcache_flush |
---|
49 | |
---|
50 | /** |
---|
51 | @this waits for at least the given time (in cycles). The actual |
---|
52 | time spent in this call is not predictable. |
---|
53 | |
---|
54 | @param time Number of cycles to wait for |
---|
55 | */ |
---|
56 | void srl_sleep_cycles( unsigned int time ); |
---|
57 | |
---|
58 | /** |
---|
59 | @this returns the absolute timestamp counter from the |
---|
60 | initialization of the platform. |
---|
61 | |
---|
62 | @return Cycles from the initialization of the system |
---|
63 | */ |
---|
64 | |
---|
65 | |
---|
66 | static inline unsigned int srl_cycle_count() |
---|
67 | { |
---|
68 | return proctime(); |
---|
69 | } |
---|
70 | |
---|
71 | /** |
---|
72 | @this aborts the current execution. On most systems, @this will |
---|
73 | simply hang. |
---|
74 | */ |
---|
75 | static inline void srl_abort() |
---|
76 | { |
---|
77 | asm volatile ("break 0"); |
---|
78 | while(1); |
---|
79 | } |
---|
80 | |
---|
81 | #endif |
---|