summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2016-03-30 10:27:58 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-04-07 13:00:39 -0700
commitfa643a9fc754e6a5c18181ecb928fa9a5c12e7ae (patch)
tree25419df8ec4a379f9eb9fc1108422625299102ca /common
parent55032aa1236dc4f85485147f5927cfaf513def98 (diff)
downloadchrome-ec-fa643a9fc754e6a5c18181ecb928fa9a5c12e7ae.tar.gz
cr50: add support for creating multiple serial endpoints
CR50 will need three serial endpoints for the streaming AP and EC UART and exporting its own console through USB. This change adds a macro to create endpoints that can be recognized by the usb_serial driver. BUG=chrome-os-partner:50702 BRANCH=none TEST=Verify "/dev/google/Cr50*/serial/Blob" prints capital letters when lower case letters are input. Change-Id: Iddf2c957a00dc3cd5448a6a00de2cf61ef5dd84c Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/336441 Tested-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/blob.c113
-rw-r--r--common/build.mk1
2 files changed, 0 insertions, 114 deletions
diff --git a/common/blob.c b/common/blob.c
deleted file mode 100644
index 5e563598a3..0000000000
--- a/common/blob.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/* Copyright 2015 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Handle an opaque blob of data */
-
-#include "blob.h"
-#include "common.h"
-#include "console.h"
-#include "printf.h"
-#include "queue.h"
-#include "task.h"
-#include "util.h"
-
-#define CPRINTS(format, args...) cprints(CC_USB, format, ## args)
-
-#define INCOMING_QUEUE_SIZE 100
-#define OUTGOING_QUEUE_SIZE 100
-
-
-static void incoming_add(struct queue_policy const *queue_policy, size_t count)
-{
- task_wake(TASK_ID_BLOB);
-}
-
-static void incoming_remove(struct queue_policy const *queue_policy,
- size_t count)
-{
- blob_is_ready_for_more_bytes();
-}
-
-static struct queue_policy const incoming_policy = {
- .add = incoming_add,
- .remove = incoming_remove,
-};
-
-static void outgoing_add(struct queue_policy const *queue_policy, size_t count)
-{
- blob_is_ready_to_emit_bytes();
-}
-
-static void outgoing_remove(struct queue_policy const *queue_policy,
- size_t count)
-{
- /* we don't care */
-}
-
-static struct queue_policy const outgoing_policy = {
- .add = outgoing_add,
- .remove = outgoing_remove,
-};
-
-static struct queue const incoming_q = QUEUE(INCOMING_QUEUE_SIZE, uint8_t,
- incoming_policy);
-
-static struct queue const outgoing_q = QUEUE(OUTGOING_QUEUE_SIZE, uint8_t,
- outgoing_policy);
-
-
-/* Call this to send data to the blob-handler */
-size_t put_bytes_to_blob(uint8_t *buffer, size_t count)
-{
- return QUEUE_ADD_UNITS(&incoming_q, buffer, count);
-}
-
-/* Call this to get data back fom the blob-handler */
-size_t get_bytes_from_blob(uint8_t *buffer, size_t count)
-{
- return QUEUE_REMOVE_UNITS(&outgoing_q, buffer, count);
-}
-
-#define WEAK_FUNC(FOO) \
- void __ ## FOO(void) {} \
- void FOO(void) \
- __attribute__((weak, alias(STRINGIFY(CONCAT2(__, FOO)))))
-
-/* Default callbacks for outsiders */
-WEAK_FUNC(blob_is_ready_for_more_bytes);
-WEAK_FUNC(blob_is_ready_to_emit_bytes);
-
-/* Do the magic */
-void blob_task(void)
-{
- static uint8_t buf[INCOMING_QUEUE_SIZE];
- size_t count, i;
- task_id_t me = task_get_current();
-
- while (1) {
- CPRINTS("task %d waiting for events...", me);
- task_wait_event(-1);
- CPRINTS("task %d awakened!", me);
-
- count = QUEUE_REMOVE_UNITS(&incoming_q, buf, sizeof(buf));
-
- CPRINTS("task %d gets: count=%d buf=((%s))", me, count, buf);
-
- /*
- * Just to have something to test to begin with, we'll
- * implement "tr a-zA-Z A-Za-z" and return the result.
- */
- for (i = 0; i < count; i++) {
- char tmp = buf[i];
- if (tmp >= 'a' && tmp <= 'z')
- buf[i] = tmp - ('a' - 'A');
- else if (tmp >= 'A' && tmp <= 'Z')
- buf[i] = tmp + ('a' - 'A');
- }
-
- count = QUEUE_ADD_UNITS(&outgoing_q, buf, count);
- CPRINTS("task %d puts: count=%d buf=((%s))", me, buf);
- }
-}
diff --git a/common/build.mk b/common/build.mk
index 4995cfe6e8..426f2d412f 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -89,7 +89,6 @@ common-$(CONFIG_USB_PD_TCPC)+=usb_pd_tcpc.o
common-$(CONFIG_VBOOT_HASH)+=sha256.o vboot_hash.o
common-$(CONFIG_VSTORE)+=vstore.o
common-$(CONFIG_WIRELESS)+=wireless.o
-common-$(HAS_TASK_BLOB)+=blob.o
common-$(HAS_TASK_CHIPSET)+=chipset.o
common-$(HAS_TASK_CONSOLE)+=console.o console_output.o uart_buffering.o
common-$(HAS_TASK_CONSOLE)+=memory_commands.o