@@ -171,7 +171,6 @@ int init_sata_controller(uint32_t bus, uint32_t dev, uint32_t fun)
171171uint32_t ahci_enable (uint32_t bus , uint32_t dev , uint32_t fun )
172172{
173173 uint16_t reg16 ;
174- uint32_t iobar ;
175174 uint32_t reg ;
176175 uint32_t bar ;
177176
@@ -180,8 +179,6 @@ uint32_t ahci_enable(uint32_t bus, uint32_t dev, uint32_t fun)
180179
181180 bar = pci_config_read32 (bus , dev , fun , AHCI_ABAR_OFFSET );
182181 AHCI_DEBUG_PRINTF ("PCI BAR: %08x\r\n" , bar );
183- iobar = pci_config_read32 (bus , dev , fun , AHCI_AIDPBA_OFFSET );
184- AHCI_DEBUG_PRINTF ("PCI I/O space: %08x\r\n" , iobar );
185182
186183 reg |= PCI_COMMAND_BUS_MASTER ;
187184 reg |= PCI_COMMAND_MEM_SPACE ;
@@ -197,29 +194,6 @@ uint32_t ahci_enable(uint32_t bus, uint32_t dev, uint32_t fun)
197194 return bar ;
198195}
199196
200- /**
201- * @brief Dumps the status of the specified AHCI port.
202- *
203- * This function dumps the status of the AHCI port with the given index.
204- * It prints the status of various port registers for debugging purposes.
205- *
206- * @param base The AHCI Base Address Register (ABAR) for accessing AHCI registers.
207- * @param i The index of the AHCI port to dump status for.
208- */
209- void ahci_dump_port (uint32_t base , int i )
210- {
211- uint32_t cmd , ci , is , tfd , serr , ssst ;
212-
213- cmd = mmio_read32 (AHCI_PxCMD (base , i ));
214- ci = mmio_read32 (AHCI_PxCI (base , i ));
215- is = mmio_read32 (AHCI_PxIS (base , i ));
216- tfd = mmio_read32 (AHCI_PxTFD (base , i ));
217- serr = mmio_read32 (AHCI_PxSERR (base , i ));
218- ssst = mmio_read32 (AHCI_PxSSTS (base , i ));
219- AHCI_DEBUG_PRINTF ("%d: cmd:0x%x ci:0x%x is: 0x%x tfd: 0x%x serr: 0x%x ssst: 0x%x\r\n" ,
220- i , cmd , ci , is , tfd , serr , ssst );
221- }
222-
223197#ifdef WOLFBOOT_ATA_DISK_LOCK
224198#ifdef WOLFBOOT_ATA_DISK_LOCK_PASSWORD
225199static int sata_get_unlock_secret (uint8_t * secret , int * secret_size )
@@ -362,7 +336,7 @@ static int sata_get_unlock_secret(uint8_t *secret, int *secret_size)
362336#error "implement get_tpm_policy "
363337#endif
364338
365- if (policy_size > TPM_MAX_POLICY_SIZE )
339+ if (policy_size > TPM_MAX_POLICY_SIZE || ret != 0 )
366340 return -1 ;
367341
368342 memcpy (policy , pol , policy_size );
@@ -464,15 +438,21 @@ int sata_unlock_disk(int drv, int freeze)
464438 }
465439 r = ata_identify_device (drv );
466440 AHCI_DEBUG_PRINTF ("ATA identify: returned %d\r\n" , r );
441+ if (r != 0 )
442+ return -1 ;
467443 ata_st = ata_security_get_state (drv );
468444 wolfBoot_printf ("ATA: State SEC%d\r\n" , ata_st );
469445 }
470446 else if (ata_st == ATA_SEC4 ) {
471447 AHCI_DEBUG_PRINTF ("ATA identify: calling device unlock\r\n" , r );
472448 r = ata_security_unlock_device (drv , (char * )secret , 0 );
473449 AHCI_DEBUG_PRINTF ("ATA device unlock: returned %d\r\n" , r );
450+ if (r != 0 )
451+ return -1 ;
474452 r = ata_identify_device (drv );
475453 AHCI_DEBUG_PRINTF ("ATA identify: returned %d\r\n" , r );
454+ if (r != 0 )
455+ return -1 ;
476456 ata_st = ata_security_get_state (drv );
477457 if (ata_st == ATA_SEC5 ) {
478458 if (freeze ) {
@@ -487,6 +467,8 @@ int sata_unlock_disk(int drv, int freeze)
487467 }
488468 r = ata_identify_device (drv );
489469 AHCI_DEBUG_PRINTF ("ATA identify: returned %d\r\n" , r );
470+ if (r != 0 )
471+ return -1 ;
490472 }
491473 }
492474 ata_st = ata_security_get_state (drv );
@@ -583,6 +565,7 @@ void sata_enable(uint32_t base)
583565
584566 cap = mmio_read32 (AHCI_HBA_CAP (base ));
585567 n_ports = (cap & 0x1F ) + 1 ;
568+ (void )n_ports ;
586569 sata_only = (cap & AHCI_CAP_SAM );
587570 cap_sud = (cap & AHCI_CAP_SSS );
588571
@@ -601,8 +584,8 @@ void sata_enable(uint32_t base)
601584 if ((ports_impl & (1 << i )) != 0 ) {
602585 uint32_t reg ;
603586 uint32_t ssts = mmio_read32 (AHCI_PxSSTS (base , i ));
604- uint8_t ipm = (ssts >> 8 ) & 0xFF ;
605587 uint8_t det = ssts & 0x0F ;
588+ uint8_t ipm ;
606589 volatile struct hba_cmd_header * hdr ;
607590
608591
@@ -736,6 +719,7 @@ void sata_enable(uint32_t base)
736719 AHCI_DEBUG_PRINTF ("ATA%d associated to AHCI port %d\r\n" ,
737720 drv , i );
738721 r = ata_identify_device (drv );
722+ (void )r ;
739723 AHCI_DEBUG_PRINTF ("ATA identify: returned %d\r\n" , r );
740724 }
741725 } else {
0 commit comments