diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2016-12-14 21:31:25 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-01-05 21:13:09 -0800 |
commit | 32b064108a94fa163b5e9f9aef2b85615c68ee1d (patch) | |
tree | e5cd6fe1bf84f555d5aa32f7ab970eb9001f827e /common/build.mk | |
parent | 02d9c311ec93b3dc87f8c600b9f3653e3b13009a (diff) | |
download | chrome-ec-32b064108a94fa163b5e9f9aef2b85615c68ee1d.tar.gz |
common: introduce malloc/free implementation
The new code allows to replace the existing one buffer at a time
shared memory facility with a malloc/free implementation. A new
configuration option is being provided (CONFIG_MALLOC).
The names of functions allocating and freeing memory are not being
changed to allow to switch between the two implementations seamlessly.
A double linked list of buffers is used to keep track of free and
allocated memory. During initialization the entire free memory block
is considered a single free buffer. No allocations/frees are allowed
from within interrupts. The control structures are protected by a
semaphore, so allocate and free invocation could be blocking.
A test is added which randomly allocates and frees memory, continuing
until all branches in the allocate and free functions are taken.
BUG=chrome-os-partner:
TEST=make buildall -j succeeds, which includes testing the new
malloc/free implementation.
Change-Id: I5e71c0190c6c247ec73bb459f66a6d7a06e3d248
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/420466
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/build.mk')
-rw-r--r-- | common/build.mk | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/common/build.mk b/common/build.mk index df17dd0f22..02541536c7 100644 --- a/common/build.mk +++ b/common/build.mk @@ -40,7 +40,7 @@ common-$(CONFIG_CHARGER_V2)+=charge_state_v2.o common-$(CONFIG_CMD_I2CWEDGE)+=i2c_wedge.o common-$(CONFIG_COMMON_GPIO)+=gpio.o gpio_commands.o common-$(CONFIG_COMMON_PANIC_OUTPUT)+=panic_output.o -common-$(CONFIG_COMMON_RUNTIME)+=hooks.o main.o system.o shared_mem.o +common-$(CONFIG_COMMON_RUNTIME)+=hooks.o main.o system.o common-$(CONFIG_COMMON_TIMER)+=timer.o common-$(CONFIG_CRC8)+= crc8.o common-$(CONFIG_DEVICE_STATE)+=device_state.o @@ -114,6 +114,12 @@ common-$(HAS_TASK_LIGHTBAR)+=lb_common.o lightbar.o common-$(HAS_TASK_MOTIONSENSE)+=motion_sense.o common-$(HAS_TASK_TPM)+=tpm_registers.o +ifeq ($(CONFIG_MALLOC),y) +common-$(CONFIG_COMMON_RUNTIME)+=shmalloc.o +else +common-$(CONFIG_COMMON_RUNTIME)+=shared_mem.o +endif + ifeq ($(CTS_MODULE),) common-$(TEST_BUILD)+=test_util.o else |