OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [test_suite0/] [src/] [api/] [cache.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Test cache control system call
3
 *
4
 * Copyright (C) 2010 B Labs Ltd.
5
 *
6
 * Author: Bahadir Balban
7
 */
8
#include INC_GLUE(memory.h)
9
#include <l4lib/lib/cap.h>
10
#include <l4/api/cache.h>
11
#include <linker.h>
12
#include <stdio.h>
13
 
14
#include <l4lib/macros.h>
15
#include L4LIB_INC_ARCH(syscalls.h)
16
 
17
/* This simply tests that all cache calls are working */
18
int test_cctrl_basic(void)
19
{
20
        struct capability *virtcap = cap_get_by_type(CAP_TYPE_MAP_VIRTMEM);
21
        void *start = (void *)__pfn_to_addr(virtcap->start);
22
        void *end = (void *)__end;
23
        int err;
24
 
25
        if ((err = l4_cache_control(start, end, L4_INVALIDATE_ICACHE)) < 0)
26
                return err;
27
 
28
        if ((err = l4_cache_control(start, end, L4_INVALIDATE_DCACHE)) < 0)
29
                return err;
30
 
31
        if ((err = l4_cache_control(start, end, L4_CLEAN_INVALIDATE_DCACHE)) < 0)
32
                return err;
33
 
34
        if ((err = l4_cache_control(start, end, L4_CLEAN_DCACHE)) < 0)
35
                return err;
36
 
37
        if ((err = l4_cache_control(start, end, L4_INVALIDATE_TLB)) < 0)
38
                return err;
39
 
40
        return 0;
41
}
42
 
43
int test_cctrl_sync_caches()
44
{
45
        /*
46
         * Double-map a physical page and fill it with
47
         * mov r0, r0, r0 * PAGE_SIZE - 1
48
         * b return_label
49
         */
50
 
51
        /* Flush the Dcache for that page */
52
 
53
        /* Invalidate I cache for that page */
54
 
55
        /* Execute the page */
56
 
57
        /*
58
         * Create a new address space and execute the page from
59
         * that space
60
         */
61
        return 0;
62
}
63
 
64
int test_api_cctrl(void)
65
{
66
        int err;
67
 
68
        if ((err = test_cctrl_basic()) < 0)
69
                goto out_err;
70
 
71
 
72
        printf("CACHE CONTROL:                 -- PASSED --\n");
73
        return 0;
74
 
75
out_err:
76
        printf("CACHE CONTROL:                 -- FAILED --\n");
77
        return err;
78
 
79
}
80
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.