source: soft/giet_vm/libs/libsrl/srl_sched_wait.c @ 203

Last change on this file since 203 was 178, checked in by karaoui, 12 years ago

updating libs.

File size: 1.9 KB
Line 
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
43DECLARE_WAIT(eq, ==)
44
45DECLARE_WAIT(ne, !=)
46
47DECLARE_WAIT(le, <=)
48
49DECLARE_WAIT(ge, >=)
50
51DECLARE_WAIT(lt, <)
52
53DECLARE_WAIT(gt, >)
54
55//TODO
56void srl_sched_wait_priv(uint32_t date )
57{
58        do{
59                context_switch();
60        }while (srl_cycle_count() > date);
61}
62
63void 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
Note: See TracBrowser for help on using the repository browser.