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

📄 pquicc.c

📁 文件内包含了nuclues的内核代码和针对Power PC的编译器。需要用VirtNet生成一个虚拟网卡才可使用
💻 C
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************/
/*                                                                          */
/*      Copyright (c) 1993 - 1998 by Accelerated Technology, Inc.           */
/*                                                                          */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the subject */
/* matter of this material.  All manufacturing, reproduction, use and sales */
/* rights pertaining to this subject matter are governed by the license     */
/* agreement.  The recipient of this software implicity accepts the terms   */
/* of the license.                                                          */
/*                                                                          */
/****************************************************************************/
/****************************************************************************/
/*                                                                          */
/* FILENAME                                                 VERSION         */
/*                                                                          */
/*   pquicc.c                                       MPC860/Diab 1.0         */
/*                                                                          */
/* DESCRIPTION                                                              */
/*                                                                          */
/*    This file will hold all the routines which handle the interface       */
/*  between NUCLEUS NET and the MPC860 (PQUICC) ETHERNET Controller.        */
/*  Some code is not necessary for PQUICC, but necessary to maintain the    */
/*  consistence with the generic code of NUCLEUS NET                        */
/*                                                                          */
/* AUTHOR                                                                   */
/*                                                                          */
/*    Bill Haggerty, Accelerated Technology,                                */
/*                                                                          */
/* DATA STRUCTURES                                                          */
/*                                                                          */
/*                                                                          */
/* FUNCTIONS                                                                */
/*                                                                          */
/*                                                                          */
/* DEPENDENCIES                                                             */
/*                                                                          */
/*                                                                          */
/* HISTORY                                                                  */
/*                                                                          */
/*        NAME                  DATE                 REMARKS                */
/*                                                                          */
/*     B. Haggerty            05-07-1998          Created version 1.0       */
/*                                                                          */
/****************************************************************************/
#include "nucleus.h"
#include "externs.h"
#include "protocol.h"
#include "tcp_errs.h"
#include "data.h"
#include "net.h"

#include "mpc860.h"
#include "pquicc.h"

#define PQUICC_ID 1

/* The pragmas are to set the transmit and receive buffers in a    */
/* separate block of memory that is not cached                     */

#pragma section CPM_BUF ".bufdata" ".bufdata"
#pragma use_section CPM_BUF RX_Buff_Mem, TX_Buff_Mem


unsigned char         RX_Buff_Mem[10][NET_MAX_BUFFER_SIZE],
                      TX_Buff_Mem[10][NET_MAX_BUFFER_SIZE];
NU_HISR               PQUICC_Ether_Inter_Control;
void                  NU_Ether_Inter_PLUS (void);
extern void           PQUICC_LISR (INT);

int                   Hisr_Activated;
struct  pda           *pquicc;
int                   Numbuffs;

unsigned long         immr;
struct _rx_bd         *First_RX_BD;
struct _tx_bd         *First_TX_BD;

struct _rx_bd
{
    unsigned short        status;
    unsigned short        data_len;
    unsigned long         data_ptr;
}*rx_bd;

struct _tx_bd
{
    unsigned short        status;
    unsigned short        data_len;
    unsigned long         data_ptr;
}*tx_bd;

/****************************************************************************/
/* FUNCTION                                                                 */
/*                                                                          */
/*     get_IMMR                                                             */
/*                                                                          */
/* DESCRIPTION                                                              */
/*                                                                          */
/*    Returns the IMMR value in r3 register.                                */
/*                                                                          */
/* CALLED BY                                                                */
/*                                                                          */
/*    PQUICC_BD_Init                                                        */
/*    PQUICC_Open                                                           */
/*                                                                          */
/* CALLS                                                                    */
/*                                                                          */
/*    None                                                                  */
/*                                                                          */
/* INPUTS                                                                   */
/*                                                                          */
/*    None                                                                  */
/*                                                                          */
/* OUTPUTS                                                                  */
/*                                                                          */
/*    unsigned long : value in IMMR register                                */
/*                                                                          */
/* HISTORY                                                                  */
/*                                                                          */
/*    NAME                DATE        REMARKS                               */
/*                                                                          */
/*     B. Haggerty            05-07-1998          Created version 1.0       */
/*                                                                          */
/****************************************************************************/

unsigned long get_IMMR(void)
{
    asm(" mfspr  r3,638 ");        /* IMMR is spr #638 */
}

