summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorLee Leahy <leroy.p.leahy@intel.com>2016-04-23 07:58:27 -0700
committerLeroy P Leahy <leroy.p.leahy@intel.com>2016-04-30 15:40:20 +0200
commit6bcbe5749b9f1a82004299bb63fba7e99b8ed358 (patch)
treebed3efa66c5d56b50a78515b29184c7e39404bda /src/lib
parent733b39aed4b12aa1e6ec5b4b7db9bb48ba88e015 (diff)
downloadcoreboot-6bcbe5749b9f1a82004299bb63fba7e99b8ed358.tar.xz
lib/regscript: Add exclusive-or (xor) support
Add xor support which enables toggling of a bit: * REG_SCRIPT_COMMAND_RXW enum value * REG_*_RXW* macros to support using REG_SCRIPT_COMMAND_RXW * REG_*_XOR* macros to support using REG_SCRIPT_COMMAND_RXW * reg_script_rxw routine to perform and/xor operation * case in reg_script_run_step to call reg_script_rxw TEST=Build and run on Galileo Gen2 Change-Id: I50a492c7c2643df5dc2d2fa7113e3722c1e480c7 Signed-off-by: Lee Leahy <leroy.p.leahy@intel.com> Reviewed-on: https://review.coreboot.org/14495 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/reg_script.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/lib/reg_script.c b/src/lib/reg_script.c
index 7f8200006e..7530dc32b8 100644
--- a/src/lib/reg_script.c
+++ b/src/lib/reg_script.c
@@ -521,6 +521,41 @@ static void reg_script_rmw(struct reg_script_context *ctx)
reg_script_set_step(ctx, step);
}
+static void reg_script_rxw(struct reg_script_context *ctx)
+{
+ uint64_t value;
+ const struct reg_script *step = reg_script_get_step(ctx);
+ struct reg_script write_step = *step;
+
+/*
+ * XOR logic table
+ * Input XOR Value
+ * 0 0 0
+ * 0 1 1
+ * 1 0 1
+ * 1 1 0
+ *
+ * Supported operations
+ *
+ * Input Mask Temp XOR Value Operation
+ * 0 0 0 0 0 Clear bit
+ * 1 0 0 0 0
+ * 0 0 0 1 1 Set bit
+ * 1 0 0 1 1
+ * 0 1 0 0 0 Preserve bit
+ * 1 1 1 0 1
+ * 0 1 0 1 1 Toggle bit
+ * 1 1 1 1 0
+ */
+ value = reg_script_read(ctx);
+ value &= step->mask;
+ value ^= step->value;
+ write_step.value = value;
+ reg_script_set_step(ctx, &write_step);
+ reg_script_write(ctx);
+ reg_script_set_step(ctx, step);
+}
+
/* In order to easily chain scripts together handle the REG_SCRIPT_COMMAND_NEXT
* as recursive call with a new context that has the same dev and resource
* as the previous one. That will run to completion and then move on to the
@@ -544,6 +579,9 @@ static void reg_script_run_step(struct reg_script_context *ctx,
case REG_SCRIPT_COMMAND_RMW:
reg_script_rmw(ctx);
break;
+ case REG_SCRIPT_COMMAND_RXW:
+ reg_script_rxw(ctx);
+ break;
case REG_SCRIPT_COMMAND_POLL:
for (try = 0; try < step->timeout; try += POLL_DELAY) {
value = reg_script_read(ctx) & step->mask;