Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

clib/PKTDRV.C

Go to the documentation of this file.
00001 /****************************************************************************
00002 *
00003 * (C) 2000 by BECK IPC GmbH
00004 *
00005 *  BECK IPC GmbH
00006 *  Garbenheimerstr. 38
00007 *  D-35578 Wetzlar
00008 *
00009 *  Phone : (49)-6441-905-240
00010 *  Fax   : (49)-6441-905-245
00011 *
00012 * ---------------------------------------------------------------------------
00013 * Module        : IPC@Chip SC12: PKTDRV.C
00014 * Function      : Packet driver interface enables access to the ethernet of SC12 
00015 *                 Required memory model: Large
00016 *
00017 * Author        : Bartat
00018 * Date          : 10.10.00
00019 * ---------------------------------------------------------------------------
00020 
00021 $Header: PKTDRV.C, 6, 16.01.2002 11:45:05, Christoph Stoidner$
00022 
00023 $Log:
00024  6    IPC@CHIP  1.5         16.01.2002 11:45:05  Christoph Stoidner add starteam
00025       directives
00026  5    IPC@CHIP  1.4         16.01.2002 11:04:49  Christoph Stoidner add some
00027       comments
00028 
00029  4    IPC@CHIP  1.3         14.12.2001 12:15:49  Markus Bartat   added
00030       set_rcv_mode functions
00031  3    IPC@CHIP  1.2         17.09.2001 11:19:41  Markus Bartat   added new
00032       functions for wildcard and multicast api calls
00033  2    IPC@CHIP  1.1         19.06.2001 13:35:06  Markus Bartat   start: Added
00034       comments to the c functions
00035  1    IPC@CHIP  1.0         14.02.2001 16:09:33  Christoph Stoidner
00036 $
00037 
00038 * History       :
00039 *
00040 *  Vx.yy                 Author  Changes
00041 *
00042 *             10.10.00   mb      Create
00043 *             12.09.01   mb       added multicast and wildcard_access  functions
00044 *             06.12.01   mb       added set_rcv_mode functions
00045 /************************************************************************/
00046 //          INCLUDES
00047 /************************************************************************/
00048 #include <DOS.H>
00049 #include "pktdrv.h"
00050 /************************************************************************/
00051 //    driver installed: SC12 serviceint 0xA0  0x16
00052 /************************************************************************/
00053 unsigned char PktDriver_Installed(void)
00054 {
00055 
00056    union  REGS  inregs;
00057    union  REGS  outregs;
00058 
00059 
00060    inregs.h.ah = 0x16;
00061    int86(0xA0,&inregs,&outregs);
00062 
00063    //check bit3 of dx
00064    if(outregs.x.dx & 0x08)
00065       return 1;
00066 
00067    return 0;
00068 
00069 }
00070 
00071 /************************************************************************/
00072 //          Get Driver Info
00073 /************************************************************************/
00074 unsigned char Get_Driver_Info(Driver_Info * drv_info )
00075 {
00076 
00077     union  REGS  inregs;
00078    union  REGS  outregs;
00079 
00080      inregs.h.ah = DRIVER_INFO;
00081      inregs.h.al = 0xff;
00082 
00083      int86(PKTVECT,&inregs,&outregs);
00084 
00085      if(outregs.x.cflag) return outregs.h.dh;
00086 
00087      drv_info->version = outregs.x.bx;
00088      drv_info->_class  = outregs.h.ch;
00089      drv_info->type    = outregs.x.dx;
00090      drv_info->number  = outregs.h.cl;
00091      drv_info->basic   = outregs.h.al;
00092      return 0;
00093 }
00094 /************************************************************************/
00095 //          get ethernet-address
00096 /************************************************************************/
00097 
00098 unsigned char Get_Eth_Address(unsigned char *buffer, unsigned int len)
00099 {
00100    union  REGS  inregs;
00101   union  REGS  outregs;
00102   struct SREGS sregs;
00103 
00104   inregs.h.ah      = GET_ADDRESS;
00105    inregs.x.cx      = len;
00106   inregs.x.di      = FP_OFF(buffer);
00107   sregs.es         = FP_SEG(buffer);
00108   int86x(PKTVECT,&inregs,&outregs,&sregs);
00109 
00110 
00111    if(outregs.x.flags&0x01)
00112   {
00113     return outregs.h.dh;
00114   }
00115   return 0;
00116 }
00117 
00118 /************************************************************************/
00119 //          send packet
00120 /************************************************************************/
00121 unsigned char Send_Packet(unsigned char * buffer, unsigned int len)
00122 {
00123 
00124     union  REGS  inregs;
00125     union  REGS  outregs;
00126     struct SREGS sregs;
00127 
00128     inregs.h.ah      = SEND_PKT;
00129     inregs.x.cx      = len;
00130     inregs.x.si      = FP_OFF(buffer);
00131     sregs.ds         = FP_SEG(buffer);
00132     int86x(PKTVECT,&inregs,&outregs,&sregs);
00133 
00134 
00135     if(outregs.x.flags&0x01)
00136     {
00137       return outregs.h.dh;
00138     }
00139     return 0;
00140 
00141 }
00142 
00143 /*************************************************************************/
00144 //               set access type
00145 /*************************************************************************/
00146 unsigned int Set_Access_Type(Driver_Info * drv_info, fpFktPtr Receiver, int * pkt_type, int *handle)
00147 {
00148 
00149 
00150   union  REGS  inregs;
00151   union  REGS  outregs;
00152   struct SREGS sregs;
00153 
00154 
00155   inregs.h.dl = drv_info->number;   /* Number */
00156   sregs.ds    = FP_SEG(pkt_type);  /* Packet type template, pkt_type is a global varia */
00157   inregs.x.si = FP_OFF(pkt_type);
00158   inregs.x.cx = sizeof(int);
00159   sregs.es    = FP_SEG(Receiver);  /* Address of receive handler */
00160   inregs.x.di = FP_OFF(Receiver);
00161   inregs.x.bx = drv_info->type;    /* Type */
00162    inregs.h.ah = ACCESS_TYPE;      /* Access_type() function */
00163   inregs.h.al = drv_info->_class;  /* Class */
00164   int86x(PKTVECT,&inregs,&outregs,&sregs);
00165 
00166   if(outregs.x.cflag)
00167   {
00168      return  outregs.h.dh;
00169   }
00170   else
00171   {
00172      *handle = outregs.x.ax;
00173      return 0;
00174   }
00175 
00176 }
00177 /************************************************************************/
00178 //    Release type
00179 /************************************************************************/
00180 unsigned int Release_Type(unsigned int handle)
00181 {
00182 
00183   union  REGS  inregs;
00184   union  REGS  outregs;
00185 
00186   inregs.x.bx = handle;
00187   inregs.h.ah = RELEASE_TYPE;
00188   int86(PKTVECT,&inregs,&outregs);
00189   if(outregs.x.cflag)
00190   return outregs.h.dh;
00191   return 0;
00192 }
00193 
00194 
00195 
00196 
00197 
00198 /*************************************************************************/
00199 //Set/del multicast address !=0: set address 0: delete address
00200 /*************************************************************************/
00201 unsigned int Set_Multicast(unsigned char * mac_addr, int set)
00202 {
00203 
00204 
00205   union  REGS  inregs;
00206   union  REGS  outregs;
00207   struct SREGS sregs;
00208 
00209 
00210 
00211   sregs.es    = FP_SEG(mac_addr);   /* Packet type template, pkt_type is a global varia */
00212   inregs.x.di = FP_OFF(mac_addr);
00213   inregs.x.cx = 6;
00214 
00215   if(set)
00216   {
00217      inregs.h.ah = SET_MULTICAST;     /* Access_type() function */
00218   }
00219   else
00220   {
00221     inregs.h.ah = DEL_MULTICAST;      /* Access_type() function */
00222   }
00223   int86x(PKTVECT,&inregs,&outregs,&sregs);
00224 
00225   if(outregs.x.cflag)
00226   {
00227      return  outregs.h.dh;
00228   }
00229   else
00230   {
00231      return 0;
00232   }
00233 }
00234 
00235 
00236 
00237 
00238 /*************************************************************************/
00239 //               set wildcard access type
00240 /*************************************************************************/
00241 unsigned int Set_WildcardAccess_Type(Driver_Info * drv_info, fpFktPtr Receiver, int * pkt_type, int *handle)
00242 {
00243 
00244 
00245   union  REGS  inregs;
00246   union  REGS  outregs;
00247   struct SREGS sregs;
00248 
00249 
00250   inregs.h.dl = drv_info->number;   /* Number */
00251   sregs.ds    = FP_SEG(pkt_type);  /* Packet type template, pkt_type is a global varia */
00252   inregs.x.si = FP_OFF(pkt_type);
00253   inregs.x.cx = sizeof(int);
00254   sregs.es    = FP_SEG(Receiver);  /* Address of receive handler */
00255    inregs.x.di = FP_OFF(Receiver);
00256    inregs.x.bx = drv_info->type;     /* Type */
00257   inregs.h.ah = INSTALL_WILDCARD;  /* Access_type() function */
00258   inregs.h.al = drv_info->_class;  /* Class */
00259   int86x(PKTVECT,&inregs,&outregs,&sregs);
00260 
00261   if(outregs.x.cflag)
00262   {
00263      return  outregs.h.dh;
00264   }
00265   else
00266   {
00267      *handle = outregs.x.ax;
00268      return 0;
00269   }
00270 
00271 }
00272 
00273 
00274 /************************************************************************/
00275 //    Get receive mode
00276 /************************************************************************/
00277 unsigned int Get_Receive_Mode(unsigned char * error)
00278 {
00279 
00280   union  REGS  inregs;
00281   union  REGS  outregs;
00282 
00283   *error=0;
00284   inregs.h.ah = GET_RCVMODE;
00285   int86(PKTVECT,&inregs,&outregs);
00286   if(outregs.x.cflag)
00287   {
00288   *error=outregs.h.dh;
00289   return 0;
00290   }
00291   return outregs.x.ax;
00292 }
00293 
00294 
00295 /************************************************************************/
00296 //    Set receive mode , possible only receive all
00297 /************************************************************************/
00298 unsigned int Set_Receive_Mode(unsigned int mode,unsigned char * error)
00299 {
00300 
00301   union  REGS  inregs;
00302   union  REGS  outregs;
00303 
00304   *error=0;
00305   inregs.h.ah = SET_RCVMODE;
00306   inregs.x.cx = mode;
00307 
00308   int86(PKTVECT,&inregs,&outregs);
00309   if(outregs.x.cflag)
00310   {
00311   *error=outregs.h.dh;
00312   return 0;
00313   }
00314   return outregs.x.ax;
00315 }
00316 
00317 
00318 /************************************************************************/
00319 //end pktdrv.c
00320 /************************************************************************/

Generated on Sun Aug 4 21:47:27 2002 for k/os mp3v2 by doxygen1.2.16