AHCI: Use fls() from BitUtils.
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <util/BitUtils.h>
|
||||||
|
|
||||||
#define TRACE(a...) dprintf("ahci: " a)
|
#define TRACE(a...) dprintf("ahci: " a)
|
||||||
#define FLOW(a...) dprintf("ahci: " a)
|
#define FLOW(a...) dprintf("ahci: " a)
|
||||||
@@ -335,7 +336,8 @@ AHCIController::ResetController()
|
|||||||
if (fPCIVendorID == PCI_VENDOR_INTEL) {
|
if (fPCIVendorID == PCI_VENDOR_INTEL) {
|
||||||
// Intel PCS—Port Control and Status
|
// Intel PCS—Port Control and Status
|
||||||
// SATA port enable bits must be set
|
// SATA port enable bits must be set
|
||||||
int portCount = std::max(fls(fRegs->pi), 1 + (int)((fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK));
|
int portCount = std::max((int)fls(fRegs->pi),
|
||||||
|
1 + (int)((fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK));
|
||||||
if (portCount > 8) {
|
if (portCount > 8) {
|
||||||
// TODO: fix this when specification available
|
// TODO: fix this when specification available
|
||||||
TRACE("don't know how to enable SATA ports 9 to %d\n", portCount);
|
TRACE("don't know how to enable SATA ports 9 to %d\n", portCount);
|
||||||
|
|||||||
@@ -126,17 +126,3 @@ swap_words(void *data, size_t size)
|
|||||||
word++;
|
word++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
fls(unsigned mask)
|
|
||||||
{
|
|
||||||
if (mask == 0)
|
|
||||||
return 0;
|
|
||||||
int pos = 1;
|
|
||||||
while (mask != 1) {
|
|
||||||
mask >>= 1;
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ status_t sg_memcpy(const physical_entry *sgTable, int sgCount, const void *data,
|
|||||||
|
|
||||||
void swap_words(void *data, size_t size);
|
void swap_words(void *data, size_t size);
|
||||||
|
|
||||||
int fls(unsigned mask);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user