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

Subversion Repositories or1k

[/] [or1k/] [branches/] [oc/] [orpmon/] [cmds/] [cpu.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 809 simons
#include "common.h"
2
#include "spr_defs.h"
3
 
4
int ic_enable_cmd (int argc, char *argv[])
5
{
6
  unsigned long addr;
7
  unsigned long sr;
8
 
9
  if (argc) return -1;
10
  /* Invalidate IC */
11
  for (addr = 0; addr < 8192; addr += 16)
12
    asm("l.mtspr r0,%0,%1": : "r" (addr), "i" (SPR_ICBIR));
13
 
14
  /* Enable IC */
15
  asm("l.mfspr %0,r0,%1": "=r" (sr) : "i" (SPR_SR));
16
  sr |= SPR_SR_ICE;
17
  asm("l.mtspr r0,%0,%1": : "r" (sr), "i" (SPR_SR));
18
  asm("l.nop");
19
  asm("l.nop");
20
  asm("l.nop");
21
  asm("l.nop");
22
  return 0;
23
}
24
 
25
int ic_disable_cmd (int argc, char *argv[])
26
{
27
  unsigned long sr;
28
 
29
  if (argc) return -1;
30
  /* Disable IC */
31
  asm("l.mfspr %0,r0,%1": "=r" (sr) : "i" (SPR_SR));
32
  sr &= ~SPR_SR_ICE;
33
  asm("l.mtspr r0,%0,%1": : "r" (sr), "i" (SPR_SR));
34
  asm("l.nop");
35
  asm("l.nop");
36
  asm("l.nop");
37
  asm("l.nop");
38
  return 0;
39
}
40
 
41
int dc_enable_cmd (int argc, char *argv[])
42
{
43
  unsigned long addr;
44
  unsigned long sr;
45
 
46
  if (argc) return -1;
47
  /* Invalidate DC */
48
  for (addr = 0; addr < 8192; addr += 16)
49
    asm("l.mtspr r0,%0,%1": : "r" (addr), "i" (SPR_DCBIR));
50
 
51
  /* Enable DC */
52
  asm("l.mfspr %0,r0,%1": "=r" (sr) : "i" (SPR_SR));
53
  sr |= SPR_SR_DCE;
54
  asm("l.mtspr r0,%0,%1": : "r" (sr), "i" (SPR_SR));
55
  asm("l.nop");
56
  asm("l.nop");
57
  asm("l.nop");
58
  asm("l.nop");
59
  return 0;
60
}
61
 
62
int dc_disable_cmd (int argc, char *argv[])
63
{
64
  unsigned long sr;
65
 
66
  if (argc) return -1;
67
  /* Disable DC */
68
  asm("l.mfspr %0,r0,%1": "=r" (sr) : "i" (SPR_SR));
69
  sr &= ~SPR_SR_DCE;
70
  asm("l.mtspr r0,%0,%1": : "r" (sr), "i" (SPR_SR));
71
  asm("l.nop");
72
  asm("l.nop");
73
  asm("l.nop");
74
  asm("l.nop");
75
  return 0;
76
}
77
 
78
int mfspr_cmd (int argc, char *argv[])
79
{
80
  unsigned long val, addr;
81
 
82
  if (argc ==   1) {
83
          addr = strtoul (argv[0]);
84
    /* Read SPR */
85
    asm("l.mfspr %0,%1,0": "=r" (val) : "r" (addr));
86
    printf ("\nSPR %04lx: %08lx", addr, val);
87
  } else return -1;
88
        return 0;
89
}
90
 
91
int mtspr_cmd (int argc, char *argv[])
92
{
93
  unsigned long val, addr;
94
  if (argc == 2) {
95
    addr = strtoul (argv[0]);
96
    val = strtoul (argv[1]);
97
    /* Write SPR */
98
    asm("l.mtspr %0,%1,0": : "r" (addr), "r" (val));
99
    asm("l.mfspr %0,%1,0": "=r" (val) : "r" (addr));
100
    printf ("\nSPR %04lx: %08lx", addr, val);
101
  } else return -1;
102
        return 0;
103
}
104
 
105
void module_cpu_init (void)
106
{
107
  register_command ("ic_enable", "", "enable instruction cache", ic_enable_cmd);
108
  register_command ("ic_disable", "", "disable instruction cache", ic_disable_cmd);
109
  register_command ("dc_enable", "", "enable data cache", dc_enable_cmd);
110
  register_command ("dc_disable", "", "disable data cache", dc_disable_cmd);
111
  register_command ("mfspr", "<spr_addr>", "show SPR", mfspr_cmd);
112
  register_command ("mtspr", "<spr_addr> <value>", "set SPR", mtspr_cmd);
113
}

powered by: WebSVN 2.1.0

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