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 | |
---|
13 | /** |
---|
14 | Standard API call, expands to nothing for this implementation. |
---|
15 | */ |
---|
16 | #define srl_busy_cycles(n) do{}while(0) |
---|
17 | |
---|
18 | //void useless(void *pointless,...){} |
---|
19 | /** |
---|
20 | @this flushes the cache line containing the address. |
---|
21 | */ |
---|
22 | //TODO |
---|
23 | #define srl_dcache_flush_addr 0 |
---|
24 | |
---|
25 | /* |
---|
26 | static inline cpu_dcache_invld(void *ptr){ |
---|
27 | asm volatile ( |
---|
28 | " cache %0, %1" |
---|
29 | : : "i" (0x11) , "R" (*(uint8_t*)(ptr)) |
---|
30 | : "memory" |
---|
31 | ); |
---|
32 | } |
---|
33 | */ |
---|
34 | |
---|
35 | /** |
---|
36 | @this flushes a memory zone from cache. |
---|
37 | */ |
---|
38 | //TODO |
---|
39 | //void dcache_flush(const void * addr, size_t size) |
---|
40 | #define srl_dcache_flush_zone dcache_flush |
---|
41 | |
---|
42 | /** |
---|
43 | @this waits for at least the given time (in cycles). The actual |
---|
44 | time spent in this call is not predictable. |
---|
45 | |
---|
46 | @param time Number of cycles to wait for |
---|
47 | */ |
---|
48 | void srl_sleep_cycles(unsigned int time); |
---|
49 | |
---|
50 | /** |
---|
51 | @this returns the absolute timestamp counter from the |
---|
52 | initialization of the platform. |
---|
53 | |
---|
54 | @return Cycles from the initialization of the system |
---|
55 | */ |
---|
56 | static inline unsigned int srl_cycle_count() { |
---|
57 | return giet_proctime(); |
---|
58 | } |
---|
59 | |
---|
60 | |
---|
61 | /** |
---|
62 | @this aborts the current execution. On most systems, @this will |
---|
63 | simply hang. |
---|
64 | */ |
---|
65 | static inline void srl_abort() { |
---|
66 | asm volatile ("break 0"); |
---|
67 | while (1); |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | /** |
---|
72 | * |
---|
73 | */ |
---|
74 | static inline void srl_exit() { |
---|
75 | giet_exit(); |
---|
76 | } |
---|
77 | |
---|
78 | #endif |
---|
79 | |
---|
80 | // Local Variables: |
---|
81 | // tab-width: 4 |
---|
82 | // c-basic-offset: 4 |
---|
83 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
84 | // indent-tabs-mode: nil |
---|
85 | // End: |
---|
86 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
87 | |
---|