/****************************************************************************/
/* FUNCTION                                                                 */
/*                                                                          */
/*     issue_cmd                                                            */
/*                                                                          */
/* DESCRIPTION                                                              */
/*                                                                          */
/*      Write the command to the PQUICC command register                    */
/*      and wait untill command is done.                                    */
/*                                                                          */
/* AUTHOR                                                                   */
/*                                                                          */
/*    Bill Haggerty            Accelerated Technology Inc.                  */
/*                                                                          */
/* CALLED BY                                                                */
/*                                                                          */
/*    PQUICC_Update_Hash_Table                                              */
/*    PQUICC_Xmit_Packet                                                    */
/*    PQUICC_Open                                                           */
/*                                                                          */
/* CALLS                                                                    */
/*                                                                          */
/*    None                                                                  */
/*                                                                          */
/* INPUTS                                                                   */
/*                                                                          */
/*    unsigned short : command to be put in CPCR                            */
/*                                                                          */
/* OUTPUTS                                                                  */
/*                                                                          */
/*    None                                                                  */
/*                                                                          */
/* HISTORY                                                                  */
/*                                                                          */
/*    NAME                DATE        REMARKS                               */
/*                                                                          */
/*     B. Haggerty            05-07-1998          Created version 1.0       */
/*                                                                          */
/****************************************************************************/
void issue_cmd(unsigned short cmd)
{

    unsigned short       *cr;
    unsigned long        waiting_time;

    waiting_time = 0;

    cr = &pquicc->cp_cr;

    *cr = (cmd | CMD_FLAG);

    while( (*cr) & CMD_FLAG ) /* wait for the CP zero the CMD_FLG */
      waiting_time++;

}

/******************************************************************************/
/* FUNCTION                                                                   */
/*                                                                            */
/*    PQUICC_Ioctl                                                            */
/*                                                                            */
/* DESCRIPTION                                                                */
/*                                                                            */
/*    This function processes IOCTL requests to the PQUICC driver.            */
/*                                                                            */
/* CALLED BY                                                                  */
/*                                                                            */
/*    Nucleus NET                                                             */
/*                                                                            */
/* CALLS                                                                      */
/*                                                                            */
/*    NET_Add_Multi                                                           */
/*    NET_Del_Multi                                                           */
/*                                                                            */
/*                                                                            */
/* HISTORY                                                                    */
/*                                                                            */
/*        NAME            DATE      REMARKS                                   */
/*                                                                            */
/*    Glen Johnson      03/08/98    Created Initial version.                  */
/*                                                                            */
/******************************************************************************/
STATUS  PQUICC_Ioctl(DV_DEVICE_ENTRY *dev, INT option, DV_REQ *d_req)
{
    STATUS          status = NU_SUCCESS;

    switch (option) 
    {
    case DEV_ADDMULTI :

        /* Join the ethernet multicast group. */
        status = NET_Add_Multi(dev, d_req);

        /* A status of NU_RESET means the operation was a success and as a 
           result the ethernet chip must be reset. */
        if (status == NU_RESET)
        {
            /* Reset the chip so the Multicast Hash table can be updated. */
            PQUICC_Update_Hash_Table(dev); 
            status = NU_SUCCESS;
        }
        break;

    case DEV_DELMULTI :

        /* Join the ethernet multicast group. */
        status = NET_Del_Multi(dev, d_req);

        /* A status of NU_RESET means the operation was a success and as a 
           result the ethernet chip must be reset. */
        if (status == NU_RESET)
        {
            /* Reset the chip so the Multicast Hash table can be updated. */
            /* should shut things down, then call PQUICC_Open */ 
            PQUICC_Update_Hash_Table(dev);
            status = NU_SUCCESS;
        }
        break;

    default :
        
        status = NU_INVAL;
        break;

    }

    return (status);

} /* PQUICC_Ioctl */

/****************************************************************************/
/* FUNCTION                                                                 */
/*                                                                          */
/*  PQUICC_Get_Address                                                      */
/*                                                                          */
/* DESCRIPTION                                                              */
/*                                                                          */
/*  This function will handle loading the Ethernet address for PQUICC       */
/*  Ethernet controller, which is not necessary for PQUICC, but necessary to*/
/*  maintain the interface with the generic code of NUCLEUS NET             */
/*                                                                          */
/* AUTHOR                                                                   */
/*                                                                          */
/*    Bill Haggerty            Accelerated Technology Inc.                  */
/*                                                                          */
/* CALLED BY                                                                */

⌨️ 快捷键说明

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