MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / Identify

Method Identify

Kernel/src/storage/ahciport.cpp:422–520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420 }
421
422 void Port::Identify(){
423
424 registers->ie = 0xffffffff;
425 registers->is = 0;
426 int spin = 0;
427
428 registers->tfd = 0;
429
430 int slot = FindCmdSlot();
431 if(slot == -1){
432 Log::Warning("[SATA] Could not find command slot!");
433 return ;
434 }
435
436 hba_cmd_header_t* commandHeader = &commandList[slot];
437
438 commandHeader->cfl = sizeof(fis_reg_h2d_t) / sizeof(uint32_t);
439
440 commandHeader->a = 0;
441 commandHeader->w = 0;
442 commandHeader->c = 0;
443 commandHeader->p = 0;
444
445 commandHeader->prdbc = 0;
446 commandHeader->pmp = 0;
447
448 hba_cmd_tbl_t* commandTable = commandTables[slot];
449 memset(commandTable, 0, sizeof(hba_cmd_tbl_t));
450
451 commandTable->prdt_entry[0].dba = physBuffers[0] & 0xFFFFFFFF;
452 commandTable->prdt_entry[0].dbau = (physBuffers[0] >> 32) & 0xFFFFFFFF;
453 commandTable->prdt_entry[0].dbc = 512 - 1; // 512 bytes per sector
454 commandTable->prdt_entry[0].i = 1;
455
456 fis_reg_h2d_t* cmdfis = (fis_reg_h2d_t*)(commandTable->cfis);
457 memset(commandTable->cfis, 0, sizeof(fis_reg_h2d_t));
458
459 cmdfis->fis_type = FIS_TYPE_REG_H2D;
460 cmdfis->c = 1; // Command
461 cmdfis->pmport = 0; // Port multiplier
462 cmdfis->command = ATA_CMD_IDENTIFY;
463
464 cmdfis->lba0 = 0;
465 cmdfis->lba1 = 0;
466 cmdfis->lba2 = 0;
467 cmdfis->device = 0;
468
469 cmdfis->lba3 = 0;
470 cmdfis->lba4 = 0;
471 cmdfis->lba5 = 0;
472
473 cmdfis->countl = 0;
474 cmdfis->counth = 0;
475
476 cmdfis->control = 0;
477
478 spin = 100;
479 while ((registers->tfd & (ATA_DEV_BUSY | ATA_DEV_DRQ)) && spin--) {

Callers

nothing calls this directly

Calls 5

WarningFunction · 0.85
memsetFunction · 0.85
startCMDFunction · 0.85
stopCMDFunction · 0.85
WaitFunction · 0.50

Tested by

no test coverage detected