80c8febd64436d7a7c864a078a8a0cd9f4282c05
[soc.git] / src / soc / decoder / isa / radixmmu.py
1 # SPDX-License-Identifier: LGPLv3+
2 # Copyright (C) 2020, 2021 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
3 # Copyright (C) 2021 Tobias Platen
4 # Funded by NLnet http://nlnet.nl
5 """core of the python-based POWER9 simulator
6
7 this is part of a cycle-accurate POWER9 simulator. its primary purpose is
8 not speed, it is for both learning and educational purposes, as well as
9 a method of verifying the HDL.
10
11 related bugs:
12
13 * https://bugs.libre-soc.org/show_bug.cgi?id=604
14 """
15
16 from nmigen.back.pysim import Settle
17 from copy import copy
18 from soc.decoder.selectable_int import (FieldSelectableInt, SelectableInt,
19 selectconcat)
20 from soc.decoder.helpers import exts, gtu, ltu, undefined
21 from soc.decoder.isa.mem import Mem
22 from soc.consts import MSRb # big-endian (PowerISA versions)
23
24 import math
25 import sys
26 import unittest
27
28 # very quick, TODO move to SelectableInt utils later
29 def genmask(shift, size):
30 res = SelectableInt(0, size)
31 for i in range(size):
32 if i < shift:
33 res[size-1-i] = SelectableInt(1, 1)
34 return res
35
36 # NOTE: POWER 3.0B annotation order! see p4 1.3.2
37 # MSB is indexed **LOWEST** (sigh)
38 # from gem5 radixwalk.hh
39 # Bitfield<63> valid; 64 - (63 + 1) = 0
40 # Bitfield<62> leaf; 64 - (62 + 1) = 1
41
42 def rpte_valid(r):
43 return bool(r[0])
44
45 def rpte_leaf(r):
46 return bool(r[1])
47
48 def NLB(x):
49 """
50 Next Level Base
51 right shifted by 8
52 """
53 return x[4:55]
54
55 def NLS(x):
56 """
57 Next Level Size
58 NLS >= 5
59 """
60 return x[59:63]
61
62 """
63 Get Root Page
64
65 //Accessing 2nd double word of partition table (pate1)
66 //Ref: Power ISA Manual v3.0B, Book-III, section 5.7.6.1
67 // PTCR Layout
68 // ====================================================
69 // -----------------------------------------------
70 // | /// | PATB | /// | PATS |
71 // -----------------------------------------------
72 // 0 4 51 52 58 59 63
73 // PATB[4:51] holds the base address of the Partition Table,
74 // right shifted by 12 bits.
75 // This is because the address of the Partition base is
76 // 4k aligned. Hence, the lower 12bits, which are always
77 // 0 are ommitted from the PTCR.
78 //
79 // Thus, The Partition Table Base is obtained by (PATB << 12)
80 //
81 // PATS represents the partition table size right-shifted by 12 bits.
82 // The minimal size of the partition table is 4k.
83 // Thus partition table size = (1 << PATS + 12).
84 //
85 // Partition Table
86 // ====================================================
87 // 0 PATE0 63 PATE1 127
88 // |----------------------|----------------------|
89 // | | |
90 // |----------------------|----------------------|
91 // | | |
92 // |----------------------|----------------------|
93 // | | | <-- effLPID
94 // |----------------------|----------------------|
95 // .
96 // .
97 // .
98 // |----------------------|----------------------|
99 // | | |
100 // |----------------------|----------------------|
101 //
102 // The effective LPID forms the index into the Partition Table.
103 //
104 // Each entry in the partition table contains 2 double words, PATE0, PATE1,
105 // corresponding to that partition.
106 //
107 // In case of Radix, The structure of PATE0 and PATE1 is as follows.
108 //
109 // PATE0 Layout
110 // -----------------------------------------------
111 // |1|RTS1|/| RPDB | RTS2 | RPDS |
112 // -----------------------------------------------
113 // 0 1 2 3 4 55 56 58 59 63
114 //
115 // HR[0] : For Radix Page table, first bit should be 1.
116 // RTS1[1:2] : Gives one fragment of the Radix treesize
117 // RTS2[56:58] : Gives the second fragment of the Radix Tree size.
118 // RTS = (RTS1 << 3 + RTS2) + 31.
119 //
120 // RPDB[4:55] = Root Page Directory Base.
121 // RPDS = Logarithm of Root Page Directory Size right shifted by 3.
122 // Thus, Root page directory size = 1 << (RPDS + 3).
123 // Note: RPDS >= 5.
124 //
125 // PATE1 Layout
126 // -----------------------------------------------
127 // |///| PRTB | // | PRTS |
128 // -----------------------------------------------
129 // 0 3 4 51 52 58 59 63
130 //
131 // PRTB[4:51] = Process Table Base. This is aligned to size.
132 // PRTS[59: 63] = Process Table Size right shifted by 12.
133 // Minimal size of the process table is 4k.
134 // Process Table Size = (1 << PRTS + 12).
135 // Note: PRTS <= 24.
136 //
137 // Computing the size aligned Process Table Base:
138 // table_base = (PRTB & ~((1 << PRTS) - 1)) << 12
139 // Thus, the lower 12+PRTS bits of table_base will
140 // be zero.
141
142
143 //Ref: Power ISA Manual v3.0B, Book-III, section 5.7.6.2
144 //
145 // Process Table
146 // ==========================
147 // 0 PRTE0 63 PRTE1 127
148 // |----------------------|----------------------|
149 // | | |
150 // |----------------------|----------------------|
151 // | | |
152 // |----------------------|----------------------|
153 // | | | <-- effPID
154 // |----------------------|----------------------|
155 // .
156 // .
157 // .
158 // |----------------------|----------------------|
159 // | | |
160 // |----------------------|----------------------|
161 //
162 // The effective Process id (PID) forms the index into the Process Table.
163 //
164 // Each entry in the partition table contains 2 double words, PRTE0, PRTE1,
165 // corresponding to that process
166 //
167 // In case of Radix, The structure of PRTE0 and PRTE1 is as follows.
168 //
169 // PRTE0 Layout
170 // -----------------------------------------------
171 // |/|RTS1|/| RPDB | RTS2 | RPDS |
172 // -----------------------------------------------
173 // 0 1 2 3 4 55 56 58 59 63
174 //
175 // RTS1[1:2] : Gives one fragment of the Radix treesize
176 // RTS2[56:58] : Gives the second fragment of the Radix Tree size.
177 // RTS = (RTS1 << 3 + RTS2) << 31,
178 // since minimal Radix Tree size is 4G.
179 //
180 // RPDB = Root Page Directory Base.
181 // RPDS = Root Page Directory Size right shifted by 3.
182 // Thus, Root page directory size = RPDS << 3.
183 // Note: RPDS >= 5.
184 //
185 // PRTE1 Layout
186 // -----------------------------------------------
187 // | /// |
188 // -----------------------------------------------
189 // 0 63
190 // All bits are reserved.
191
192
193 """
194
195 testaddr = 0x10000
196 testmem = {
197
198 0x10000: # PARTITION_TABLE_2 (not implemented yet)
199 # PATB_GR=1 PRTB=0x1000 PRTS=0xb
200 0x800000000100000b,
201
202 0x30000: # RADIX_ROOT_PTE
203 # V = 1 L = 0 NLB = 0x400 NLS = 9
204 0x8000000000040009,
205 ######## 0x4000000 #### wrong address calculated by _get_pgtable_addr
206 0x40000: # RADIX_SECOND_LEVEL
207 # V = 1 L = 1 SW = 0 RPN = 0
208 # R = 1 C = 1 ATT = 0 EAA 0x7
209 0xc000000000000187,
210
211 0x1000000: # PROCESS_TABLE_3
212 # RTS1 = 0x2 RPDB = 0x300 RTS2 = 0x5 RPDS = 13
213 0x40000000000300ad,
214 }
215
216
217
218 # see qemu/target/ppc/mmu-radix64.c for reference
219 class RADIX:
220 def __init__(self, mem, caller):
221 self.mem = mem
222 self.caller = caller
223 if(caller):
224 self.dsisr = self.caller.spr["DSISR"]
225 self.dar = self.caller.spr["DAR"]
226 self.pidr = self.caller.spr["PIDR"]
227 self.prtbl = self.caller.spr["PRTBL"]
228 self.msr = self.caller.msr
229
230 # cached page table stuff
231 self.pgtbl0 = 0
232 self.pt0_valid = False
233 self.pgtbl3 = 0
234 self.pt3_valid = False
235
236 def __call__(self, addr, sz):
237 val = self.ld(addr.value, sz, swap=False)
238 print("RADIX memread", addr, sz, val)
239 return SelectableInt(val, sz*8)
240
241 def ld(self, address, width=8, swap=True, check_in_mem=False,
242 instr_fetch=False):
243 print("RADIX: ld from addr 0x%x width %d" % (address, width))
244
245 priv = ~(self.msr(MSR_PR).value) # problem-state ==> privileged
246 if instr_fetch:
247 mode = 'EXECUTE'
248 else:
249 mode = 'LOAD'
250 addr = SelectableInt(address, 64)
251 (shift, mbits, pgbase) = self._decode_prte(addr)
252 #shift = SelectableInt(0, 32)
253
254 pte = self._walk_tree(addr, pgbase, mode, mbits, shift, priv)
255 # use pte to caclculate phys address
256 return self.mem.ld(address, width, swap, check_in_mem)
257
258 # XXX set SPRs on error
259
260 # TODO implement
261 def st(self, address, v, width=8, swap=True):
262 print("RADIX: st to addr 0x%x width %d data %x" % (address, width, v))
263
264 priv = ~(self.msr(MSR_PR).value) # problem-state ==> privileged
265 mode = 'STORE'
266 addr = SelectableInt(address, 64)
267 (shift, mbits, pgbase) = self._decode_prte(addr)
268 pte = self._walk_tree(addr, pgbase, mode, mbits, shift, priv)
269
270 # use pte to caclculate phys address (addr)
271 return self.mem.st(addr.value, v, width, swap)
272
273 # XXX set SPRs on error
274
275 def memassign(self, addr, sz, val):
276 print("memassign", addr, sz, val)
277 self.st(addr.value, val.value, sz, swap=False)
278
279 def _next_level(self, addr, entry_width, swap, check_in_mem):
280 # implement read access to mmu mem here
281
282 value = 0
283 if addr.value in testmem:
284 value = testmem[addr.value]
285 else:
286 print("not found")
287
288 ##value = self.mem.ld(addr.value, entry_width, swap, check_in_mem)
289 print("addr", hex(addr.value))
290 data = SelectableInt(value, 64) # convert to SelectableInt
291 print("value", hex(value))
292 # index += 1
293 return data;
294
295 def _walk_tree(self, addr, pgbase, mode, mbits, shift, priv=1):
296 """walk tree
297
298 // vaddr 64 Bit
299 // vaddr |-----------------------------------------------------|
300 // | Unused | Used |
301 // |-----------|-----------------------------------------|
302 // | 0000000 | usefulBits = X bits (typically 52) |
303 // |-----------|-----------------------------------------|
304 // | |<--Cursize---->| |
305 // | | Index | |
306 // | | into Page | |
307 // | | Directory | |
308 // |-----------------------------------------------------|
309 // | |
310 // V |
311 // PDE |---------------------------| |
312 // |V|L|//| NLB |///|NLS| |
313 // |---------------------------| |
314 // PDE = Page Directory Entry |
315 // [0] = V = Valid Bit |
316 // [1] = L = Leaf bit. If 0, then |
317 // [4:55] = NLB = Next Level Base |
318 // right shifted by 8 |
319 // [59:63] = NLS = Next Level Size |
320 // | NLS >= 5 |
321 // | V
322 // | |--------------------------|
323 // | | usfulBits = X-Cursize |
324 // | |--------------------------|
325 // |---------------------><--NLS-->| |
326 // | Index | |
327 // | into | |
328 // | PDE | |
329 // |--------------------------|
330 // |
331 // If the next PDE obtained by |
332 // (NLB << 8 + 8 * index) is a |
333 // nonleaf, then repeat the above. |
334 // |
335 // If the next PDE is a leaf, |
336 // then Leaf PDE structure is as |
337 // follows |
338 // |
339 // |
340 // Leaf PDE |
341 // |------------------------------| |----------------|
342 // |V|L|sw|//|RPN|sw|R|C|/|ATT|EAA| | usefulBits |
343 // |------------------------------| |----------------|
344 // [0] = V = Valid Bit |
345 // [1] = L = Leaf Bit = 1 if leaf |
346 // PDE |
347 // [2] = Sw = Sw bit 0. |
348 // [7:51] = RPN = Real Page Number, V
349 // real_page = RPN << 12 -------------> Logical OR
350 // [52:54] = Sw Bits 1:3 |
351 // [55] = R = Reference |
352 // [56] = C = Change V
353 // [58:59] = Att = Physical Address
354 // 0b00 = Normal Memory
355 // 0b01 = SAO
356 // 0b10 = Non Idenmpotent
357 // 0b11 = Tolerant I/O
358 // [60:63] = Encoded Access
359 // Authority
360 //
361 """
362 # get sprs
363 print("_walk_tree")
364 pidr = self.caller.spr["PIDR"]
365 prtbl = self.caller.spr["PRTBL"]
366 print(pidr)
367 print(prtbl)
368 p = addr[55:63]
369 print("last 8 bits ----------")
370 print
371
372 # get address of root entry
373 addr_next = self._get_prtable_addr(shift, prtbl, addr, pidr)
374
375 addr_next = SelectableInt(0x30000,64) # radix root for testing
376
377 # walk tree starts on prtbl
378 while True:
379 print("nextlevel----------------------------")
380 # read an entry
381 swap = False
382 check_in_mem = False
383 entry_width = 8
384
385 data = self._next_level(addr_next, entry_width, swap, check_in_mem)
386 valid = rpte_valid(data)
387 leaf = rpte_leaf(data)
388
389 print(" valid, leaf", valid, leaf)
390 if not valid:
391 return "invalid" # TODO: return error
392 if leaf:
393 ok = self._check_perms(data, priv, mode)
394 if ok == True: # data was ok, found phys address, return it?
395 return addr_next
396 return ok # return the error code
397 else:
398 newlookup = self._new_lookup(data, mbits, shift)
399 if newlookup == 'badtree':
400 return newlookup
401 shift, mask, pgbase = newlookup
402 print (" next level", shift, mask, pgbase)
403 shift = SelectableInt(shift.value,16) #THIS is wrong !!!
404 print("calling _get_pgtable_addr")
405 print(mask) #SelectableInt(value=0x9, bits=4)
406 print(pgbase) #SelectableInt(value=0x40000, bits=56)
407 print(shift) #SelectableInt(value=0x4, bits=16) #FIXME
408 pgbase = SelectableInt(pgbase.value,64)
409 addr_next = self._get_pgtable_addr(mask, pgbase, shift)
410 assert(addr_next == 0x40000)
411 return "TODO verify next level"
412
413 def _new_lookup(self, data, mbits, shift):
414 """
415 mbits := unsigned('0' & data(4 downto 0));
416 if mbits < 5 or mbits > 16 or mbits > r.shift then
417 v.state := RADIX_FINISH;
418 v.badtree := '1'; -- throw error
419 else
420 v.shift := v.shift - mbits;
421 v.mask_size := mbits(4 downto 0);
422 v.pgbase := data(55 downto 8) & x"00"; NLB?
423 v.state := RADIX_LOOKUP; --> next level
424 end if;
425 """
426 mbits = data[59:64]
427 print("mbits=", mbits)
428 if mbits < 5 or mbits > 16: #fixme compare with r.shift
429 print("badtree")
430 return "badtree"
431 # reduce shift (has to be done at same bitwidth)
432 shift = shift - selectconcat(SelectableInt(0, 1), mbits)
433 mask_size = mbits[1:5] # get 4 LSBs
434 pgbase = selectconcat(data[8:56], SelectableInt(0, 8)) # shift up 8
435 return shift, mask_size, pgbase
436
437 def _decode_prte(self, data):
438 """PRTE0 Layout
439 -----------------------------------------------
440 |/|RTS1|/| RPDB | RTS2 | RPDS |
441 -----------------------------------------------
442 0 1 2 3 4 55 56 58 59 63
443 """
444 # note that SelectableInt does big-endian! so the indices
445 # below *directly* match the spec, unlike microwatt which
446 # has to turn them around (to LE)
447 zero = SelectableInt(0, 1)
448 rts = selectconcat(zero,
449 data[56:59], # RTS2
450 data[1:3], # RTS1
451 )
452 masksize = data[59:64] # RPDS
453 mbits = selectconcat(zero, masksize)
454 pgbase = selectconcat(data[8:56], # part of RPDB
455 SelectableInt(0, 16),)
456
457 return (rts, mbits, pgbase)
458
459 def _segment_check(self, addr, mbits, shift):
460 """checks segment valid
461 mbits := '0' & r.mask_size;
462 v.shift := r.shift + (31 - 12) - mbits;
463 nonzero := or(r.addr(61 downto 31) and not finalmask(30 downto 0));
464 if r.addr(63) /= r.addr(62) or nonzero = '1' then
465 v.state := RADIX_FINISH;
466 v.segerror := '1';
467 elsif mbits < 5 or mbits > 16 or mbits > (r.shift + (31 - 12)) then
468 v.state := RADIX_FINISH;
469 v.badtree := '1';
470 else
471 v.state := RADIX_LOOKUP;
472 """
473 # note that SelectableInt does big-endian! so the indices
474 # below *directly* match the spec, unlike microwatt which
475 # has to turn them around (to LE)
476 mask = genmask(shift, 44)
477 nonzero = addr[1:32] & mask[13:44] # mask 31 LSBs (BE numbered 13:44)
478 print ("RADIX _segment_check nonzero", bin(nonzero.value))
479 print ("RADIX _segment_check addr[0-1]", addr[0].value, addr[1].value)
480 if addr[0] != addr[1] or nonzero == 1:
481 return "segerror"
482 limit = shift + (31 - 12)
483 if mbits < 5 or mbits > 16 or mbits > limit:
484 return "badtree"
485 new_shift = shift + (31 - 12) - mbits
486 return new_shift
487
488 def _check_perms(self, data, priv, mode):
489 """check page permissions
490 // Leaf PDE |
491 // |------------------------------| |----------------|
492 // |V|L|sw|//|RPN|sw|R|C|/|ATT|EAA| | usefulBits |
493 // |------------------------------| |----------------|
494 // [0] = V = Valid Bit |
495 // [1] = L = Leaf Bit = 1 if leaf |
496 // PDE |
497 // [2] = Sw = Sw bit 0. |
498 // [7:51] = RPN = Real Page Number, V
499 // real_page = RPN << 12 -------------> Logical OR
500 // [52:54] = Sw Bits 1:3 |
501 // [55] = R = Reference |
502 // [56] = C = Change V
503 // [58:59] = Att = Physical Address
504 // 0b00 = Normal Memory
505 // 0b01 = SAO
506 // 0b10 = Non Idenmpotent
507 // 0b11 = Tolerant I/O
508 // [60:63] = Encoded Access
509 // Authority
510 //
511 -- test leaf bit
512 -- check permissions and RC bits
513 perm_ok := '0';
514 if r.priv = '1' or data(3) = '0' then
515 if r.iside = '0' then
516 perm_ok := data(1) or (data(2) and not r.store);
517 else
518 -- no IAMR, so no KUEP support for now
519 -- deny execute permission if cache inhibited
520 perm_ok := data(0) and not data(5);
521 end if;
522 end if;
523 rc_ok := data(8) and (data(7) or not r.store);
524 if perm_ok = '1' and rc_ok = '1' then
525 v.state := RADIX_LOAD_TLB;
526 else
527 v.state := RADIX_FINISH;
528 v.perm_err := not perm_ok;
529 -- permission error takes precedence over RC error
530 v.rc_error := perm_ok;
531 end if;
532 """
533 # decode mode into something that matches microwatt equivalent code
534 instr_fetch, store = 0, 0
535 if mode == 'STORE':
536 store = 1
537 if mode == 'EXECUTE':
538 inst_fetch = 1
539
540 # check permissions and RC bits
541 perm_ok = 0
542 if priv == 1 or data[60] == 0:
543 if instr_fetch == 0:
544 perm_ok = data[62] | (data[61] & (store == 0))
545 # no IAMR, so no KUEP support for now
546 # deny execute permission if cache inhibited
547 perm_ok = data[63] & ~data[58]
548 rc_ok = data[55] & (data[56] | (store == 0))
549 if perm_ok == 1 and rc_ok == 1:
550 return True
551
552 return "perm_err" if perm_ok == 0 else "rc_err"
553
554 def _get_prtable_addr(self, shift, prtbl, addr, pid):
555 """
556 if r.addr(63) = '1' then
557 effpid := x"00000000";
558 else
559 effpid := r.pid;
560 end if;
561 x"00" & r.prtbl(55 downto 36) &
562 ((r.prtbl(35 downto 12) and not finalmask(23 downto 0)) or
563 (effpid(31 downto 8) and finalmask(23 downto 0))) &
564 effpid(7 downto 0) & "0000";
565 """
566 print ("_get_prtable_addr_", shift, prtbl, addr, pid)
567 finalmask = genmask(shift, 44)
568 finalmask24 = finalmask[20:44]
569 if addr[0].value == 1:
570 effpid = SelectableInt(0, 32)
571 else:
572 effpid = pid #self.pid # TODO, check on this
573 zero16 = SelectableInt(0, 16)
574 zero4 = SelectableInt(0, 4)
575 res = selectconcat(zero16,
576 prtbl[8:28], #
577 (prtbl[28:52] & ~finalmask24) | #
578 (effpid[0:24] & finalmask24), #
579 effpid[24:32],
580 zero4
581 )
582 return res
583
584 def _get_pgtable_addr(self, mask_size, pgbase, addrsh):
585 """
586 x"00" & r.pgbase(55 downto 19) &
587 ((r.pgbase(18 downto 3) and not mask) or (addrsh and mask)) &
588 "000";
589 """
590 mask16 = genmask(mask_size+5, 16)
591 zero8 = SelectableInt(0, 8)
592 zero3 = SelectableInt(0, 3)
593 res = selectconcat(zero8,
594 pgbase[8:45], #
595 (pgbase[45:61] & ~mask16) | #
596 (addrsh & mask16), #
597 zero3
598 )
599 return res
600
601 def _get_pte(self, shift, addr, pde):
602 """
603 x"00" &
604 ((r.pde(55 downto 12) and not finalmask) or
605 (r.addr(55 downto 12) and finalmask))
606 & r.pde(11 downto 0);
607 """
608 finalmask = genmask(shift, 44)
609 zero8 = SelectableInt(0, 8)
610 res = selectconcat(zero8,
611 (pde[8:52] & ~finalmask) | #
612 (addr[8:52] & finalmask), #
613 pde[52:64],
614 )
615 return res
616
617
618 class TestRadixMMU(unittest.TestCase):
619
620 def test_genmask(self):
621 shift = SelectableInt(5, 6)
622 mask = genmask(shift, 43)
623 print (" mask", bin(mask.value))
624
625 self.assertEqual(sum([1, 2, 3]), 6, "Should be 6")
626
627 def test_get_pgtable_addr(self):
628
629 mem = None
630 caller = None
631 dut = RADIX(mem, caller)
632
633 mask_size=4
634 pgbase = SelectableInt(0,64)
635 addrsh = SelectableInt(0,16)
636 ret = dut._get_pgtable_addr(mask_size, pgbase, addrsh)
637 print("ret=",ret)
638 assert(ret==0)
639
640 def test_walk_tree(self):
641 # set up dummy minimal ISACaller
642 spr = {'DSISR': SelectableInt(0, 64),
643 'DAR': SelectableInt(0, 64),
644 'PIDR': SelectableInt(0, 64),
645 'PRTBL': SelectableInt(0, 64)
646 }
647 # set problem state == 0 (other unit tests, set to 1)
648 msr = SelectableInt(0, 64)
649 msr[MSRb.PR] = 0
650 class ISACaller: pass
651 caller = ISACaller()
652 caller.spr = spr
653 caller.msr = msr
654
655 shift = SelectableInt(5, 6)
656 mask = genmask(shift, 43)
657 print (" mask", bin(mask.value))
658
659 mem = Mem(row_bytes=8)
660 mem = RADIX(mem, caller)
661 # -----------------------------------------------
662 # |/|RTS1|/| RPDB | RTS2 | RPDS |
663 # -----------------------------------------------
664 # |0|1 2|3|4 55|56 58|59 63|
665 data = SelectableInt(0, 64)
666 data[1:3] = 0b01
667 data[56:59] = 0b11
668 data[59:64] = 0b01101 # mask
669 data[55] = 1
670 (rts, mbits, pgbase) = mem._decode_prte(data)
671 print (" rts", bin(rts.value), rts.bits)
672 print (" mbits", bin(mbits.value), mbits.bits)
673 print (" pgbase", hex(pgbase.value), pgbase.bits)
674 addr = SelectableInt(0x1000, 64)
675 check = mem._segment_check(addr, mbits, shift)
676 print (" segment check", check)
677
678 print("walking tree")
679 addr = SelectableInt(testaddr,64)
680 # pgbase = None
681 mode = None
682 #mbits = None
683 shift = rts
684 result = mem._walk_tree(addr, pgbase, mode, mbits, shift)
685 print(" walking tree result", result)
686
687
688 if __name__ == '__main__':
689 unittest.main()