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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [monitor/] [monitor/] [common/] [mmu.c] - Blame information for rev 180

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 59 hellwig
/*
2
 * mmu.c -- memory and TLB access
3
 */
4
 
5
 
6
#include "common.h"
7
#include "stdarg.h"
8
#include "romlib.h"
9
#include "mmu.h"
10
#include "start.h"
11
 
12
 
13
static Word tlbIndex;
14
static Word tlbEntryHi;
15
static Word tlbEntryLo;
16 84 hellwig
static Word badAddress;
17 180 hellwig
static Word badAccess;
18 59 hellwig
 
19
 
20
Word mmuReadWord(Word vAddr) {
21
  return *(Word *)vAddr;
22
}
23
 
24
 
25
Half mmuReadHalf(Word vAddr) {
26
  return *(Half *)vAddr;
27
}
28
 
29
 
30
Byte mmuReadByte(Word vAddr) {
31
  return *(Byte *)vAddr;
32
}
33
 
34
 
35
void mmuWriteWord(Word vAddr, Word data) {
36
  *(Word *)vAddr = data;
37
}
38
 
39
 
40
void mmuWriteHalf(Word vAddr, Half data) {
41
  *(Half *)vAddr = data;
42
}
43
 
44
 
45
void mmuWriteByte(Word vAddr, Byte data) {
46
  *(Byte *)vAddr = data;
47
}
48
 
49
 
50
Word mmuGetIndex(void) {
51
  return tlbIndex;
52
}
53
 
54
 
55
void mmuSetIndex(Word value) {
56
  tlbIndex = value;
57
}
58
 
59
 
60
Word mmuGetEntryHi(void) {
61
  return tlbEntryHi;
62
}
63
 
64
 
65
void mmuSetEntryHi(Word value) {
66
  tlbEntryHi = value;
67
}
68
 
69
 
70
Word mmuGetEntryLo(void) {
71
  return tlbEntryLo;
72
}
73
 
74
 
75
void mmuSetEntryLo(Word value) {
76
  tlbEntryLo = value;
77
}
78
 
79
 
80 84 hellwig
Word mmuGetBadAddr(void) {
81
  return badAddress;
82
}
83
 
84
 
85
void mmuSetBadAddr(Word value) {
86
  badAddress = value;
87
}
88
 
89
 
90 180 hellwig
Word mmuGetBadAccs(void) {
91
  return badAccess;
92
}
93
 
94
 
95
void mmuSetBadAccs(Word value) {
96
  badAccess = value;
97
}
98
 
99
 
100 59 hellwig
TLB_Entry mmuGetTLB(int index) {
101
  Word hi;
102
  Word lo;
103
  TLB_Entry result;
104
 
105
  hi = getTLB_HI(index);
106
  lo = getTLB_LO(index);
107
  result.page = hi & PAGE_MASK;
108
  result.frame = lo & PAGE_MASK;
109
  result.write = (lo & TLB_WRITE) ? true : false;
110
  result.valid = (lo & TLB_VALID) ? true : false;
111
  return result;
112
}
113
 
114
 
115
void mmuSetTLB(int index, TLB_Entry tlbEntry) {
116
  Word flags;
117
 
118
  flags = 0;
119
  if (tlbEntry.write) {
120
    flags |= TLB_WRITE;
121
  }
122
  if (tlbEntry.valid) {
123
    flags |= TLB_VALID;
124
  }
125
  setTLB(index, tlbEntry.page, tlbEntry.frame | flags);
126
}

powered by: WebSVN 2.1.0

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