Lines Matching +full:mode +full:- +full:reg

8  *  Description..: Packet-driver interface for 16/32-bit C :
24 #include "pcap-dos.h"
25 #include "pcap-int.h"
79 /* Data located in a real-mode segment. This becomes far at runtime
106 #define LAST_RX_BUF offsetof (PktRealStub,_pktRxBuf [NUM_RX_BUF-1])
112 extern BYTE pktRxEnd; /* marks the end of r-mode code/data */
119 #define LAST_RX_BUF (WORD) &pktRxBuf [NUM_RX_BUF-1]
149 LOCAL WORD realSeg; /* DOS para-address of allocated area */
150 LOCAL SWI_REGS reg;
156 static __dpmi_regs reg;
171 LOCAL struct DPMI_regs reg;
181 #else /* real-mode Borland etc. */
185 } reg;
201 PUBLIC PKT_INFO pktInfo; /* packet-driver information */
227 "Invalid receiver mode specified",
235 "Bad Check-sum",
253 return ("DIX-Ether");
255 return ("ProNET-10");
289 PUBLIC char const *PktRXmodeStr (PKT_RX_MODE mode)
297 "Receive all packets (promiscuous mode)"
300 if (mode > DIM(modeStr))
302 return (modeStr [mode-1]);
312 _dx_real_int ((UINT)pktInfo.intr, &reg);
313 okay = ((reg.flags & 1) == 0); /* OK if carry clear */
316 __dpmi_int ((int)pktInfo.intr, &reg);
317 okay = ((reg.x.flags & 1) == 0);
328 s.es = FP_SEG (&reg);
329 r.x.edi = FP_OFF (&reg);
330 reg.r_flags = 0;
331 reg.r_ss = reg.r_sp = 0; /* DPMI host provides stack */
337 reg.r_flags = 0;
338 intr (pktInfo.intr, (struct REGPACK*)&reg);
339 okay = ((reg.r_flags & 1) == 0);
344 else pktInfo.error = PktGetErrorStr (reg.r_dx >> 8);
387 pktInfo.intr = (found ? intr-1 : 0);
396 reg.r_ax = 0x0200 + pktInfo.class;
397 reg.r_bx = 0xFFFF;
398 reg.r_dx = 0;
399 reg.r_cx = 0;
402 reg.ds = 0;
403 reg.esi = 0;
404 reg.es = RP_SEG (realBase);
405 reg.edi = (WORD) &PktReceiver;
408 reg.x.ds = 0;
409 reg.x.si = 0;
410 reg.x.es = rm_mem.rm_segment;
411 reg.x.di = PktReceiver;
414 reg.r_ds = 0;
415 reg.r_si = 0;
416 reg.r_es = rm_base_seg;
417 reg.r_di = PktReceiver;
420 reg.r_ds = 0;
421 reg.r_si = 0;
422 reg.r_es = FP_SEG (&PktReceiver);
423 reg.r_di = FP_OFF (&PktReceiver);
429 pktInfo.handle = reg.r_ax;
437 reg.r_ax = 0x0300;
438 reg.r_bx = handle;
449 reg.r_ax = 0x0400; /* Function 4, send pkt */
450 reg.r_cx = len; /* total size of frame */
454 reg.x.ds = rm_mem.rm_segment; /* DOS data segment and */
455 reg.x.si = pktTxBuf; /* DOS offset to buffer */
459 reg.r_ds = rm_base_seg;
460 reg.r_si = pktTxBuf;
464 reg.r_ds = FP_SEG (&pktTxBuf);
465 reg.r_si = FP_OFF (&pktTxBuf);
468 reg.r_ds = FP_SEG (eth);
469 reg.r_si = FP_OFF (eth);
489 if (rx->handle != pktInfo.handle)
493 PktReleaseHandle (rx->handle);
496 count_1 = rx->firstCount;
497 count_2 = rx->secondCount;
526 reg.r_ax = 0x0500;
527 reg.r_bx = handle;
535 reg.r_ax = 0x0700;
536 reg.r_bx = handle;
542 PUBLIC BOOL PktSetReceiverMode (PKT_RX_MODE mode)
547 reg.r_ax = 0x1400;
548 reg.r_bx = pktInfo.handle;
549 reg.r_cx = (WORD)mode;
554 receiveMode = mode;
560 PUBLIC BOOL PktGetReceiverMode (PKT_RX_MODE *mode)
562 reg.r_ax = 0x1500;
563 reg.r_bx = pktInfo.handle;
568 *mode = reg.r_ax;
579 reg.r_ax = 0x1800;
580 reg.r_bx = handle;
586 ReadRealMem (&pktStat, DOS_ADDR(reg.ds,reg.esi), sizeof(pktStat));
589 dosmemget (DOS_ADDR(reg.x.ds,reg.x.si), sizeof(pktStat), &pktStat);
592 memcpy (&pktStat, (void*)DOS_ADDR(reg.r_ds,reg.r_si), sizeof(pktStat));
595 _fmemcpy (&pktStat, MK_FP(reg.r_ds,reg.r_si), sizeof(pktStat));
610 pktStat.inPackets -= initialStat.inPackets;
611 pktStat.outPackets -= initialStat.outPackets;
612 pktStat.inBytes -= initialStat.inBytes;
613 pktStat.outBytes -= initialStat.outBytes;
614 pktStat.inErrors -= initialStat.inErrors;
615 pktStat.outErrors -= initialStat.outErrors;
616 pktStat.outErrors -= initialStat.outErrors;
617 pktStat.lost -= initialStat.lost;
638 reg.r_ax = 0x0600;
639 reg.r_bx = pktInfo.handle;
640 reg.r_cx = sizeof (*addr);
643 reg.x.es = rm_mem.rm_segment;
644 reg.x.di = pktTemp;
646 reg.r_es = rm_base_seg;
647 reg.r_di = pktTemp;
649 reg.r_es = FP_SEG (&pktTemp);
650 reg.r_di = FP_OFF (&pktTemp); /* ES:DI = address for result */
676 /* copy addr to real-mode scrath area */
691 reg.r_ax = 0x1900;
692 reg.r_cx = sizeof (*addr); /* address length */
695 reg.x.es = rm_mem.rm_segment; /* DOS offset to param */
696 reg.x.di = pktTemp; /* DOS segment to param */
698 reg.r_es = rm_base_seg;
699 reg.r_di = pktTemp;
701 reg.r_es = FP_SEG (&pktTemp);
702 reg.r_di = FP_OFF (&pktTemp);
715 reg.r_ax = 0x01FF;
716 reg.r_bx = 0;
721 pktInfo.number = reg.r_cx & 0xFF;
722 pktInfo.class = reg.r_cx >> 8;
724 pktInfo.minVer = reg.r_bx % 10;
725 pktInfo.majVer = reg.r_bx / 10;
727 pktInfo.majVer = reg.r_bx; // !!
729 pktInfo.funcs = reg.r_ax & 0xFF;
730 pktInfo.type = reg.r_dx & 0xFF;
733 ReadRealMem (&pktInfo.name, DOS_ADDR(reg.ds,reg.esi), sizeof(pktInfo.name));
736 dosmemget (DOS_ADDR(reg.x.ds,reg.x.si), sizeof(pktInfo.name), &pktInfo.name);
739 memcpy (&pktInfo.name, (void*)DOS_ADDR(reg.r_ds,reg.r_si), sizeof(pktInfo.name));
742 _fmemcpy (&pktInfo.name, MK_FP(reg.r_ds,reg.r_si), sizeof(pktInfo.name));
751 reg.r_ax = 0x0A00;
757 ReadRealMem (&pktInfo.majVer, DOS_ADDR(reg.es,reg.edi), PKT_PARAM_SIZE);
760 dosmemget (DOS_ADDR(reg.x.es,reg.x.di), PKT_PARAM_SIZE, &pktInfo.majVer);
763 memcpy (&pktInfo.majVer, (void*)DOS_ADDR(reg.r_es,reg.r_di), PKT_PARAM_SIZE);
766 _fmemcpy (&pktInfo.majVer, MK_FP(reg.r_es,reg.r_di), PKT_PARAM_SIZE);
786 size = min (head->firstCount, sizeof(RX_ELEMENT));
788 _fmemcpy (buf, &head->destin, len);
791 size = -1;
816 return (inOfs - outOfs) / sizeof(RX_ELEMENT);
817 return (NUM_RX_BUF - (outOfs - inOfs) / sizeof(RX_ELEMENT));
846 size = -1;
882 return (inOfs - outOfs) / sizeof(RX_ELEMENT);
883 return (NUM_RX_BUF - (outOfs - inOfs) / sizeof(RX_ELEMENT));
912 size = -1;
948 return (inOfs - outOfs) / sizeof(RX_ELEMENT);
949 return (NUM_RX_BUF - (outOfs - inOfs) / sizeof(RX_ELEMENT));
957 #else /* real-mode small/large model */
968 size = min (head->firstCount, sizeof(RX_ELEMENT));
970 _fmemcpy (buf, &head->destin, len);
973 size = -1;
997 return ((inOfs - outOfs) / sizeof(RX_ELEMENT));
998 return (NUM_RX_BUF - (outOfs - inOfs) / sizeof(RX_ELEMENT));
1020 unsigned ofs; /* clear the DOS-mem to prevent further upcalls */
1043 PUTS ("Error restoring receiver mode.");
1046 PUTS ("Error releasing PKT-DRVR handle.");
1053 printf ("Internal stats: too-small %lu, too-large %lu, bad-sync %lu, "
1054 "wrong-handle %lu\n",
1076 PUBLIC BOOL PktInitDriver (PKT_RX_MODE mode)
1108 PUTS ("Error getting pkt-drvr information.");
1124 PUTS ("Cannot allocate real-mode stub.");
1139 PUTS ("real-mode init failed.");
1151 PUTS ("real-mode init failed.");
1191 PUTS ("Error setting pkt-drvr access.");
1203 if (!PktSetReceiverMode(mode))
1205 PUTS ("Error setting receiver mode.");
1212 PUTS ("Error getting receiver mode.");
1218 printf ("Pkt-driver information:\n"
1228 " Hi-perf : %s\n"
1229 " RX mode : %s\n"
1230 " Eth-addr : %02X:%02X:%02X:%02X:%02X:%02X\n",
1322 * of code (which must be within the first 64K of the protected mode
1328 * NOTE THIS ROUTINE REQUIRES 386|DOS-EXTENDER 3.0 OR LATER.
1331 * start_offs start of real mode code in program segment
1332 * end_offs 1 byte past end of real mode code in program segment
1333 * real_basep returned; real mode ptr to use as a base for the
1334 * real mode code (eg, to get the real mode FAR
1338 * offsets within the real mode segment are
1339 * the same as the link-time offsets in the
1340 * protected mode program segment
1341 * prot_basep returned; prot mode ptr to use as a base for getting
1343 * so that adding the prot mode offset of a
1347 * rmem_adrp returned; real mode para addr of allocated
1350 * USE THIS TO CONSTRUCT A REAL MODE PTR, USE
1364 ULONG rm_base; /* base real mode para addr for accessing */
1377 /* Round start_offs down to a paragraph (16-byte) boundary so we can set up
1378 * the real mode pointer easily. Round up end_offs to make sure we allocate
1384 /* Allocate the conventional memory for our real mode code. Remember to
1385 * round byte count UP to 16-byte paragraph size. We alloc it
1395 len = ((end_offs - start_offs) + 15) >> 4;
1415 /* Construct real mode & protected mode pointers to access the allocated
1416 * memory. Note we know start_offs is aligned on a paragraph (16-byte)
1419 * We make the offsets come out rights by backing off the real mode selector
1422 rm_base = ((ULONG) *rmem_adrp) - (start_offs >> 4);
1426 /* Copy the real mode code/data to the allocated memory
1431 len = end_offs - start_offs;