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 mbed-os by
emac_stack_mem.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2016 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef MBED_EMAC_STACK_MEM_H 00017 #define MBED_EMAC_STACK_MEM_H 00018 00019 #if DEVICE_EMAC 00020 00021 #include <stdint.h> 00022 00023 /** 00024 * Stack memory module 00025 * 00026 * This interface provides abstraction for memory modules used in different IP stacks (often to accommodate zero copy). 00027 * Emac interface may be required to accept output packets and provide received data using this stack specific API. 00028 * This header should be implemented for each IP stack, so that we keep emacs module independent. 00029 */ 00030 typedef void emac_stack_mem_t; 00031 typedef void emac_stack_mem_chain_t; 00032 typedef void emac_stack_t; 00033 00034 /** 00035 * Allocates stack memory 00036 * 00037 * @param stack Emac stack context 00038 * @param size Size of memory to allocate 00039 * @param align Memory alignment requirements 00040 * @return Allocated memory struct, or NULL in case of error 00041 */ 00042 emac_stack_mem_t *emac_stack_mem_alloc(emac_stack_t* stack, uint32_t size, uint32_t align); 00043 00044 /** 00045 * Free memory allocated using @a stack_mem_alloc 00046 * 00047 * @param stack Emac stack context 00048 * @param mem Memory to be freed 00049 */ 00050 void emac_stack_mem_free(emac_stack_t* stack, emac_stack_mem_t *mem); 00051 00052 /** 00053 * Return pointer to the payload 00054 * 00055 * @param stack Emac stack context 00056 * @param mem Memory structure 00057 * @return Pointer to the payload 00058 */ 00059 void *emac_stack_mem_ptr(emac_stack_t* stack, emac_stack_mem_t *mem); 00060 00061 /** 00062 * Return actual payload size 00063 * 00064 * @param stack Emac stack context 00065 * @param mem Memory structure 00066 * @return Size in bytes 00067 */ 00068 uint32_t emac_stack_mem_len(emac_stack_t* stack, emac_stack_mem_t *mem); 00069 00070 /** 00071 * Sets the actual payload size (the allocated payload size will not change) 00072 * 00073 * @param stack Emac stack context 00074 * @param mem Memory structure 00075 * @param len Actual payload size 00076 */ 00077 void emac_stack_mem_set_len(emac_stack_t* stack, emac_stack_mem_t *mem, uint32_t len); 00078 00079 /** 00080 * Returns first memory structure from the list and move the head to point to the next node 00081 * 00082 * @param stack Emac stack context 00083 * @param list Pointer to the list 00084 * @return First memory structure from the list 00085 */ 00086 emac_stack_mem_t *emac_stack_mem_chain_dequeue(emac_stack_t* stack, emac_stack_mem_chain_t **chain); 00087 00088 /** 00089 * Return total length of the memory chain 00090 * 00091 * @param stack Emac stack context 00092 * @param chain Memory chain 00093 * @return Chain length 00094 */ 00095 uint32_t emac_stack_mem_chain_len(emac_stack_t* stack, emac_stack_mem_chain_t *chain); 00096 00097 /** 00098 * Increases the reference counter for the memory 00099 * 00100 * @param stack Emac stack context 00101 * @param mem Memory structure 00102 */ 00103 void emac_stack_mem_ref(emac_stack_t* stack, emac_stack_mem_t *mem); 00104 00105 #endif /* DEVICE_EMAC */ 00106 00107 #endif /* EMAC_MBED_STACK_MEM_h */
Generated on Tue Jul 12 2022 13:15:47 by
