|
| 1 | +#include "bget.h" |
| 2 | +#include <ti/drivers/dpl/HwiP.h> |
| 3 | +#include <ti/drivers/dpl/SwiP.h> |
| 4 | + |
| 5 | +typedef unsigned int dpl_CSState; |
| 6 | + |
| 7 | +typedef union _dpl_cs_state_union_t |
| 8 | +{ |
| 9 | + /** critical section variable as declared in the interface */ |
| 10 | + dpl_CSState state; |
| 11 | + /** @internal field used to access internal data */ |
| 12 | + struct _dpl_cs_state_aggr_t |
| 13 | + { |
| 14 | + /** field to store Swi_disable() return value */ |
| 15 | + uint_least16_t swikey; |
| 16 | + /** field to store Hwi_disable() return value */ |
| 17 | + uint_least16_t hwikey; |
| 18 | + } each; |
| 19 | +} dpl_CSStateUnion; |
| 20 | + |
| 21 | +/* This is enter critical section for DPL supported devices */ |
| 22 | +dpl_CSState dpl_enterCSImpl(void) |
| 23 | +{ |
| 24 | + |
| 25 | + dpl_CSStateUnion cu; |
| 26 | + cu.each.swikey = (uint_least16_t) SwiP_disable(); |
| 27 | + cu.each.hwikey = (uint_least16_t) HwiP_disable(); |
| 28 | + return cu.state; |
| 29 | +} |
| 30 | + |
| 31 | +/* This is exit critical section for DPL supported devices */ |
| 32 | +void dpl_leaveCSImpl(dpl_CSState key) |
| 33 | +{ |
| 34 | + dpl_CSStateUnion * cu = (dpl_CSStateUnion *) &key; |
| 35 | + HwiP_restore((uint32_t) cu->each.hwikey); |
| 36 | + SwiP_restore((uint32_t) cu->each.swikey); |
| 37 | +} |
| 38 | + |
| 39 | +/* Protected allocation */ |
| 40 | +void * pvPortMalloc(size_t xWantedSize) |
| 41 | +{ |
| 42 | + void * retVal = NULL; |
| 43 | + |
| 44 | + dpl_CSState state; |
| 45 | + state = dpl_enterCSImpl(); |
| 46 | + |
| 47 | + retVal = bget(xWantedSize); |
| 48 | + |
| 49 | + dpl_leaveCSImpl(state); |
| 50 | + return retVal; |
| 51 | +} |
| 52 | + |
| 53 | +/* Protected Deallocation */ |
| 54 | +void vPortFree(void * pv) |
| 55 | +{ |
| 56 | + dpl_CSState state; |
| 57 | + state = dpl_enterCSImpl(); |
| 58 | + |
| 59 | + brel(pv); |
| 60 | + |
| 61 | + dpl_leaveCSImpl(state); |
| 62 | +} |
| 63 | + |
| 64 | +void * pvPortRealloc(void * pv, size_t size) |
| 65 | +{ |
| 66 | + void * retVal = NULL; |
| 67 | + |
| 68 | + dpl_CSState state; |
| 69 | + state = dpl_enterCSImpl(); |
| 70 | + |
| 71 | + retVal = bgetr(pv, size); |
| 72 | + |
| 73 | + dpl_leaveCSImpl(state); |
| 74 | + return retVal; |
| 75 | +} |
0 commit comments