Пример #1
0
        public static int DriverMain(IntelResources resources)
        {
            ExtensionContract /*.Exp*/       ep = (resources.ec).Acquire();
            ServiceProviderContract /*.Exp*/ sp = (resources.nicsp).Acquire();

            Intel device = new Intel(resources);

            device.Initialize();

            ep.SendSuccess();

            try {
                for (bool run = true; run;)
                {
                    switch receive {
                    case sp.Connect(ServiceContract /*.Exp*/ exp):
                        NicDeviceContract /*.Exp*/ nd = exp as NicDeviceContract /*.Exp*/;

                        if (nd != null)
                        {
                            Tracing.Log(Tracing.Debug, "Connect success.");
                            sp.SendAckConnect();
                            IntelDeviceChannel.CreateThread(device, nd);
                        }
                        else
                        {
                            Tracing.Log(Tracing.Error, "Connect failed.");
                            sp.SendNackConnect(exp);
                        }
                        break;

                    case sp.ChannelClosed():
                        device.Shutdown();
                        run = false;
                        break;

                    case ep.Shutdown():
                        device.Shutdown();
                        ep.SendAckShutdown();
                        break;

                    case ep.ChannelClosed():
                        device.Shutdown();
                        run = false;
                        break;

                    case unsatisfiable:
                        DebugStub.Break();
                        break;
                    }
                }
            }
            finally {
                //delete ep;
                //delete sp;
            }
            return(0);
        }
        private FromDeviceFlags GetRecvPktFlags(uint stat_err_flags)
        {
            FromDeviceFlags fromDevFlags = 0;

            if (((RxErrStatFields.CRC_ERROR | RxErrStatFields.SYMBOL_ERROR |
                  RxErrStatFields.SEQUENCE_ERROR | RxErrStatFields.CARRIER_EXT_ERROR |
                  RxErrStatFields.RX_DATA_ERROR) & stat_err_flags) != 0)
            {
                Intel.DebugPrint("Packet Rsv Error\n");
                fromDevFlags |= FromDeviceFlags.ReceiveError;
            }
            else
            {
                fromDevFlags |= FromDeviceFlags.ReceiveSuccess;
            }

            if (((stat_err_flags & RxErrStatFields.IGNORE_CHECKSUM) == 0) &&
                ((stat_err_flags & RxErrStatFields.IP_CHECKSUM_CALC) != 0))
            {
                if ((stat_err_flags & RxErrStatFields.IP_CHECKSUM_ERROR) != 0)
                {
                    Intel.DebugPrint("Bad Ip Checksum\n");
                    fromDevFlags |= FromDeviceFlags.BadIp4Checksum;
                }
                else
                {
                    // Good IP checksum flag???
                }
            }

            if (((stat_err_flags & RxErrStatFields.IGNORE_CHECKSUM) == 0) &&
                ((stat_err_flags & RxErrStatFields.TCP_CHECKSUM_CALC) != 0))
            {
                if ((stat_err_flags & RxErrStatFields.TCP_CHECKSUM_ERROR) != 0)
                {
                    fromDevFlags |= (FromDeviceFlags.BadTcp4Checksum |
                                     FromDeviceFlags.BadUdp4Checksum);
                    // don't know if UDP or TCP
                    Intel.DebugPrint("Bad TCP/UDP Checksum\n");
                }
                else
                {
                    fromDevFlags |= (FromDeviceFlags.GoodTcp4Checksum |
                                     FromDeviceFlags.GoodUdp4Checksum);
                }
            }

            //DebugStub.Assert((fromDevFlags == (FromDeviceFlags.ReceiveSuccess)) || (fromDevFlags == (FromDeviceFlags.ReceiveSuccess | FromDeviceFlags.GoodTcp4Checksum | FromDeviceFlags.GoodUdp4Checksum)));

            return(fromDevFlags);
        }
Пример #3
0
/*
        internal static UIntPtr GetPhysicalAddress(UIntPtr va)
        {
            UIntPtr pa;         // Physical address
            UIntPtr paLeft;     // Bytes remaining on physical page
            if (!DeviceService.GetDmaPhysicalAddress(va, out pa, out paLeft) ||
                pa == UIntPtr.Zero ||
                paLeft < Intel.IEEE8023FrameBytes) {
                throw new ApplicationException("Bad DMA pointer");
            }
            return pa;
        }
*/

        internal void Dump(string preamble, uint count)
        {
            if (count > this.capacity) {
                count = this.capacity;
            }
            Intel.DebugWriteLine("Head {0} Tail {1}\n",
                                 DebugStub.ArgList(this.Head, this.Tail));
            for (uint i = 0; i < count; i++) {
                ulong address = this.region.Read64((int)(i * 16));
                ulong fields  = this.region.Read64((int)(i * 16 + 8));
                Intel.DebugWriteLine("{0}: [{1}] Address {2:x16} Sp={3:x4} Err={4:x1} Sta={5:x2} Checksum {6:x4} Length {7:x4}",
                                     DebugStub.ArgList(preamble, i, address,
                                               (fields >> 48) & 0xffff,
                                               (fields >> 40) & 0xff,
                                               (fields >> 32) & 0xff,
                                               (fields >> 16) & 0xffff,
                                               fields & 0xffff));
            }
        }
Пример #4
0
 public IntelDeviceChannel(
     Intel theDevice
     )
 {
     this.device = theDevice;
 }