diplomacy: add RWXC permissions also to ResourceMappings
This commit is contained in:
parent
5436be54ff
commit
bca3db0866
@ -118,14 +118,15 @@ trait CoreplexNetworkModule extends HasCoreplexParameters {
|
||||
private def collect(path: List[String], value: ResourceValue): List[(String, ResourceAddress)] = {
|
||||
value match {
|
||||
case r: ResourceAddress => List((path(1), r))
|
||||
case b: ResourceMapping => List((path(1), ResourceAddress(b.address, b.permissions)))
|
||||
case ResourceMap(value, _) => value.toList.flatMap { case (key, seq) => seq.flatMap(r => collect(key :: path, r)) }
|
||||
case _ => Nil
|
||||
}
|
||||
}
|
||||
private val ranges = collect(Nil, outer.bindingTree).groupBy(_._2).toList.flatMap { case (key, seq) =>
|
||||
AddressRange.fromSets(key.address).map { r => (r, key.r, key.w, key.x, key.c, seq.map(_._1)) }
|
||||
AddressRange.fromSets(key.address).map { r => (r, key.permissions, seq.map(_._1)) }
|
||||
}.sortBy(_._1)
|
||||
private val json = ranges.map { case (range, r, w, x, c, names) =>
|
||||
private val json = ranges.map { case (range, ResourcePermissions(r, w, x, c), names) =>
|
||||
println(fmt.format(
|
||||
range.base,
|
||||
range.base+range.size,
|
||||
|
@ -26,12 +26,12 @@ object JSON
|
||||
}
|
||||
|
||||
private def helper(res: ResourceValue)(implicit path: Map[String, String]): Seq[String] = res match {
|
||||
case ResourceAddress(address, r, w, x, c) =>
|
||||
case ResourceAddress(address, ResourcePermissions(r, w, x, c)) =>
|
||||
AddressRange.fromSets(address).map { case AddressRange(base, size) =>
|
||||
s"""{"base":${base},"size":${size},"r":${r},"w":${w},"x":${x},"c":${c}}"""}
|
||||
case ResourceMapping(address, offset) =>
|
||||
case ResourceMapping(address, offset, ResourcePermissions(r, w, x, c)) =>
|
||||
AddressRange.fromSets(address).map { case AddressRange(base, size) =>
|
||||
s"""{"base":${base},"size":${size},"offset":${offset}}"""}
|
||||
s"""{"base":${base},"size":${size},"offset":${offset},"r":${r},"w":${w},"x":${x},"c":${c}}"""}
|
||||
case ResourceInt(value) => Seq(value.toString)
|
||||
case ResourceString(value) => Seq("\"" + value + "\"")
|
||||
case ResourceReference(value) => Seq("\"&" + path(value) + "\"")
|
||||
|
@ -7,8 +7,9 @@ import config._
|
||||
import scala.collection.immutable.{ListMap,SortedMap}
|
||||
|
||||
sealed trait ResourceValue
|
||||
final case class ResourceAddress(address: Seq[AddressSet], r: Boolean, w: Boolean, x: Boolean, c: Boolean) extends ResourceValue
|
||||
final case class ResourceMapping(address: Seq[AddressSet], offset: BigInt) extends ResourceValue
|
||||
case class ResourcePermissions(r: Boolean, w: Boolean, x: Boolean, c: Boolean) // Not part of DTS
|
||||
final case class ResourceAddress(address: Seq[AddressSet], permissions: ResourcePermissions) extends ResourceValue
|
||||
final case class ResourceMapping(address: Seq[AddressSet], offset: BigInt, permissions: ResourcePermissions) extends ResourceValue
|
||||
final case class ResourceInt(value: BigInt) extends ResourceValue
|
||||
final case class ResourceString(value: String) extends ResourceValue
|
||||
final case class ResourceReference(value: String) extends ResourceValue
|
||||
@ -125,7 +126,7 @@ class SimpleBus(devname: String, devcompat: Seq[String], offset: BigInt = 0) ext
|
||||
{
|
||||
override def describe(resources: ResourceBindings): Description = {
|
||||
val ranges = resources("ranges").map {
|
||||
case Binding(_, a: ResourceAddress) => ResourceMapping(a.address, offset)
|
||||
case Binding(_, a: ResourceAddress) => ResourceMapping(a.address, offset, a.permissions)
|
||||
}
|
||||
require (!ranges.isEmpty, s"SimpleBus $devname must set ranges")
|
||||
|
||||
|
@ -57,11 +57,11 @@ case class TLManagerParameters(
|
||||
require (minAlignment >= maxTransfer, s"minAlignment ($minAlignment) must be >= maxTransfer ($maxTransfer)")
|
||||
|
||||
def toResource: ResourceAddress = {
|
||||
ResourceAddress(address,
|
||||
ResourceAddress(address, ResourcePermissions(
|
||||
r = supportsAcquireB || supportsGet,
|
||||
w = supportsAcquireT || supportsPutFull,
|
||||
x = executable,
|
||||
c = supportsAcquireB)
|
||||
c = supportsAcquireB))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user