summaryrefslogtreecommitdiff
path: root/common/memory_commands.c
diff options
context:
space:
mode:
authorLouis Yung-Chieh Lo <yjlou@chromium.org>2011-12-07 18:57:21 +0000
committerVincent Palatin <vpalatin@chromium.org>2011-12-07 19:10:02 +0000
commit6396911897e4cd40f52636d710cee2865acf15e3 (patch)
treea7aa03f7716bd30edaf820afad3a1e36f79c426a /common/memory_commands.c
parentbdf7da5b082f6d18dd27f1e5d8cca0b12154a28c (diff)
downloadchrome-ec-6396911897e4cd40f52636d710cee2865acf15e3.tar.gz
Initial sources import 2/3
source files mainly done by Louis. Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Change-Id: I93fa38126e208cf3e525828b37bb407099686c6e
Diffstat (limited to 'common/memory_commands.c')
-rw-r--r--common/memory_commands.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/common/memory_commands.c b/common/memory_commands.c
new file mode 100644
index 0000000000..e54d567080
--- /dev/null
+++ b/common/memory_commands.c
@@ -0,0 +1,70 @@
+/* Copyright (c) 2011 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.
+ */
+
+/* System module for Chrome EC */
+
+#include "console.h"
+#include "registers.h"
+#include "uart.h"
+#include "util.h"
+#include "version.h"
+
+
+static int command_write_word(int argc, char **argv)
+{
+ volatile uint32_t *address;
+ uint32_t value;
+
+ if (argc != 3) {
+ uart_puts("Usage: ww <address> <value>\n");
+ return EC_ERROR_UNKNOWN;
+ }
+ address = (uint32_t*)strtoi(argv[1], NULL, 0);
+ value = strtoi(argv[2], NULL, 0);
+
+ uart_printf("write word 0x%p = 0x%08x\n", address, value);
+ uart_flush_output();
+
+ *address = value;
+
+ return EC_SUCCESS;
+}
+
+
+static int command_read_word(int argc, char **argv)
+{
+ volatile uint32_t *address;
+ uint32_t value;
+
+ if (argc != 2) {
+ uart_puts("Usage: rw <address>\n");
+ return EC_ERROR_UNKNOWN;
+ }
+ address = (uint32_t*)strtoi(argv[1], NULL, 0);
+ value = *address;
+
+ uart_printf("read word 0x%p = 0x%08x\n", address, value);
+ uart_flush_output();
+
+ return EC_SUCCESS;
+}
+
+
+static const struct console_command console_commands[] = {
+ {"rw", command_read_word},
+ {"ww", command_write_word},
+ {"readword", command_read_word},
+ {"writeword", command_write_word},
+};
+static const struct console_group command_group = {
+ "Memory", console_commands, ARRAY_SIZE(console_commands)
+};
+
+
+int memory_commands_init(void)
+{
+ /* Register our internal commands */
+ return console_register_commands(&command_group);
+}