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

📄 tcic.c

📁 VXWORKS源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
** This routine gets IRQ level of the socket.** RETURNS: The IRQ level of the socket.*/LOCAL int tcicIrqGet    (    int sock			/* socket no. */    )    {    int value;    semTake (&tcicMuteSem, WAIT_FOREVER);	/* mutual execlusion start */    tcicSetl (TCIC_ADDR, (sock << TCIC_ADDR_SS_SHFT) |	      TCIC_ADDR_INDREG | TCIC_SCF1(sock));    value = TCIC_GETW (TCIC_DATA) & 0x0f;    semGive (&tcicMuteSem);		 	/* mutual execlusion stop */    return (value);    }  /********************************************************************************* tcicIrqSet - Set IRQ level of the socket.** This routine sets IRQ level of the socket.** RETURNS: OK, or ERROR if the IRQ level is greater than 15.*/LOCAL STATUS tcicIrqSet    (    int sock,			/* socket no. */    int irq			/* IRQ for PC card */    )    {    short scf1;        if (irq > 15)	return (ERROR);    semTake (&tcicMuteSem, WAIT_FOREVER);	/* mutual execlusion start */    tcicSetl (TCIC_ADDR, (sock << TCIC_ADDR_SS_SHFT) |	      TCIC_ADDR_INDREG | TCIC_SCF1(sock));        scf1 = TCIC_GETW (TCIC_DATA);    scf1 &= ~(TCIC_SCF1_IRQOC | TCIC_SCF1_IRQ_MASK);    scf1 |= irq;    TCIC_SETW (TCIC_DATA, scf1);        semGive (&tcicMuteSem);		 	/* mutual execlusion stop */    return (OK);    }/********************************************************************************* tcicReset - Reset a card in the socket.** This routine resets a card in the socket.** RETURNS: OK (always).*/LOCAL STATUS tcicReset    (    int sock			/* socket no. */    )    {    int ix;    short value;        semTake (&tcicMuteSem, WAIT_FOREVER);	/* mutual execlusion start */    /* Turn off interrupts, select memory-only interface */    tcicSetl (TCIC_ADDR, (sock << TCIC_ADDR_SS_SHFT) |	      TCIC_ADDR_INDREG | TCIC_SCF1(sock));    value = TCIC_GETW (TCIC_DATA);    value &= ~(TCIC_SCF1_IRQ_MASK | TCIC_SCF1_IOSTS);    TCIC_SETW (TCIC_DATA, value);        /* Reset event mask, since we've turned off I/O mode */    TCIC_SETW (TCIC_ADDR, TCIC_SCF2(sock));    value = TCIC_GETW (TCIC_DATA);    value &= TCIC_SCF2_MDBR | TCIC_SCF2_IDBR | TCIC_SCF2_RI;    TCIC_SETW (TCIC_DATA, value);        /* Turn off I/O windows */    for (ix = 0; ix < 2; ix++)	{	TCIC_SETW (TCIC_ADDR, TCIC_IWIN(sock, ix) + TCIC_ICTL_X);	TCIC_SETW (TCIC_DATA, 0);        }        /* Turn off memory windows */    for (ix = 0; ix < 4; ix++)	{	TCIC_SETW (TCIC_ADDR, TCIC_MWIN(sock, ix) + TCIC_MCTL_X);	TCIC_SETW (TCIC_DATA, 0);        }        semGive (&tcicMuteSem);		 	/* mutual execlusion stop */    return (OK);    }/********************************************************************************* tcicIowinGet - Get the IO window of the socket.** This routine gets the IO window of the socket.** RETURNS: OK, or ERROR if the window number is greater than max windows.*/LOCAL STATUS tcicIowinGet    (    int		 sock,		/* socket no. */    PCMCIA_IOWIN *io		/* IO window structure to get */    )    {    short base;    short ioctl;    long  addr;        if (io->window >= TCIC_IO_WINDOWS)	return (ERROR);    semTake (&tcicMuteSem, WAIT_FOREVER);	/* mutual execlusion start */    TCIC_SETW (TCIC_ADDR+2, TCIC_ADR2_INDREG | (sock << TCIC_SS_SHFT));    addr = TCIC_IWIN(sock, io->window);    TCIC_SETW (TCIC_ADDR, addr + TCIC_IBASE_X);    base = TCIC_GETW (TCIC_DATA);    TCIC_SETW (TCIC_ADDR, addr + TCIC_ICTL_X);    ioctl = TCIC_GETW (TCIC_DATA);    if (ioctl & TCIC_ICTL_TINY)	io->start = io->stop = base;    else	{	io->start = base & (base-1);	io->stop = io->start + (base ^ (base-1));        }    io->extraws	= ioctl & TCIC_ICTL_WSCNT_MASK;    io->flags	= (ioctl & TCIC_ICTL_ENA) ? MAP_ACTIVE : 0;    if ((ioctl & TCIC_ICTL_BW_MASK) == TCIC_ICTL_BW_16)	io->flags |= MAP_16BIT;    semGive (&tcicMuteSem);		 	/* mutual execlusion stop */    return (OK);    }/********************************************************************************* tcicIowinSet - Set the IO window of the socket.** This routine sets the IO window of the socket.** RETURNS: OK, or ERROR if there is an error.*/LOCAL STATUS tcicIowinSet    (    int		 sock,		/* socket no. */    PCMCIA_IOWIN *io		/* IO window structure to set */    )    {    long addr;    int base;    int len;    int ix;    short ioctl;        if ((io->window >= TCIC_IO_WINDOWS) || (io->start > 0xffff) ||	(io->stop > 0xffff) || (io->stop < io->start))	return (ERROR);    semTake (&tcicMuteSem, WAIT_FOREVER);	/* mutual execlusion start */    TCIC_SETW (TCIC_ADDR+2, TCIC_ADR2_INDREG | (sock << TCIC_SS_SHFT));    addr = TCIC_IWIN(sock, io->window);    base = io->start;    len  = io->stop - io->start + 1;    /* adject base address according to the length */    for (ix = 0; ix < 16; ix++)	if ((1 << ix) >= len)	    break;    if (len != 1)	{	base &= ~((1 << ix) - 1);	base += 1 << (ix - 1);	}    TCIC_SETW (TCIC_ADDR, addr + TCIC_IBASE_X);    TCIC_SETW (TCIC_DATA, base);        ioctl  = TCIC_ICTL_QUIET | (sock << TCIC_ICTL_SS_SHFT);    ioctl |= (len == 0) ? TCIC_ICTL_TINY : 0;    ioctl |= (io->flags & MAP_ACTIVE) ? TCIC_ICTL_ENA : 0;    ioctl |= io->extraws & TCIC_ICTL_WSCNT_MASK;    ioctl |= (io->flags & MAP_16BIT) ? TCIC_ICTL_BW_16 : TCIC_ICTL_BW_8;    TCIC_SETW (TCIC_ADDR, addr + TCIC_ICTL_X);    TCIC_SETW (TCIC_DATA, ioctl);        semGive (&tcicMuteSem);		 	/* mutual execlusion stop */    return (OK);    }/********************************************************************************* tcicMemwinGet - Get the memory window of the socket.** This routine gets the memory window of the socket.** RETURNS: OK, or ERROR if the window number is greater than max windows.*/LOCAL STATUS tcicMemwinGet    (    int		  sock,		/* socket no. */    PCMCIA_MEMWIN *mem		/* memory window structure to get */    )    {    long base;    long mmap;    short addr;    short ctl;        if (mem->window >= TCIC_MEM_WINDOWS)	return (ERROR);    semTake (&tcicMuteSem, WAIT_FOREVER);	/* mutual execlusion start */    TCIC_SETW (TCIC_ADDR+2, TCIC_ADR2_INDREG | (sock << TCIC_SS_SHFT));    addr = TCIC_MWIN(sock, mem->window);        TCIC_SETW (TCIC_ADDR, addr + TCIC_MBASE_X);    base = TCIC_GETW (TCIC_DATA);    if (base & TCIC_MBASE_4K_BIT)	{	mem->start = base & TCIC_MBASE_HA_MASK;	mem->stop  = mem->start;        }    else	{	base &= TCIC_MBASE_HA_MASK;	mem->start = (base & (base-1));	mem->stop  = mem->start + (base ^ (base-1));        }    mem->start = mem->start << TCIC_MBASE_HA_SHFT;    mem->stop  = (mem->stop << TCIC_MBASE_HA_SHFT) + 0x0fff;        TCIC_SETW (TCIC_ADDR, addr + TCIC_MMAP_X);    mmap = TCIC_GETW(TCIC_DATA);    mem->flags = (mmap & TCIC_MMAP_REG) ? MAP_ATTRIB : 0;    mmap = (base + mmap) & TCIC_MMAP_CA_MASK;    mem->cardstart = mmap << TCIC_MMAP_CA_SHFT;        TCIC_SETW (TCIC_ADDR, addr + TCIC_MCTL_X);    ctl = TCIC_GETW (TCIC_DATA);    mem->flags	|= (ctl & TCIC_MCTL_ENA) ? MAP_ACTIVE : 0;    mem->flags	|= (ctl & TCIC_MCTL_B8) ? 0 : MAP_16BIT;    mem->flags	|= (ctl & TCIC_MCTL_WP) ? MAP_WRPROT : 0;    mem->extraws = (ctl & TCIC_MCTL_WSCNT_MASK);        semGive (&tcicMuteSem);		 	/* mutual execlusion stop */    return (OK);    }/********************************************************************************* tcicMemwinSet - Set the memory window of the socket.** This routine sets the memory window of the socket.** RETURNS: OK, or ERROR if there is an error.*/LOCAL STATUS tcicMemwinSet    (    int		  sock,		/* socket no. */    PCMCIA_MEMWIN *mem		/* memory window structure to set */    )    {    short addr;    short ctl;    long base;    long len;    long mmap;        if ((mem->window >= TCIC_MEM_WINDOWS) || (mem->cardstart > 0xffffff) ||	(mem->start > 0xffffff) || (mem->stop > 0xffffff) ||	(mem->start > mem->stop) || (mem->extraws > 7))	return (ERROR);    semTake (&tcicMuteSem, WAIT_FOREVER);	/* mutual execlusion start */    TCIC_SETW (TCIC_ADDR+2, TCIC_ADR2_INDREG | (sock << TCIC_SS_SHFT));    addr = TCIC_MWIN(sock, mem->window);    base = mem->start & ~0xfff;    len  = (mem->stop - base) | 0xfff;    if (len == 0x0fff)	base = (base >> TCIC_MBASE_HA_SHFT) | TCIC_MBASE_4K_BIT;    else	base = (base | (len+1)>>1) >> TCIC_MBASE_HA_SHFT;    TCIC_SETW (TCIC_ADDR, addr + TCIC_MBASE_X);    TCIC_SETW (TCIC_DATA, base);        mmap = (mem->cardstart >> TCIC_MMAP_CA_SHFT) - base;    mmap &= TCIC_MMAP_CA_MASK;    if (mem->flags & MAP_ATTRIB)	mmap |= TCIC_MMAP_REG;    TCIC_SETW (TCIC_ADDR, addr + TCIC_MMAP_X);    TCIC_SETW (TCIC_DATA, mmap);    ctl  = TCIC_MCTL_QUIET | (sock << TCIC_MCTL_SS_SHFT);    ctl |= mem->extraws & TCIC_MCTL_WSCNT_MASK;    ctl |= (mem->flags & MAP_16BIT) ? 0 : TCIC_MCTL_B8;    ctl |= (mem->flags & MAP_WRPROT) ? TCIC_MCTL_WP : 0;    ctl |= (mem->flags & MAP_ACTIVE) ? TCIC_MCTL_ENA : 0;    TCIC_SETW (TCIC_ADDR, addr + TCIC_MCTL_X);    TCIC_SETW (TCIC_DATA, ctl);        semGive (&tcicMuteSem);		 	/* mutual execlusion stop */    return (OK);    }/********************************************************************************* tcicSetl - Set a long word value to the register.** This routine sets a long word value to the register.** RETURNS: N/A*/LOCAL void tcicSetl    (    int  reg,			/* register no. */    long value			/* value to set */    )    {    sysOutWord (tcicBase+reg,   value & 0xffff);    sysOutWord (tcicBase+reg+2, value >> 16);    }/********************************************************************************* tcicGetl - Get a long word value from the register.** This routine gets a long word value from the register.** RETURNS: A long word value of the register.*/LOCAL long tcicGetl    (    int  reg			/* register no. */    )    {    long value0;    long value1;    value0 = sysInWord (tcicBase+reg);    value1 = sysInWord (tcicBase+reg+2);    return ((value1 << 16) | (value0 & 0xffff));    }/********************************************************************************* tcicAuxGetb - Get a byte value from the aux register.** This routine gets a byte value from the aux register.** RETURNS: A byte value of the register.*/LOCAL char tcicAuxGetb    (    int reg			/* register no. */    )    {    char mode = (TCIC_GETB (TCIC_MODE) & TCIC_MODE_PGMMASK) | reg;    TCIC_SETB (TCIC_MODE, mode);    return (TCIC_GETB (TCIC_AUX));    }/********************************************************************************* tcicAuxSetb - Set a byte value to the aux register.** This routine sets a byte value to the aux register.** RETURNS: N/A*/LOCAL void tcicAuxSetb    (    int  reg,			/* register no. */    char value			/* value to set */    )    {    char mode = (TCIC_GETB (TCIC_MODE) & TCIC_MODE_PGMMASK) | reg;    TCIC_SETB (TCIC_MODE, mode);    TCIC_SETB (TCIC_AUX, value);    }#ifdef __unused__/********************************************************************************* tcicAuxGetw - Get a word value from the aux register.** This routine gets a word value from the aux register.** RETURNS: A word value of the register.*/LOCAL short tcicAuxGetw    (    int reg			/* register no. */    )    {    char mode = (TCIC_GETB (TCIC_MODE) & TCIC_MODE_PGMMASK) | reg;    TCIC_SETB (TCIC_MODE, mode);    return (TCIC_GETW (TCIC_AUX));    }#endif/********************************************************************************* tcicAuxSetw - Set a word value to the aux register.** This routine sets a word value to the aux register.** RETURNS: N/A*/LOCAL void tcicAuxSetw    (    int   reg,			/* register no. */    short value			/* value to set */    )    {    char mode = (TCIC_GETB (TCIC_MODE) & TCIC_MODE_PGMMASK) | reg;    TCIC_SETB (TCIC_MODE, mode);    TCIC_SETW (TCIC_AUX, value);    }

⌨️ 快捷键说明

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