From bca3db086637a97a0670c6bad633c8c0417a66cd Mon Sep 17 00:00:00 2001 From: "Wesley W. Terpstra" Date: Wed, 28 Jun 2017 14:07:40 -0700 Subject: [PATCH] diplomacy: add RWXC permissions also to ResourceMappings --- src/main/scala/coreplex/CoreplexNetwork.scala | 5 +++-- src/main/scala/diplomacy/JSON.scala | 6 +++--- src/main/scala/diplomacy/Resources.scala | 7 ++++--- src/main/scala/uncore/tilelink2/Parameters.scala | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/scala/coreplex/CoreplexNetwork.scala b/src/main/scala/coreplex/CoreplexNetwork.scala index 70eb30e4..afe42ecb 100644 --- a/src/main/scala/coreplex/CoreplexNetwork.scala +++ b/src/main/scala/coreplex/CoreplexNetwork.scala @@ -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, diff --git a/src/main/scala/diplomacy/JSON.scala b/src/main/scala/diplomacy/JSON.scala index e9632878..448e7b42 100644 --- a/src/main/scala/diplomacy/JSON.scala +++ b/src/main/scala/diplomacy/JSON.scala @@ -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) + "\"") diff --git a/src/main/scala/diplomacy/Resources.scala b/src/main/scala/diplomacy/Resources.scala index ffa0ec22..cbccb1ff 100644 --- a/src/main/scala/diplomacy/Resources.scala +++ b/src/main/scala/diplomacy/Resources.scala @@ -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") diff --git a/src/main/scala/uncore/tilelink2/Parameters.scala b/src/main/scala/uncore/tilelink2/Parameters.scala index 44ef9258..af2e8151 100644 --- a/src/main/scala/uncore/tilelink2/Parameters.scala +++ b/src/main/scala/uncore/tilelink2/Parameters.scala @@ -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)) } }