Fork of Smoothie to port to mbed non-LPC targets.
Fork of Smoothie by
libs/ahbmalloc.cpp@3:f151d08d335c, 2014-03-02 (annotated)
- Committer:
- Bigcheese
- Date:
- Sun Mar 02 06:33:08 2014 +0000
- Revision:
- 3:f151d08d335c
- Parent:
- 2:1df0b61d3b5a
Bunch of stuff. Need to locally merge in updated USB changes.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Michael J. Spencer |
2:1df0b61d3b5a | 1 | #include "ahbmalloc.h" |
Michael J. Spencer |
2:1df0b61d3b5a | 2 | |
Michael J. Spencer |
2:1df0b61d3b5a | 3 | #include <cstring> |
Michael J. Spencer |
2:1df0b61d3b5a | 4 | |
Michael J. Spencer |
2:1df0b61d3b5a | 5 | #include <cstdint> |
Michael J. Spencer |
2:1df0b61d3b5a | 6 | // #include <stdio.h> |
Michael J. Spencer |
2:1df0b61d3b5a | 7 | |
Michael J. Spencer |
2:1df0b61d3b5a | 8 | #include "platform_memory.h" |
Michael J. Spencer |
2:1df0b61d3b5a | 9 | |
Michael J. Spencer |
2:1df0b61d3b5a | 10 | void* ahbmalloc(size_t size, BANK bank) |
Michael J. Spencer |
2:1df0b61d3b5a | 11 | { |
Michael J. Spencer |
2:1df0b61d3b5a | 12 | switch(bank) |
Michael J. Spencer |
2:1df0b61d3b5a | 13 | { |
Michael J. Spencer |
2:1df0b61d3b5a | 14 | case AHB_BANK_0: |
Michael J. Spencer |
2:1df0b61d3b5a | 15 | return AHB0.alloc(size); |
Michael J. Spencer |
2:1df0b61d3b5a | 16 | case AHB_BANK_1: |
Michael J. Spencer |
2:1df0b61d3b5a | 17 | return AHB1.alloc(size); |
Michael J. Spencer |
2:1df0b61d3b5a | 18 | default: |
Michael J. Spencer |
2:1df0b61d3b5a | 19 | return NULL; |
Michael J. Spencer |
2:1df0b61d3b5a | 20 | } |
Michael J. Spencer |
2:1df0b61d3b5a | 21 | } |
Michael J. Spencer |
2:1df0b61d3b5a | 22 | |
Michael J. Spencer |
2:1df0b61d3b5a | 23 | void ahbfree(void* ptr, size_t size) |
Michael J. Spencer |
2:1df0b61d3b5a | 24 | { |
Michael J. Spencer |
2:1df0b61d3b5a | 25 | MemoryPool* m = MemoryPool::first; |
Michael J. Spencer |
2:1df0b61d3b5a | 26 | while (m) |
Michael J. Spencer |
2:1df0b61d3b5a | 27 | { |
Michael J. Spencer |
2:1df0b61d3b5a | 28 | if (m->has(ptr)) |
Michael J. Spencer |
2:1df0b61d3b5a | 29 | { |
Michael J. Spencer |
2:1df0b61d3b5a | 30 | m->dealloc(ptr); |
Michael J. Spencer |
2:1df0b61d3b5a | 31 | return; |
Michael J. Spencer |
2:1df0b61d3b5a | 32 | } |
Michael J. Spencer |
2:1df0b61d3b5a | 33 | m = m->next; |
Michael J. Spencer |
2:1df0b61d3b5a | 34 | } |
Michael J. Spencer |
2:1df0b61d3b5a | 35 | } |