Beispiel #1
0
 /// <summary>
 /// Destroys the MSD disk device.
 /// </summary>
 public void Destroy()
 {
     DeviceManager.Devices.Remove(this);
     msd = null;
 }
Beispiel #2
0
        /// <summary>
        /// Initialises a new disk device interface for the specified MSD. 
        /// Also determines the device's maximum size.
        /// </summary>
        /// <param name="anMSD">The MSD to create an interface for.</param>
        public MassStorageDevice_DiskDevice(MassStorageDevice anMSD)
        {
            msd = anMSD;

            uint* capacityBuffer = (uint*)FOS_System.Heap.AllocZeroed(8, "MassStorageDevice : MassStorageDevice_DiskDevice()");
            try
            {
                //Send SCSI Read Capacity (10) command
                anMSD.SendSCSICommand_IN(0x25, 0, 8, capacityBuffer, null);

                // MSB ... LSB converted to LSB...MSB
                //  i.e. big-endian converted to little endian
                capacityBuffer[0] = Utils.htonl(capacityBuffer[0]);
                capacityBuffer[1] = Utils.htonl(capacityBuffer[1]);

                // capacityBuffer[0] = Last LBA i.e. last addressable LBA
                //      So the count of blocks is Last LBA + 1
                blockCount = ((ulong)capacityBuffer[0]) + 1;
                // capacityBuffer[1] = Block size
                blockSize = (ulong)capacityBuffer[1];
            }
            finally
            {
                FOS_System.Heap.Free(capacityBuffer);
            }

            DeviceManager.AddDevice(this);
        }