From 6650f694f2682dad3c5d4326c7c34913a82f46e0 Mon Sep 17 00:00:00 2001 From: Krzysztof Mazur Date: Tue, 22 Aug 2017 21:14:06 +0200 Subject: [PATCH] add support for rational period Signed-off-by: Krzysztof Mazur --- src/gcp.h | 2 ++ src/grader-ctl.c | 2 ++ src/rtunit-comm.c | 10 ++++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gcp.h b/src/gcp.h index e66dd8e..1ea3208 100644 --- a/src/gcp.h +++ b/src/gcp.h @@ -164,5 +164,7 @@ #define GCP_CPSCHED_BACKOFF_TIME 0x019 /* microseconds */ #define GCP_CPSCHED_START_AFTER 0x01a #define GCP_CPSCHED_EVENT_DELAY 0x01b /* microseconds */ +#define GCP_CPSCHED_PERIOD_N 0x01c /* position numerator */ +#define GCP_CPSCHED_PERIOD_D 0x01d /* position denominator */ #endif diff --git a/src/grader-ctl.c b/src/grader-ctl.c index ece1f74..eccf2ad 100644 --- a/src/grader-ctl.c +++ b/src/grader-ctl.c @@ -432,6 +432,8 @@ static int parse_cmd(const char *cmd) { "start-after", GCP_CPSCHED_START_AFTER }, { "add-event", GCP_CADD_EVENT }, { "event-delay", GCP_CPSCHED_EVENT_DELAY }, + { "period-n", GCP_CPSCHED_PERIOD_N }, + { "period-d", GCP_CPSCHED_PERIOD_D }, { NULL, 0 }, }; diff --git a/src/rtunit-comm.c b/src/rtunit-comm.c index 48e0710..30d8116 100644 --- a/src/rtunit-comm.c +++ b/src/rtunit-comm.c @@ -130,7 +130,8 @@ static struct pu_buff *gcp_psched_ack(unsigned int command, if (command == GCP_CPSCHED_START || command == GCP_CPSCHED_START || command == GCP_CPSCHED_SYNC - || command == GCP_CPSCHED_PERIOD) + || command == GCP_CPSCHED_PERIOD + || command == GCP_CPSCHED_PERIOD_N) value <<= 32 - GCP_PSCHED_VALUE_BITS; if (is_write) @@ -250,7 +251,7 @@ static void gcp_receive_seqcmd_ack(unsigned int hdr, const u32 *frame) payload = le32_to_cpu(frame[GCP_PAYLOAD]); info("got response: payload: %08x", payload); if (command >= GCP_CPSCHED_SYNC - && command <= GCP_CPSCHED_EVENT_DELAY) { + && command <= GCP_CPSCHED_PERIOD_D) { skb = gcp_psched_ack(command, payload); } else if (command >= GCP_CADD_EVENT) { skb = gcp_cadd_event_ack(command, payload); @@ -434,7 +435,8 @@ static int gcp_format_payload_param(unsigned int command, struct pu_buff *skb, *payload = id << GCP_PSCHED_ID_SHIFT; if (command == GCP_CPSCHED_START || command == GCP_CPSCHED_START || command == GCP_CPSCHED_SYNC - || command == GCP_CPSCHED_PERIOD) { + || command == GCP_CPSCHED_PERIOD + || command == GCP_CPSCHED_PERIOD_N) { value += (1 << (32 - GCP_PSCHED_VALUE_BITS)) / 2; value >>= 32 - GCP_PSCHED_VALUE_BITS; } @@ -478,7 +480,7 @@ static int gcp_format_payload(unsigned int command, struct pu_buff *skb, u32 *payload) { if (command >= GCP_CPSCHED_SYNC - && command <= GCP_CPSCHED_EVENT_DELAY) { + && command <= GCP_CPSCHED_PERIOD_D) { return gcp_format_payload_param(command, skb, payload); } else if (command == GCP_CADD_EVENT) { return gcp_format_payload_cadd_event(command, skb, payload); -- 2.10.2