summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorHanhui <hanhui@acoinfo.com>2021-09-16 13:22:34 (GMT)
committer Hanhui <hanhui@acoinfo.com>2021-09-16 13:22:34 (GMT)
commita4cc7432a5031b80b556250128e513ae22124b5d (patch)
tree51950194f14c6a1746cc0264acfe40520208a913
parentab5b6a29a3447cc5c2040f0e778c2178e7424fba (diff)
downloadlibsylixos-a4cc7432a5031b80b556250128e513ae22124b5d.zip
libsylixos-a4cc7432a5031b80b556250128e513ae22124b5d.tar.gz
libsylixos-a4cc7432a5031b80b556250128e513ae22124b5d.tar.bz2
Update device tree and optimize network device.
-rw-r--r--SylixOS/appl/editors/vi/src/vi.c6
-rw-r--r--SylixOS/appl/zip/zlib/src/example.c2
-rw-r--r--SylixOS/arch/arm64/mm/cache/arm64CacheAsm.S2
-rw-r--r--SylixOS/arch/riscv/mm/mmu/riscvSv39Mmu.c8
-rw-r--r--SylixOS/debug/gdb/gdbserver.c1
-rw-r--r--SylixOS/devtree/devtree.h45
-rw-r--r--SylixOS/devtree/devtreeLib.c2
-rw-r--r--SylixOS/devtree/devtreePci.c443
-rw-r--r--SylixOS/driver/net/dm9000.c32
-rw-r--r--SylixOS/fs/mtd/nand/nand_base.c4
-rw-r--r--SylixOS/fs/mtd/nand/nand_bbt.c2
-rw-r--r--SylixOS/fs/mtd/onenand/onenand_base.c2
-rw-r--r--SylixOS/fs/yaffs2/yaffs_yaffs2.c4
-rw-r--r--SylixOS/kernel/include/k_api.h9
-rw-r--r--SylixOS/kernel/include/k_kernel.h2
-rw-r--r--SylixOS/kernel/interface/InterDefer.c28
-rw-r--r--SylixOS/loader/src/loader_shell.c1
-rw-r--r--SylixOS/net/lwip/bonding/netbonding.c50
-rw-r--r--SylixOS/net/lwip/bridge/netbridge.c48
-rw-r--r--SylixOS/net/lwip/lwip_if.c3
-rw-r--r--SylixOS/net/lwip/mroute/ip4_mrt.c6
-rw-r--r--SylixOS/net/lwip/mroute/ip6_mrt.c6
-rw-r--r--SylixOS/net/lwip/netdev/netdev.c51
-rw-r--r--SylixOS/net/lwip/netdev/netdev.h6
-rw-r--r--SylixOS/net/lwip/packet/af_packet.c2
-rw-r--r--SylixOS/system/device/ahci/ahciLib.c4
-rw-r--r--SylixOS/system/device/ata/ata.c4
-rw-r--r--SylixOS/system/device/pci/pciShow.c2
-rw-r--r--SylixOS/system/device/sdcard/host/sdhci.c169
-rw-r--r--SylixOS/system/device/sdcard/host/sdhci.h2
-rw-r--r--SylixOS/system/include/s_class.h20
-rw-r--r--SylixOS/system/ioLib/ioFile.c10
-rw-r--r--SylixOS/system/ioLib/ioLib.c11
-rw-r--r--SylixOS/system/ioLib/ioLockF.c53
-rw-r--r--SylixOS/system/ioLib/ioStat.c6
-rw-r--r--SylixOS/vpmpdm/dlmalloc/dlmalloc.h4
-rw-r--r--SylixOS/vpmpdm/ptmalloc3/ptmalloc3_sylixos.h4
-rw-r--r--libsylixos.mk1
38 files changed, 845 insertions, 210 deletions
diff --git a/SylixOS/appl/editors/vi/src/vi.c b/SylixOS/appl/editors/vi/src/vi.c
index 4db2847..0c6be13 100644
--- a/SylixOS/appl/editors/vi/src/vi.c
+++ b/SylixOS/appl/editors/vi/src/vi.c
@@ -2459,8 +2459,10 @@ static int file_insert(const char * fn, char *p
}
size = statbuf.st_size;
p = text_hole_make(p, size);
- if (p == NULL)
+ if (p == NULL) {
+ close(fd);
goto fi0;
+ }
cnt = safe_read(fd, p, size);
if (cnt < 0) {
status_line_bold("\"%s\" %s", fn, strerror(errno));
@@ -4103,4 +4105,4 @@ static void crash_test()
}
}
#endif
-#endif /* LW_CFG_SHELL_EN > 0 */ \ No newline at end of file
+#endif /* LW_CFG_SHELL_EN > 0 */
diff --git a/SylixOS/appl/zip/zlib/src/example.c b/SylixOS/appl/zip/zlib/src/example.c
index 07e7d55..293a853 100644
--- a/SylixOS/appl/zip/zlib/src/example.c
+++ b/SylixOS/appl/zip/zlib/src/example.c
@@ -401,7 +401,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen)
d_stream.next_out = uncompr;
d_stream.avail_out = (uInt)uncomprLen;
- inflate(&d_stream, Z_NO_FLUSH);
+ err = inflate(&d_stream, Z_NO_FLUSH);
CHECK_ERR(err, "inflate");
d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */
diff --git a/SylixOS/arch/arm64/mm/cache/arm64CacheAsm.S b/SylixOS/arch/arm64/mm/cache/arm64CacheAsm.S
index c20bd44..0719929 100644
--- a/SylixOS/arch/arm64/mm/cache/arm64CacheAsm.S
+++ b/SylixOS/arch/arm64/mm/cache/arm64CacheAsm.S
@@ -10,7 +10,7 @@
;**
;**--------------文件信息--------------------------------------------------------------------------------
;**
-;** 文 件 名: armCacheV8Asm.S
+;** 文 件 名: arm64CacheAsm.S
;**
;** 创 建 人: Wang.Xuan (王翾)
;**
diff --git a/SylixOS/arch/riscv/mm/mmu/riscvSv39Mmu.c b/SylixOS/arch/riscv/mm/mmu/riscvSv39Mmu.c
index 327799e..3a199aa 100644
--- a/SylixOS/arch/riscv/mm/mmu/riscvSv39Mmu.c
+++ b/SylixOS/arch/riscv/mm/mmu/riscvSv39Mmu.c
@@ -957,10 +957,10 @@ static VOID sv39MmuMakeTrans (PLW_MMU_CONTEXT pmmuctx,
** 注 意 : 这里不需要清除快表 TLB, 因为 VMM 自身会作此操作.
*********************************************************************************************************/
static VOID c9xxMmuMakeTrans (PLW_MMU_CONTEXT pmmuctx,
- LW_PTE_TRANSENTRY *p_pteentry,
- addr_t ulVirtualAddr,
- phys_addr_t paPhysicalAddr,
- ULONG ulFlag)
+ LW_PTE_TRANSENTRY *p_pteentry,
+ addr_t ulVirtualAddr,
+ phys_addr_t paPhysicalAddr,
+ ULONG ulFlag)
{
UINT8 ucV, ucR, ucW, ucX, ucU, ucG, ucRSW;
diff --git a/SylixOS/debug/gdb/gdbserver.c b/SylixOS/debug/gdb/gdbserver.c
index 0de8aea..e013b53 100644
--- a/SylixOS/debug/gdb/gdbserver.c
+++ b/SylixOS/debug/gdb/gdbserver.c
@@ -1231,6 +1231,7 @@ static INT gdbGetElfOffset (pid_t pid,
if (read(iFd, &ehdr, sizeof(ehdr)) < sizeof(ehdr)) { /* 读取ELF头 */
_DebugHandle(__ERRORMESSAGE_LEVEL, "Read elf header error.\r\n");
+ close(iFd);
return (PX_ERROR);
}
diff --git a/SylixOS/devtree/devtree.h b/SylixOS/devtree/devtree.h
index fea885d..a7d0629 100644
--- a/SylixOS/devtree/devtree.h
+++ b/SylixOS/devtree/devtree.h
@@ -44,6 +44,12 @@
#define ROOT_NODE_ADDR_CELLS_DEFAULT 1
/*********************************************************************************************************
+ 无效地址定义
+*********************************************************************************************************/
+
+#define OF_BAD_ADDR (-1)
+
+/*********************************************************************************************************
加载标识定义
*********************************************************************************************************/
@@ -58,8 +64,8 @@
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
-#define RESOURCE_SIZE(res) (res.iomem.DEVRES_ulEnd - \
- res.iomem.DEVRES_ulStart + 1)
+#define RESOURCE_SIZE(res) ((res).iomem.DEVRES_ulEnd - \
+ (res).iomem.DEVRES_ulStart + 1)
/*********************************************************************************************************
设备树相关定义
@@ -127,6 +133,24 @@ typedef struct devtree_phandle_iterator {
} LW_DEVTREE_PHANDLE_ITERATOR;
typedef LW_DEVTREE_PHANDLE_ITERATOR *PLW_DEVTREE_PHANDLE_ITERATOR;
+typedef struct devtree_pci_range_parser {
+ PLW_DEVTREE_NODE DTPRP_pdtnDev;
+ const UINT32 *DTPRP_puiRange;
+ const UINT32 *DTPRP_puiEnd;
+ INT DTPRP_iNp;
+ INT DTPRP_iPna;
+} LW_DEVTREE_PCI_RANGE_PARSER;
+typedef LW_DEVTREE_PCI_RANGE_PARSER *PLW_DEVTREE_PCI_RANGE_PARSER;
+
+typedef struct devtree_pci_range {
+ UINT32 DTPR_uiPciSpace;
+ UINT64 DTPR_ullPciAddr;
+ UINT64 DTPR_ullCpuAddr;
+ UINT64 DTPR_ullSize;
+ UINT32 DTPR_uiFlags;
+} LW_DEVTREE_PCI_RANGE;
+typedef LW_DEVTREE_PCI_RANGE *PLW_DEVTREE_PCI_RANGE;
+
typedef PVOID (*FUNC_DT_ALLOC)(size_t stSize, size_t stAlign);
typedef INT (*FUNC_SCAN_CALLBACK)(PVOID pvBase, INT iOffset,
CPCHAR cpcName, INT iDepth, PVOID pvData);
@@ -385,6 +409,23 @@ LW_API INT API_DeviceTreeSpiCtrlRegister(PLW_DT_SPI_CTRL ps
LW_API INT API_DeviceTreeSpiDevRegister(PLW_DT_SPI_CTRL pspictrl,
PLW_DEVTREE_NODE pdtnDev);
+/*********************************************************************************************************
+ PCI 相关接口
+*********************************************************************************************************/
+
+LW_API INT API_DeviceTreePciBusRangeParse(PLW_DEVTREE_NODE pdtnDev,
+ PLW_DEV_RESOURCE pdevresource);
+
+LW_API INT API_DeviceTreePciHostBridgeResourcesGet(PLW_DEVTREE_NODE pdtnDev,
+ UINT8 ucBusNo,
+ UINT8 ucBusMax,
+ LW_LIST_LINE_HEADER *pplineheadResource,
+ UINT64 *pullIoBase);
+
+LW_API INT API_DeviceTreePciRangesParse(PLW_DEVTREE_NODE pdtnDev,
+ LW_LIST_LINE_HEADER *pplineheadResource,
+ PLW_DEV_RESOURCE *pdevresBusRange);
+
#include "devtree_error.h"
#include "devtree_inline.h"
#include "devtree_value.h"
diff --git a/SylixOS/devtree/devtreeLib.c b/SylixOS/devtree/devtreeLib.c
index 91c811a..5f03219 100644
--- a/SylixOS/devtree/devtreeLib.c
+++ b/SylixOS/devtree/devtreeLib.c
@@ -679,7 +679,7 @@ PVOID API_DeviceTreeAddressIoremap (PLW_DEVTREE_NODE pdtnDev, INT iIndex)
}
return (API_VmmIoRemapNocache((PVOID)devresource.iomem.DEVRES_ulStart,
- RESOURCE_SIZE(&devresource)));
+ RESOURCE_SIZE(devresource)));
}
/*********************************************************************************************************
** 函数名称: API_DeviceTreeFindNodeOptsByPath
diff --git a/SylixOS/devtree/devtreePci.c b/SylixOS/devtree/devtreePci.c
new file mode 100644
index 0000000..6b0804c
--- /dev/null
+++ b/SylixOS/devtree/devtreePci.c
@@ -0,0 +1,443 @@
+/*********************************************************************************************************
+**
+** 中国软件开源组织
+**
+** 嵌入式实时操作系统
+**
+** SylixOS(TM) LW : long wing
+**
+** Copyright All Rights Reserved
+**
+**--------------文件信息--------------------------------------------------------------------------------
+**
+** 文 件 名: devtreePci.c
+**
+** 创 建 人: Wang.Xuan (王翾)
+**
+** 文件创建日期: 2021 年 07 月 30 日
+**
+** 描 述: 设备树接口 PCI 设备相关接口实现
+*********************************************************************************************************/
+#define __SYLIXOS_KERNEL
+#define __SYLIXOS_DEVTREE_DRV
+#include "SylixOS.h"
+/*********************************************************************************************************
+ 裁剪宏
+*********************************************************************************************************/
+#if LW_CFG_DEVTREE_EN > 0
+#include "devtree.h"
+#include "system/device/pci/pciDev.h"
+/*********************************************************************************************************
+** 函数名称: __deviceTreePciFlagsGet
+** 功能描述: 获取 PCI 的资源类型
+** 输 入 : puiAddr 解析的资源内容
+** 输 出 : 资源类型
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static UINT __deviceTreePciFlagsGet (const UINT32 *puiAddr)
+{
+ UINT uiFlags = 0;
+ UINT32 uiValue = BE32_TO_CPU(puiAddr);
+
+ switch ((uiValue >> 24) & 0x03) {
+
+ case 0x01:
+ uiFlags = PCI_IORESOURCE_IO;
+ break;
+
+ case 0x02: /* 32 bits */
+ uiFlags = PCI_IORESOURCE_MEM;
+ break;
+
+ case 0x03: /* 64 bits */
+ uiFlags = PCI_IORESOURCE_MEM_64;
+ break;
+ }
+
+ if (uiValue & 0x40000000) {
+ uiFlags = PCI_IORESOURCE_PREFETCH;
+ }
+
+ return (uiFlags);
+}
+/*********************************************************************************************************
+** 函数名称: __deviceTreePciParserInit
+** 功能描述: 初始化 PCI 设备树节点资源解析
+** 输 入 : pdtpciparser 资源解析结构
+** pdtnDev 设备树节点
+** pcName 资源名称
+** 输 出 : ERROR_CODE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static INT __deviceTreePciParserInit (PLW_DEVTREE_PCI_RANGE_PARSER pdtpciparser,
+ PLW_DEVTREE_NODE pdtnDev,
+ CPCHAR pcName)
+{
+ const INT iNa = 3;
+ const INT iNs = 2;
+ INT iRlen;
+
+ pdtpciparser->DTPRP_pdtnDev = pdtnDev;
+ pdtpciparser->DTPRP_iPna = API_DeviceTreeNAddrCells(pdtnDev);
+ pdtpciparser->DTPRP_iNp = pdtpciparser->DTPRP_iPna + iNa + iNs;
+
+ pdtpciparser->DTPRP_puiRange = API_DeviceTreePropertyGet(pdtnDev, pcName, &iRlen);
+ if (pdtpciparser->DTPRP_puiRange == LW_NULL) {
+ _ErrorHandle(ENOENT);
+ return (PX_ERROR);
+ }
+
+ pdtpciparser->DTPRP_puiEnd = pdtpciparser->DTPRP_puiRange + iRlen / sizeof(UINT32);
+
+ return (ERROR_NONE);
+}
+/*********************************************************************************************************
+** 函数名称: __deviceTreePciRangeParserOne
+** 功能描述: 解析一条 PCI 设备树节点资源
+** 输 入 : pdtpciparser 资源解析结构
+** pdtpcirange range 资源结构
+** 输 出 : 解析出的 range 资源结构
+** 全局变量:
+** 调用模块:
+** API 函数
+*********************************************************************************************************/
+static PLW_DEVTREE_PCI_RANGE __deviceTreePciRangeParserOne (PLW_DEVTREE_PCI_RANGE_PARSER pdtpciparser,
+ PLW_DEVTREE_PCI_RANGE pdtpcirange)
+{
+ const INT iNa = 3;
+ const INT iNs = 2;
+ UINT32 uiFlags;
+ UINT64 ullPciAddr;
+ UINT64 ullCpuAddr;
+ UINT64 ullSize;
+
+ if (!pdtpcirange) {
+ return (LW_NULL);
+ }
+
+ if (!pdtpciparser->DTPRP_puiRange ||
+ ((pdtpciparser->DTPRP_puiRange + pdtpciparser->DTPRP_iNp) > pdtpciparser->DTPRP_puiEnd)) {
+ return (LW_NULL);
+ }
+
+ pdtpcirange->DTPR_uiPciSpace = BE32_TO_CPU(pdtpciparser->DTPRP_puiRange);
+ pdtpcirange->DTPR_uiFlags = __deviceTreePciFlagsGet(pdtpciparser->DTPRP_puiRange);
+ pdtpcirange->DTPR_ullPciAddr = __deviceTreeNumberRead(pdtpciparser->DTPRP_puiRange + 1, iNs);
+ pdtpcirange->DTPR_ullCpuAddr = API_DeviceTreeAddressTranslate(pdtpciparser->DTPRP_pdtnDev,
+ pdtpciparser->DTPRP_puiRange + iNa);
+ pdtpcirange->DTPR_ullSize = __deviceTreeNumberRead(pdtpciparser->DTPRP_puiRange +
+ pdtpciparser->DTPRP_iPna + iNa, iNs);
+
+ pdtpciparser->DTPRP_puiRange += pdtpciparser->DTPRP_iNp;
+
+ while ((pdtpciparser->DTPRP_puiRange + pdtpciparser->DTPRP_iNp) <= pdtpciparser->DTPRP_puiEnd) {
+ uiFlags = __deviceTreePciFlagsGet(pdtpciparser->DTPRP_puiRange);
+ ullPciAddr = __deviceTreeNumberRead(pdtpciparser->DTPRP_puiRange + 1, iNs);
+ ullCpuAddr = API_DeviceTreeAddressTranslate(pdtpciparser->DTPRP_pdtnDev,
+ pdtpciparser->DTPRP_puiRange + iNa);
+ ullSize = __deviceTreeNumberRead(pdtpciparser->DTPRP_puiRange +
+ pdtpciparser->DTPRP_iPna + iNa, iNs);
+
+ if (uiFlags != pdtpcirange->DTPR_uiFlags) {
+ break;
+ }
+
+ if ((ullPciAddr != pdtpcirange->DTPR_ullPciAddr + pdtpcirange->DTPR_ullSize) ||
+ (ullCpuAddr != pdtpcirange->DTPR_ullCpuAddr + pdtpcirange->DTPR_ullSize)) {
+ break;
+ }
+
+ pdtpcirange->DTPR_ullSize += ullSize;
+ pdtpciparser->DTPRP_puiRange += pdtpciparser->DTPRP_iNp;
+ }
+
+ return (pdtpcirange);
+}
+/*********************************************************************************************************
+** 函数名称: __deviceTreePciRangeToResource
+** 功能描述: 将一条 PCI Range 资源翻译为 resource
+** 输 入 : pdtpcirange range 资源结构
+** pdtnDev 设备树节点
+** pdevresource 翻译出的 resource
+** 输 出 : ERROR_CODE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static INT __deviceTreePciRangeToResource (PLW_DEVTREE_PCI_RANGE pdtpcirange,
+ PLW_DEVTREE_NODE pdtnDev,
+ PLW_DEV_RESOURCE pdevresource)
+{
+ pdevresource->DEVRES_pcName = pdtnDev->DTN_pcFullName;
+ pdevresource->DEVRES_ulFlags = pdtpcirange->DTPR_uiFlags;
+ pdevresource->iomem.DEVRES_ulStart = pdtpcirange->DTPR_ullCpuAddr;
+ pdevresource->iomem.DEVRES_ulEnd = pdtpcirange->DTPR_ullCpuAddr + pdtpcirange->DTPR_ullSize - 1;
+
+ return (ERROR_NONE);
+}
+/*********************************************************************************************************
+** 函数名称: __deviceTreePciResourceOffsetAdd
+** 功能描述: 将一条 resource 加入资源链表
+** 输 入 : pplineheadResource 资源链表头
+** pdevresource 要加入的资源
+** ullOffset 当前的偏移
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static VOID __deviceTreePciResourceOffsetAdd (LW_LIST_LINE_HEADER *pplineheadResource,
+ PLW_DEV_RESOURCE pdevresource,
+ UINT64 ullOffset)
+{
+ PLW_DEV_RESOURCE_ENTRY pdevresentry;
+
+ pdevresentry = __SHEAP_ZALLOC(sizeof(LW_DEV_RESOURCE_ENTRY));
+ if (!pdevresentry) {
+ return;
+ }
+
+ pdevresentry->DEVRESE_ullOffset = ullOffset;
+ pdevresentry->DEVRESE_pdevres = pdevresource;
+
+ _List_Line_Add_Tail(&pdevresentry->DEVRESE_plineManage,
+ pplineheadResource);
+}
+/*********************************************************************************************************
+** 函数名称: __deviceTreePciResourceListFree
+** 功能描述: 释放一条 resource 资源链表
+** 输 入 : plineheadResource 资源链表头
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static VOID __deviceTreePciResourceListFree (LW_LIST_LINE_HEADER *pplineheadResource)
+{
+ PLW_DEV_RESOURCE_ENTRY pdevresentry;
+ PLW_LIST_LINE plineTemp;
+
+ for (plineTemp = *pplineheadResource;
+ plineTemp != LW_NULL;
+ plineTemp = _list_line_get_next(plineTemp)) {
+
+ pdevresentry = _LIST_ENTRY(plineTemp, LW_DEV_RESOURCE_ENTRY, DEVRESE_plineManage);
+ if (pdevresentry->DEVRESE_pdevres) {
+ __SHEAP_FREE(pdevresentry->DEVRESE_pdevres);
+ }
+
+ _List_Line_Del(&pdevresentry->DEVRESE_plineManage,
+ pplineheadResource);
+
+ __SHEAP_FREE(pdevresentry);
+ }
+}
+/*********************************************************************************************************
+** 函数名称: API_DeviceTreePciBusRangeParse
+** 功能描述: PCI 设备树节点获取总线范围
+** 输 入 : pdtnDev 指定的设备树节点
+** pdevresource 存储地址范围的资源变量
+** 输 出 : ERROR_CODE
+** 全局变量:
+** 调用模块:
+** API 函数
+*********************************************************************************************************/
+LW_API
+INT API_DeviceTreePciBusRangeParse (PLW_DEVTREE_NODE pdtnDev, PLW_DEV_RESOURCE pdevresource)
+{
+ UINT32 uiBusRange[2];
+ INT iError;
+
+ if (!pdtnDev || !pdevresource) {
+ _ErrorHandle(EINVAL);
+ return (PX_ERROR);
+ }
+
+ iError = API_DeviceTreePropertyU32ArrayRead(pdtnDev, "bus-range",
+ uiBusRange, ARRAY_SIZE(uiBusRange));
+ if (iError) {
+ return (iError);
+ }
+
+ pdevresource->DEVRES_pcName = pdtnDev->DTN_pcFullName;
+ pdevresource->DEVRES_ulFlags = PCI_IORESOURCE_BUS;
+ pdevresource->bus.DEVRES_ulStart = uiBusRange[0];
+ pdevresource->bus.DEVRES_ulEnd = uiBusRange[1];
+
+ return (ERROR_NONE);
+}
+/*********************************************************************************************************
+** 函数名称: API_DeviceTreePciHostBridgeResourcesGet
+** 功能描述: PCI 设备树节点获取 PCI 桥片上资源
+** 输 入 : pdtnDev 指定的设备树节点
+** ucBusNo 起始 BUS 序号
+** ucBusMax 结束 BUS 序号
+** pplineheadResource 存储资源的链表头
+** pullIoBase IO 基地址
+** 输 出 : ERROR_CODE
+** 全局变量:
+** 调用模块:
+** API 函数
+*********************************************************************************************************/
+LW_API
+INT API_DeviceTreePciHostBridgeResourcesGet (PLW_DEVTREE_NODE pdtnDev,
+ UINT8 ucBusNo,
+ UINT8 ucBusMax,
+ LW_LIST_LINE_HEADER *pplineheadResource,
+ UINT64 *pullIoBase)
+{
+ LW_DEVTREE_PCI_RANGE_PARSER dtpciparser;
+ LW_DEVTREE_PCI_RANGE dtpcirange;
+ LW_DEV_RESOURCE devresTemp;
+ PLW_DEV_RESOURCE pdevresource;
+ PLW_DEV_RESOURCE pdevresBusRange;
+ INT iError;
+
+ if (!pdtnDev || !pplineheadResource) {
+ _ErrorHandle(EINVAL);
+ return (PX_ERROR);
+ }
+
+ if (pullIoBase) {
+ *pullIoBase = (UINT64)OF_BAD_ADDR;
+ }
+
+ pdevresBusRange = __SHEAP_ZALLOC(sizeof(LW_DEV_RESOURCE));
+ if (!pdevresBusRange) {
+ _ErrorHandle(ENOMEM);
+ return (PX_ERROR);
+ }
+
+ /*
+ * 解析 PCI BUS 资源
+ */
+ iError = API_DeviceTreePciBusRangeParse(pdtnDev, pdevresBusRange);
+ if (iError) {
+ pdevresBusRange->bus.DEVRES_ulStart = ucBusNo;
+ pdevresBusRange->bus.DEVRES_ulEnd = ucBusMax;
+ pdevresBusRange->DEVRES_ulFlags = PCI_IORESOURCE_BUS;
+ } else {
+ if (pdevresBusRange->bus.DEVRES_ulEnd > (pdevresBusRange->bus.DEVRES_ulStart + ucBusMax)) {
+ pdevresBusRange->bus.DEVRES_ulEnd = pdevresBusRange->bus.DEVRES_ulStart + ucBusMax;
+ }
+ }
+
+ __deviceTreePciResourceOffsetAdd(pplineheadResource,
+ pdevresBusRange, 0); /* 将 BUS 资源加入链表 */
+
+ /*
+ * 解析 PCI IO、MEM 资源
+ */
+ iError = __deviceTreePciParserInit(&dtpciparser, pdtnDev, "ranges");
+ if (iError) {
+ goto failed;
+ }
+
+ while (__deviceTreePciRangeParserOne(&dtpciparser, &dtpcirange)) {
+ if ((dtpcirange.DTPR_ullCpuAddr == OF_BAD_ADDR) ||
+ (dtpcirange.DTPR_ullSize == 0)) {
+ continue;
+ }
+
+ iError = __deviceTreePciRangeToResource(&dtpcirange,
+ pdtnDev,
+ &devresTemp); /* Range 资源转换为 resource */
+ if (iError) {
+ continue;
+ }
+
+ pdevresource = __SHEAP_ALLOC(sizeof(LW_DEV_RESOURCE));
+ if (!pdevresource) {
+ _ErrorHandle(ENOMEM);
+ goto failed;
+ }
+
+ lib_memcpy(pdevresource, &devresTemp, sizeof(LW_DEV_RESOURCE));
+
+ if (pdevresource->DEVRES_ulFlags == PCI_IORESOURCE_IO) {
+ if (!pullIoBase) {
+ _ErrorHandle(EINVAL);
+ goto failed;
+ }
+
+ *pullIoBase = dtpcirange.DTPR_ullCpuAddr;
+ }
+
+ __deviceTreePciResourceOffsetAdd(pplineheadResource,
+ pdevresource,
+ pdevresource->iomem.DEVRES_ulStart - dtpcirange.DTPR_ullPciAddr);
+ }
+
+ return (ERROR_NONE);
+
+failed:
+ __deviceTreePciResourceListFree(pplineheadResource);
+
+ return (PX_ERROR);
+}
+/*********************************************************************************************************
+** 函数名称: API_DeviceTreePciRangesParse
+** 功能描述: PCI 设备树节点获取 PCI IO、MEM、BUS 范围
+** 输 入 : pdtnDev 指定的设备树节点
+** pplineheadResource 存储地址范围的链表头
+** pdevresBusRange BUS 的范围
+** 输 出 : ERROR_CODE
+** 全局变量:
+** 调用模块:
+** API 函数
+*********************************************************************************************************/
+LW_API
+INT API_DeviceTreePciRangesParse (PLW_DEVTREE_NODE pdtnDev,
+ LW_LIST_LINE_HEADER *pplineheadResource,
+ PLW_DEV_RESOURCE *pdevresBusRange)
+{
+ PLW_DEV_RESOURCE_ENTRY pdevreseTmp;
+ PLW_DEV_RESOURCE pdevres;
+ PLW_LIST_LINE plineTemp;
+ UINT64 ullIoBase;
+ INT iError;
+
+ if (!pdtnDev || !pplineheadResource) {
+ _ErrorHandle(EINVAL);
+ return (PX_ERROR);
+ }
+
+ *pplineheadResource = LW_NULL;
+
+ iError = API_DeviceTreePciHostBridgeResourcesGet(pdtnDev,
+ 0,
+ 0xff,
+ pplineheadResource,
+ &ullIoBase);
+ if (iError) {
+ return (iError);
+ }
+
+ for (plineTemp = *pplineheadResource;
+ plineTemp != LW_NULL;
+ plineTemp = _list_line_get_next(plineTemp)) { /* 对资源进行一次分析 */
+
+ pdevreseTmp = _LIST_ENTRY(plineTemp, LW_DEV_RESOURCE_ENTRY, DEVRESE_plineManage);
+ pdevres = pdevreseTmp->DEVRESE_pdevres;
+
+ switch (pdevres->DEVRES_ulFlags) {
+
+ case PCI_IORESOURCE_IO:
+ case PCI_IORESOURCE_MEM:
+ case PCI_IORESOURCE_MEM_64:
+ break;
+
+ case PCI_IORESOURCE_BUS:
+ if (pdevresBusRange) {
+ *pdevresBusRange = pdevres;
+ }
+ break;
+ }
+ }
+
+ return (ERROR_NONE);
+}
+
+#endif /* LW_CFG_DEVTREE_EN > 0 */
+/*********************************************************************************************************
+ END
+*********************************************************************************************************/
diff --git a/SylixOS/driver/net/dm9000.c b/SylixOS/driver/net/dm9000.c
index 0edee26..0c2c536 100644
--- a/SylixOS/driver/net/dm9000.c
+++ b/SylixOS/driver/net/dm9000.c
@@ -760,26 +760,26 @@ static int dm9000_rxmode (struct netdev *netdev, int flags)
if (flags & IFF_PROMISC) {
rcr |= RCR_PRMSC;
- }
- if (flags & IFF_ALLMULTI) {
+ } else if (flags & IFF_ALLMULTI || netdev_macfilter_count(netdev) > 4) {
rcr |= RCR_ALL;
- }
- /*
- * the multicast address in Hash Table : 64 bits
- */
- NETDEV_MACFILTER_FOREACH(netdev, ha) {
- hash_val = ether_crc_le(6, ha->hwaddr) & 0x3f;
- hash_table[hash_val / 16] |= (UINT16) 1 << (hash_val % 16);
- }
+ } else {
+ /*
+ * the multicast address in Hash Table : 64 bits
+ */
+ NETDEV_MACFILTER_FOREACH(netdev, ha) {
+ hash_val = ether_crc_le(6, ha->hwaddr) & 0x3f;
+ hash_table[hash_val / 16] |= (UINT16) 1 << (hash_val % 16);
+ }
- /*
- * Write the hash table to MAC MD table
- */
- for (i = 0, oft = DM9000_MAR; i < 4; i++) {
- dm9000_io_write(dm9000, oft++, hash_table[i]);
- dm9000_io_write(dm9000, oft++, hash_table[i] >> 8);
+ /*
+ * Write the hash table to MAC MD table
+ */
+ for (i = 0, oft = DM9000_MAR; i < 4; i++) {
+ dm9000_io_write(dm9000, oft++, hash_table[i]);
+ dm9000_io_write(dm9000, oft++, hash_table[i] >> 8);
+ }
}
dm9000_io_write(dm9000, DM9000_RCR, rcr);
diff --git a/SylixOS/fs/mtd/nand/nand_base.c b/SylixOS/fs/mtd/nand/nand_base.c
index 4ae30a7..7281086 100644
--- a/SylixOS/fs/mtd/nand/nand_base.c
+++ b/SylixOS/fs/mtd/nand/nand_base.c
@@ -2011,8 +2011,8 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
blockmask = (1 << (chip->phys_erase_shift - chip->page_shift)) - 1;
/* Invalidate the page cache, when we write to the cached page */
- if (to <= (chip->pagebuf << chip->page_shift) &&
- (chip->pagebuf << chip->page_shift) < (to + ops->len))
+ if (to <= ((loff_t)chip->pagebuf << chip->page_shift) &&
+ ((loff_t)chip->pagebuf << chip->page_shift) < (to + ops->len))
chip->pagebuf = -1;
/* Don't allow multipage oob writes with offset */
diff --git a/SylixOS/fs/mtd/nand/nand_bbt.c b/SylixOS/fs/mtd/nand/nand_bbt.c
index 30e1527..4ff34ff 100644
--- a/SylixOS/fs/mtd/nand/nand_bbt.c
+++ b/SylixOS/fs/mtd/nand/nand_bbt.c
@@ -807,7 +807,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
/* Must we save the block contents? */
if (td->options & NAND_BBT_SAVECONTENT) {
/* Make it block aligned */
- to &= ~((loff_t)((1 << this->bbt_erase_shift) - 1));
+ to &= ~((loff_t)(((loff_t)1 << this->bbt_erase_shift) - 1));
len = 1 << this->bbt_erase_shift;
res = mtd_read(mtd, to, len, &retlen, buf);
if (res < 0) {
diff --git a/SylixOS/fs/mtd/onenand/onenand_base.c b/SylixOS/fs/mtd/onenand/onenand_base.c
index 02b287c..726ab34 100644
--- a/SylixOS/fs/mtd/onenand/onenand_base.c
+++ b/SylixOS/fs/mtd/onenand/onenand_base.c
@@ -718,7 +718,7 @@ static void onenand_invalidate_bufferram(struct mtd_info *mtd, loff_t addr,
/* Invalidate BufferRAM */
for (i = 0; i < MAX_BUFFERRAM; i++) {
- loff_t buf_addr = this->bufferram[i].blockpage << this->page_shift;
+ loff_t buf_addr = (loff_t)this->bufferram[i].blockpage << this->page_shift;
if (buf_addr >= addr && buf_addr < end_addr)
this->bufferram[i].blockpage = -1;
diff --git a/SylixOS/fs/yaffs2/yaffs_yaffs2.c b/SylixOS/fs/yaffs2/yaffs_yaffs2.c
index b674e54..e4c2b75 100644
--- a/SylixOS/fs/yaffs2/yaffs_yaffs2.c
+++ b/SylixOS/fs/yaffs2/yaffs_yaffs2.c
@@ -878,7 +878,7 @@ int yaffs2_handle_hole(struct yaffs_obj *obj, loff_t new_size)
increase = new_size - old_file_size;
- if (increase < YAFFS_SMALL_HOLE_THRESHOLD * dev->data_bytes_per_chunk &&
+ if (increase < (loff_t)YAFFS_SMALL_HOLE_THRESHOLD * dev->data_bytes_per_chunk &&
yaffs_check_alloc_available(dev, YAFFS_SMALL_HOLE_THRESHOLD + 1))
small_hole = 1;
else
@@ -1051,7 +1051,7 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev,
} else if (tags.chunk_id > 0) {
/* chunk_id > 0 so it is a data chunk... */
loff_t endpos;
- loff_t chunk_base = (tags.chunk_id - 1) *
+ loff_t chunk_base = (loff_t)(tags.chunk_id - 1) *
dev->data_bytes_per_chunk;
*found_chunks = 1;
diff --git a/SylixOS/kernel/include/k_api.h b/SylixOS/kernel/include/k_api.h
index 7a05b36..b9b9574 100644
--- a/SylixOS/kernel/include/k_api.h
+++ b/SylixOS/kernel/include/k_api.h
@@ -1114,6 +1114,15 @@ LW_API INT API_InterDeferContext(VOID); /* 是否
LW_API ULONG API_InterDeferJobAdd(PLW_JOB_QUEUE pjobq, VOIDFUNCPTR pfunc, PVOID pvArg);
/* 向中断延迟处理队列加入任务 */
+LW_API ULONG API_InterDeferJobAddEx(PLW_JOB_QUEUE pjobq,
+ VOIDFUNCPTR pfunc,
+ PVOID pvArg0,
+ PVOID pvArg1,
+ PVOID pvArg2,
+ PVOID pvArg3,
+ PVOID pvArg4,
+ PVOID pvArg5); /* 向中断延迟处理队列加入任务 */
+
LW_API ULONG API_InterDeferJobDelete(PLW_JOB_QUEUE pjobq, BOOL bMatchArg,
VOIDFUNCPTR pfunc, PVOID pvArg);
/* 从中断延迟处理队列删除任务 */
diff --git a/SylixOS/kernel/include/k_kernel.h b/SylixOS/kernel/include/k_kernel.h
index ace44f9..3f1ad26 100644
--- a/SylixOS/kernel/include/k_kernel.h
+++ b/SylixOS/kernel/include/k_kernel.h
@@ -53,7 +53,7 @@
#define __SYLIXOS_MAJOR_VER 2
#define __SYLIXOS_MINOR_VER 2
-#define __SYLIXOS_PATCH_VER 0
+#define __SYLIXOS_PATCH_VER 1
#define __SYLIXOS_PATCH_PAD 0
/*********************************************************************************************************
diff --git a/SylixOS/kernel/interface/InterDefer.c b/SylixOS/kernel/interface/InterDefer.c
index a2c63bc..244df16 100644
--- a/SylixOS/kernel/interface/InterDefer.c
+++ b/SylixOS/kernel/interface/InterDefer.c
@@ -229,6 +229,34 @@ ULONG API_InterDeferJobAdd (PLW_JOB_QUEUE pjobq, VOIDFUNCPTR pfunc, PVOID pv
return (_jobQueueAdd(pjobq, pfunc, pvArg, LW_NULL, LW_NULL, LW_NULL, LW_NULL, LW_NULL));
}
/*********************************************************************************************************
+** 函数名称: API_InterDeferJobAddEx
+** 功能描述: 向中断延迟处理队列加入一个任务
+** 输 入 : pjobq 队列
+** pfunc 处理函数
+** pvArg[0...5] 处理参数
+** 输 出 : ERROR CODE
+** 全局变量:
+** 调用模块:
+ API 函数
+*********************************************************************************************************/
+LW_API
+ULONG API_InterDeferJobAddEx (PLW_JOB_QUEUE pjobq,
+ VOIDFUNCPTR pfunc,
+ PVOID pvArg0,
+ PVOID pvArg1,
+ PVOID pvArg2,
+ PVOID pvArg3,
+ PVOID pvArg4,
+ PVOID pvArg5)
+{
+ if (!pjobq) {
+ _ErrorHandle(EINVAL);
+ return (EINVAL);
+ }
+
+ return (_jobQueueAdd(pjobq, pfunc, pvArg0, pvArg1, pvArg2, pvArg3, pvArg4, pvArg5));
+}
+/*********************************************************************************************************
** 函数名称: API_InterDeferJobDelete
** 功能描述: 从中断延迟处理队列删除任务
** 输 入 : pjobq 队列
diff --git a/SylixOS/loader/src/loader_shell.c b/SylixOS/loader/src/loader_shell.c
index 263e6fd..573798d 100644
--- a/SylixOS/loader/src/loader_shell.c
+++ b/SylixOS/loader/src/loader_shell.c
@@ -383,6 +383,7 @@ static INT __tshellExec (INT iArgC, PCHAR *ppcArgV)
}
if (fstat(fileno(pfile), &statBuf) < ERROR_NONE) { /* 获得文件信息 */
+ fclose(pfile);
return (-ERROR_TSHELL_CMDNOTFUND); /* 无法找到命令 */
}
diff --git a/SylixOS/net/lwip/bonding/netbonding.c b/SylixOS/net/lwip/bonding/netbonding.c
index 9c889eb..3be7bd2 100644
--- a/SylixOS/net/lwip/bonding/netbonding.c
+++ b/SylixOS/net/lwip/bonding/netbonding.c
@@ -448,7 +448,7 @@ static int netbd_rxmode (struct netdev *netdev, int flags)
netbd_eth = (netbd_eth_t *)netbd->eth_ring;
for (i = 0; i < netbd->eth_cnt; i++) {
if (netbd_eth->netdev->drv->rxmode) {
- netbd_eth->netdev->drv->rxmode(netbd_eth->netdev, flags);
+ netbd_eth->netdev->drv->rxmode(netbd_eth->netdev, flags | IFF_PROMISC);
}
netbd_eth = (netbd_eth_t *)_list_ring_get_next(&netbd_eth->ring);
}
@@ -854,15 +854,13 @@ int netbd_delete_dev (const char *bddev, int bdindex, const char *sub, int sub_
} else { /* IFF_PROMISC off */
flags = netif_get_flags(netif);
- if (flags & IFF_PROMISC) {
- ifreq.ifr_name[0] = 0;
- ifreq.ifr_flags = flags & ~IFF_PROMISC;
- if (netif->ioctl) {
- if (netif->ioctl(netif, SIOCSIFFLAGS, &ifreq)) { /* make Non IFF_PROMISC */
- _PrintHandle("sub ethernet device can not support IFF_PROMISC!\r\n");
- } else {
- netif->flags2 &= ~NETIF_FLAG2_PROMISC;
- }
+ ifreq.ifr_name[0] = 0;
+ ifreq.ifr_flags = flags & ~IFF_PROMISC;
+ if (netif->ioctl) {
+ if (netif->ioctl(netif, SIOCSIFFLAGS, &ifreq)) { /* make Non IFF_PROMISC */
+ _PrintHandle("sub ethernet device can not support IFF_PROMISC!\r\n");
+ } else {
+ netif->flags2 &= ~NETIF_FLAG2_PROMISC;
}
}
}
@@ -1279,15 +1277,13 @@ int netbd_delete (const char *bddev, int bdindex)
} else { /* IFF_PROMISC off */
flags = netif_get_flags(netif);
- if (flags & IFF_PROMISC) {
- ifreq.ifr_name[0] = 0;
- ifreq.ifr_flags = flags & ~IFF_PROMISC;
- if (netif->ioctl) {
- if (netif->ioctl(netif, SIOCSIFFLAGS, &ifreq)) {
- _PrintHandle("sub ethernet device can not support IFF_PROMISC!\r\n");
- } else {
- netif->flags2 &= ~NETIF_FLAG2_PROMISC;
- }
+ ifreq.ifr_name[0] = 0;
+ ifreq.ifr_flags = flags & ~IFF_PROMISC;
+ if (netif->ioctl) {
+ if (netif->ioctl(netif, SIOCSIFFLAGS, &ifreq)) {
+ _PrintHandle("sub ethernet device can not support IFF_PROMISC!\r\n");
+ } else {
+ netif->flags2 &= ~NETIF_FLAG2_PROMISC;
}
}
}
@@ -1438,15 +1434,13 @@ void netbd_sub_delete_hook (netdev_t *netdev)
} else { /* IFF_PROMISC off */
flags = netif_get_flags(netif);
- if (flags & IFF_PROMISC) {
- ifreq.ifr_name[0] = 0;
- ifreq.ifr_flags = flags & ~IFF_PROMISC;
- if (netif->ioctl) {
- if (netif->ioctl(netif, SIOCSIFFLAGS, &ifreq)) { /* make Non IFF_PROMISC */
- _PrintHandle("sub ethernet device can not support IFF_PROMISC!\r\n");
- } else {
- netif->flags2 &= ~NETIF_FLAG2_PROMISC;
- }
+ ifreq.ifr_name[0] = 0;
+ ifreq.ifr_flags = flags & ~IFF_PROMISC;
+ if (netif->ioctl) {
+ if (netif->ioctl(netif, SIOCSIFFLAGS, &ifreq)) { /* make Non IFF_PROMISC */
+ _PrintHandle("sub ethernet device can not support IFF_PROMISC!\r\n");
+ } else {
+ netif->flags2 &= ~NETIF_FLAG2_PROMISC;
}
}
}
diff --git a/SylixOS/net/lwip/bridge/netbridge.c b/SylixOS/net/lwip/bridge/netbridge.c
index 2b932f7..9c1e993 100644
--- a/SylixOS/net/lwip/bridge/netbridge.c
+++ b/SylixOS/net/lwip/bridge/netbridge.c
@@ -573,15 +573,13 @@ int netbr_delete_dev (const char *brdev, int brindex, const char *sub, int sub_
}
flags = netif_get_flags(netif);
- if (flags & IFF_PROMISC) {
- ifreq.ifr_name[0] = 0;
- ifreq.ifr_flags = flags & ~IFF_PROMISC;
- if (netif->ioctl) {
- if (netif->ioctl(netif, SIOCSIFFLAGS, &ifreq)) { /* make Non IFF_PROMISC */
- _PrintHandle("sub ethernet device can not support IFF_PROMISC!\r\n");
- } else {
- netif->flags2 &= ~NETIF_FLAG2_PROMISC;
- }
+ ifreq.ifr_name[0] = 0;
+ ifreq.ifr_flags = flags & ~IFF_PROMISC;
+ if (netif->ioctl) {
+ if (netif->ioctl(netif, SIOCSIFFLAGS, &ifreq)) { /* make Non IFF_PROMISC */
+ _PrintHandle("sub ethernet device can not support IFF_PROMISC!\r\n");
+ } else {
+ netif->flags2 &= ~NETIF_FLAG2_PROMISC;
}
}
@@ -739,15 +737,13 @@ int netbr_delete (const char *brdev, int brindex)
}
flags = netif_get_flags(netif);
- if (flags & IFF_PROMISC) {
- ifreq.ifr_name[0] = 0;
- ifreq.ifr_flags = flags & ~IFF_PROMISC;
- if (netif->ioctl) {
- if (netif->ioctl(netif, SIOCSIFFLAGS, &ifreq)) {
- _PrintHandle("sub ethernet device can not support IFF_PROMISC!\r\n");
- } else {
- netif->flags2 &= ~NETIF_FLAG2_PROMISC;
- }
+ ifreq.ifr_name[0] = 0;
+ ifreq.ifr_flags = flags & ~IFF_PROMISC;
+ if (netif->ioctl) {
+ if (netif->ioctl(netif, SIOCSIFFLAGS, &ifreq)) {
+ _PrintHandle("sub ethernet device can not support IFF_PROMISC!\r\n");
+ } else {
+ netif->flags2 &= ~NETIF_FLAG2_PROMISC;
}
}
@@ -861,15 +857,13 @@ void netbr_sub_delete_hook (netdev_t *netdev)
}
flags = netif_get_flags(netif);
- if (flags & IFF_PROMISC) {
- ifreq.ifr_name[0] = 0;
- ifreq.ifr_flags = flags & ~IFF_PROMISC;
- if (netif->ioctl) {
- if (netif->ioctl(netif, SIOCSIFFLAGS, &ifreq)) { /* make Non IFF_PROMISC */
- _PrintHandle("sub ethernet device can not support IFF_PROMISC!\r\n");
- } else {
- netif->flags2 &= ~NETIF_FLAG2_PROMISC;
- }
+ ifreq.ifr_name[0] = 0;
+ ifreq.ifr_flags = flags & ~IFF_PROMISC;
+ if (netif->ioctl) {
+ if (netif->ioctl(netif, SIOCSIFFLAGS, &ifreq)) { /* make Non IFF_PROMISC */
+ _PrintHandle("sub ethernet device can not support IFF_PROMISC!\r\n");
+ } else {
+ netif->flags2 &= ~NETIF_FLAG2_PROMISC;
}
}
diff --git a/SylixOS/net/lwip/lwip_if.c b/SylixOS/net/lwip/lwip_if.c
index 61b0024..3849ed4 100644
--- a/SylixOS/net/lwip/lwip_if.c
+++ b/SylixOS/net/lwip/lwip_if.c
@@ -431,7 +431,8 @@ char *if_indextoname (unsigned ifindex, char *ifname)
char *ret;
if (!ifname) {
- errno = EINVAL;
+ _ErrorHandle(EINVAL);
+ return (LW_NULL);
}
LWIP_IF_LIST_LOCK(LW_FALSE); /* 进入临界区 */
diff --git a/SylixOS/net/lwip/mroute/ip4_mrt.c b/SylixOS/net/lwip/mroute/ip4_mrt.c
index 7a06382..bd46ffb 100644
--- a/SylixOS/net/lwip/mroute/ip4_mrt.c
+++ b/SylixOS/net/lwip/mroute/ip4_mrt.c
@@ -421,6 +421,8 @@ static u8_t ip4_mrt_down (struct raw_pcb *pcb)
((struct sockaddr_in *)&(ifr.ifr_addr))->sin_family = AF_INET;
((struct sockaddr_in *)&(ifr.ifr_addr))->sin_addr.s_addr = INADDR_ANY;
ifp->ioctl(ifp, SIOCDELMULTI, &ifr);
+ } else {
+ ifp->flags2 &= ~NETIF_FLAG2_ALLMULTI;
}
}
}
@@ -569,6 +571,8 @@ static u8_t ip4_mrt_add_vif (struct vifctl *vifcp)
((struct sockaddr_in *)&(ifr.ifr_addr))->sin_addr.s_addr = INADDR_ANY;
if (ifp->ioctl(ifp, SIOCADDMULTI, &ifr)) {
return (EOPNOTSUPP);
+ } else {
+ ifp->flags2 |= NETIF_FLAG2_ALLMULTI;
}
}
} else {
@@ -632,6 +636,8 @@ static u8_t ip4_mrt_del_vif (const vifi_t *vifip)
((struct sockaddr_in *)&(ifr.ifr_addr))->sin_family = AF_INET;
((struct sockaddr_in *)&(ifr.ifr_addr))->sin_addr.s_addr = INADDR_ANY;
ifp->ioctl(ifp, SIOCDELMULTI, &ifr);
+ } else {
+ ifp->flags2 &= ~NETIF_FLAG2_ALLMULTI;
}
}
}
diff --git a/SylixOS/net/lwip/mroute/ip6_mrt.c b/SylixOS/net/lwip/mroute/ip6_mrt.c
index 2fad8f0..31cd455 100644
--- a/SylixOS/net/lwip/mroute/ip6_mrt.c
+++ b/SylixOS/net/lwip/mroute/ip6_mrt.c
@@ -284,6 +284,8 @@ static u8_t ip6_mrt_down (struct raw_pcb *pcb)
((struct sockaddr_in6 *)&(ifr.ifr_addr))->sin6_family = AF_INET6;
((struct sockaddr_in6 *)&(ifr.ifr_addr))->sin6_addr = in6addr_any;
ifp->ioctl(ifp, SIOCDELMULTI, &ifr);
+ } else {
+ ifp->flags2 &= ~NETIF_FLAG2_ALLMULTI;
}
}
}
@@ -376,6 +378,8 @@ static u8_t ip6_mrt_add_mif (struct mif6ctl *mifcp)
((struct sockaddr_in6 *)&(ifr.ifr_addr))->sin6_addr = in6addr_any;
if (ifp->ioctl(ifp, SIOCADDMULTI, &ifr)) {
return (EOPNOTSUPP);
+ } else {
+ ifp->flags2 |= NETIF_FLAG2_ALLMULTI;
}
}
} else {
@@ -431,6 +435,8 @@ static u8_t ip6_mrt_del_mif (mifi_t *mifip)
((struct sockaddr_in6 *)&(ifr.ifr_addr))->sin6_family = AF_INET6;
((struct sockaddr_in6 *)&(ifr.ifr_addr))->sin6_addr = in6addr_any;
ifp->ioctl(ifp, SIOCDELMULTI, &ifr);
+ } else {
+ ifp->flags2 &= ~NETIF_FLAG2_ALLMULTI;
}
}
}
diff --git a/SylixOS/net/lwip/netdev/netdev.c b/SylixOS/net/lwip/netdev/netdev.c
index e8df8ca..6803eb5 100644
--- a/SylixOS/net/lwip/netdev/netdev.c
+++ b/SylixOS/net/lwip/netdev/netdev.c
@@ -204,6 +204,7 @@ static err_t netdev_netif_igmp_mac_filter (struct netif *netif,
mem_free(mac);
netif_set_maddr_hook(netif, group, 0);
+#if NETDEV_ALWAYS_ALLMULTI > 0
if (!netdev->mac_filter) {
flags = netif_get_flags(netif);
if (flags & IFF_ALLMULTI) {
@@ -211,6 +212,7 @@ static err_t netdev_netif_igmp_mac_filter (struct netif *netif,
netif->flags2 &= ~NETIF_FLAG2_ALLMULTI;
}
}
+#endif /* NETDEV_ALWAYS_ALLMULTI > 0 */
} else {
if (mac) {
@@ -232,13 +234,20 @@ static err_t netdev_netif_igmp_mac_filter (struct netif *netif,
netdev->mac_filter = mac;
netif_set_maddr_hook(netif, group, 1);
+#if NETDEV_ALWAYS_ALLMULTI > 0
flags = netif_get_flags(netif);
if (!(flags & IFF_ALLMULTI)) {
NETDEV_RXMODE(netdev, flags | IFF_ALLMULTI);
netif->flags2 |= NETIF_FLAG2_ALLMULTI;
}
+#endif /* NETDEV_ALWAYS_ALLMULTI > 0 */
}
+#if NETDEV_ALWAYS_ALLMULTI == 0
+ flags = netif_get_flags(netif);
+ NETDEV_RXMODE(netdev, flags);
+#endif /* NETDEV_ALWAYS_ALLMULTI == 0 */
+
return (ERR_OK);
}
@@ -286,6 +295,7 @@ static err_t netdev_netif_mld_mac_filter (struct netif *netif,
mem_free(mac);
netif_set_maddr6_hook(netif, group, 0);
+#if NETDEV_ALWAYS_ALLMULTI > 0
if (!netdev->mac_filter) {
flags = netif_get_flags(netif);
if (flags & IFF_ALLMULTI) {
@@ -293,6 +303,7 @@ static err_t netdev_netif_mld_mac_filter (struct netif *netif,
netif->flags2 &= ~NETIF_FLAG2_ALLMULTI;
}
}
+#endif /* NETDEV_ALWAYS_ALLMULTI > 0 */
} else {
if (mac) {
@@ -314,13 +325,20 @@ static err_t netdev_netif_mld_mac_filter (struct netif *netif,
netdev->mac_filter = mac;
netif_set_maddr6_hook(netif, group, 1);
+#if NETDEV_ALWAYS_ALLMULTI > 0
flags = netif_get_flags(netif);
if (!(flags & IFF_ALLMULTI)) {
NETDEV_RXMODE(netdev, flags | IFF_ALLMULTI);
netif->flags2 |= NETIF_FLAG2_ALLMULTI;
}
+#endif /* NETDEV_ALWAYS_ALLMULTI > 0 */
}
+#if NETDEV_ALWAYS_ALLMULTI == 0
+ flags = netif_get_flags(netif);
+ NETDEV_RXMODE(netdev, flags);
+#endif /* NETDEV_ALWAYS_ALLMULTI == 0 */
+
return (ERR_OK);
}
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
@@ -366,8 +384,9 @@ static int netdev_netif_ioctl (struct netif *netif, int cmd, void *arg)
if (netdev->drv->rxmode) {
ifreq = (struct ifreq *)arg;
flags = netif_get_flags(netif);
- if ((flags & (IFF_PROMISC | IFF_ALLMULTI)) !=
- (ifreq->ifr_flags & (IFF_PROMISC | IFF_ALLMULTI))) { /* rx mode changed */
+ if (((flags & (IFF_PROMISC | IFF_ALLMULTI)) !=
+ (ifreq->ifr_flags & (IFF_PROMISC | IFF_ALLMULTI))) ||
+ (ifreq->ifr_name[0] == '\0')) { /* rx mode need changed */
ret = netdev->drv->rxmode(netdev, ifreq->ifr_flags);
} else {
ret = 0; /* do not allow to change other flags */
@@ -746,6 +765,8 @@ static err_t netdev_netif_init (struct netif *netif)
NETDEV_UP(netdev);
}
+ NETDEV_RXMODE(netdev, netdev->if_flags); /* init rxmode */
+
#if LWIP_IPV6 && LWIP_IPV6_MLD
/*
* For hardware/netifs that implement MAC filtering.
@@ -759,8 +780,6 @@ static err_t netdev_netif_init (struct netif *netif)
}
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
- NETDEV_RXMODE(netdev, netdev->if_flags); /* init rxmode */
-
return (ERR_OK);
}
@@ -1170,6 +1189,20 @@ int netdev_foreache (FUNCPTR pfunc, void *arg0, void *arg1,
return (0);
}
+/* Get netdev flags */
+int netdev_flags (netdev_t *netdev)
+{
+ struct netif *netif;
+
+ if (!netdev || (netdev->magic_no != NETDEV_MAGIC)) {
+ return (0);
+ }
+
+ netif = (struct netif *)netdev->sys;
+
+ return (netif_get_flags(netif));
+}
+
/* netdev start poll mode */
int netdev_poll_enable (netdev_t *netdev, int (*poll_input)(struct netdev *, struct pbuf *), void *poll_arg)
{
@@ -1551,11 +1584,16 @@ int netdev_macfilter_add (netdev_t *netdev, const UINT8 hwaddr[])
if (type == NETDEV_MAC_TYPE_MULTICAST) {
netif = (struct netif *)(netdev->sys);
+#if NETDEV_ALWAYS_ALLMULTI > 0
flags = netif_get_flags(netif);
if (!(flags & IFF_ALLMULTI)) {
NETDEV_RXMODE(netdev, flags | IFF_ALLMULTI);
netif->flags2 |= NETIF_FLAG2_ALLMULTI;
}
+#else /* NETDEV_ALWAYS_ALLMULTI > 0 */
+ flags = netif_get_flags(netif);
+ NETDEV_RXMODE(netdev, flags);
+#endif /* NETDEV_ALWAYS_ALLMULTI == 0 */
}
return (0);
@@ -1594,11 +1632,16 @@ int netdev_macfilter_delete (netdev_t *netdev, const UINT8 hwaddr[])
if (!netdev->mac_filter) {
netif = (struct netif *)(netdev->sys);
+#if NETDEV_ALWAYS_ALLMULTI > 0
flags = netif_get_flags(netif);
if (flags & IFF_ALLMULTI) {
NETDEV_RXMODE(netdev, flags & ~IFF_ALLMULTI);
netif->flags2 &= ~NETIF_FLAG2_ALLMULTI;
}
+#else /* NETDEV_ALWAYS_ALLMULTI > 0 */
+ flags = netif_get_flags(netif);
+ NETDEV_RXMODE(netdev, flags);
+#endif /* NETDEV_ALWAYS_ALLMULTI == 0 */
}
return (0);
diff --git a/SylixOS/net/lwip/netdev/netdev.h b/SylixOS/net/lwip/netdev/netdev.h
index f9a9555..4038e87 100644
--- a/SylixOS/net/lwip/netdev/netdev.h
+++ b/SylixOS/net/lwip/netdev/netdev.h
@@ -59,6 +59,9 @@
/* netdev declaration */
struct netdev;
+/* When add a multicast address, whether to allow all multicast packets */
+#define NETDEV_ALWAYS_ALLMULTI 0
+
/*
* netdev media address list
*/
@@ -284,7 +287,7 @@ typedef struct netdev {
void *priv; /* user network device private data */
/* the following member is used by system, driver MUST set zero and do not used! */
- int if_flags;
+ int if_flags; /* ONLY IFF_RUNNING and IFF_UP flags will automated update, use netdev_flags() instead */
/* wireless externed */
void *wireless_handlers; /* iw_handler_def ptr */
@@ -314,6 +317,7 @@ int netdev_delete(netdev_t *netdev); /* WARNING: You MUST DO NOT lock device th
int netdev_index(netdev_t *netdev, unsigned int *index);
int netdev_ifname(netdev_t *netdev, char *ifname);
int netdev_foreache(FUNCPTR pfunc, void *arg0, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5);
+int netdev_flags(netdev_t *netdev);
/* netdev outer firewall set,
* The system will automatically call fw() with each received packet,
diff --git a/SylixOS/net/lwip/packet/af_packet.c b/SylixOS/net/lwip/packet/af_packet.c
index fe221d5..d673b57 100644
--- a/SylixOS/net/lwip/packet/af_packet.c
+++ b/SylixOS/net/lwip/packet/af_packet.c
@@ -1252,7 +1252,7 @@ INT packet_connect (AF_PACKET_T *pafpacket, const struct sockaddr *name, sockle
return (ERROR_NONE);
}
/*********************************************************************************************************
-** 函数名称: packet_recvfrom
+** 函数名称: packet_recvfrom2
** 功能描述: recvfrom
** 输 入 : pafpacket afpacket file
** mem buffer
diff --git a/SylixOS/system/device/ahci/ahciLib.c b/SylixOS/system/device/ahci/ahciLib.c
index b1d061c..0300b2d 100644
--- a/SylixOS/system/device/ahci/ahciLib.c
+++ b/SylixOS/system/device/ahci/ahciLib.c
@@ -278,7 +278,9 @@ UINT64 API_AhciDriveSectorCountGet (AHCI_CTRL_HANDLE hCtrl, UINT uiDrive)
ullSectors = hCtrl->AHCICTRL_uiLbaTotalSecs[uiDrive];
} else { /* CHS 模式 */
- ullSectors = hDrive->AHCIDRIVE_uiCylinder * hDrive->AHCIDRIVE_uiHead * hDrive->AHCIDRIVE_uiSector;
+ ullSectors = (UINT64)hDrive->AHCIDRIVE_uiCylinder *
+ hDrive->AHCIDRIVE_uiHead *
+ hDrive->AHCIDRIVE_uiSector;
}
return (ullSectors);
diff --git a/SylixOS/system/device/ata/ata.c b/SylixOS/system/device/ata/ata.c
index 7dfb5cf..b44eb5f 100644
--- a/SylixOS/system/device/ata/ata.c
+++ b/SylixOS/system/device/ata/ata.c
@@ -830,7 +830,7 @@ static INT ataBlkDevFill (ATA_DEV_HANDLE hDev)
if ((hDrive->ATADRIVE_ucOkLba) &&
(hDrive->ATADRIVE_ullCapacity) &&
- (hDrive->ATADRIVE_ullCapacity > (UINT64)(uiCylinders * uiHeads * uiSectors))) {
+ (hDrive->ATADRIVE_ullCapacity > ((UINT64)uiCylinders * uiHeads * uiSectors))) {
ullBlkMax = hDrive->ATADRIVE_ullCapacity - hDev->ATADEV_ullBlkOffset;
ATA_LOG(ATA_LOG_PRT,
@@ -839,7 +839,7 @@ static INT ataBlkDevFill (ATA_DEV_HANDLE hDev)
uiCylinders, uiHeads, uiSectors, hInfo, uiBytes);
} else {
- ullBlkMax = (UINT64)(uiCylinders * uiHeads * uiSectors) - hDev->ATADEV_ullBlkOffset;
+ ullBlkMax = ((UINT64)uiCylinders * uiHeads * uiSectors) - hDev->ATADEV_ullBlkOffset;
ATA_LOG(ATA_LOG_PRT,
"ctrl %d drive %d blk dev use chs cyl=%d, heads=%d, secs=%d info=%p bytes=%d.\r\n",
diff --git a/SylixOS/system/device/pci/pciShow.c b/SylixOS/system/device/pci/pciShow.c
index 6ec9047..0cf45a2 100644
--- a/SylixOS/system/device/pci/pciShow.c
+++ b/SylixOS/system/device/pci/pciShow.c
@@ -1338,7 +1338,7 @@ static VOID __pciCapPcieSlot (INT iBus, INT iSlot, INT iFunc, UINT uiOffset)
}
if (usSlotCtl & PCI_EXP_SLTCTL_PWRC) {
printf(" Power Controller %s",
- (usSlotCtl & PCI_EXP_SLTCTL_PWRI) >> 10 == 0 ? "on" : "off");
+ (usSlotCtl & PCI_EXP_SLTCTL_PWRC) >> 10 == 0 ? "on" : "off");
}
}
/*********************************************************************************************************
diff --git a/SylixOS/system/device/sdcard/host/sdhci.c b/SylixOS/system/device/sdcard/host/sdhci.c
index 26e5671..8a11585 100644
--- a/SylixOS/system/device/sdcard/host/sdhci.c
+++ b/SylixOS/system/device/sdcard/host/sdhci.c
@@ -85,7 +85,7 @@
#define __SDHCI_SDIOINTSVR_PRIO 197
#define __SDHCI_SDIOINTSVR_STKSZ (8 * 1024)
/*********************************************************************************************************
- 传输事务线操作宏定义
+ 传输事务线程操作宏定义
*********************************************************************************************************/
#define __SDHCI_TRANS_PREP() INTREG iregInterLevel
#define __SDHCI_TRANS_LOCK(pt) LW_SPIN_LOCK_QUICK(&pt->SDHCITS_slLock, &iregInterLevel)
@@ -157,6 +157,7 @@ struct __sdhci_trans {
BOOL SDHCITS_bCmdFinish;
BOOL SDHCITS_bDatFinish;
+ BOOL SDHCITS_bTransFinish;
INT SDHCITS_iCmdError;
INT SDHCITS_iDatError; /* 事务状态控制 */
@@ -173,8 +174,6 @@ struct __sdhci_trans {
LW_OBJECT_HANDLE SDHCITS_hSdioIntThread; /* 负责 SDIO 中断处理线程 */
LW_OBJECT_HANDLE SDHCITS_hSdioIntSem; /* SDIO 中断同步信号 */
- UINT32 SDHCITS_uiIntSta;
-
INT SDHCITS_iStage;
#define __SDHCI_TRANS_STAGE_START 0
#define __SDHCI_TRANS_STAGE_STOP 1
@@ -306,9 +305,12 @@ static VOID __sdhciDataPrepareSdma(__PSDHCI_HOST psdhcihost);
static VOID __sdhciDataPrepareAdma(__PSDHCI_HOST psdhcihost);
static VOID __sdhciTransferIntSet(__PSDHCI_HOST psdhcihost);
-static VOID __sdhciIntDisAndEn(__PSDHCI_HOST psdhcihost,
- UINT32 uiDisMask,
- UINT32 uiEnMask);
+static VOID __sdhciIntStatusDisAndEn(__PSDHCI_HOST psdhcihost,
+ UINT32 uiDisMask,
+ UINT32 uiEnMask);
+static VOID __sdhciIntSignalDisAndEn(__PSDHCI_HOST psdhcihost,
+ UINT32 uiDisMask,
+ UINT32 uiEnMask);
static VOID __sdhciSdioIntEn(__PSDHCI_HOST psdhcihost, BOOL bEnable);
/*********************************************************************************************************
FOR TRANSACTION
@@ -329,7 +331,7 @@ static INT __sdhciTransClean(__SDHCI_TRANS *psdhcitrans);
static irqreturn_t __sdhciTransIrq(VOID *pvArg, ULONG ulVector);
static PVOID __sdhciSdioIntSvr(VOID *pvArg);
-static VOID __sdhciTransHandle(__SDHCI_TRANS *psdhcitrans);
+static VOID __sdhciTransHandle(__SDHCI_TRANS *psdhcitrans, UINT32 uiIntSta);
static INT __sdhciTransCmdHandle(__SDHCI_TRANS *psdhcitrans, UINT32 uiIntSta);
static INT __sdhciTransDatHandle(__SDHCI_TRANS *psdhcitrans, UINT32 uiIntSta);
@@ -528,8 +530,6 @@ LW_API PVOID API_SdhciHostCreate (CPCHAR pcAdapterName,
lib_memcpy(&psdhcihost->SDHCIHS_sdhcihostattr,
psdhcihostattr, sizeof(LW_SDHCI_HOST_ATTR));
/* 保存属性域 */
- __sdhciIntDisAndEn(psdhcihost, SDHCI_INT_ALL_MASK, 0); /* 禁止所有中断 */
-
psdhcitrans = __sdhciTransNew(psdhcihost);
if (!psdhcitrans) {
goto __err1;
@@ -559,7 +559,12 @@ LW_API PVOID API_SdhciHostCreate (CPCHAR pcAdapterName,
__sdhciTimeoutSet(psdhcihost);
- __sdhciIntDisAndEn(psdhcihost, SDHCI_INT_ALL_MASK | SDHCI_INT_CARD_INT, __SDHCI_INT_EN_MASK);
+ __sdhciIntStatusDisAndEn(psdhcihost,
+ SDHCI_INT_ALL_MASK | SDHCI_INT_CARD_INT,
+ __SDHCI_INT_EN_MASK);
+ __sdhciIntSignalDisAndEn(psdhcihost,
+ SDHCI_INT_ALL_MASK | SDHCI_INT_CARD_INT,
+ __SDHCI_INT_EN_MASK);
return ((PVOID)psdhcihost);
@@ -1955,9 +1960,9 @@ static INT __sdhciCmdSend (__PSDHCI_HOST psdhcihost,
__timeout:
SDCARD_DEBUG_MSG(__ERRORMESSAGE_LEVEL,"timeout error.\r\n");
- psdhcitrans->SDHCITS_iCmdError = PX_ERROR;
- psdhcitrans->SDHCITS_iDatError = PX_ERROR;
- __sdhciTransFinish(psdhcitrans);
+ psdhcitrans->SDHCITS_iCmdError = PX_ERROR;
+ psdhcitrans->SDHCITS_iDatError = PX_ERROR;
+ psdhcitrans->SDHCITS_bTransFinish = LW_TRUE; /* 本次事务结束 */
return (PX_ERROR);
}
@@ -2283,10 +2288,15 @@ static VOID __sdhciTransDmaSync (__PSDHCI_TRANS psdhcitrans,
static VOID __sdhciTransferIntSet (__PSDHCI_HOST psdhcihost)
{
PLW_SDHCI_HOST_ATTR psdhcihostattr = &psdhcihost->SDHCIHS_sdhcihostattr;
+ __SDHCI_TRANS *psdhcitrans = psdhcihost->SDHCIHS_psdhcitrans;
+
UINT32 uiIntIoMsk; /* 使用一般传输时的中断掩码 */
UINT32 uiIntDmaMsk; /* 使用 DMA 传输时的中断掩码 */
UINT32 uiEnMask; /* 最终使能掩码 */
+ __SDHCI_TRANS_PREP();
+
+ __SDHCI_TRANS_LOCK(psdhcitrans);
uiIntIoMsk = SDHCI_INT_SPACE_AVAIL | SDHCI_INT_DATA_AVAIL;
uiIntDmaMsk = SDHCI_INT_DMA_END | SDHCI_INT_ADMA_ERROR;
uiEnMask = SDHCI_READL(psdhcihostattr, SDHCI_INTSTA_ENABLE); /* 读取32位(包括错误中断) */
@@ -2307,10 +2317,11 @@ static VOID __sdhciTransferIntSet (__PSDHCI_HOST psdhcihost)
*/
SDHCI_WRITEL(psdhcihostattr, SDHCI_INTSTA_ENABLE, uiEnMask);
SDHCI_WRITEL(psdhcihostattr, SDHCI_SIGNAL_ENABLE, uiEnMask);
+ __SDHCI_TRANS_UNLOCK(psdhcitrans);
}
/*********************************************************************************************************
-** 函数名称: __sdhciIntDisAndEn
-** 功能描述: 中断设置(使能\禁能).设置中断状态(错误\一般状态)和中断信号(错误\一般信号)寄存器.
+** 函数名称: __sdhciIntStatusDisAndEn
+** 功能描述: 中断状态(错误\一般状态)设置(使能\禁能).
** 输 入: psdhcihost SDHCI HOST 结构指针
** uiDisMask 禁能掩码
** uiEnMask 使能掩码
@@ -2318,23 +2329,51 @@ static VOID __sdhciTransferIntSet (__PSDHCI_HOST psdhcihost)
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __sdhciIntDisAndEn (__PSDHCI_HOST psdhcihost,
- UINT32 uiDisMask,
- UINT32 uiEnMask)
+static VOID __sdhciIntStatusDisAndEn (__PSDHCI_HOST psdhcihost,
+ UINT32 uiDisMask,
+ UINT32 uiEnMask)
{
PLW_SDHCI_HOST_ATTR psdhcihostattr = &psdhcihost->SDHCIHS_sdhcihostattr;
+ __SDHCI_TRANS *psdhcitrans = psdhcihost->SDHCIHS_psdhcitrans;
UINT32 uiMask;
+ __SDHCI_TRANS_PREP();
+
+ __SDHCI_TRANS_LOCK(psdhcitrans);
uiMask = SDHCI_READL(psdhcihostattr, SDHCI_INTSTA_ENABLE);
uiMask &= ~uiDisMask;
uiMask |= uiEnMask;
- /*
- * 因为这两个寄存器的位标位置都完全相同,
- * 所以可以同时用一个掩码.
- */
SDHCI_WRITEL(psdhcihostattr, SDHCI_INTSTA_ENABLE, uiMask);
+ __SDHCI_TRANS_UNLOCK(psdhcitrans);
+}
+/*********************************************************************************************************
+** 函数名称: __sdhciIntSignalDisAndEn
+** 功能描述: 中断信号(错误\一般状态)设置(使能\禁能).
+** 输 入: psdhcihost SDHCI HOST 结构指针
+** uiDisMask 禁能掩码
+** uiEnMask 使能掩码
+** 输 出: NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static VOID __sdhciIntSignalDisAndEn (__PSDHCI_HOST psdhcihost,
+ UINT32 uiDisMask,
+ UINT32 uiEnMask)
+{
+ PLW_SDHCI_HOST_ATTR psdhcihostattr = &psdhcihost->SDHCIHS_sdhcihostattr;
+ __SDHCI_TRANS *psdhcitrans = psdhcihost->SDHCIHS_psdhcitrans;
+ UINT32 uiMask;
+
+ __SDHCI_TRANS_PREP();
+
+ __SDHCI_TRANS_LOCK(psdhcitrans);
+ uiMask = SDHCI_READL(psdhcihostattr, SDHCI_SIGNAL_ENABLE);
+ uiMask &= ~uiDisMask;
+ uiMask |= uiEnMask;
+
SDHCI_WRITEL(psdhcihostattr, SDHCI_SIGNAL_ENABLE, uiMask);
+ __SDHCI_TRANS_UNLOCK(psdhcitrans);
}
/*********************************************************************************************************
** 函数名称: __sdhciSdioIntEn
@@ -2348,9 +2387,15 @@ static VOID __sdhciIntDisAndEn (__PSDHCI_HOST psdhcihost,
static VOID __sdhciSdioIntEn (__PSDHCI_HOST psdhcihost, BOOL bEnable)
{
PLW_SDHCI_HOST_ATTR psdhcihostattr = &psdhcihost->SDHCIHS_sdhcihostattr;
+ __SDHCI_TRANS *psdhcitrans = psdhcihost->SDHCIHS_psdhcitrans;
+
UINT32 uiMask;
+ __SDHCI_TRANS_PREP();
+
+ __SDHCI_TRANS_LOCK(psdhcitrans);
if (psdhcihost->SDHCIHS_bSdioIntEnable == bEnable) {
+ __SDHCI_TRANS_UNLOCK(psdhcitrans);
return;
}
@@ -2364,6 +2409,7 @@ static VOID __sdhciSdioIntEn (__PSDHCI_HOST psdhcihost, BOOL bEnable)
SDHCI_WRITEL(psdhcihostattr, SDHCI_INTSTA_ENABLE, uiMask);
SDHCI_WRITEL(psdhcihostattr, SDHCI_SIGNAL_ENABLE, uiMask);
psdhcihost->SDHCIHS_bSdioIntEnable = bEnable;
+ __SDHCI_TRANS_UNLOCK(psdhcitrans);
}
/*********************************************************************************************************
** 函数名称: __sdhciTransNew
@@ -2414,6 +2460,9 @@ static __SDHCI_TRANS *__sdhciTransNew (__PSDHCI_HOST psdhcihost)
goto __err2;
}
+ __sdhciIntStatusDisAndEn(psdhcihost, SDHCI_INT_ALL_MASK, 0); /* 禁止所有中断状态 */
+ __sdhciIntSignalDisAndEn(psdhcihost, SDHCI_INT_ALL_MASK, 0); /* 禁止所有中断信号 */
+
API_InterVectorConnect(psdhcihost->SDHCIHS_sdhcihostattr.SDHCIHOST_ulIntVector,
__sdhciTransIrq,
(VOID *)psdhcitrans,
@@ -2608,11 +2657,12 @@ static INT __sdhciTransPrepare (__SDHCI_TRANS *psdhcitrans,
psdhcitrans->SDHCITS_uiBlkCntRemain = 0;
}
- psdhcitrans->SDHCITS_iTransType = iTransType;
- psdhcitrans->SDHCITS_bCmdFinish = LW_FALSE;
- psdhcitrans->SDHCITS_bDatFinish = LW_FALSE;
- psdhcitrans->SDHCITS_iCmdError = ERROR_NONE;
- psdhcitrans->SDHCITS_iDatError = ERROR_NONE;
+ psdhcitrans->SDHCITS_iTransType = iTransType;
+ psdhcitrans->SDHCITS_bCmdFinish = LW_FALSE;
+ psdhcitrans->SDHCITS_bDatFinish = LW_FALSE;
+ psdhcitrans->SDHCITS_bTransFinish = LW_FALSE;
+ psdhcitrans->SDHCITS_iCmdError = ERROR_NONE;
+ psdhcitrans->SDHCITS_iDatError = ERROR_NONE;
psdhcitrans->SDHCITS_psdcmd = psdmsg->SDMSG_psdcmdCmd;
psdhcitrans->SDHCITS_psdcmdStop = psdmsg->SDMSG_psdcmdStop;
@@ -2644,7 +2694,10 @@ static INT __sdhciTransStart (__SDHCI_TRANS *psdhcitrans)
if (SDHCI_QUIRK_FLG(&psdhcitrans->SDHCITS_psdhcihost->SDHCIHS_sdhcihostattr,
SDHCI_QUIRK_FLG_REENABLE_INTS_ON_EVERY_TRANSACTION)) {
__sdhciIntClear(psdhcitrans->SDHCITS_psdhcihost);
- __sdhciIntDisAndEn(psdhcitrans->SDHCITS_psdhcihost, SDHCI_INT_ALL_MASK, __SDHCI_INT_EN_MASK);
+ __sdhciIntStatusDisAndEn(psdhcitrans->SDHCITS_psdhcihost,
+ SDHCI_INT_ALL_MASK, __SDHCI_INT_EN_MASK);
+ __sdhciIntSignalDisAndEn(psdhcitrans->SDHCITS_psdhcihost,
+ SDHCI_INT_ALL_MASK, __SDHCI_INT_EN_MASK);
}
if (psdhcitrans->SDHCITS_pucDatBuffCurr) {
@@ -2716,7 +2769,8 @@ static INT __sdhciTransClean (__SDHCI_TRANS *psdhcitrans)
if (SDHCI_QUIRK_FLG(&psdhcitrans->SDHCITS_psdhcihost->SDHCIHS_sdhcihostattr,
SDHCI_QUIRK_FLG_REENABLE_INTS_ON_EVERY_TRANSACTION)) {
- __sdhciIntDisAndEn(psdhcitrans->SDHCITS_psdhcihost, SDHCI_INT_ALL_MASK, 0);
+ __sdhciIntStatusDisAndEn(psdhcitrans->SDHCITS_psdhcihost, SDHCI_INT_ALL_MASK, 0);
+ __sdhciIntSignalDisAndEn(psdhcitrans->SDHCITS_psdhcihost, SDHCI_INT_ALL_MASK, 0);
__sdhciIntClear(psdhcitrans->SDHCITS_psdhcihost);
}
__SDHCI_TRANS_UNLOCK(psdhcitrans);
@@ -2753,12 +2807,10 @@ static irqreturn_t __sdhciTransIrq (VOID *pvArg, ULONG ulVector)
__redo:
__SDHCI_TRANS_LOCK(psdhcitrans);
uiIntSta = SDHCI_READL(psdhcihostattr, SDHCI_INT_STATUS);
- psdhcitrans->SDHCITS_uiIntSta = uiIntSta;
SDHCI_WRITEL(psdhcihostattr, SDHCI_INT_STATUS, uiIntSta);
__SDHCI_TRANS_UNLOCK(psdhcitrans);
if (!uiIntSta || uiIntSta == 0xffffffff) {
- SDHCI_WRITEL(psdhcihostattr, SDHCI_INT_STATUS, uiIntSta);
SDCARD_DEBUG_MSG(__ERRORMESSAGE_LEVEL, "unknown int signals\r\n");
API_InterVectorGetFlag(ulVector, &ulIntFlag);
@@ -2770,12 +2822,14 @@ __redo:
}
if (__SDHCI_ISRDEFER_EN(psdhcitrans)) {
- API_InterVectorDisable(ulVector);
- API_InterDeferJobAdd(psdhcitrans->SDHCITS_pjobqueue,
- (VOIDFUNCPTR)__sdhciTransHandle,
- (PVOID)psdhcitrans);
+ __sdhciIntSignalDisAndEn(psdhcihost, uiIntSta, 0);
+ API_InterDeferJobAddEx(psdhcitrans->SDHCITS_pjobqueue,
+ (VOIDFUNCPTR)__sdhciTransHandle,
+ (PVOID)psdhcitrans,
+ (PVOID)(ULONG)uiIntSta,
+ LW_NULL, LW_NULL, LW_NULL, LW_NULL);
} else {
- __sdhciTransHandle(psdhcitrans);
+ __sdhciTransHandle(psdhcitrans, uiIntSta);
}
/*
@@ -2799,30 +2853,22 @@ __end:
** 函数名称: __sdhciTransHandle
** 功能描述: SDHCI 传输处理程序
** 输 入: psdhcitrans 传输控制块
+ uiIntSta 当前需要处理的中断状态
** 输 出: NONE
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __sdhciTransHandle (__SDHCI_TRANS *psdhcitrans)
+static VOID __sdhciTransHandle (__SDHCI_TRANS *psdhcitrans, UINT32 uiIntSta)
{
__SDHCI_HOST *psdhcihost = psdhcitrans->SDHCITS_psdhcihost;
LW_SDHCI_HOST_ATTR *psdhcihostattr = &psdhcihost->SDHCIHS_sdhcihostattr;
BOOL bSdioInt = LW_FALSE;
- UINT32 uiIntSta;
-
- __SDHCI_TRANS_PREP();
-
- __SDHCI_TRANS_LOCK(psdhcitrans);
- uiIntSta = psdhcitrans->SDHCITS_uiIntSta;
- __SDHCI_TRANS_UNLOCK(psdhcitrans);
if (uiIntSta & SDHCI_INT_CMD_MASK) {
- SDHCI_WRITEL(psdhcihostattr, SDHCI_INT_STATUS, uiIntSta & SDHCI_INT_CMD_MASK);
__sdhciTransCmdHandle(psdhcitrans, uiIntSta & SDHCI_INT_CMD_MASK);
}
if (uiIntSta & SDHCI_INT_DATA_MASK) {
- SDHCI_WRITEL(psdhcihostattr, SDHCI_INT_STATUS, uiIntSta & SDHCI_INT_DATA_MASK);
__sdhciTransDatHandle(psdhcitrans, uiIntSta & SDHCI_INT_DATA_MASK);
}
@@ -2838,15 +2884,10 @@ static VOID __sdhciTransHandle (__SDHCI_TRANS *psdhcitrans)
bSdioInt = LW_TRUE;
}
- uiIntSta &= ~(SDHCI_INT_CMD_MASK | SDHCI_INT_DATA_MASK);
- uiIntSta &= ~(SDHCI_INT_ERROR);
-
if (uiIntSta & SDHCI_INT_BUS_POWER) {
SDCARD_DEBUG_MSGX(__ERRORMESSAGE_LEVEL,
"sdhci(%s): card consumed too much power!\r\n",
__SDHCI_HOST_NAME(psdhcitrans->SDHCITS_psdhcihost));
- SDHCI_WRITEL(psdhcihostattr, SDHCI_INT_STATUS, SDHCI_INT_BUS_POWER);
- uiIntSta &= ~SDHCI_INT_BUS_POWER;
}
if (uiIntSta & SDHCI_INT_CARD_INT) {
@@ -2854,10 +2895,6 @@ static VOID __sdhciTransHandle (__SDHCI_TRANS *psdhcitrans)
uiIntSta &= ~SDHCI_INT_CARD_INT;
}
- if (uiIntSta) {
- SDHCI_WRITEL(psdhcihostattr, SDHCI_INT_STATUS, uiIntSta);
- }
-
KN_IO_MB();
if (!SDHCI_QUIRK_FLG(psdhcihostattr, SDHCI_QUIRK_FLG_CANNOT_SDIO_INT) &&
@@ -2868,7 +2905,11 @@ static VOID __sdhciTransHandle (__SDHCI_TRANS *psdhcitrans)
}
if (__SDHCI_ISRDEFER_EN(psdhcitrans)) {
- API_InterVectorEnable(psdhcihostattr->SDHCIHOST_ulIntVector);
+ __sdhciIntSignalDisAndEn(psdhcihost, 0, uiIntSta);
+ }
+
+ if (psdhcitrans->SDHCITS_bTransFinish) {
+ __sdhciTransFinish(psdhcitrans);
}
}
/*********************************************************************************************************
@@ -2990,8 +3031,8 @@ static INT __sdhciTransCmdHandle (__SDHCI_TRANS *psdhcitrans, UINT32 uiIntSta)
}
}
- psdhcitrans->SDHCITS_iCmdError = PX_ERROR;
- __sdhciTransFinish(psdhcitrans); /* 结束本次传输 */
+ psdhcitrans->SDHCITS_iCmdError = PX_ERROR;
+ psdhcitrans->SDHCITS_bTransFinish = LW_TRUE; /* 本次事务结束 */
return (PX_ERROR);
}
@@ -3032,9 +3073,9 @@ static INT __sdhciTransDatHandle (__SDHCI_TRANS *psdhcitrans, UINT32 uiIntSta)
if (bStop || !psdhcitrans->SDHCITS_pucDatBuffCurr) {
if (psdcmd && SD_CMD_TEST_RSP(psdcmd, SD_RSP_BUSY)) {
if (uiIntSta & SDHCI_INT_DATA_TIMEOUT) {
- psdhcitrans->SDHCITS_iDatError = PX_ERROR;
+ psdhcitrans->SDHCITS_iDatError = PX_ERROR;
+ psdhcitrans->SDHCITS_bTransFinish = LW_TRUE; /* 本次事务结束 */
SDCARD_DEBUG_MSG(__ERRORMESSAGE_LEVEL, "timeout on busy irq.\r\n");
- __sdhciTransFinish(psdhcitrans);
return (PX_ERROR);
}
@@ -3046,7 +3087,7 @@ static INT __sdhciTransDatHandle (__SDHCI_TRANS *psdhcitrans, UINT32 uiIntSta)
* 如果命令未完成,需待命令中断产生后结束事务
*/
if (psdhcitrans->SDHCITS_bCmdFinish) {
- __sdhciTransFinish(psdhcitrans);
+ psdhcitrans->SDHCITS_bTransFinish = LW_TRUE; /* 本次事务结束 */
}
return (ERROR_NONE);
@@ -3200,7 +3241,7 @@ __ret:
psdhcitrans->SDHCITS_bCmdFinish = LW_TRUE;
if (psdhcitrans->SDHCITS_iStage == __SDHCI_TRANS_STAGE_STOP) {
- __sdhciTransFinish(psdhcitrans); /* 本次事务结束 */
+ psdhcitrans->SDHCITS_bTransFinish = LW_TRUE; /* 本次事务结束 */
return (ERROR_NONE);
}
@@ -3219,7 +3260,7 @@ __ret:
return (ERROR_NONE);
}
- __sdhciTransFinish(psdhcitrans); /* 本次事务结束 */
+ psdhcitrans->SDHCITS_bTransFinish = LW_TRUE; /* 本次事务结束 */
} else {
/*
@@ -3280,7 +3321,7 @@ static INT __sdhciTransDatFinish (__SDHCI_TRANS *psdhcitrans)
}
}
- __sdhciTransFinish(psdhcitrans);
+ psdhcitrans->SDHCITS_bTransFinish = LW_TRUE; /* 本次事务结束 */
return (ERROR_NONE);
}
diff --git a/SylixOS/system/device/sdcard/host/sdhci.h b/SylixOS/system/device/sdcard/host/sdhci.h
index ac192a0..9193f37 100644
--- a/SylixOS/system/device/sdcard/host/sdhci.h
+++ b/SylixOS/system/device/sdcard/host/sdhci.h
@@ -557,7 +557,7 @@ typedef struct lw_sdhci_host_attr {
* 主要针对不同的特性开关, 如是否使用 ACMD12 等.
*
* SDHCI_QUIRK_FLG_SDIO_INT_OOB
- * 通常情况想, SDHCI 本身支持 SDIO 中断功能, 如果控制器确实不支持SDIO硬件中断, 则内部使用查询模式.
+ * 通常情况下, SDHCI 本身支持 SDIO 中断功能, 如果控制器确实不支持 SDIO 硬件中断, 则内部使用查询模式.
* 但是, 有的 SDIO 设备自身通过额外的 GPIO 引脚产生 SDIO 中断信号, 即不由 SDHCI 控制器本身产生, 因此
* 叫做带外中断(Out-of-Band). 使能此标志后, 将忽略 SDHCI_QUIRK_FLG_CANNOT_SDIO_INT 标志, 并且需要
* 驱动自己实现带外中断服务.
diff --git a/SylixOS/system/include/s_class.h b/SylixOS/system/include/s_class.h
index c46b5c1..9c460a4 100644
--- a/SylixOS/system/include/s_class.h
+++ b/SylixOS/system/include/s_class.h
@@ -208,21 +208,35 @@ typedef LW_DEVTREE_TABLE_ITEM *PLW_DEVTREE_TABLE;
typedef struct dev_resource {
union {
struct {
- addr_t DEVRES_ulStart; /* IO 地址资源的起始地址 */
- addr_t DEVRES_ulEnd; /* IO 地址资源的结束地址 */
+ addr_t DEVRES_ulStart; /* IO、MEM 地址资源的起始地址 */
+ addr_t DEVRES_ulEnd; /* IO、MEM 地址资源的结束地址 */
} iomem;
struct {
+ addr_t DEVRES_ulStart; /* BUS 资源的起始地址 */
+ addr_t DEVRES_ulEnd; /* BUS 资源的结束地址 */
+ } bus;
+
+ struct {
ULONG DEVRES_ulIrq; /* 中断资源的中断号 */
ULONG DEVRES_ulFlags; /* 中断资源的中断类型 */
} irq;
};
CPCHAR DEVRES_pcName; /* 资源的名称 */
+ ULONG DEVRES_ulFlags; /* 资源的类型 */
+ ULONG DEVRES_ulReserve[16];
} LW_DEV_RESOURCE;
typedef LW_DEV_RESOURCE *PLW_DEV_RESOURCE;
-#endif /* LW_CFG_DEVTREE_EN */
+typedef struct dev_resource_entry {
+ LW_LIST_LINE DEVRESE_plineManage;
+ PLW_DEV_RESOURCE DEVRESE_pdevres;
+ UINT64 DEVRESE_ullOffset;
+ LW_DEV_RESOURCE DEVRESE_devres;
+} LW_DEV_RESOURCE_ENTRY;
+typedef LW_DEV_RESOURCE_ENTRY *PLW_DEV_RESOURCE_ENTRY;
+#endif /* LW_CFG_DEVTREE_EN */
/*********************************************************************************************************
设备头
*********************************************************************************************************/
diff --git a/SylixOS/system/ioLib/ioFile.c b/SylixOS/system/ioLib/ioFile.c
index fe06ac7..5fe8296 100644
--- a/SylixOS/system/ioLib/ioFile.c
+++ b/SylixOS/system/ioLib/ioFile.c
@@ -1363,18 +1363,18 @@ INT API_IosFdRefDec (INT iFd)
} else if (bCallFunc) {
pfdentry->FDENTRY_state = FDSTAT_CLOSING; /* 准备调用驱动 close 函数 */
}
- _IosUnlock(); /* 退出 IO 临界区 */
-
+
_FdLockfClearFdEntry(pfdentry, __PROC_GET_PID_CUR()); /* 回收记录锁 */
+ _IosUnlock(); /* 退出 IO 临界区 */
+
if (bCallFunc) { /* 正常文件需要调用驱动 */
_IosFileClose(pfdentry);
}
_IosFileDelete(pfdentry);
} else {
- _IosUnlock(); /* 退出 IO 临界区 */
-
_FdLockfClearFdEntry(pfdentry, __PROC_GET_PID_CUR()); /* 回收记录锁 */
+ _IosUnlock(); /* 退出 IO 临界区 */
}
LW_THREAD_UNSAFE(); /* 退出安全状态 */
@@ -1428,9 +1428,9 @@ INT API_IosFdEntryReclaim (PLW_FD_ENTRY pfdentry, ULONG ulRefDec, pid_t pid)
LW_THREAD_SAFE(); /* 进入安全状态, 防止关闭过程 */
/* 当前任务被删除 */
+ _FdLockfClearFdEntry(pfdentry, pid); /* 回收指定进程创建的记录锁 */
_IosUnlock(); /* 退出 IO 临界区 */
- _FdLockfClearFdEntry(pfdentry, pid); /* 回收指定进程创建的记录锁 */
if (bCallFunc) { /* 正常文件需要调用驱动 */
#if LW_CFG_NET_EN > 0
if (pfdentry->FDENTRY_iType == LW_DRV_TYPE_SOCKET) {
diff --git a/SylixOS/system/ioLib/ioLib.c b/SylixOS/system/ioLib/ioLib.c
index fe006e2..88940e9 100644
--- a/SylixOS/system/ioLib/ioLib.c
+++ b/SylixOS/system/ioLib/ioLib.c
@@ -455,12 +455,13 @@ static VOID _IosThreadDelete (LW_OBJECT_HANDLE ulId, PVOID pvRetVal, PLW_CLAS
{
extern VOID __fdLockfCleanupHook(PLW_CLASS_TCB ptcbDel);
- if (ptcbDel && ptcbDel->TCB_pvIoEnv) {
- _IosEnvDelete((PLW_IO_ENV)ptcbDel->TCB_pvIoEnv); /* 删除私有 io 环境 */
- ptcbDel->TCB_pvIoEnv = LW_NULL; /* 防止重启后造成误判 */
+ if (ptcbDel) {
+ if (ptcbDel->TCB_pvIoEnv) {
+ _IosEnvDelete((PLW_IO_ENV)ptcbDel->TCB_pvIoEnv); /* 删除私有 io 环境 */
+ ptcbDel->TCB_pvIoEnv = LW_NULL; /* 防止重启后造成误判 */
+ }
+ __fdLockfCleanupHook(ptcbDel); /* 删除阻塞文件锁 */
}
-
- __fdLockfCleanupHook(ptcbDel); /* 删除阻塞文件锁 */
}
/*********************************************************************************************************
** 函数名称: _IosInit
diff --git a/SylixOS/system/ioLib/ioLockF.c b/SylixOS/system/ioLib/ioLockF.c
index 8245a54..fc4d83f 100644
--- a/SylixOS/system/ioLib/ioLockF.c
+++ b/SylixOS/system/ioLib/ioLockF.c
@@ -97,22 +97,22 @@ static VOID __fdLockfPrint (CPCHAR pcMsg, PLW_FD_LOCKF pfdlockf)
PLW_FD_LOCKF pfdlockfBlock;
if (!pfdlockf) {
- printf(pcMsg);
+ _PrintFormat(pcMsg);
return;
}
- printf("%s: lock %p for ", pcMsg, pfdlockf);
- printf("proc %d", pfdlockf->FDLOCK_pid);
- printf(", %s, start %llx, end %llx",
- pfdlockf->FDLOCK_usType == F_RDLCK ? "shared" :
- pfdlockf->FDLOCK_usType == F_WRLCK ? "exclusive" :
- pfdlockf->FDLOCK_usType == F_UNLCK ? "unlock" :
- "unknown", pfdlockf->FDLOCK_oftStart, pfdlockf->FDLOCK_oftEnd);
+ _PrintFormat("%s: lock %p for ", pcMsg, pfdlockf);
+ _PrintFormat("proc %d", pfdlockf->FDLOCK_pid);
+ _PrintFormat(", %s, start %llx, end %llx",
+ pfdlockf->FDLOCK_usType == F_RDLCK ? "shared" :
+ pfdlockf->FDLOCK_usType == F_WRLCK ? "exclusive" :
+ pfdlockf->FDLOCK_usType == F_UNLCK ? "unlock" :
+ "unknown", pfdlockf->FDLOCK_oftStart, pfdlockf->FDLOCK_oftEnd);
if (pfdlockf->FDLOCK_plineBlockHd) {
pfdlockfBlock = _LIST_ENTRY(pfdlockf->FDLOCK_plineBlockHd, LW_FD_LOCKF, FDLOCK_lineBlock);
- printf(" block %p\n", pfdlockfBlock);
+ _PrintFormat(" block %p\r\n", pfdlockfBlock);
} else {
- printf("\n");
+ _PrintFormat("\r\n");
}
#endif /* DEBUG_PRINT_EN */
}
@@ -132,19 +132,19 @@ static VOID __fdLockfPrintList (CPCHAR pcMsg, PLW_FD_LOCKF pfdlockf)
PLW_FD_LOCKF pfdlockfTmp, pfdlockfBlock;
PCHAR pcOpen, pcClose;
- printf("%s: lock list:\n", pcMsg);
+ _PrintFormat("%s: lock list:\r\n", pcMsg);
for (pfdlockfTmp = *pfdlockf->FDLOCK_pfdlockHead;
pfdlockfTmp != LW_NULL;
pfdlockfTmp = pfdlockfTmp->FDLOCK_pfdlockNext) {
- printf("\tlock %p for ", pfdlockfTmp);
- printf("proc %d", pfdlockfTmp->FDLOCK_pid);
+ _PrintFormat("\tlock %p for ", pfdlockfTmp);
+ _PrintFormat("proc %d", pfdlockfTmp->FDLOCK_pid);
- printf(", %s, start %llx, end %llx",
- pfdlockfTmp->FDLOCK_usType == F_RDLCK ? "shared" :
- pfdlockfTmp->FDLOCK_usType == F_WRLCK ? "exclusive" :
- pfdlockfTmp->FDLOCK_usType == F_UNLCK ? "unlock" :
- "unknown", pfdlockfTmp->FDLOCK_oftStart, pfdlockfTmp->FDLOCK_oftEnd);
+ _PrintFormat(", %s, start %llx, end %llx",
+ pfdlockfTmp->FDLOCK_usType == F_RDLCK ? "shared" :
+ pfdlockfTmp->FDLOCK_usType == F_WRLCK ? "exclusive" :
+ pfdlockfTmp->FDLOCK_usType == F_UNLCK ? "unlock" :
+ "unknown", pfdlockfTmp->FDLOCK_oftStart, pfdlockfTmp->FDLOCK_oftEnd);
pcOpen = " is blocking { ";
pcClose = "";
@@ -155,19 +155,18 @@ static VOID __fdLockfPrintList (CPCHAR pcMsg, PLW_FD_LOCKF pfdlockf)
pfdlockfBlock = _LIST_ENTRY(plineTmp, LW_FD_LOCKF, FDLOCK_lineBlock);
- printf("%s", pcOpen);
+ _PrintFormat("%s", pcOpen);
pcOpen = ", ";
pcClose = " }";
- printf("proc %d", pfdlockfBlock->FDLOCK_pid);
-
- printf(", %s, start %llx, end %llx",
- pfdlockfBlock->FDLOCK_usType == F_RDLCK ? "shared" :
- pfdlockfBlock->FDLOCK_usType == F_WRLCK ? "exclusive" :
- pfdlockfBlock->FDLOCK_usType == F_UNLCK ? "unlock" :
- "unknown", pfdlockfBlock->FDLOCK_oftStart, pfdlockfBlock->FDLOCK_oftEnd);
+ _PrintFormat("proc %d", pfdlockfBlock->FDLOCK_pid);
+ _PrintFormat(", %s, start %llx, end %llx",
+ pfdlockfBlock->FDLOCK_usType == F_RDLCK ? "shared" :
+ pfdlockfBlock->FDLOCK_usType == F_WRLCK ? "exclusive" :
+ pfdlockfBlock->FDLOCK_usType == F_UNLCK ? "unlock" :
+ "unknown", pfdlockfBlock->FDLOCK_oftStart, pfdlockfBlock->FDLOCK_oftEnd);
}
- printf("%s\n", pcClose);
+ _PrintFormat("%s\r\n", pcClose);
}
#endif /* DEBUG_PRINT_EN */
}
diff --git a/SylixOS/system/ioLib/ioStat.c b/SylixOS/system/ioLib/ioStat.c
index 0d425b9..2e9ce41 100644
--- a/SylixOS/system/ioLib/ioStat.c
+++ b/SylixOS/system/ioLib/ioStat.c
@@ -801,12 +801,8 @@ VOID sync (VOID)
_IosLock(); /* 进入 IO 临界区 */
if (pfdentry->FDENTRY_state == FDSTAT_REQCLOSE) {
pfdentry->FDENTRY_state = FDSTAT_CLOSING;
- _IosUnlock(); /* 退出 IO 临界区 */
-
_IosFileClose(pfdentry); /* 调用驱动关闭文件 */
-
- _IosLock(); /* 进入 IO 临界区 */
-
+ /* 在 IOS lock 状态被调用 */
} else if (pfdentry->FDENTRY_state == FDSTAT_SYNC) {
pfdentry->FDENTRY_state = FDSTAT_OK;
}
diff --git a/SylixOS/vpmpdm/dlmalloc/dlmalloc.h b/SylixOS/vpmpdm/dlmalloc/dlmalloc.h
index 21d2dd6..62c73f5 100644
--- a/SylixOS/vpmpdm/dlmalloc/dlmalloc.h
+++ b/SylixOS/vpmpdm/dlmalloc/dlmalloc.h
@@ -42,7 +42,11 @@ void dlmalloc_abort(void);
#define USE_DL_PREFIX 1
/* Use system page size */
+#if LW_CFG_VMM_EN > 0
#define malloc_getpagesize getpagesize()
+#else
+#define malloc_getpagesize ((size_t)16U * (size_t)1024U)
+#endif /* LW_CFG_VMM_EN > 0 */
/* Use the supplied emulation of sbrk */
#define MORECORE dlmalloc_sbrk
diff --git a/SylixOS/vpmpdm/ptmalloc3/ptmalloc3_sylixos.h b/SylixOS/vpmpdm/ptmalloc3/ptmalloc3_sylixos.h
index eea75c5..0afbed6 100644
--- a/SylixOS/vpmpdm/ptmalloc3/ptmalloc3_sylixos.h
+++ b/SylixOS/vpmpdm/ptmalloc3/ptmalloc3_sylixos.h
@@ -26,7 +26,11 @@ void ptmalloc_abort(void);
#define USE_DL_PREFIX 1
/* Use system page size */
+#if LW_CFG_VMM_EN > 0
#define malloc_getpagesize getpagesize()
+#else
+#define malloc_getpagesize ((size_t)16U * (size_t)1024U)
+#endif /* LW_CFG_VMM_EN > 0 */
/* Use the supplied emulation of sbrk */
#define MORECORE ptmalloc_sbrk
diff --git a/libsylixos.mk b/libsylixos.mk
index 9ba9d52..fb8e585 100644
--- a/libsylixos.mk
+++ b/libsylixos.mk
@@ -1980,6 +1980,7 @@ SylixOS/devtree/devtreeLib.c \
SylixOS/devtree/devtreeMdio.c \
SylixOS/devtree/devtreeI2c.c \
SylixOS/devtree/devtreeSpi.c \
+SylixOS/devtree/devtreePci.c \
SylixOS/devtree/devtreePhandle.c \
SylixOS/devtree/devtreeProperty.c \
SylixOS/driver/fdt/fdtdec_common.c \