* gPCI was never set anymore after my changes. I replaced it now by a fPCI
member in AHCIController, since, at least in theory, every PCI device could come with its own module. * Fixed exported module names to indicate compliance with the new device manager. * Apparently, GCC4 doesn't like mixing C++/C linkage even for variables anymore, though it really shouldn't care about that. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25699 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -112,6 +112,10 @@ const device_info kSupportedDevices[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
device_manager_info *gDeviceManager;
|
||||||
|
scsi_for_sim_interface *gSCSI;
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
get_device_info(uint16 vendorID, uint16 deviceID, const char **name,
|
get_device_info(uint16 vendorID, uint16 deviceID, const char **name,
|
||||||
uint32 *flags)
|
uint32 *flags)
|
||||||
|
|||||||
@@ -15,18 +15,21 @@
|
|||||||
#define FLOW(a...) dprintf("ahci: " a)
|
#define FLOW(a...) dprintf("ahci: " a)
|
||||||
|
|
||||||
|
|
||||||
AHCIController::AHCIController(device_node *node, pci_device *device)
|
AHCIController::AHCIController(device_node *node,
|
||||||
: fNode(node)
|
pci_device_module_info *pciModule, pci_device *device)
|
||||||
, fPCIDevice(device)
|
:
|
||||||
, fPCIVendorID(0xffff)
|
fNode(node),
|
||||||
, fPCIDeviceID(0xffff)
|
fPCI(pciModule),
|
||||||
, fFlags(0)
|
fPCIDevice(device),
|
||||||
, fCommandSlotCount(0)
|
fPCIVendorID(0xffff),
|
||||||
, fPortCountMax(0)
|
fPCIDeviceID(0xffff),
|
||||||
, fPortCountAvail(0)
|
fFlags(0),
|
||||||
, fPortImplementedMask(0)
|
fCommandSlotCount(0),
|
||||||
, fIRQ(0)
|
fPortCountMax(0),
|
||||||
, fInstanceCheck(-1)
|
fPortCountAvail(0),
|
||||||
|
fPortImplementedMask(0),
|
||||||
|
fIRQ(0),
|
||||||
|
fInstanceCheck(-1)
|
||||||
{
|
{
|
||||||
memset(fPort, 0, sizeof(fPort));
|
memset(fPort, 0, sizeof(fPort));
|
||||||
|
|
||||||
@@ -48,7 +51,7 @@ status_t
|
|||||||
AHCIController::Init()
|
AHCIController::Init()
|
||||||
{
|
{
|
||||||
pci_info pciInfo;
|
pci_info pciInfo;
|
||||||
gPCI->get_pci_info(fPCIDevice, &pciInfo);
|
fPCI->get_pci_info(fPCIDevice, &pciInfo);
|
||||||
|
|
||||||
fPCIVendorID = pciInfo.vendor_id;
|
fPCIVendorID = pciInfo.vendor_id;
|
||||||
fPCIDeviceID = pciInfo.device_id;
|
fPCIDeviceID = pciInfo.device_id;
|
||||||
@@ -70,30 +73,30 @@ AHCIController::Init()
|
|||||||
get_device_info(fPCIVendorID, fPCIDeviceID, NULL, &fFlags);
|
get_device_info(fPCIVendorID, fPCIDeviceID, NULL, &fFlags);
|
||||||
|
|
||||||
uchar capabilityOffset;
|
uchar capabilityOffset;
|
||||||
status_t res = gPCI->find_pci_capability(fPCIDevice, PCI_cap_id_sata, &capabilityOffset);
|
status_t res = fPCI->find_pci_capability(fPCIDevice, PCI_cap_id_sata, &capabilityOffset);
|
||||||
if (res == B_OK) {
|
if (res == B_OK) {
|
||||||
uint32 satacr0;
|
uint32 satacr0;
|
||||||
uint32 satacr1;
|
uint32 satacr1;
|
||||||
TRACE("PCI SATA capability found at offset 0x%x\n", capabilityOffset);
|
TRACE("PCI SATA capability found at offset 0x%x\n", capabilityOffset);
|
||||||
satacr0 = gPCI->read_pci_config(fPCIDevice, capabilityOffset, 4);
|
satacr0 = fPCI->read_pci_config(fPCIDevice, capabilityOffset, 4);
|
||||||
satacr1 = gPCI->read_pci_config(fPCIDevice, capabilityOffset + 4, 4);
|
satacr1 = fPCI->read_pci_config(fPCIDevice, capabilityOffset + 4, 4);
|
||||||
TRACE("satacr0 = 0x%08lx, satacr1 = 0x%08lx\n", satacr0, satacr1);
|
TRACE("satacr0 = 0x%08lx, satacr1 = 0x%08lx\n", satacr0, satacr1);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16 pcicmd = gPCI->read_pci_config(fPCIDevice, PCI_command, 2);
|
uint16 pcicmd = fPCI->read_pci_config(fPCIDevice, PCI_command, 2);
|
||||||
TRACE("pcicmd old 0x%04x\n", pcicmd);
|
TRACE("pcicmd old 0x%04x\n", pcicmd);
|
||||||
pcicmd &= ~(PCI_command_io | PCI_command_int_disable);
|
pcicmd &= ~(PCI_command_io | PCI_command_int_disable);
|
||||||
pcicmd |= PCI_command_master | PCI_command_memory;
|
pcicmd |= PCI_command_master | PCI_command_memory;
|
||||||
TRACE("pcicmd new 0x%04x\n", pcicmd);
|
TRACE("pcicmd new 0x%04x\n", pcicmd);
|
||||||
gPCI->write_pci_config(fPCIDevice, PCI_command, 2, pcicmd);
|
fPCI->write_pci_config(fPCIDevice, PCI_command, 2, pcicmd);
|
||||||
|
|
||||||
if (fPCIVendorID == PCI_VENDOR_JMICRON) {
|
if (fPCIVendorID == PCI_VENDOR_JMICRON) {
|
||||||
uint32 ctrl = gPCI->read_pci_config(fPCIDevice, PCI_JMICRON_CONTROLLER_CONTROL_1, 4);
|
uint32 ctrl = fPCI->read_pci_config(fPCIDevice, PCI_JMICRON_CONTROLLER_CONTROL_1, 4);
|
||||||
TRACE("Jmicron controller control 1 old 0x%08lx\n", ctrl);
|
TRACE("Jmicron controller control 1 old 0x%08lx\n", ctrl);
|
||||||
ctrl &= ~((1 << 9) | (1 << 12) | (1 << 14)); // disable SFF 8038i emulation
|
ctrl &= ~((1 << 9) | (1 << 12) | (1 << 14)); // disable SFF 8038i emulation
|
||||||
ctrl |= (1 << 8) | (1 << 13) | (1 << 15); // enable AHCI controller
|
ctrl |= (1 << 8) | (1 << 13) | (1 << 15); // enable AHCI controller
|
||||||
TRACE("Jmicron controller control 1 new 0x%08lx\n", ctrl);
|
TRACE("Jmicron controller control 1 new 0x%08lx\n", ctrl);
|
||||||
gPCI->write_pci_config(fPCIDevice, PCI_JMICRON_CONTROLLER_CONTROL_1, 4, ctrl);
|
fPCI->write_pci_config(fPCIDevice, PCI_JMICRON_CONTROLLER_CONTROL_1, 4, ctrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
fIRQ = pciInfo.u.h0.interrupt_line;
|
fIRQ = pciInfo.u.h0.interrupt_line;
|
||||||
@@ -258,9 +261,9 @@ AHCIController::ResetController()
|
|||||||
int portCount = 1 + ((fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK);
|
int portCount = 1 + ((fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK);
|
||||||
if (portCount > 8)
|
if (portCount > 8)
|
||||||
panic("Intel AHCI: too many SATA ports! Please report at http://dev.haiku-os.org");
|
panic("Intel AHCI: too many SATA ports! Please report at http://dev.haiku-os.org");
|
||||||
uint16 pcs = gPCI->read_pci_config(fPCIDevice, 0x92, 2);
|
uint16 pcs = fPCI->read_pci_config(fPCIDevice, 0x92, 2);
|
||||||
pcs |= (0xff >> (8 - portCount));
|
pcs |= (0xff >> (8 - portCount));
|
||||||
gPCI->write_pci_config(fPCIDevice, 0x92, 2, pcs);
|
fPCI->write_pci_config(fPCIDevice, 0x92, 2, pcs);
|
||||||
}
|
}
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,17 +12,20 @@
|
|||||||
|
|
||||||
class AHCIController {
|
class AHCIController {
|
||||||
public:
|
public:
|
||||||
AHCIController(device_node *node, pci_device *pciDevice);
|
AHCIController(device_node *node,
|
||||||
|
pci_device_module_info *pciModule,
|
||||||
|
pci_device *pciDevice);
|
||||||
~AHCIController();
|
~AHCIController();
|
||||||
|
|
||||||
status_t Init();
|
status_t Init();
|
||||||
void Uninit();
|
void Uninit();
|
||||||
|
|
||||||
void ExecuteRequest(scsi_ccb *request);
|
void ExecuteRequest(scsi_ccb *request);
|
||||||
uchar AbortRequest(scsi_ccb *request);
|
uchar AbortRequest(scsi_ccb *request);
|
||||||
uchar TerminateRequest(scsi_ccb *request);
|
uchar TerminateRequest(scsi_ccb *request);
|
||||||
uchar ResetDevice(uchar targetID, uchar targetLUN);
|
uchar ResetDevice(uchar targetID, uchar targetLUN);
|
||||||
void GetRestrictions(uchar targetID, bool *isATAPI, bool *noAutoSense, uint32 *maxBlocks);
|
void GetRestrictions(uchar targetID, bool *isATAPI,
|
||||||
|
bool *noAutoSense, uint32 *maxBlocks);
|
||||||
|
|
||||||
device_node * DeviceNode() { return fNode; }
|
device_node * DeviceNode() { return fNode; }
|
||||||
|
|
||||||
@@ -37,6 +40,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
device_node * fNode;
|
device_node * fNode;
|
||||||
|
pci_device_module_info *fPCI;
|
||||||
pci_device * fPCIDevice;
|
pci_device * fPCIDevice;
|
||||||
uint16 fPCIVendorID;
|
uint16 fPCIVendorID;
|
||||||
uint16 fPCIDeviceID;
|
uint16 fPCIDeviceID;
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AHCI_DEVICE_MODULE_NAME "busses/scsi/ahci/device_v1"
|
#define AHCI_DEVICE_MODULE_NAME "busses/scsi/ahci/driver_v1"
|
||||||
#define AHCI_SIM_MODULE_NAME "busses/scsi/ahci/sim/v1"
|
#define AHCI_SIM_MODULE_NAME "busses/scsi/ahci/sim/driver_v1"
|
||||||
|
|
||||||
// RW1 = Write 1 to set bit (writing 0 is ignored)
|
// RW1 = Write 1 to set bit (writing 0 is ignored)
|
||||||
// RWC = Write 1 to clear bit (writing 0 is ignored)
|
// RWC = Write 1 to clear bit (writing 0 is ignored)
|
||||||
@@ -256,7 +256,6 @@ status_t get_device_info(uint16 vendorID, uint16 deviceID, const char **name, ui
|
|||||||
|
|
||||||
extern scsi_sim_interface gAHCISimInterface;
|
extern scsi_sim_interface gAHCISimInterface;
|
||||||
extern device_manager_info *gDeviceManager;
|
extern device_manager_info *gDeviceManager;
|
||||||
extern pci_device_module_info *gPCI;
|
|
||||||
extern scsi_for_sim_interface *gSCSI;
|
extern scsi_for_sim_interface *gSCSI;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,6 @@
|
|||||||
#define FLOW(a...)
|
#define FLOW(a...)
|
||||||
|
|
||||||
|
|
||||||
pci_device_module_info *gPCI;
|
|
||||||
device_manager_info *gDeviceManager;
|
|
||||||
scsi_for_sim_interface *gSCSI;
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - SIM module interface
|
// #pragma mark - SIM module interface
|
||||||
|
|
||||||
|
|
||||||
@@ -137,13 +132,15 @@ ahci_sim_init_bus(device_node *node, void **_cookie)
|
|||||||
device_node *pciParent = gDeviceManager->get_parent_node(parent);
|
device_node *pciParent = gDeviceManager->get_parent_node(parent);
|
||||||
gDeviceManager->put_node(parent);
|
gDeviceManager->put_node(parent);
|
||||||
|
|
||||||
|
pci_device_module_info *pci;
|
||||||
pci_device *pciDevice;
|
pci_device *pciDevice;
|
||||||
gDeviceManager->get_driver(pciParent, NULL, (void **)&pciDevice);
|
gDeviceManager->get_driver(pciParent, (driver_module_info **)&pci,
|
||||||
|
(void **)&pciDevice);
|
||||||
gDeviceManager->put_node(pciParent);
|
gDeviceManager->put_node(pciParent);
|
||||||
|
|
||||||
TRACE("ahci_sim_init_bus: pciDevice %p\n", pciDevice);
|
TRACE("ahci_sim_init_bus: pciDevice %p\n", pciDevice);
|
||||||
|
|
||||||
AHCIController *controller = new(std::nothrow) AHCIController(node,
|
AHCIController *controller = new(std::nothrow) AHCIController(node, pci,
|
||||||
pciDevice);
|
pciDevice);
|
||||||
if (!controller)
|
if (!controller)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|||||||
Reference in New Issue
Block a user