diff options
author | Hanhui <hanhui@acoinfo.com> | 2020-07-23 17:18:28 (GMT) |
---|---|---|
committer | Hanhui <hanhui@acoinfo.com> | 2020-07-23 17:18:28 (GMT) |
commit | 8e58c89af9a0c3b0656fe53064330911c56fe489 (patch) | |
tree | b1a861a5afb31fdd0ab849b457edb1b2abcf8e5f /SylixOS | |
parent | b4279ee1b1591c21f9f452c8d4271c0336704a1a (diff) | |
download | libsylixos-8e58c89af9a0c3b0656fe53064330911c56fe489.zip libsylixos-8e58c89af9a0c3b0656fe53064330911c56fe489.tar.gz libsylixos-8e58c89af9a0c3b0656fe53064330911c56fe489.tar.bz2 |
Add IP route user custom hook and fixed DNS select bug.
Diffstat (limited to 'SylixOS')
-rw-r--r-- | SylixOS/config/net/net_cfg.h | 4 | ||||
-rw-r--r-- | SylixOS/kernel/include/k_kernel.h | 2 | ||||
-rw-r--r-- | SylixOS/net/lwip/lwip_config.h | 11 | ||||
-rw-r--r-- | SylixOS/net/lwip/lwip_fix.c | 14 | ||||
-rw-r--r-- | SylixOS/net/lwip/lwip_hook.h | 4 | ||||
-rw-r--r-- | SylixOS/net/lwip/lwip_iphook.c | 104 | ||||
-rw-r--r-- | SylixOS/net/lwip/lwip_iphook.h | 16 | ||||
-rw-r--r-- | SylixOS/net/lwip/src/api/api_lib.c | 5 | ||||
-rw-r--r-- | SylixOS/net/lwip/src/core/netif.c | 2 | ||||
-rw-r--r-- | SylixOS/net/lwip/tools/ppp/lwip_ppp.c | 49 | ||||
-rw-r--r-- | SylixOS/shell/ttinyShell/ttinyShellColor.c | 10 | ||||
-rw-r--r-- | SylixOS/system/device/ahci/ahci.c | 34 | ||||
-rw-r--r-- | SylixOS/system/device/spipe/spipeLib.c | 9 |
13 files changed, 233 insertions, 31 deletions
diff --git a/SylixOS/config/net/net_cfg.h b/SylixOS/config/net/net_cfg.h index c517dc8..3ba45e4 100644 --- a/SylixOS/config/net/net_cfg.h +++ b/SylixOS/config/net/net_cfg.h @@ -37,8 +37,8 @@ #define LW_CFG_NET_MROUTER 1 /* 配置为支持组播路由模式 */ #define LW_CFG_NET_BALANCING 1 /* 源地址流量均衡路由支持 */ #define LW_CFG_NET_IPV6 1 /* 是否使能 IPv6 协议支持 */ -#define LW_CFG_NET_SAFE 1 /* 全双工安全选项 (实验性) */ - +#define LW_CFG_NET_SAFE 1 /* 1: 全双工安全选项 */ + /* 2: 全双工 + 删除安全 */ /********************************************************************************************************* * 基本设置 * 依存关系: 1: 计数信号量, 读写锁 diff --git a/SylixOS/kernel/include/k_kernel.h b/SylixOS/kernel/include/k_kernel.h index c41165c..6dbbb2f 100644 --- a/SylixOS/kernel/include/k_kernel.h +++ b/SylixOS/kernel/include/k_kernel.h @@ -51,7 +51,7 @@ #define __SYLIXOS_MAJOR_VER 1 #define __SYLIXOS_MINOR_VER 12 -#define __SYLIXOS_PATCH_VER 5 +#define __SYLIXOS_PATCH_VER 6 #define __SYLIXOS_PATCH_PAD 0 /********************************************************************************************************* diff --git a/SylixOS/net/lwip/lwip_config.h b/SylixOS/net/lwip/lwip_config.h index 7dcfd99..6829871 100644 --- a/SylixOS/net/lwip/lwip_config.h +++ b/SylixOS/net/lwip/lwip_config.h @@ -51,7 +51,16 @@ extern "C" { #define SYS_LIGHTWEIGHT_PROT 1 #define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS 1 -#define LWIP_MPU_COMPATIBLE 0 /* Do not use MPU support. */ + +/********************************************************************************************************* + Thread stack safe +*********************************************************************************************************/ + +#if LW_CFG_NET_SAFE > 1 +#define LWIP_MPU_COMPATIBLE 1 +#else +#define LWIP_MPU_COMPATIBLE 0 +#endif /********************************************************************************************************* Platform memcpy smemcpy diff --git a/SylixOS/net/lwip/lwip_fix.c b/SylixOS/net/lwip/lwip_fix.c index 13ac8f7..4f9b6c5 100644 --- a/SylixOS/net/lwip/lwip_fix.c +++ b/SylixOS/net/lwip/lwip_fix.c @@ -1239,6 +1239,10 @@ int ip6_input_hook (struct pbuf *p, struct netif *pnetif) return (0); /* do not eaten packet */ } /********************************************************************************************************* + User Route Hook +*********************************************************************************************************/ +extern struct netif *lwip_ip_route_hook(int ip_type, const void *src, const void *dest); +/********************************************************************************************************* ** 函数名称: ip_route_src_hook ** 功能描述: sylixos ip route hook ** 输 入 : pipsrc source address @@ -1252,6 +1256,11 @@ struct netif *ip_route_src_hook (const ip4_addr_t *pipsrc, const ip4_addr_t *pip #if LW_CFG_NET_ROUTER > 0 struct netif *netif; + netif = lwip_ip_route_hook(4, pipsrc, pipdest); /* IP_HOOK_V4 == 4 */ + if (netif) { + return (netif); + } + #if LW_CFG_NET_BALANCING > 0 netif = srt_route_search_hook(pipsrc, pipdest); /* source route first */ #else @@ -1323,6 +1332,11 @@ struct netif *ip6_route_src_hook (const ip6_addr_t *pip6src, const ip6_addr_t *p #if LW_CFG_NET_ROUTER > 0 struct netif *netif; + netif = lwip_ip_route_hook(6, pip6src, pip6dest); /* IP_HOOK_V6 == 6 */ + if (netif) { + return (netif); + } + #if LW_CFG_NET_BALANCING > 0 netif = srt6_route_search_hook(pip6src, pip6dest); /* source route first */ #else diff --git a/SylixOS/net/lwip/lwip_hook.h b/SylixOS/net/lwip/lwip_hook.h index 8246267..20ff4ec 100644 --- a/SylixOS/net/lwip/lwip_hook.h +++ b/SylixOS/net/lwip/lwip_hook.h @@ -105,8 +105,8 @@ extern int ethernet_vlan_check_hook(struct netif *pnetif, const struct eth_hdr * ip hook *********************************************************************************************************/ -extern int lwip_ip_hook(int ip_type, int hook_type, struct pbuf *p, struct netif *in, struct netif *out); -struct pbuf *lwip_ip_nat_hook(int ip_type, int hook_type, struct pbuf *p, struct netif *in, struct netif *out); +extern int lwip_ip_hook(int ip_type, int hook_type, struct pbuf *p, struct netif *in, struct netif *out); +extern struct pbuf *lwip_ip_nat_hook(int ip_type, int hook_type, struct pbuf *p, struct netif *in, struct netif *out); #endif /* __LWIP_HOOK_H */ /********************************************************************************************************* diff --git a/SylixOS/net/lwip/lwip_iphook.c b/SylixOS/net/lwip/lwip_iphook.c index 6af3a9c..b9b1a69 100644 --- a/SylixOS/net/lwip/lwip_iphook.c +++ b/SylixOS/net/lwip/lwip_iphook.c @@ -43,6 +43,7 @@ typedef IP_HOOK_NODE *PIP_HOOK_NODE; *********************************************************************************************************/ static LW_LIST_LINE_HEADER _G_plineIpHook; static struct pbuf *(*_G_pfuncIpHookNat)(); +static struct netif *(*_G_pfuncIpHookRoute)(); /********************************************************************************************************* ** 函数名称: lwip_ip_hook ** 功能描述: lwip ip 回调函数 @@ -88,12 +89,29 @@ struct pbuf *lwip_ip_nat_hook (int ip_type, int hook_type, struct pbuf *p, struc { if (_G_pfuncIpHookNat) { return (_G_pfuncIpHookNat(ip_type, hook_type, p, in, out)); - } else { return (p); } } /********************************************************************************************************* +** 函数名称: lwip_ip_route_hook +** 功能描述: lwip ROUTE 回调函数 +** 输 入 : ip_type ip 类型 IP_HOOK_V4 / IP_HOOK_V6 +** src 源地址 +** dest 目的地址 +** 输 出 : netif +** 全局变量: +** 调用模块: +*********************************************************************************************************/ +struct netif *lwip_ip_route_hook (int ip_type, const void *src, const void *dest) +{ + if (_G_pfuncIpHookRoute) { + return (_G_pfuncIpHookRoute(ip_type, src, dest)); + } else { + return (LW_NULL); + } +} +/********************************************************************************************************* ** 函数名称: net_ip_hook_add ** 功能描述: lwip ip 添加回调函数 ** 输 入 : name ip 回调类型 @@ -314,6 +332,90 @@ int net_ip_hook_nat_isadd (struct pbuf *(*hook)(int ip_type, int hook_type, str return (ERROR_NONE); } /********************************************************************************************************* +** 函数名称: net_ip_hook_route_add +** 功能描述: lwip ip 添加回调函数 +** 输 入 : hook 回调函数 +** 输 出 : -1: 失败 +** 0: 成功 +** 全局变量: +** 调用模块: +*********************************************************************************************************/ +int net_ip_hook_route_add (struct netif *(*hook)(int ip_type, const void *src, const void *dest)) +{ + if (!hook) { + _ErrorHandle(EINVAL); + return (PX_ERROR); + } + + LOCK_TCPIP_CORE(); + if (_G_pfuncIpHookRoute) { + UNLOCK_TCPIP_CORE(); + _ErrorHandle(EBUSY); + return (PX_ERROR); + } + + _G_pfuncIpHookRoute = hook; + UNLOCK_TCPIP_CORE(); + + return (ERROR_NONE); +} +/********************************************************************************************************* +** 函数名称: net_ip_hook_route_delete +** 功能描述: lwip ip 删除 ROUTE 专用回调函数 +** 输 入 : hook 回调函数 +** 输 出 : -1: 失败 +** 0: 成功 +** 全局变量: +** 调用模块: +*********************************************************************************************************/ +int net_ip_hook_route_delete (struct netif *(*hook)(int ip_type, const void *src, const void *dest)) +{ + if (!hook) { + _ErrorHandle(EINVAL); + return (PX_ERROR); + } + + LOCK_TCPIP_CORE(); + if (_G_pfuncIpHookRoute != hook) { + UNLOCK_TCPIP_CORE(); + _ErrorHandle(EINVAL); + return (PX_ERROR); + } + + _G_pfuncIpHookRoute = LW_NULL; + UNLOCK_TCPIP_CORE(); + + return (ERROR_NONE); +} +/********************************************************************************************************* +** 函数名称: net_ip_hook_route_isadd +** 功能描述: lwip ip 回调函数是否已经安装 +** 输 入 : hook 回调函数 +** pbIsAdd 是否已经添加了 +** 输 出 : -1: 失败 +** 0: 成功 +** 全局变量: +** 调用模块: +*********************************************************************************************************/ +int net_ip_hook_route_isadd (struct netif *(*hook)(int ip_type, const void *src, const void *dest), BOOL *pbIsAdd) +{ + if (!hook || !pbIsAdd) { + _ErrorHandle(EINVAL); + return (PX_ERROR); + } + + LOCK_TCPIP_CORE(); + if (_G_pfuncIpHookRoute != hook) { + *pbIsAdd = LW_FALSE; + + } else { + *pbIsAdd = LW_TRUE; + } + UNLOCK_TCPIP_CORE(); + + return (ERROR_NONE); +} +/********************************************************************************************************* ** 函数名称: net_ip_hook_pbuf_set_ifout ** 功能描述: IP_HT_LOCAL_OUT 回调函数可通过此函数改变数据包发送网口 ** 输 入 : p 数据包 diff --git a/SylixOS/net/lwip/lwip_iphook.h b/SylixOS/net/lwip/lwip_iphook.h index 668a329..0d81be9 100644 --- a/SylixOS/net/lwip/lwip_iphook.h +++ b/SylixOS/net/lwip/lwip_iphook.h @@ -70,6 +70,12 @@ #define IP_HT_NAT_POST_ROUTING 4 /********************************************************************************************************* + 特殊路由回调 +*********************************************************************************************************/ + +#define IP_HT_ROUTING 0 + +/********************************************************************************************************* 通用回调类型内核函数 *********************************************************************************************************/ @@ -96,6 +102,16 @@ int net_ip_hook_nat_isadd(struct pbuf *(*hook)(int ip_type, int hook_type, stru struct netif *in, struct netif *out), BOOL *pbIsAdd); /********************************************************************************************************* + 特殊路由回调 +*********************************************************************************************************/ + +int net_ip_hook_route_add(struct netif *(*hook)(int ip_type, const void *src, const void *dest)); + +int net_ip_hook_route_delete(struct netif *(*hook)(int ip_type, const void *src, const void *dest)); + +int net_ip_hook_route_isadd(struct netif *(*hook)(int ip_type, const void *src, const void *dest), BOOL *pbIsAdd); + +/********************************************************************************************************* 设置 pbuf 成员 注意: 出于兼容性考虑, 不允许直接设置 if_out 成员变量. diff --git a/SylixOS/net/lwip/src/api/api_lib.c b/SylixOS/net/lwip/src/api/api_lib.c index 58e4977..41636e2 100644 --- a/SylixOS/net/lwip/src/api/api_lib.c +++ b/SylixOS/net/lwip/src/api/api_lib.c @@ -626,7 +626,7 @@ netconn_recv_data(struct netconn *conn, void **new_buf, u8_t apiflags) if (conn->flags & NETCONN_FLAG_MBOXINVALID) { if (lwip_netconn_is_deallocated_msg(buf)) { /* the netconn has been closed from another thread */ - API_MSG_VAR_FREE_ACCEPT(msg); + /* SylixOS remove: API_MSG_VAR_FREE_ACCEPT(msg); */ return ERR_CONN; } } @@ -1323,7 +1323,8 @@ netconn_gethostbyname(const char *name, ip_addr_t *addr) } #endif /* LWIP_NETCONN_SEM_PER_THREAD */ - cberr = tcpip_send_msg_wait_sem(lwip_netconn_do_gethostbyname, &API_VAR_REF(msg), API_EXPR_REF(API_VAR_REF(msg).sem)); + /* SylixOS Fixed here: change `API_EXPR_REF(API_VAR_REF(msg).sem)` to `API_VAR_REF(msg).sem` */ + cberr = tcpip_send_msg_wait_sem(lwip_netconn_do_gethostbyname, &API_VAR_REF(msg), API_VAR_REF(msg).sem); #if !LWIP_NETCONN_SEM_PER_THREAD sys_sem_free(API_EXPR_REF(API_VAR_REF(msg).sem)); #endif /* !LWIP_NETCONN_SEM_PER_THREAD */ diff --git a/SylixOS/net/lwip/src/core/netif.c b/SylixOS/net/lwip/src/core/netif.c index dbd9491..d56d15e 100644 --- a/SylixOS/net/lwip/src/core/netif.c +++ b/SylixOS/net/lwip/src/core/netif.c @@ -883,7 +883,7 @@ netif_set_default(struct netif *netif) netif_default = netif; #if defined(SYLIXOS) && LW_CFG_LWIP_DNS_SWITCH > 0 /* SylixOS Add */ - { + if (netif) { int i; for (i = 0; i < DNS_MAX_SERVERS; i++) { if (!ip_addr_isany_val(netif->dns_save[i])) { diff --git a/SylixOS/net/lwip/tools/ppp/lwip_ppp.c b/SylixOS/net/lwip/tools/ppp/lwip_ppp.c index ed9bc96..e20875b 100644 --- a/SylixOS/net/lwip/tools/ppp/lwip_ppp.c +++ b/SylixOS/net/lwip/tools/ppp/lwip_ppp.c @@ -35,6 +35,7 @@ #include "netif/ppp/pppapi.h" #include "netif/ppp/pppos.h" #include "lwip_ppp.h" +#include "net/if_lock.h" #include "net/if_event.h" #include "net/if_ether.h" /********************************************************************************************************* @@ -249,8 +250,13 @@ static VOID __pppOsThread (ppp_pcb *pcb) if ((pctxp->CTXP_bNeedDelete) && (pcb->phase == PPP_PHASE_DEAD)) { /* 需要删除 PPP 连接 */ - close(pctxp->CTXP_iFd); + LWIP_IF_LIST_LOCK(LW_TRUE); pppapi_free(pcb); + LWIP_IF_LIST_UNLOCK(); + + if (pctxp->CTXP_iFd >= 0) { + close(pctxp->CTXP_iFd); + } if (pctxp->CTXP_cUser) { lib_free(pctxp->CTXP_cUser); } @@ -495,8 +501,8 @@ __error_handle: ** 输 入 : pcEthIf 使用的以太网网卡名 ** pcIp 服务器地址 ** usPort 服务器端口 -** pcSecret 未使用 -** stSecretLen 未使用 +** pcSecret 安全密钥 +** stSecretLen 安全密钥长度 ** pcIfName 如果创建成功, 则返回网络设备名称 ** stMaxSize ifname 缓冲区大小 ** 输 出 : PPP 连接网卡是否安装成功 @@ -514,11 +520,12 @@ INT API_PppOl2tpCreate (CPCHAR pcEthIf, size_t stMaxSize) { INT iErrLevel = 0; + UINT8 *pucSecret; PPP_CTX_PRIV *pctxp; struct netif *netif; ip_addr_t ipaddr; - if (!pcEthIf || !pcIp || !usPort || !pcIfName || (stMaxSize < IF_NAMESIZE)) { + if (!pcIp || !usPort || !pcIfName || (stMaxSize < IF_NAMESIZE)) { _ErrorHandle(EINVAL); return (PX_ERROR); } @@ -528,18 +535,26 @@ INT API_PppOl2tpCreate (CPCHAR pcEthIf, return (PX_ERROR); } - pctxp = (PPP_CTX_PRIV *)__SHEAP_ALLOC(sizeof(PPP_CTX_PRIV)); + if (pcSecret && stSecretLen) { + pctxp = (PPP_CTX_PRIV *)__SHEAP_ALLOC(sizeof(PPP_CTX_PRIV) + stSecretLen); + } else { + pctxp = (PPP_CTX_PRIV *)__SHEAP_ALLOC(sizeof(PPP_CTX_PRIV)); + } if (pctxp == LW_NULL) { _ErrorHandle(ENOMEM); return (PX_ERROR); } lib_bzero(pctxp, sizeof(PPP_CTX_PRIV)); - netif = netif_find(pcEthIf); - if (netif == LW_NULL) { - _ErrorHandle(ENODEV); - iErrLevel = 1; - goto __error_handle; + if (pcEthIf) { + netif = netif_find(pcEthIf); + if (netif == LW_NULL) { + _ErrorHandle(ENODEV); + iErrLevel = 1; + goto __error_handle; + } + } else { + netif = LW_NULL; /* 不指定物理网络接口 */ } pctxp->CTXP_uiType = PPP_OL2TP; @@ -548,9 +563,16 @@ INT API_PppOl2tpCreate (CPCHAR pcEthIf, pctxp->CTXP_ucPhase = PPP_PHASE_DEAD; pctxp->CTXP_iFd = PX_ERROR; + if (pcSecret && stSecretLen) { + pucSecret = (UINT8 *)pctxp + sizeof(PPP_CTX_PRIV); + lib_memcpy(pucSecret, pcSecret, stSecretLen); + } else { + pucSecret = LW_NULL; + stSecretLen = 0; + } + pctxp->CTXP_pcb = pppapi_pppol2tp_create(&pctxp->CTXP_netif, netif, &ipaddr, ntohs(usPort), - (u8_t *)pcSecret, (u8_t)stSecretLen, - __pppLinkStatCb, pctxp); + pucSecret, (u8_t)stSecretLen, __pppLinkStatCb, pctxp); if (pctxp->CTXP_pcb == LW_NULL) { _ErrorHandle(ENODEV); iErrLevel = 1; @@ -608,7 +630,10 @@ INT API_PppDelete (CPCHAR pcIfName) __KERNEL_SPACE_EXIT(); } else { + LWIP_IF_LIST_LOCK(LW_TRUE); pppapi_free(pcb); /* 直接删除 */ + LWIP_IF_LIST_UNLOCK(); + if (pctxp->CTXP_cUser) { lib_free(pctxp->CTXP_cUser); } diff --git a/SylixOS/shell/ttinyShell/ttinyShellColor.c b/SylixOS/shell/ttinyShell/ttinyShellColor.c index 513fb97..5400c9e 100644 --- a/SylixOS/shell/ttinyShell/ttinyShellColor.c +++ b/SylixOS/shell/ttinyShell/ttinyShellColor.c @@ -259,13 +259,15 @@ VOID API_TShellColorRefresh (VOID) PCHAR pcColor; PCHAR pcNext; CHAR cStrColors[2048]; + INT iLen; - if (__tshellVarGetRt("LS_COLORS", cStrColors, sizeof(cStrColors))) { + __tshellColorDel(); /* 删除所有配色方案 */ + + iLen = __tshellVarGetRt("LS_COLORS", cStrColors, sizeof(cStrColors)); + if (iLen <= 0) { return; } - - __tshellColorDel(); /* 删除所有配色方案 */ - + pcNext = cStrColors; TSHELL_SKIP_CHAR(pcNext, ':'); diff --git a/SylixOS/system/device/ahci/ahci.c b/SylixOS/system/device/ahci/ahci.c index ace32f1..bb802f8 100644 --- a/SylixOS/system/device/ahci/ahci.c +++ b/SylixOS/system/device/ahci/ahci.c @@ -4062,7 +4062,7 @@ static PVOID __ahciMonitorThread (PVOID pvArg) AHCI_LOG(AHCI_LOG_ERR, "msg handle error ctrl %d.\r\n", hCtrl->AHCICTRL_uiIndex); continue; } - hCtrl = tCtrlMsg.AHCIMSG_hCtrl; + hCtrl = tCtrlMsg.AHCIMSG_hCtrl; iDrive = tCtrlMsg.AHCIMSG_uiDrive; if ((iDrive < 0) || (iDrive >= hCtrl->AHCICTRL_uiImpPortNum)) { /* 驱动器索引错误 */ @@ -4146,9 +4146,39 @@ static PVOID __ahciMonitorThread (PVOID pvArg) hDrive->AHCIDRIVE_uiIntError, hDrive->AHCIDRIVE_uiIntStatus); if (hDrive->AHCIDRIVE_ucType == AHCI_TYPE_ATA) { + UINT uiReg; + AHCI_LOG(AHCI_LOG_ERR, "error ctrl %d drive %d ata drive status init.\r\n", hCtrl->AHCICTRL_uiIndex, iDrive); - __ahciDiskCtrlInit(hCtrl, iDrive); + + uiReg = AHCI_PORT_READ(hDrive, AHCI_PxSCTL); + uiReg &= ~0x0ff; + uiReg |= AHCI_PSCTL_DET_RESET | AHCI_PSCTL_IPM_PARSLUM_DISABLED | AHCI_PSSTS_SPD_GEN2; + AHCI_PORT_WRITE(hDrive, AHCI_PxSCTL, uiReg); + AHCI_PORT_READ(hDrive, AHCI_PxSCTL); + + API_TimeMSleep(1); + + uiReg = AHCI_PORT_READ(hDrive, AHCI_PxSCTL); + + iRetry = 5; + do { + uiReg = (uiReg & 0x0f0) | 0x300; + AHCI_PORT_WRITE(hDrive, AHCI_PxSCTL, uiReg); + API_TimeMSleep(200); + + uiReg = AHCI_PORT_READ(hDrive, AHCI_PxSCTL); + } while (((uiReg & 0xf0f) != 0x300) && (--iRetry > 0)); + + iRet = API_AhciDriveRegWait(hDrive, + AHCI_PxSSTS, AHCI_PSSTS_DET_MSK, LW_FALSE, AHCI_PSSTS_DET_PHY, + 1, 50, &uiReg); + if (iRet != ERROR_NONE) { + break; + } + + AHCI_PORT_WRITE(hDrive, AHCI_PxSERR, 0xffffffff); + } else if (hDrive->AHCIDRIVE_ucType == AHCI_TYPE_ATAPI) { #if AHCI_ATAPI_EN > 0 /* 是否使能 ATAPI */ AHCI_LOG(AHCI_LOG_PRT, "error ctrl %d drive %d atapi drive status init.\r\n", diff --git a/SylixOS/system/device/spipe/spipeLib.c b/SylixOS/system/device/spipe/spipeLib.c index 7ba260d..3763899 100644 --- a/SylixOS/system/device/spipe/spipeLib.c +++ b/SylixOS/system/device/spipe/spipeLib.c @@ -622,13 +622,16 @@ __continue_write: lib_memcpy(pcIn, pcBuffer, stLen); /* 后半部分 */ pcBuffer += stLen; lib_memcpy(pcBase, pcBuffer, (stNBytesToWrite - stLen)); /* 前半部分 */ - pcIn = pcBase + (stNBytesToWrite - stLen); + pcIn = pcBase + (stNBytesToWrite - stLen); + pcBuffer += stNBytesToWrite - stLen; } else if (stNBytesToWrite < stLen) { lib_memcpy(pcIn, pcBuffer, stNBytesToWrite); /* 直接拷贝 */ - pcIn += stNBytesToWrite; + pcIn += stNBytesToWrite; + pcBuffer += stNBytesToWrite; } else { lib_memcpy(pcIn, pcBuffer, stNBytesToWrite); - pcIn = pcBase; /* 后半部分全部拷贝 */ + pcIn = pcBase; /* 后半部分全部拷贝 */ + pcBuffer += stNBytesToWrite; } } |