1 from nmigen
import Signal
2 from nmigen
.cli
import main
4 # The purpose of this Module is to check the Permissions of a given PTE
5 # against the requested access permissions.
6 # This module will either validate (by setting the valid bit HIGH) the request
7 # or find a permission fault and invalidate (by setting the valid bit LOW)
11 # data_size: (bit count) The size of the data words being processed
14 # 1. Data is valid -> valid is HIGH
15 # 2. Data is not valid -> valid is LOW
16 class PermissionValidator():
17 def __init__(self
, data_size
):
19 self
.data
= Signal(data_size
);
20 self
.xwr
= Signal(3) # Execute, Write, Read
21 self
.super = Signal(1) # Supervisor Mode
22 self
.super_access
= Signal(1) # Supervisor Access
23 self
.asid
= Signal(15) # Address Space IDentifier (ASID)
26 self
.valid
= Signal(1) # Denotes if the permissions are correct
28 def elaborate(self
, platform
):
31 # Check if ASID matches OR entry is global
32 If(data
[64:78] == self
.asid
or data
[5] == 1,
33 # Check Execute, Write, Read (XWR) Permissions
34 If(data
[3] == self
.xwr
[2] and data
[2] == self
.xwr
[1] \
35 and data
[1] == self
.xwr
[0],
38 # Check if entry is in user mode
39 # Check if supervisor has access
42 ).Elif(self
.super_access
== 1,
48 # Check if entry is in user mode