1 | /* |
---|
2 | * This file is part of MutekH. |
---|
3 | * |
---|
4 | * MutekH is free software; you can redistribute it and/or modify it |
---|
5 | * under the terms of the GNU Lesser General Public License as published |
---|
6 | * by the Free Software Foundation; version 2.1 of the License. |
---|
7 | * |
---|
8 | * MutekH is distributed in the hope that it will be useful, but |
---|
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
11 | * Lesser General Public License for more details. |
---|
12 | * |
---|
13 | * You should have received a copy of the GNU Lesser General Public |
---|
14 | * License along with MutekH; if not, write to the Free Software |
---|
15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
16 | * 02110-1301 USA |
---|
17 | * |
---|
18 | * Copyright (c) UPMC, Lip6, SoC |
---|
19 | */ |
---|
20 | |
---|
21 | #include "srl_private_types.h" |
---|
22 | #include "srl_sched_wait.h" |
---|
23 | #include "srl_hw_helpers.h" |
---|
24 | #include "stdio.h" |
---|
25 | |
---|
26 | #define endian_cpu32(x) (x) |
---|
27 | |
---|
28 | #define DECLARE_WAIT(name, cmp) \ |
---|
29 | \ |
---|
30 | void srl_sched_wait_##name( void *addr, sint32_t val ) \ |
---|
31 | { \ |
---|
32 | srl_dcache_flush_addr(addr); \ |
---|
33 | if ( ((sint32_t)*((unsigned int *)addr)) cmp val ) \ |
---|
34 | return; \ |
---|
35 | do { \ |
---|
36 | srl_sched_wait_priv(100);?? \ |
---|
37 | srl_dcache_flush_addr(addr); \ |
---|
38 | } while (((sint32_t)*((unsigned int*)addr)) cmp val ); \ |
---|
39 | } |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | DECLARE_WAIT(eq, ==) |
---|
44 | |
---|
45 | DECLARE_WAIT(ne, !=) |
---|
46 | |
---|
47 | DECLARE_WAIT(le, <=) |
---|
48 | |
---|
49 | DECLARE_WAIT(ge, >=) |
---|
50 | |
---|
51 | DECLARE_WAIT(lt, <) |
---|
52 | |
---|
53 | DECLARE_WAIT(gt, >) |
---|
54 | |
---|
55 | //TODO |
---|
56 | void srl_sched_wait_priv(uint32_t date ) |
---|
57 | { |
---|
58 | do{ |
---|
59 | context_switch(); |
---|
60 | }while (srl_cycle_count() > date); |
---|
61 | } |
---|
62 | |
---|
63 | void srl_sleep_cycles( uint32_t n ) |
---|
64 | { |
---|
65 | uint32_t next_run_to = srl_cycle_count()+n; |
---|
66 | |
---|
67 | while(srl_cycle_count() < next_run_to) |
---|
68 | srl_sched_wait_priv(next_run_to); |
---|
69 | } |
---|
70 | |
---|