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.
emac_membuf.cpp
00001 /* 00002 * Copyright (c) 2017, ARM Limited, All Rights Reserved 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00006 * not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #include "mbed.h" 00019 #include "greentea-client/test_env.h" 00020 #include "unity.h" 00021 #include "utest.h" 00022 00023 #include "mbed.h" 00024 00025 #include "EMAC.h" 00026 #include "EMACMemoryManager.h" 00027 #include "emac_TestMemoryManager.h" 00028 00029 #include "emac_initialize.h" 00030 #include "emac_membuf.h" 00031 #include "emac_util.h" 00032 00033 int emac_if_memory_buffer_read(void *buf, unsigned char *eth_frame) 00034 { 00035 int eth_frame_index = 0; 00036 int invalid_data_index = 0; 00037 00038 for (emac_mem_buf_t *mem_buf = buf; mem_buf != NULL; mem_buf = emac_m_mngr_get()->get_next(mem_buf)) { 00039 unsigned char *buf_payload = (unsigned char *) emac_m_mngr_get()->get_ptr(mem_buf); 00040 int buf_payload_len = emac_m_mngr_get()->get_len(mem_buf); 00041 00042 for (int index = 0; index < buf_payload_len; index++) { 00043 if (eth_frame_index < ETH_FRAME_HEADER_LEN) { 00044 eth_frame[eth_frame_index] = buf_payload[index]; 00045 } else { 00046 if (buf_payload[index] != (uint8_t) eth_frame_index) { 00047 invalid_data_index = eth_frame_index; 00048 break; 00049 } 00050 } 00051 eth_frame_index++; 00052 } 00053 } 00054 00055 return invalid_data_index; 00056 } 00057 00058 void emac_if_memory_buffer_write(void *buf, unsigned char *eth_frame, bool write_data) 00059 { 00060 int eth_frame_index = 0; 00061 00062 for (emac_mem_buf_t *mem_buf = buf; mem_buf != NULL; mem_buf = emac_m_mngr_get()->get_next(mem_buf)) { 00063 unsigned char *buf_payload = (unsigned char *) emac_m_mngr_get()->get_ptr(mem_buf); 00064 int buf_payload_len = emac_m_mngr_get()->get_len(mem_buf); 00065 00066 for (int index = 0; index < buf_payload_len; index++) { 00067 if (eth_frame_index < ETH_FRAME_HEADER_LEN) { 00068 buf_payload[index] = eth_frame[eth_frame_index]; 00069 } else if (write_data) { 00070 buf_payload[index] = (char) eth_frame_index; 00071 } else { 00072 break; 00073 } 00074 eth_frame_index++; 00075 } 00076 } 00077 }
Generated on Tue Aug 9 2022 00:37:06 by
1.7.2