Pinned to some recent date
features/netsocket/emac_stack_mem.h@0:fb7af294d5d9, 2016-11-17 (annotated)
- Committer:
- Simon Cooksey
- Date:
- Thu Nov 17 16:43:53 2016 +0000
- Revision:
- 0:fb7af294d5d9
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Simon Cooksey |
0:fb7af294d5d9 | 1 | /* mbed Microcontroller Library |
Simon Cooksey |
0:fb7af294d5d9 | 2 | * Copyright (c) 2016 ARM Limited |
Simon Cooksey |
0:fb7af294d5d9 | 3 | * |
Simon Cooksey |
0:fb7af294d5d9 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Simon Cooksey |
0:fb7af294d5d9 | 5 | * you may not use this file except in compliance with the License. |
Simon Cooksey |
0:fb7af294d5d9 | 6 | * You may obtain a copy of the License at |
Simon Cooksey |
0:fb7af294d5d9 | 7 | * |
Simon Cooksey |
0:fb7af294d5d9 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Simon Cooksey |
0:fb7af294d5d9 | 9 | * |
Simon Cooksey |
0:fb7af294d5d9 | 10 | * Unless required by applicable law or agreed to in writing, software |
Simon Cooksey |
0:fb7af294d5d9 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Simon Cooksey |
0:fb7af294d5d9 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Simon Cooksey |
0:fb7af294d5d9 | 13 | * See the License for the specific language governing permissions and |
Simon Cooksey |
0:fb7af294d5d9 | 14 | * limitations under the License. |
Simon Cooksey |
0:fb7af294d5d9 | 15 | */ |
Simon Cooksey |
0:fb7af294d5d9 | 16 | #ifndef MBED_EMAC_STACK_MEM_H |
Simon Cooksey |
0:fb7af294d5d9 | 17 | #define MBED_EMAC_STACK_MEM_H |
Simon Cooksey |
0:fb7af294d5d9 | 18 | |
Simon Cooksey |
0:fb7af294d5d9 | 19 | #if DEVICE_EMAC |
Simon Cooksey |
0:fb7af294d5d9 | 20 | |
Simon Cooksey |
0:fb7af294d5d9 | 21 | #include <stdint.h> |
Simon Cooksey |
0:fb7af294d5d9 | 22 | |
Simon Cooksey |
0:fb7af294d5d9 | 23 | /** |
Simon Cooksey |
0:fb7af294d5d9 | 24 | * Stack memory module |
Simon Cooksey |
0:fb7af294d5d9 | 25 | * |
Simon Cooksey |
0:fb7af294d5d9 | 26 | * This interface provides abstraction for memory modules used in different IP stacks (often to accommodate zero copy). |
Simon Cooksey |
0:fb7af294d5d9 | 27 | * Emac interface may be required to accept output packets and provide received data using this stack specific API. |
Simon Cooksey |
0:fb7af294d5d9 | 28 | * This header should be implemented for each IP stack, so that we keep emacs module independent. |
Simon Cooksey |
0:fb7af294d5d9 | 29 | */ |
Simon Cooksey |
0:fb7af294d5d9 | 30 | typedef void emac_stack_mem_t; |
Simon Cooksey |
0:fb7af294d5d9 | 31 | typedef void emac_stack_mem_chain_t; |
Simon Cooksey |
0:fb7af294d5d9 | 32 | typedef void emac_stack_t; |
Simon Cooksey |
0:fb7af294d5d9 | 33 | |
Simon Cooksey |
0:fb7af294d5d9 | 34 | /** |
Simon Cooksey |
0:fb7af294d5d9 | 35 | * Allocates stack memory |
Simon Cooksey |
0:fb7af294d5d9 | 36 | * |
Simon Cooksey |
0:fb7af294d5d9 | 37 | * @param stack Emac stack context |
Simon Cooksey |
0:fb7af294d5d9 | 38 | * @param size Size of memory to allocate |
Simon Cooksey |
0:fb7af294d5d9 | 39 | * @param align Memory alignment requirements |
Simon Cooksey |
0:fb7af294d5d9 | 40 | * @return Allocated memory struct, or NULL in case of error |
Simon Cooksey |
0:fb7af294d5d9 | 41 | */ |
Simon Cooksey |
0:fb7af294d5d9 | 42 | emac_stack_mem_t *emac_stack_mem_alloc(emac_stack_t* stack, uint32_t size, uint32_t align); |
Simon Cooksey |
0:fb7af294d5d9 | 43 | |
Simon Cooksey |
0:fb7af294d5d9 | 44 | /** |
Simon Cooksey |
0:fb7af294d5d9 | 45 | * Free memory allocated using @a stack_mem_alloc |
Simon Cooksey |
0:fb7af294d5d9 | 46 | * |
Simon Cooksey |
0:fb7af294d5d9 | 47 | * @param stack Emac stack context |
Simon Cooksey |
0:fb7af294d5d9 | 48 | * @param mem Memory to be freed |
Simon Cooksey |
0:fb7af294d5d9 | 49 | */ |
Simon Cooksey |
0:fb7af294d5d9 | 50 | void emac_stack_mem_free(emac_stack_t* stack, emac_stack_mem_t *mem); |
Simon Cooksey |
0:fb7af294d5d9 | 51 | |
Simon Cooksey |
0:fb7af294d5d9 | 52 | /** |
Simon Cooksey |
0:fb7af294d5d9 | 53 | * Return pointer to the payload |
Simon Cooksey |
0:fb7af294d5d9 | 54 | * |
Simon Cooksey |
0:fb7af294d5d9 | 55 | * @param stack Emac stack context |
Simon Cooksey |
0:fb7af294d5d9 | 56 | * @param mem Memory structure |
Simon Cooksey |
0:fb7af294d5d9 | 57 | * @return Pointer to the payload |
Simon Cooksey |
0:fb7af294d5d9 | 58 | */ |
Simon Cooksey |
0:fb7af294d5d9 | 59 | void *emac_stack_mem_ptr(emac_stack_t* stack, emac_stack_mem_t *mem); |
Simon Cooksey |
0:fb7af294d5d9 | 60 | |
Simon Cooksey |
0:fb7af294d5d9 | 61 | /** |
Simon Cooksey |
0:fb7af294d5d9 | 62 | * Return actual payload size |
Simon Cooksey |
0:fb7af294d5d9 | 63 | * |
Simon Cooksey |
0:fb7af294d5d9 | 64 | * @param stack Emac stack context |
Simon Cooksey |
0:fb7af294d5d9 | 65 | * @param mem Memory structure |
Simon Cooksey |
0:fb7af294d5d9 | 66 | * @return Size in bytes |
Simon Cooksey |
0:fb7af294d5d9 | 67 | */ |
Simon Cooksey |
0:fb7af294d5d9 | 68 | uint32_t emac_stack_mem_len(emac_stack_t* stack, emac_stack_mem_t *mem); |
Simon Cooksey |
0:fb7af294d5d9 | 69 | |
Simon Cooksey |
0:fb7af294d5d9 | 70 | /** |
Simon Cooksey |
0:fb7af294d5d9 | 71 | * Sets the actual payload size (the allocated payload size will not change) |
Simon Cooksey |
0:fb7af294d5d9 | 72 | * |
Simon Cooksey |
0:fb7af294d5d9 | 73 | * @param stack Emac stack context |
Simon Cooksey |
0:fb7af294d5d9 | 74 | * @param mem Memory structure |
Simon Cooksey |
0:fb7af294d5d9 | 75 | * @param len Actual payload size |
Simon Cooksey |
0:fb7af294d5d9 | 76 | */ |
Simon Cooksey |
0:fb7af294d5d9 | 77 | void emac_stack_mem_set_len(emac_stack_t* stack, emac_stack_mem_t *mem, uint32_t len); |
Simon Cooksey |
0:fb7af294d5d9 | 78 | |
Simon Cooksey |
0:fb7af294d5d9 | 79 | /** |
Simon Cooksey |
0:fb7af294d5d9 | 80 | * Returns first memory structure from the list and move the head to point to the next node |
Simon Cooksey |
0:fb7af294d5d9 | 81 | * |
Simon Cooksey |
0:fb7af294d5d9 | 82 | * @param stack Emac stack context |
Simon Cooksey |
0:fb7af294d5d9 | 83 | * @param list Pointer to the list |
Simon Cooksey |
0:fb7af294d5d9 | 84 | * @return First memory structure from the list |
Simon Cooksey |
0:fb7af294d5d9 | 85 | */ |
Simon Cooksey |
0:fb7af294d5d9 | 86 | emac_stack_mem_t *emac_stack_mem_chain_dequeue(emac_stack_t* stack, emac_stack_mem_chain_t **chain); |
Simon Cooksey |
0:fb7af294d5d9 | 87 | |
Simon Cooksey |
0:fb7af294d5d9 | 88 | /** |
Simon Cooksey |
0:fb7af294d5d9 | 89 | * Return total length of the memory chain |
Simon Cooksey |
0:fb7af294d5d9 | 90 | * |
Simon Cooksey |
0:fb7af294d5d9 | 91 | * @param stack Emac stack context |
Simon Cooksey |
0:fb7af294d5d9 | 92 | * @param chain Memory chain |
Simon Cooksey |
0:fb7af294d5d9 | 93 | * @return Chain length |
Simon Cooksey |
0:fb7af294d5d9 | 94 | */ |
Simon Cooksey |
0:fb7af294d5d9 | 95 | uint32_t emac_stack_mem_chain_len(emac_stack_t* stack, emac_stack_mem_chain_t *chain); |
Simon Cooksey |
0:fb7af294d5d9 | 96 | |
Simon Cooksey |
0:fb7af294d5d9 | 97 | /** |
Simon Cooksey |
0:fb7af294d5d9 | 98 | * Increases the reference counter for the memory |
Simon Cooksey |
0:fb7af294d5d9 | 99 | * |
Simon Cooksey |
0:fb7af294d5d9 | 100 | * @param stack Emac stack context |
Simon Cooksey |
0:fb7af294d5d9 | 101 | * @param mem Memory structure |
Simon Cooksey |
0:fb7af294d5d9 | 102 | */ |
Simon Cooksey |
0:fb7af294d5d9 | 103 | void emac_stack_mem_ref(emac_stack_t* stack, emac_stack_mem_t *mem); |
Simon Cooksey |
0:fb7af294d5d9 | 104 | |
Simon Cooksey |
0:fb7af294d5d9 | 105 | #endif /* DEVICE_EMAC */ |
Simon Cooksey |
0:fb7af294d5d9 | 106 | |
Simon Cooksey |
0:fb7af294d5d9 | 107 | #endif /* EMAC_MBED_STACK_MEM_h */ |