ATAPIDiscDevice.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/StringView.h>
  7. #include <Kernel/Devices/DeviceManagement.h>
  8. #include <Kernel/Sections.h>
  9. #include <Kernel/Storage/ATA/ATAPIDiscDevice.h>
  10. #include <Kernel/Storage/ATA/IDEChannel.h>
  11. #include <Kernel/Storage/ATA/IDEController.h>
  12. #include <Kernel/Storage/StorageManagement.h>
  13. namespace Kernel {
  14. NonnullRefPtr<ATAPIDiscDevice> ATAPIDiscDevice::create(const ATAController& controller, ATADevice::Address ata_address, u16 capabilities, u64 max_addressable_block)
  15. {
  16. auto minor_device_number = StorageManagement::generate_storage_minor_number();
  17. auto device_name = MUST(KString::formatted("hd{:c}", 'a' + minor_device_number.value()));
  18. auto disc_device_or_error = DeviceManagement::try_create_device<ATAPIDiscDevice>(controller, ata_address, minor_device_number.value(), capabilities, max_addressable_block, move(device_name));
  19. // FIXME: Find a way to propagate errors
  20. VERIFY(!disc_device_or_error.is_error());
  21. return disc_device_or_error.release_value();
  22. }
  23. ATAPIDiscDevice::ATAPIDiscDevice(const ATAController& controller, ATADevice::Address ata_address, MinorNumber minor_number, u16 capabilities, u64 max_addressable_block, NonnullOwnPtr<KString> early_storage_name)
  24. : ATADevice(controller, ata_address, minor_number, capabilities, 0, max_addressable_block, move(early_storage_name))
  25. {
  26. }
  27. ATAPIDiscDevice::~ATAPIDiscDevice()
  28. {
  29. }
  30. StringView ATAPIDiscDevice::class_name() const
  31. {
  32. return "ATAPIDiscDevice";
  33. }
  34. }