Ejemplo n.º 1
0
        internal IntelRingBuffer(uint capacity)
            //requires capacity > 0 && IsPowerOf2(capacity);
        {
            uint length  = capacity * DescriptorBytes;
            DmaMemory region = new DmaMemory((int)length); //TODO: DmaMemory.AllocatePhysical(length, AlignmentBytes);

            // (ARM only, not x86) PlatformService.SetCacheAttributes(region.VirtualAddress,
            //                                   (UIntPtr)region.Length,
            //                                   false,
            //                                   false);

            this.region     = region;
            this.mapEntries = new MapEntry [capacity];
            for (int i = 0; i < capacity; i++) {
                 this.mapEntries[i].mem = new DmaMemory((int)Intel.IEEE8023FrameBytes);
            }
            this.capacity   = capacity;

            this.head       = 0;
            this.tail       = 0;
            this.count      = 0;

            // Clear out ring buffer
            for (int i = 0; i < region.Length; i += 4) {
                region.Write32(i, 0);
            }
        }