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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [orpmon/] [cmds/] [cpu.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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