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 | srl_dcache_flush_addr(addr); \ |
---|
32 | if (((sint32_t) * ((unsigned int *) addr)) cmp val) \ |
---|
33 | return; \ |
---|
34 | do { \ |
---|
35 | srl_sched_wait_priv(100);?? \ |
---|
36 | srl_dcache_flush_addr(addr); \ |
---|
37 | } while (((sint32_t) * ((unsigned int *) addr)) cmp val); \ |
---|
38 | } |
---|
39 | |
---|
40 | |
---|
41 | |
---|
42 | DECLARE_WAIT(eq, ==) |
---|
43 | |
---|
44 | DECLARE_WAIT(ne, !=) |
---|
45 | |
---|
46 | DECLARE_WAIT(le, <=) |
---|
47 | |
---|
48 | DECLARE_WAIT(ge, >=) |
---|
49 | |
---|
50 | DECLARE_WAIT(lt, <) |
---|
51 | |
---|
52 | DECLARE_WAIT(gt, >) |
---|
53 | |
---|
54 | //TODO |
---|
55 | void srl_sched_wait_priv(uint32_t date) { |
---|
56 | do { |
---|
57 | context_switch(); |
---|
58 | } while (srl_cycle_count() > date); |
---|
59 | } |
---|
60 | |
---|
61 | void srl_sleep_cycles(uint32_t n) { |
---|
62 | uint32_t next_run_to = srl_cycle_count() + n; |
---|
63 | |
---|
64 | while (srl_cycle_count() < next_run_to) { |
---|
65 | srl_sched_wait_priv(next_run_to); |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | |
---|
70 | // Local Variables: |
---|
71 | // tab-width: 4 |
---|
72 | // c-basic-offset: 4 |
---|
73 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
74 | // indent-tabs-mode: nil |
---|
75 | // End: |
---|
76 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
77 | |
---|