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