ahci.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. #include "ahci.h"
  2. #include <common/kprint.h>
  3. #include <mm/slab.h>
  4. #include <syscall/syscall.h>
  5. #include <syscall/syscall_num.h>
  6. #include <sched/sched.h>
  7. struct pci_device_structure_header_t *ahci_devs[MAX_AHCI_DEVICES];
  8. struct block_device_request_queue ahci_req_queue;
  9. uint32_t count_ahci_devices = 0;
  10. static uint64_t ahci_port_base_vaddr; // 端口映射base addr
  11. static uint64_t ahci_port_base_phys_addr; // 端口映射的物理基地址(ahci控制器的参数的地址都是物理地址)
  12. static void start_cmd(HBA_PORT *port);
  13. static void stop_cmd(HBA_PORT *port);
  14. static void port_rebase(HBA_PORT *port, int portno);
  15. static long ahci_query_disk();
  16. // Find a free command list slot
  17. static int ahci_find_cmdslot(HBA_PORT *port);
  18. // 计算HBA_MEM的虚拟内存地址
  19. #define cal_HBA_MEM_VIRT_ADDR(device_num) (AHCI_MAPPING_BASE + (ul)(((struct pci_device_structure_general_device_t *)(ahci_devs[device_num]))->BAR5 - ((((struct pci_device_structure_general_device_t *)(ahci_devs[0]))->BAR5) & PAGE_2M_MASK)))
  20. /**
  21. * @brief 初始化ahci模块
  22. *
  23. */
  24. void ahci_init()
  25. {
  26. kinfo("Initializing AHCI...");
  27. pci_get_device_structure(0x1, 0x6, ahci_devs, &count_ahci_devices);
  28. if (count_ahci_devices == 0)
  29. {
  30. kwarn("There is no AHCI device found on this computer!");
  31. return;
  32. }
  33. // 映射ABAR
  34. kdebug("phys_2_virt(ahci_devs[0])= %#018lx", (ahci_devs[0]));
  35. kdebug("((struct pci_device_structure_general_device_t *)phys_2_virt(ahci_devs[0])))->BAR5= %#018lx", ((struct pci_device_structure_general_device_t *)(ahci_devs[0]))->BAR5);
  36. uint32_t bar5 = ((struct pci_device_structure_general_device_t *)(ahci_devs[0]))->BAR5;
  37. mm_map_phys_addr(AHCI_MAPPING_BASE, (ul)(bar5)&PAGE_2M_MASK, PAGE_2M_SIZE, PAGE_KERNEL_PAGE | PAGE_PWT | PAGE_PCD, false);
  38. kdebug("ABAR mapped!");
  39. for (int i = 0; i < count_ahci_devices; ++i)
  40. {
  41. // kdebug("[%d] class_code=%d, sub_class=%d, progIF=%d, ABAR=%#010lx", i, ahci_devs[i]->Class_code, ahci_devs[i]->SubClass, ahci_devs[i]->ProgIF, ((struct pci_device_structure_general_device_t *)(ahci_devs[i]))->BAR5);
  42. // 赋值HBA_MEM结构体
  43. ahci_devices[i].dev_struct = ahci_devs[i];
  44. ahci_devices[i].hba_mem = (HBA_MEM *)(cal_HBA_MEM_VIRT_ADDR(i));
  45. kdebug("ahci_devices[i].hba_mem = %#018lx", (ul)ahci_devices[i].hba_mem);
  46. }
  47. // todo: 支持多个ahci控制器。
  48. ahci_port_base_vaddr = (uint64_t)kmalloc(1048576, 0);
  49. kdebug("ahci_port_base_vaddr=%#018lx", ahci_port_base_vaddr);
  50. ahci_probe_port(0);
  51. port_rebase(&ahci_devices[0].hba_mem->ports[0], 0);
  52. // 初始化请求队列
  53. ahci_req_queue.in_service = NULL;
  54. wait_queue_init(&ahci_req_queue.wait_queue_list, NULL);
  55. ahci_req_queue.request_count = 0;
  56. kinfo("AHCI initialized.");
  57. }
  58. // Check device type
  59. static int check_type(HBA_PORT *port)
  60. {
  61. uint32_t ssts = port->ssts;
  62. uint8_t ipm = (ssts >> 8) & 0x0F;
  63. uint8_t det = ssts & 0x0F;
  64. if (det != HBA_PORT_DET_PRESENT) // Check drive status
  65. return AHCI_DEV_NULL;
  66. if (ipm != HBA_PORT_IPM_ACTIVE)
  67. return AHCI_DEV_NULL;
  68. switch (port->sig)
  69. {
  70. case SATA_SIG_ATAPI:
  71. return AHCI_DEV_SATAPI;
  72. case SATA_SIG_SEMB:
  73. return AHCI_DEV_SEMB;
  74. case SATA_SIG_PM:
  75. return AHCI_DEV_PM;
  76. default:
  77. return AHCI_DEV_SATA;
  78. }
  79. }
  80. /**
  81. * @brief 检测端口连接的设备的类型
  82. *
  83. * @param device_num ahci控制器号
  84. */
  85. static void ahci_probe_port(const uint32_t device_num)
  86. {
  87. HBA_MEM *abar = ahci_devices[device_num].hba_mem;
  88. uint32_t pi = abar->pi;
  89. for (int i = 0; i < 32; ++i, (pi >>= 1))
  90. {
  91. if (pi & 1)
  92. {
  93. uint dt = check_type(&abar->ports[i]);
  94. ahci_devices[i].type = dt;
  95. if (dt == AHCI_DEV_SATA)
  96. {
  97. kdebug("SATA drive found at port %d", i);
  98. }
  99. else if (dt == AHCI_DEV_SATAPI)
  100. {
  101. kdebug("SATAPI drive found at port %d", i);
  102. }
  103. else if (dt == AHCI_DEV_SEMB)
  104. {
  105. kdebug("SEMB drive found at port %d", i);
  106. }
  107. else if (dt == AHCI_DEV_PM)
  108. {
  109. kdebug("PM drive found at port %d", i);
  110. }
  111. else
  112. {
  113. // kdebug("No drive found at port %d", i);
  114. }
  115. }
  116. }
  117. }
  118. // Start command engine
  119. static void start_cmd(HBA_PORT *port)
  120. {
  121. // Wait until CR (bit15) is cleared
  122. while ((port->cmd) & HBA_PxCMD_CR)
  123. ;
  124. // Set FRE (bit4) and ST (bit0)
  125. port->cmd |= HBA_PxCMD_FRE;
  126. port->cmd |= HBA_PxCMD_ST;
  127. }
  128. // Stop command engine
  129. static void stop_cmd(HBA_PORT *port)
  130. {
  131. // Clear ST (bit0)
  132. port->cmd &= ~HBA_PxCMD_ST;
  133. // Clear FRE (bit4)
  134. port->cmd &= ~HBA_PxCMD_FRE;
  135. // Wait until FR (bit14), CR (bit15) are cleared
  136. while (1)
  137. {
  138. if (port->cmd & HBA_PxCMD_FR)
  139. continue;
  140. if (port->cmd & HBA_PxCMD_CR)
  141. continue;
  142. break;
  143. }
  144. }
  145. static void port_rebase(HBA_PORT *port, int portno)
  146. {
  147. // Before rebasing Port memory space, OS must wait for current pending commands to finish
  148. // and tell HBA to stop receiving FIS from the port. Otherwise an accidently incoming FIS may be
  149. // written into a partially configured memory area.
  150. stop_cmd(port); // Stop command engine
  151. // Command list offset: 1K*portno
  152. // Command list entry size = 32
  153. // Command list entry maxim count = 32
  154. // Command list maxim size = 32*32 = 1K per port
  155. port->clb = virt_2_phys(ahci_port_base_vaddr + (portno << 10));
  156. memset((void *)(phys_2_virt(port->clb)), 0, 1024);
  157. // FIS offset: 32K+256*portno
  158. // FIS entry size = 256 bytes per port
  159. port->fb = virt_2_phys(ahci_port_base_vaddr + (32 << 10) + (portno << 8));
  160. memset((void *)(phys_2_virt(port->fb)), 0, 256);
  161. // Command table offset: 40K + 8K*portno
  162. // Command table size = 256*32 = 8K per port
  163. HBA_CMD_HEADER *cmdheader = (HBA_CMD_HEADER *)(phys_2_virt(port->clb));
  164. for (int i = 0; i < 32; ++i)
  165. {
  166. cmdheader[i].prdtl = 8; // 8 prdt entries per command table
  167. // 256 bytes per command table, 64+16+48+16*8
  168. // Command table offset: 40K + 8K*portno + cmdheader_index*256
  169. cmdheader[i].ctba = virt_2_phys((ahci_port_base_vaddr + (40 << 10) + (portno << 13) + (i << 8)));
  170. memset((void *)phys_2_virt(cmdheader[i].ctba), 0, 256);
  171. }
  172. start_cmd(port); // Start command engine
  173. }
  174. /**
  175. * @brief read data from SATA device using 48bit LBA address
  176. *
  177. * @param port HBA PORT
  178. * @param startl low 32bits of start addr
  179. * @param starth high 32bits of start addr
  180. * @param count total sectors to read
  181. * @param buf buffer
  182. * @return true done
  183. * @return false failed
  184. */
  185. static bool ahci_read(HBA_PORT *port, uint32_t startl, uint32_t starth, uint32_t count, uint64_t buf)
  186. {
  187. port->is = (uint32_t)-1; // Clear pending interrupt bits
  188. int spin = 0; // Spin lock timeout counter
  189. int slot = ahci_find_cmdslot(port);
  190. if (slot == -1)
  191. return E_NOEMPTYSLOT;
  192. HBA_CMD_HEADER *cmdheader = (HBA_CMD_HEADER *)phys_2_virt(port->clb);
  193. cmdheader += slot;
  194. cmdheader->cfl = sizeof(FIS_REG_H2D) / sizeof(uint32_t); // Command FIS size
  195. cmdheader->w = 0; // Read from device
  196. cmdheader->prdtl = (uint16_t)((count - 1) >> 4) + 1; // PRDT entries count
  197. HBA_CMD_TBL *cmdtbl = (HBA_CMD_TBL *)phys_2_virt(cmdheader->ctba);
  198. memset(cmdtbl, 0, sizeof(HBA_CMD_TBL) + (cmdheader->prdtl - 1) * sizeof(HBA_PRDT_ENTRY));
  199. // 8K bytes (16 sectors) per PRDT
  200. int i;
  201. for (i = 0; i < cmdheader->prdtl - 1; ++i)
  202. {
  203. cmdtbl->prdt_entry[i].dba = virt_2_phys(buf);
  204. cmdtbl->prdt_entry[i].dbc = 8 * 1024 - 1; // 8K bytes (this value should always be set to 1 less than the actual value)
  205. cmdtbl->prdt_entry[i].i = 1;
  206. buf += 4 * 1024; // 4K uint16_ts
  207. count -= 16; // 16 sectors
  208. }
  209. // Last entry
  210. cmdtbl->prdt_entry[i].dba = virt_2_phys(buf);
  211. cmdtbl->prdt_entry[i].dbc = (count << 9) - 1; // 512 bytes per sector
  212. cmdtbl->prdt_entry[i].i = 1;
  213. // Setup command
  214. FIS_REG_H2D *cmdfis = (FIS_REG_H2D *)(&cmdtbl->cfis);
  215. cmdfis->fis_type = FIS_TYPE_REG_H2D;
  216. cmdfis->c = 1; // Command
  217. cmdfis->command = AHCI_CMD_READ_DMA_EXT;
  218. cmdfis->lba0 = (uint8_t)startl;
  219. cmdfis->lba1 = (uint8_t)(startl >> 8);
  220. cmdfis->lba2 = (uint8_t)(startl >> 16);
  221. cmdfis->device = 1 << 6; // LBA mode
  222. cmdfis->lba3 = (uint8_t)(startl >> 24);
  223. cmdfis->lba4 = (uint8_t)starth;
  224. cmdfis->lba5 = (uint8_t)(starth >> 8);
  225. cmdfis->countl = count & 0xFF;
  226. cmdfis->counth = (count >> 8) & 0xFF;
  227. // The below loop waits until the port is no longer busy before issuing a new command
  228. while ((port->tfd & (AHCI_DEV_BUSY | AHCI_DEV_DRQ)) && spin < 1000000)
  229. {
  230. spin++;
  231. }
  232. if (spin == 1000000)
  233. {
  234. kerror("Port is hung");
  235. return E_PORT_HUNG;
  236. }
  237. port->ci = 1 << slot; // Issue command
  238. current_pcb->flags |= PF_NEED_SCHED;
  239. sched();
  240. int retval = AHCI_SUCCESS;
  241. // Wait for completion
  242. while (1)
  243. {
  244. // In some longer duration reads, it may be helpful to spin on the DPS bit
  245. // in the PxIS port field as well (1 << 5)
  246. if ((port->ci & (1 << slot)) == 0)
  247. break;
  248. if (port->is & HBA_PxIS_TFES) // Task file error
  249. {
  250. kerror("Read disk error");
  251. retval = E_TASK_FILE_ERROR;
  252. break;
  253. }
  254. }
  255. // Check again
  256. if (port->is & HBA_PxIS_TFES)
  257. {
  258. kerror("Read disk error");
  259. retval = E_TASK_FILE_ERROR;
  260. }
  261. enter_syscall_int(SYS_AHCI_END_REQ, 0, 0, 0, 0, 0, 0, 0, 0);
  262. return retval;
  263. }
  264. static bool ahci_write(HBA_PORT *port, uint32_t startl, uint32_t starth, uint32_t count,
  265. uint64_t buf)
  266. {
  267. // kdebug("ahci write");
  268. port->is = 0xffff; // Clear pending interrupt bits
  269. int slot = ahci_find_cmdslot(port);
  270. if (slot == -1)
  271. return E_NOEMPTYSLOT;
  272. HBA_CMD_HEADER *cmdheader = (HBA_CMD_HEADER *)phys_2_virt(port->clb);
  273. cmdheader += slot;
  274. cmdheader->cfl = sizeof(FIS_REG_H2D) / sizeof(uint32_t); // Command FIS size
  275. cmdheader->w = 1;
  276. cmdheader->c = 1;
  277. cmdheader->p = 1;
  278. cmdheader->prdtl = (uint16_t)((count - 1) >> 4) + 1; // PRDT entries count
  279. HBA_CMD_TBL *cmdtbl = (HBA_CMD_TBL *)phys_2_virt(cmdheader->ctba);
  280. memset(cmdtbl, 0, sizeof(HBA_CMD_TBL) + (cmdheader->prdtl - 1) * sizeof(HBA_PRDT_ENTRY));
  281. int i = 0;
  282. for (i = 0; i < cmdheader->prdtl - 1; ++i)
  283. {
  284. cmdtbl->prdt_entry[i].dba = virt_2_phys(buf);
  285. cmdtbl->prdt_entry[i].dbc = 8 * 1024 - 1; // 8K bytes
  286. cmdtbl->prdt_entry[i].i = 0;
  287. buf += 4 * 1024; // 4K words
  288. count -= 16; // 16 sectors
  289. }
  290. cmdtbl->prdt_entry[i].dba = virt_2_phys(buf);
  291. cmdtbl->prdt_entry[i].dbc = count << 9; // 512 bytes per sector
  292. cmdtbl->prdt_entry[i].i = 0;
  293. FIS_REG_H2D *cmdfis = (FIS_REG_H2D *)(&cmdtbl->cfis);
  294. cmdfis->fis_type = FIS_TYPE_REG_H2D;
  295. cmdfis->c = 1; // Command
  296. cmdfis->command = AHCI_CMD_WRITE_DMA_EXT;
  297. cmdfis->lba0 = (uint8_t)startl;
  298. cmdfis->lba1 = (uint8_t)(startl >> 8);
  299. cmdfis->lba2 = (uint8_t)(startl >> 16);
  300. cmdfis->lba3 = (uint8_t)(startl >> 24);
  301. cmdfis->lba4 = (uint8_t)starth;
  302. cmdfis->lba5 = (uint8_t)(starth >> 8);
  303. cmdfis->device = 1 << 6; // LBA mode
  304. cmdfis->countl = count & 0xff;
  305. cmdfis->counth = count >> 8;
  306. // printk("[slot]{%d}", slot);
  307. port->ci = 1; // Issue command
  308. current_pcb->flags |= PF_NEED_SCHED;
  309. sched();
  310. int retval = AHCI_SUCCESS;
  311. while (1)
  312. {
  313. // In some longer duration reads, it may be helpful to spin on the DPS bit
  314. // in the PxIS port field as well (1 << 5)
  315. if ((port->ci & (1 << slot)) == 0)
  316. break;
  317. if (port->is & HBA_PxIS_TFES)
  318. { // Task file error
  319. kerror("Write disk error");
  320. retval = E_TASK_FILE_ERROR;
  321. break;
  322. }
  323. }
  324. if (port->is & HBA_PxIS_TFES)
  325. {
  326. kerror("Write disk error");
  327. retval = E_TASK_FILE_ERROR;
  328. }
  329. // kdebug("ahci write retval=%d", retval);
  330. enter_syscall_int(SYS_AHCI_END_REQ, 0, 0, 0, 0, 0, 0, 0, 0);
  331. return retval;
  332. }
  333. // Find a free command list slot
  334. static int ahci_find_cmdslot(HBA_PORT *port)
  335. {
  336. // If not set in SACT and CI, the slot is free
  337. uint32_t slots = (port->sact | port->ci);
  338. int num_of_cmd_clots = (ahci_devices[0].hba_mem->cap & 0x0f00) >> 8; // bit 12-8
  339. for (int i = 0; i < num_of_cmd_clots; i++)
  340. {
  341. if ((slots & 1) == 0)
  342. return i;
  343. slots >>= 1;
  344. }
  345. kerror("Cannot find free command list entry");
  346. return -1;
  347. }
  348. long ahci_open()
  349. {
  350. return 0;
  351. }
  352. long ahci_close()
  353. {
  354. return 0;
  355. }
  356. /**
  357. * @brief 创建ahci磁盘请求包
  358. *
  359. * @param cmd 控制命令
  360. * @param base_addr 48位LBA地址
  361. * @param count total sectors to read
  362. * @param buf 缓冲区线性地址
  363. * @param ahci_ctrl_num ahci控制器号
  364. * @param port_num ahci控制器端口号
  365. * @return struct block_device_request_packet*
  366. */
  367. static struct ahci_request_packet_t *ahci_make_request(long cmd, uint64_t base_addr, uint64_t count, uint64_t buffer, uint8_t ahci_ctrl_num, uint8_t port_num)
  368. {
  369. struct ahci_request_packet_t *pack = (struct ahci_request_packet_t *)kmalloc(sizeof(struct ahci_request_packet_t), 0);
  370. wait_queue_init(&pack->blk_pak.wait_queue, current_pcb);
  371. pack->blk_pak.device_type = BLK_TYPE_AHCI;
  372. // 由于ahci不需要中断即可读取磁盘,因此end handler为空
  373. switch (cmd)
  374. {
  375. case AHCI_CMD_READ_DMA_EXT:
  376. pack->blk_pak.end_handler = NULL;
  377. pack->blk_pak.cmd = AHCI_CMD_READ_DMA_EXT;
  378. break;
  379. case AHCI_CMD_WRITE_DMA_EXT:
  380. pack->blk_pak.end_handler = NULL;
  381. pack->blk_pak.cmd = AHCI_CMD_WRITE_DMA_EXT;
  382. break;
  383. default:
  384. pack->blk_pak.end_handler = NULL;
  385. pack->blk_pak.cmd = cmd;
  386. break;
  387. }
  388. pack->blk_pak.LBA_start = base_addr;
  389. pack->blk_pak.count = count;
  390. pack->blk_pak.buffer_vaddr = buffer;
  391. pack->ahci_ctrl_num = ahci_ctrl_num;
  392. pack->port_num = port_num;
  393. return pack;
  394. }
  395. /**
  396. * @brief 结束磁盘请求
  397. *
  398. */
  399. void ahci_end_request()
  400. {
  401. ahci_req_queue.in_service->wait_queue.pcb->state = PROC_RUNNING;
  402. // ahci_req_queue.in_service->wait_queue.pcb->flags |= PF_NEED_SCHED;
  403. // current_pcb->flags |= PF_NEED_SCHED;
  404. kfree((uint64_t *)ahci_req_queue.in_service);
  405. ahci_req_queue.in_service = NULL;
  406. // 进行下一轮的磁盘请求 (由于未实现单独的io调度器,这里会造成长时间的io等待)
  407. if (ahci_req_queue.request_count > 0)
  408. ahci_query_disk();
  409. }
  410. static long ahci_query_disk()
  411. {
  412. wait_queue_node_t *wait_queue_tmp = container_of(list_next(&ahci_req_queue.wait_queue_list.wait_list), wait_queue_node_t, wait_list);
  413. struct ahci_request_packet_t *pack = (struct ahci_request_packet_t *)container_of(wait_queue_tmp, struct block_device_request_packet, wait_queue);
  414. ahci_req_queue.in_service = (struct block_device_request_packet *)pack;
  415. list_del(&(ahci_req_queue.in_service->wait_queue.wait_list));
  416. --ahci_req_queue.request_count;
  417. long ret_val;
  418. switch (pack->blk_pak.cmd)
  419. {
  420. case AHCI_CMD_READ_DMA_EXT:
  421. ret_val = ahci_read(&(ahci_devices[pack->ahci_ctrl_num].hba_mem->ports[pack->port_num]), pack->blk_pak.LBA_start & 0xFFFFFFFF, ((pack->blk_pak.LBA_start) >> 32) & 0xFFFFFFFF, pack->blk_pak.count, pack->blk_pak.buffer_vaddr);
  422. break;
  423. case AHCI_CMD_WRITE_DMA_EXT:
  424. ret_val = ahci_write(&(ahci_devices[pack->ahci_ctrl_num].hba_mem->ports[pack->port_num]), pack->blk_pak.LBA_start & 0xFFFFFFFF, ((pack->blk_pak.LBA_start) >> 32) & 0xFFFFFFFF, pack->blk_pak.count, pack->blk_pak.buffer_vaddr);
  425. break;
  426. default:
  427. kerror("Unsupport ahci command: %#05lx", pack->blk_pak.cmd);
  428. ret_val = E_UNSUPPORTED_CMD;
  429. break;
  430. }
  431. // ahci_end_request();
  432. return ret_val;
  433. }
  434. /**
  435. * @brief 将请求包提交到io队列
  436. *
  437. * @param pack
  438. */
  439. static void ahci_submit(struct ahci_request_packet_t *pack)
  440. {
  441. list_append(&(ahci_req_queue.wait_queue_list.wait_list), &(pack->blk_pak.wait_queue.wait_list));
  442. ++ahci_req_queue.request_count;
  443. if (ahci_req_queue.in_service == NULL) // 当前没有正在请求的io包,立即执行磁盘请求
  444. ahci_query_disk();
  445. }
  446. /**
  447. * @brief ahci驱动程序的传输函数
  448. *
  449. * @param cmd 控制命令
  450. * @param base_addr 48位LBA地址
  451. * @param count total sectors to read
  452. * @param buf 缓冲区线性地址
  453. * @param ahci_ctrl_num ahci控制器号
  454. * @param port_num ahci控制器端口号
  455. * @return long
  456. */
  457. static long ahci_transfer(long cmd, uint64_t base_addr, uint64_t count, uint64_t buf, uint8_t ahci_ctrl_num, uint8_t port_num)
  458. {
  459. struct ahci_request_packet_t *pack = NULL;
  460. if (cmd == AHCI_CMD_READ_DMA_EXT || cmd == AHCI_CMD_WRITE_DMA_EXT)
  461. {
  462. pack = ahci_make_request(cmd, base_addr, count, buf, ahci_ctrl_num, port_num);
  463. ahci_submit(pack);
  464. }
  465. else
  466. return E_UNSUPPORTED_CMD;
  467. return AHCI_SUCCESS;
  468. }
  469. /**
  470. * @brief todo: io控制器函数
  471. *
  472. * @param cmd 命令
  473. * @param arg 参数
  474. * @return long
  475. */
  476. static long ahci_ioctl(long cmd, long arg)
  477. {
  478. }
  479. struct block_device_operation ahci_operation =
  480. {
  481. .open = ahci_open,
  482. .close = ahci_close,
  483. .ioctl = ahci_ioctl,
  484. .transfer = ahci_transfer,
  485. };