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

📄 portio.c

📁 ertfs文件系统里面既有完整ucos程序
💻 C
字号:
//
// portio.c
//  
//   EBS - ERTFS
//  
//   Copyright EBS Inc , 1993,1994,1995
//   All rights reserved.
//   This code may not be redistributed in source or linkable object form
//   without the consent of its author.
//
//
//    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


// This is for ERTFS_STAND_ALONE only. Not used in RTIP enviroment

#include <pcdisk.h>

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

#define ASSEMBLY_IO 0

#if (defined(__BORLANDC__))
// *******************************************************************
// SPECIAL Definitions for BORLAND                                       
// *******************************************************************
#define _FP_SEG(X) FP_SEG(X)
#define _FP_OFF(X) FP_OFF(X)
#endif


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)


// Only need to shut down the bios if floppy 
#if (USE_FLOPPY)
/* If running in real mode on a PC and the BIOS clock ISR is enabled then 
   this routine sets the bios motor timer counter to a high value so it does
   not turn off the floppy motors behind our back */

void shut_bios_timer_off(void)
{
PFBYTE bios_motor_timer = 0;
    if (!bios_motor_timer)
    {
        bios_motor_timer = (PFBYTE) (MK_FP(0x40, 0x40));
    }
    *bios_motor_timer = 0xff;
}

#endif  // (USE_FLOPPY)

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 + -