Files
OpenCellular/include/shared_mem.h
Randall Spangler 371d06bbfd Tidy shared memory module
Adds shmem command to print amount of shared memory.  This is also a
useful indicator of how much IRAM is left, since shared memory will
expand to fill all unused IRAM.

Removes never-implemented wait param to shared_mem_acquire().

BUG=none
TEST=shmem

Change-Id: I798ff644d701dcba52219b70bec99c06a23d03ec
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29809
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-08-09 17:40:37 -07:00

51 lines
1.4 KiB
C

/* 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.
*/
/*
* Shared memory interface for Chrome EC.
*
* This is intended to supply a relatively large block of memory for use by a
* task for a relatively short amount of time. For example, verified boot may
* need a buffer to hold signature data during a verification operation. It is
* NOT intended for allocating long-term buffers; those should in general be
* static variables allocated at compile-time. It is NOT a full-featured
* replacement for malloc() / free().
*/
#ifndef __CROS_EC_SHARED_MEM_H
#define __CROS_EC_SHARED_MEM_H
#include "common.h"
/**
* Initializes the module.
*/
int shared_mem_init(void);
/**
* Returns the maximum amount of shared memory which can be acquired, in
* bytes.
*/
int shared_mem_size(void);
/**
* Acquires a shared memory area of the requested size in bytes.
*
* @param size Number of bytes requested
* @param dest_ptr If successful, set on return to the start of the
* granted memory buffer.
*
* @return EC_SUCCESS if successful, EC_ERROR_BUSY if buffer in use, or
* other non-zero error code.
*/
int shared_mem_acquire(int size, char **dest_ptr);
/**
* Releases a shared memory area previously allocated via shared_mem_acquire().
*/
void shared_mem_release(void *ptr);
#endif /* __CROS_EC_SHARED_MEM_H */