1 |
6 |
hellwig |
|
2 |
|
|
Hardware
|
3 |
|
|
========
|
4 |
|
|
|
5 |
|
|
General
|
6 |
|
|
-------
|
7 |
|
|
|
8 |
|
|
32 bits virtual addresses
|
9 |
|
|
30 bits physical addresses
|
10 |
|
|
32 bits data path width
|
11 |
|
|
32 bits instruction width
|
12 |
|
|
|
13 |
|
|
32 integer registers
|
14 |
|
|
byte addressable, big endian machine
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
Physical Address Space Utilisation
|
18 |
|
|
----------------------------------
|
19 |
|
|
|
20 |
|
|
The main memory extends from address 0 to MEMORY_SIZE,
|
21 |
|
|
which has an upper limit of 512 MB. The ROM is located
|
22 |
|
|
at 0x20000000; its size, ROM_SIZE, is at most 256 MB.
|
23 |
|
|
The I/O is memory-mapped and located at 0x30000000; its
|
24 |
|
|
size is again at most 256 MB. The I/O address space is
|
25 |
|
|
divided evenly into 256 devices; each device may occupy
|
26 |
|
|
up to 1 MB of address space.
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
Machine Data Types
|
30 |
|
|
------------------
|
31 |
|
|
|
32 |
|
|
word 32 bits
|
33 |
|
|
half 16 bits
|
34 |
|
|
byte 8 bits
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
Paging
|
38 |
|
|
------
|
39 |
|
|
|
40 |
|
|
4 KB page size
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
TLB
|
44 |
|
|
---
|
45 |
|
|
A TLB (translation lookaside buffer) is used to map virtual addresses to
|
46 |
|
|
physical ones. The mapping does not apply to addresses with both high-order
|
47 |
|
|
bits set; these addresses refer to physical memory and are never mapped by
|
48 |
|
|
the TLB. The TLB has 32 entries, each of which can be used to map a virtual
|
49 |
|
|
page number to a physical frame number. More than one page can be mapped to
|
50 |
|
|
the same physical frame ('aliasing'). It is a severe programming error,
|
51 |
|
|
however, to have more than one entry for the same virtual page number in
|
52 |
|
|
the TLB. The result of a translation under these circumstances is undefined.
|
53 |
|
|
Whenever an address translation takes place, all entries in the TLB are
|
54 |
|
|
searched in parallel ('fully associative memory'). Therefore a given page
|
55 |
|
|
number need not to be placed into a specific location in the TLB, any
|
56 |
|
|
location will do. If no entry matches the page number, the processor takes
|
57 |
|
|
an exception (see below).
|
58 |
|
|
|
59 |
|
|
TLB Entries
|
60 |
|
|
-----------
|
61 |
|
|
A TLB entry consists of two parts: the key (also called 'input' or 'EntryHi')
|
62 |
|
|
and the value (also called 'output' or 'EntryLo'). The key consists of the
|
63 |
|
|
upper 20 bits of the page number of a virtual address; the lower 12 bits are
|
64 |
|
|
zero and not stored in the entry. The key is used to locate an entry in the
|
65 |
|
|
TLB during an address translation. The only way to make sure that an entry
|
66 |
|
|
does not match any virtual address is to set both high-order bits of the
|
67 |
|
|
address; such an address is never mapped by the TLB (see above). The value
|
68 |
|
|
consists of the frame address and two flags. The low-order 12 bits of the
|
69 |
|
|
frame address are always zero; they are not stored in the entry. Furthermore,
|
70 |
|
|
the two most significant bits are always zero because the physical address
|
71 |
|
|
range is 1 GByte.
|
72 |
|
|
|
73 |
|
|
TLB Registers
|
74 |
|
|
-------------
|
75 |
|
|
Four registers allow programming of the TLB and assist in managing address
|
76 |
|
|
translations of large address spaces in spite of a moderately sized TLB.
|
77 |
|
|
Index:
|
78 |
|
|
This register specifies the location in the TLB where the next
|
79 |
|
|
write-by-index or read-by-index instruction will take place.
|
80 |
|
|
Furthermore, it will hold the index after a TLB search instruction
|
81 |
|
|
(see below).
|
82 |
|
|
EntryHi:
|
83 |
|
|
This register holds the input part of a TLB entry, either before
|
84 |
|
|
writing it or after reading it. Furthermore, any of the TLB-related
|
85 |
|
|
exceptions (miss, invalid, write) will write the page number in
|
86 |
|
|
question into this register in order to facilitate a rapid insertion
|
87 |
|
|
of an appropriate mapping for this page into the TLB.
|
88 |
|
|
EntryLo:
|
89 |
|
|
This register holds the output part of a TLB entry, either before
|
90 |
|
|
writing it or after reading it.
|
91 |
|
|
BadAddr:
|
92 |
|
|
Any of the addres translation exceptions (including the non-TLB related
|
93 |
|
|
ones such as illegal addresses, but excluding bus address errors) write
|
94 |
|
|
the offending address into this register. The operating system may find
|
95 |
|
|
this information useful.
|
96 |
|
|
|
97 |
|
|
TLB Instructions
|
98 |
|
|
----------------
|
99 |
|
|
Four instructions are used to program the TLB. All four are privileged
|
100 |
|
|
instructions that will cause an exception if executed in user mode.
|
101 |
|
|
tbs (translation buffer search):
|
102 |
|
|
The Index register is loaded with the address of the TLB entry whose
|
103 |
|
|
contents match the contents of the EntryHi register. If no TLB entry
|
104 |
|
|
matches, the high order bit of the Index register is set.
|
105 |
|
|
tbwr (translation buffer write random):
|
106 |
|
|
This instruction loads a pseudo-randomly specified TLB entry with the
|
107 |
|
|
contents of the EntryHi and EntryLo registers. A free running counter
|
108 |
|
|
supplies the pseudo-random index. Entries 0..3 are never written to
|
109 |
|
|
by this instruction.
|
110 |
|
|
tbri (translation buffer read index):
|
111 |
|
|
This instruction loads the EntryHi and EntryLo registers with the
|
112 |
|
|
contents of the TLB entry specified by the contents of the Index
|
113 |
|
|
register.
|
114 |
|
|
tbwi (translation buffer write index):
|
115 |
|
|
This instruction loads the specified TLB entry with the contents of
|
116 |
|
|
the EntryHi and EntryLo registers. The contents of the Index register
|
117 |
|
|
specify the TLB entry.
|
118 |
|
|
|
119 |
|
|
TLB Function
|
120 |
|
|
------------
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
Software
|
124 |
|
|
========
|
125 |
|
|
|
126 |
|
|
C Data Types
|
127 |
|
|
------------
|
128 |
|
|
|
129 |
|
|
long 32 bits
|
130 |
|
|
int 32 bits
|
131 |
|
|
short 16 bits
|
132 |
|
|
char 8 bits
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
Page Tables
|
136 |
|
|
-----------
|
137 |
|
|
|
138 |
|
|
2 levels of page tables
|
139 |
|
|
1024 entries per table
|
140 |
|
|
|
141 |
|
|
topmost 10 bits of virtual address select an entry in the page directory
|
142 |
|
|
this entry points to a page table
|
143 |
|
|
next 10 bits of virtual address select an entry in the page table
|
144 |
|
|
this entry points to a page frame
|
145 |
|
|
least significant 12 bits of virtual address select a byte in the page frame
|
146 |
|
|
|
147 |
|
|
a single page table occupies exactly one page
|
148 |
|
|
therefore we have 4 bytes per entry
|
149 |
|
|
|
150 |
|
|
a page table entry has the following parts:
|
151 |
|
|
20 bits physical page frame address
|