block_device.h 863 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include "../../common/glib.h"
  3. #include "stdint.h"
  4. #include <process/semaphore.h>
  5. #define BLK_TYPE_AHCI 0
  6. struct block_device_operation
  7. {
  8. long (*open)();
  9. long (*close)();
  10. long (*ioctl)(long cmd, long arg);
  11. long (*transfer)(long cmd, ul LBA_start, ul count, uint64_t buffer, uint8_t arg0, uint8_t arg1);
  12. };
  13. /**
  14. * @brief 块设备请求队列内的packet
  15. *
  16. */
  17. struct block_device_request_packet
  18. {
  19. uchar cmd;
  20. uint64_t LBA_start;
  21. uint32_t count;
  22. uint64_t buffer_vaddr;
  23. uint8_t device_type; // 0: ahci
  24. void (*end_handler)(ul num, ul arg);
  25. wait_queue_node_t wait_queue;
  26. };
  27. /**
  28. * @brief 块设备的请求队列
  29. *
  30. */
  31. struct block_device_request_queue
  32. {
  33. wait_queue_node_t wait_queue_list;
  34. struct block_device_request_packet * in_service; // 正在请求的结点
  35. ul request_count;
  36. };