Exemple #1
0
        /// <summary>
        /// Set a memory based device at a specific location of memory
        /// </summary>
        /// <param name="device">The device to set</param>
        /// <param name="startAddres">The addres the device is based from.</param>
        /// <param name="size">The size (in bytes) of memory the device fills</param>
        public void AddDevice(IMemoryMappedDevice device)
        {
            device.SetMemory(memory.AsMemory(device.BaseAddress, device.Size));
            DevicesByName.Add(device.Name, device);
            int index = 0;

            if (DevicesByIndex.Keys.Count != 0)
            {
                index = DevicesByIndex.Keys.Max() + 1;
            }
            DevicesByIndex.Add(index, device);
            memoryMap.AsSpan(device.BaseAddress, device.Size).Fill(index);
        }