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

Subversion Repositories eco32

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

Go to most recent revision | 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
 
17
 
18
Word mmuReadWord(Word vAddr) {
19
  return *(Word *)vAddr;
20
}
21
 
22
 
23
Half mmuReadHalf(Word vAddr) {
24
  return *(Half *)vAddr;
25
}
26
 
27
 
28
Byte mmuReadByte(Word vAddr) {
29
  return *(Byte *)vAddr;
30
}
31
 
32
 
33
void mmuWriteWord(Word vAddr, Word data) {
34
  *(Word *)vAddr = data;
35
}
36
 
37
 
38
void mmuWriteHalf(Word vAddr, Half data) {
39
  *(Half *)vAddr = data;
40
}
41
 
42
 
43
void mmuWriteByte(Word vAddr, Byte data) {
44
  *(Byte *)vAddr = data;
45
}
46
 
47
 
48
Word mmuGetIndex(void) {
49
  return tlbIndex;
50
}
51
 
52
 
53
void mmuSetIndex(Word value) {
54
  tlbIndex = value;
55
}
56
 
57
 
58
Word mmuGetEntryHi(void) {
59
  return tlbEntryHi;
60
}
61
 
62
 
63
void mmuSetEntryHi(Word value) {
64
  tlbEntryHi = value;
65
}
66
 
67
 
68
Word mmuGetEntryLo(void) {
69
  return tlbEntryLo;
70
}
71
 
72
 
73
void mmuSetEntryLo(Word value) {
74
  tlbEntryLo = value;
75
}
76
 
77
 
78
TLB_Entry mmuGetTLB(int index) {
79
  Word hi;
80
  Word lo;
81
  TLB_Entry result;
82
 
83
  hi = getTLB_HI(index);
84
  lo = getTLB_LO(index);
85
  result.page = hi & PAGE_MASK;
86
  result.frame = lo & PAGE_MASK;
87
  result.write = (lo & TLB_WRITE) ? true : false;
88
  result.valid = (lo & TLB_VALID) ? true : false;
89
  return result;
90
}
91
 
92
 
93
void mmuSetTLB(int index, TLB_Entry tlbEntry) {
94
  Word flags;
95
 
96
  flags = 0;
97
  if (tlbEntry.write) {
98
    flags |= TLB_WRITE;
99
  }
100
  if (tlbEntry.valid) {
101
    flags |= TLB_VALID;
102
  }
103
  setTLB(index, tlbEntry.page, tlbEntry.frame | flags);
104
}

powered by: WebSVN 2.1.0

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