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

Last change on this file since 177 was 160, checked in by karaoui, 12 years ago

giet-vm new version

File size: 2.1 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 *         Nicolas Pouillon <nipo@ssji.net>, 2008
20 */
21
22#include "srl_private_types.h"
23#include "srl_sched_wait.h"
24#include "srl_hw_helpers.h"
25#include "stdio.h"
26
27#define endian_cpu32(x) (x)
28
29#define DECLARE_WAIT(name, cmp)                                              \
30                                                                                         \
31    void srl_sched_wait_##name( void *addr, sint32_t val )                              \
32    {                                                                                           \
33                dcache_flush(addr, sizeof(addr));                                                                                               \
34        if ( ((sint32_t)*((unsigned int *)addr)) cmp val )                      \
35        return;                                                                          \
36        do {                                                                             \
37            context_switch();                                                                                                                   \
38                        dcache_flush(addr, sizeof(addr));                                                                                       \
39        } while (((sint32_t)*((unsigned int*)addr)) cmp val );          \
40    }
41
42
43
44DECLARE_WAIT(eq, ==)
45
46DECLARE_WAIT(ne, !=)
47
48DECLARE_WAIT(le, <=)
49
50DECLARE_WAIT(ge, >=)
51
52DECLARE_WAIT(lt, <)
53
54DECLARE_WAIT(gt, >)
55
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.