summaryrefslogtreecommitdiff
path: root/common/shared_mem.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-04-19 16:10:11 -0700
committerRandall Spangler <rspangler@chromium.org>2012-04-19 18:15:18 -0700
commit13ad1c007bef3922e0aae8c7e2ef067a05eb0c06 (patch)
treeccba49c2460301a85e0abe050a27c734fde1acdb /common/shared_mem.c
parent24dafefb3a63c9e2111ff87c4595ceaff7182d20 (diff)
downloadchrome-ec-13ad1c007bef3922e0aae8c7e2ef067a05eb0c06.tar.gz
Implement HOOK_SYSJUMP and use it to preserve LPC host event mask
This also changes shared_mem to use all the remaining RAM, instead of reserving a fixed-size buffer. Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:9161 TEST=manual hostevent --> all masks should be 0 hostevent smi 0x12300000 hostevent --> should confirm SMI mask was set sysjump b hostevent --> should confirm SMI mask is still set reboot hostevent --> should confirm SMI mask is back to 0 Change-Id: Iccb6da6ccc93ee5036a3f478d24b717a462d9150
Diffstat (limited to 'common/shared_mem.c')
-rw-r--r--common/shared_mem.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/common/shared_mem.c b/common/shared_mem.c
index bff3ec6da3..63edd7e755 100644
--- a/common/shared_mem.c
+++ b/common/shared_mem.c
@@ -1,35 +1,30 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2012 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.
*/
/* Shared memory module for Chrome EC */
+#include "config.h"
+#include "link_defs.h"
#include "shared_mem.h"
-#include "uart.h"
+#include "system.h"
-/* Size of shared memory buffer */
-#define SHARED_MEM_SIZE 4096
-
-static char shared_buf[SHARED_MEM_SIZE];
-static int buf_in_use = 0;
-
-
-int shared_mem_init(void)
-{
- return EC_SUCCESS;
-}
+static int buf_in_use;
int shared_mem_size(void)
{
- return SHARED_MEM_SIZE;
+ /* Use all the RAM we can. The shared memory buffer is the
+ * last thing allocated from the start of RAM, so we can use
+ * everything up to the jump data at the end of RAM. */
+ return system_usable_ram_end() - (uint32_t)__shared_mem_buf;
}
int shared_mem_acquire(int size, int wait, char **dest_ptr)
{
- if (size > SHARED_MEM_SIZE || size <= 0)
+ if (size > shared_mem_size() || size <= 0)
return EC_ERROR_INVAL;
/* TODO: if task_start() hasn't been called, fail immediately
@@ -42,7 +37,7 @@ int shared_mem_acquire(int size, int wait, char **dest_ptr)
/* TODO: atomically acquire buf_in_use. */
buf_in_use = 1;
- *dest_ptr = shared_buf;
+ *dest_ptr = __shared_mem_buf;
return EC_SUCCESS;
}