コード例 #1
0
        private void TXInitialize()
        {
            var tmp = (uint)Cosmos.Core.Memory.Heap.Alloc(8 * 16 + 16);

            TXDescs = (tmp % 16 != 0) ? (tmp + 16 - (tmp % 16)) : tmp;

            for (int i = 0; i < 8; i++)
            {
                TXDesc *desc = (TXDesc *)(TXDescs + (i * 16));
                desc->addr = 0;
                desc->cmd  = 0;
            }

            WriteRegister(REG_TXDESCLO, TXDescs);
            WriteRegister(REG_TXDESCHI, 0);

            WriteRegister(REG_TXDESCLEN, 8 * 16);
            WriteRegister(REG_TXDESCHEAD, 0);
            WriteRegister(REG_TXDESCTAIL, 0);

            //Set the transmit control register (padshortpackets)
            //E1000 only
            //WriteRegister(REG_TCTRL, (1 << 1) | (1 << 3));

            //For the e1000e
            WriteRegister(REG_TCTRL, 0b0110000000000111111000011111010);
            WriteRegister(REG_TIPG, 0x0060200A);

            WriteRegister(REG_TXDESCTAIL, 0);
        }
コード例 #2
0
        public override bool QueueBytes(byte[] buffer, int offset, int length)
        {
            //send bytes

            //Copy Buffer[offset] to ptr
            byte *ptr = (byte *)Cosmos.Core.Memory.Heap.Alloc((uint)length);
            int   a   = 0;

            for (int i = offset; i < offset + length; i++)
            {
                ptr[a] = buffer[i];
                a++;
            }

            TXDesc *desc = (TXDesc *)(TXDescs + (TXCurr * 16));

            desc->addr   = (ulong)ptr;
            desc->length = (ushort)length;
            desc->cmd    = (1 << 0) | (1 << 1) | (1 << 3);
            desc->status = 0;

            byte _TXCurr = (byte)TXCurr;

            TXCurr = (TXCurr + 1) % 8;
            WriteRegister(REG_TXDESCTAIL, TXCurr);
            int timeout = 5000;

            while ((desc->status & 0xF) == 0)
            {
                if (timeout <= 0)
                {
                    //This is most likly a driver issue
                    return(false);
                }
                timeout--;
            }
            return(true);
        }