⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 portio.c

📁 ertfs文件系统里面既有完整ucos程序
💻 C
字号:
//
//    Module description:
//        This file contains the routines insw and outsw
//  
// Note: The routines in this file are portable versions that use the
// macros OUTWORD and INWORD to move words to and from a peripheral. 
// Significant performance gains will be realized by using the assembly
// language rep insw and rep outsw constructs

#include <pcdisk.h>

// only need insw / outsw for PCMCIA_ATA and TRUE_IDE
#if (USE_ATA)

#define ASSEMBLY_IO 0

void insw(IOADDRESS ioaddr, PFWORD dst, int n)
{
#if (!ASSEMBLY_IO)
    while (n--)
        *dst++ = (word)INWORD(ioaddr);
#elif (IS_MS_PM || IS_BCC_PM)
__asm {
    pushf
    push        edi
    mov     dx, ioaddr
    mov     edi, dst
    mov     ecx, n
    cld
    rep     insw
    pop     edi
    popf
}
#else
static word near s,o,_n, _i;
__asm {
pushf
cli
}
_n = (word)n;
s = (word)_FP_SEG(dst);
o = (word)_FP_OFF(dst);
_i = ioaddr;
__asm {
    pop ax              /* get flags back into ax */
    push    es
    push    di
    push    cx
    push    dx
    mov     dx, ds:_i
    mov     es, ds:s
    mov     di, ds:o
    mov     cx, ds:_n
    push ax             /* put flags back */
    popf
    cld
    rep     insw
    pop     dx
    pop     cx
    pop     di
    pop     es
}
#endif

}

void outsw(IOADDRESS ioaddr, PFWORD src, int n)
{
#if (!ASSEMBLY_IO)
    while (n--)
        OUTWORD(ioaddr, *src++);
#elif (IS_MS_PM || IS_BCC_PM)
__asm {
    pushf
    push    esi
    mov     dx, ioaddr
    mov     ecx, n
    mov     esi, src
    cld
    rep     outsw
    pop     esi
    popf
}
#else
static word near s,o,_n,_i;
__asm {
pushf
cli
}
_n = (word)n;
_i = ioaddr;

s = (word)_FP_SEG(src);
o = (word)_FP_OFF(src);

__asm {
    pop ax              /* get flags back into ax */
    push    es
    push    cx
    push    dx
    push    ds
    push    si
    mov     dx, ds:_i
    mov     cx, ds:_n
    mov     si, ds:o
    mov     ds, ds:s
    push ax             /* put flags back */
    popf
    cld
    rep     outsw
    pop     si
    pop     ds
    pop     dx
    pop     cx
    pop     es
}
#endif
}

#endif // (USE_ATA)

void io_delay(void)     /*__fn__*/
{
    // read the NMI Status Register - this delays ~1 usec;
    // PC specific
    INBYTE(0x61);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -