summaryrefslogtreecommitdiff
path: root/cesar/test_general/proto_gaisler/cache/cache.c
blob: a2ddb46bfb6231a57c4d3d674ba70566a6319dce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*                                                     
 * $Id: hello.c,v 1.5 2004/10/26 03:32:21 corbet Exp $ 
 */                                                    
#include <linux/init.h>
#include <linux/module.h>
#include <asm/leon.h>

#define ASI 2
#define CCR 0
#define DCFG 0x0C
#define ICFG 0x08


extern __inline__ unsigned long get_ccr(void) {
	unsigned int retval;
	__asm__ __volatile__("lda [%1] %2, %0\n\t" :
			     "=r" (retval) :
			     "r" (CCR),
			     "i" (ASI));
	return (retval);
}

extern __inline__ unsigned long get_dcfg(void) {
	unsigned int retval;
	__asm__ __volatile__("lda [%1] %2, %0\n\t" :
			     "=r" (retval) :
			     "r" (DCFG),
			     "i" (ASI));
	return (retval);
}

extern __inline__ unsigned long get_icfg(void) {
	unsigned int retval;
	__asm__ __volatile__("lda [%1] %2, %0\n\t" :
			     "=r" (retval) :
			     "r" (ICFG),
			     "i" (ASI));
	return (retval);
}

/*	__asm__ __volatile__("sta %0, [%1] %2\n\t"::"r"(value), "r"(paddr),
			     "i"(ASI_LEON_BYPASS):"memory");
                 */

extern __inline__ unsigned long set_ccr(unsigned long val) {
	__asm__ __volatile__("sta %0, [%1] %2\n\t"::"r"(val), "r"(CCR),
                         "i"(ASI));
}
extern __inline__ unsigned long set_dcfg(unsigned long val) {
	__asm__ __volatile__("sta %0, [%1] %2\n\t"::"r"(val), "r"(DCFG),
                         "i"(ASI));
}
extern __inline__ unsigned long set_icfg(unsigned long val) {
	__asm__ __volatile__("sta %0, [%1] %2\n\t"::"r"(val), "r"(ICFG),
                         "i"(ASI));
}

int start_ccr;
//int start_dcfg, start_icfg;

static int hello_init(void)
{
    start_ccr = get_ccr ();
    //start_dcfg = get_dcfg();
    //start_icfg = get_icfg();
	printk("Hello, world from JL\n");
    printk("Reading cache register : CCR=0x%x\n", start_ccr);
    printk ("Disabling snooping...yes\n");
    start_ccr = start_ccr & 0xFF7FFFFF;
    set_ccr(start_ccr);
    printk ("Disabling cache...yes\n");
    set_ccr(0x00000000);
    printk("ReReading cache register : CCR=0x%x\n", get_ccr());
    //void *p = ioremap (0x8000000,0x100);

	return 0;
}

static void hello_exit(void)
{
    printk("Exiting cache test...\n");
    set_ccr (start_ccr);
    //set_dcfg (start_dcfg);
    //set_icfg (start_icfg);
    printk("Reading cache register : CCR=0x%x\n", get_ccr());
	printk("Goodbye, cruel world from JL\n");
}

module_init(hello_init);
module_exit(hello_exit);