diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage index e73718fd1d..21fe9cd8ee 100644 --- a/build/jam/HaikuImage +++ b/build/jam/HaikuImage @@ -153,7 +153,7 @@ AddDriversToHaikuImage : console dprintf $(X86_ONLY)keyboard null AddDriversToHaikuImage audio hmulti : $(BEOS_ADD_ONS_DRIVERS_AUDIO) ; AddDriversToHaikuImage midi : $(BEOS_ADD_ONS_DRIVERS_MIDI) ; AddDriversToHaikuImage bus : usb_raw ; -AddDriversToHaikuImage disk scsi : scsi_cd scsi_dsk ; +AddDriversToHaikuImage disk scsi : ahci scsi_cd scsi_dsk ; AddDriversToHaikuImage disk virtual : nbd ; AddDriversToHaikuImage dvb : cx23882 ; AddDriversToHaikuImage graphics : $(BEOS_ADD_ONS_DRIVERS_GRAPHICS) ; @@ -346,7 +346,7 @@ AddFilesToHaikuImage beos system : zbeos ; AddBootModuleSymlinksToHaikuImage config_manager bfs block_io fast_log generic_ide_pci $(X86_ONLY)isa ide ide_adapter $(X86_ONLY)ide_isa intel locked_pool $(PPC_ONLY)openpic pci scsi scsi_cd scsi_dsk scsi_periph - silicon_image_3112 legacy_sata + silicon_image_3112 legacy_sata ahci ; # add-ons diff --git a/src/add-ons/kernel/drivers/disk/Jamfile b/src/add-ons/kernel/drivers/disk/Jamfile index 4a27f1c42b..d97f86a2a0 100644 --- a/src/add-ons/kernel/drivers/disk/Jamfile +++ b/src/add-ons/kernel/drivers/disk/Jamfile @@ -1,5 +1,6 @@ SubDir HAIKU_TOP src add-ons kernel drivers disk ; -SubInclude HAIKU_TOP src add-ons kernel drivers disk scsi ; SubInclude HAIKU_TOP src add-ons kernel drivers disk acpi_loader ; +SubInclude HAIKU_TOP src add-ons kernel drivers disk ahci ; +SubInclude HAIKU_TOP src add-ons kernel drivers disk scsi ; SubInclude HAIKU_TOP src add-ons kernel drivers disk virtual ; diff --git a/src/add-ons/kernel/drivers/disk/ahci/Jamfile b/src/add-ons/kernel/drivers/disk/ahci/Jamfile new file mode 100644 index 0000000000..c78046227c --- /dev/null +++ b/src/add-ons/kernel/drivers/disk/ahci/Jamfile @@ -0,0 +1,7 @@ +SubDir HAIKU_TOP src add-ons kernel drivers disk ahci ; + + +KernelAddon ahci : + ahci.c + ahci_sim.c + ; diff --git a/src/add-ons/kernel/drivers/disk/ahci/ahci.c b/src/add-ons/kernel/drivers/disk/ahci/ahci.c new file mode 100644 index 0000000000..d315590541 --- /dev/null +++ b/src/add-ons/kernel/drivers/disk/ahci/ahci.c @@ -0,0 +1,125 @@ +/* + * Copyright 2007, Marcus Overhagen. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#include +#include + + +#define TRACE(a...) dprintf("ahci: " a) +#define FLOW(a...) dprintf("ahci: " a) + +static float +ahci_supports_device(device_node_handle parent, bool *_noConnection) +{ + TRACE("ahci_supports_device\n"); + +#if 0 + uint16 vendor_id; + uint16 device_id; + uint8 base_class; + uint8 sub_class; + uint8 class_api; + status_t res; + + if (base_class != PCI_mass_storage || sub_class != PCI_sata || class_api != PCI_sata_ahci) + return 0.0f; + + TRACE("controller found! vendor 0x%04x, device 0x%04x\n", vendor_id, device_id); + + res = pci->find_pci_capability(device, PCI_cap_id_sata, &cap_ofs); + if (res == B_OK) { + uint32 satacr0; + uint32 satacr1; + TRACE("PCI SATA capability found at offset 0x%x\n", cap_ofs); + satacr0 = pci->read_pci_config(device, cap_ofs, 4); + satacr1 = pci->read_pci_config(device, cap_ofs + 4, 4); + TRACE("satacr0 = 0x%08x, satacr1 = 0x%08x\n", satacr0, satacr1); + } +#endif + + + return 0.0; +} + + +static status_t +ahci_register_device(device_node_handle parent) +{ + TRACE("ahci_register_device\n"); + return B_OK; +} + + +static status_t +ahci_init_driver(device_node_handle node, void *user_cookie, void **_cookie) +{ + TRACE("ahci_init_driver\n"); + return B_OK; +} + + +static status_t +ahci_uninit_driver(void *cookie) +{ + TRACE("ahci_uninit_driver\n"); + return B_OK; +} + + +static void +ahci_device_removed(device_node_handle node, void *cookie) +{ + TRACE("ahci_device_removed\n"); +} + + +static void +ahci_device_cleanup(device_node_handle node) +{ + TRACE("ahci_device_cleanup\n"); +} + + +static void +ahci_get_supported_paths(const char ***_busses, const char ***_devices) +{ + TRACE("ahci_get_supported_paths\n"); +} + + +static status_t +std_ops(int32 op, ...) +{ + switch (op) { + case B_MODULE_INIT: + case B_MODULE_UNINIT: + return B_OK; + + default: + return B_ERROR; + } +} + + +driver_module_info ahci_driver = { + { + "ahci", + 0, + std_ops + }, + ahci_supports_device, + ahci_register_device, + ahci_init_driver, + ahci_uninit_driver, + ahci_device_removed, + ahci_device_cleanup, + ahci_get_supported_paths, +}; + + +module_info *modules[] = { + (module_info *)&ahci_driver, + NULL +}; diff --git a/src/add-ons/kernel/drivers/disk/ahci/ahci_defs.h b/src/add-ons/kernel/drivers/disk/ahci/ahci_defs.h new file mode 100644 index 0000000000..6029e97be0 --- /dev/null +++ b/src/add-ons/kernel/drivers/disk/ahci/ahci_defs.h @@ -0,0 +1,51 @@ +/* + * Copyright 2007, Marcus Overhagen. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#ifndef _AHCI_DEFS_H +#define _AHCI_DEFS_H + +#include + +typedef struct +{ + uint32 clb; // Command List Base Address + uint32 clbu; // Command List Base Address Upper 32-Bits + uint32 fb; // FIS Base Address + uint32 fbu; // FIS Base Address Upper 32-Bits + uint32 is; // Interrupt Status + uint32 ie; // Interrupt Enable + uint32 cmd; // Command and Status + uint32 res1; // Reserved + uint32 tfd; // Task File Data + uint32 sig; // Signature + uint32 ssts; // Serial ATA Status (SCR0: SStatus) + uint32 sctl; // Serial ATA Control (SCR2: SControl) + uint32 serr; // Serial ATA Error (SCR1: SError) + uint32 sact; // Serial ATA Active (SCR3: SActive) + uint32 ci; // Command Issue + uint32 sntf; // SNotification + uint32 res2; // Reserved for FIS-based Switching Definition + uint32 res[11]; // Reserved + uint32 vendor[2]; // Vendor Specific +} ahci_port; + + +typedef struct +{ + uint32 cap; // Host Capabilities + uint32 ghc; // Global Host Control + uint32 is; // Interrupt Status + uint32 pi; // Ports Implemented + uint32 vs; // Version + uint32 ccc_ctl; // Command Completion Coalescing Control + uint32 ccc_ports; // Command Completion Coalsecing Ports + uint32 em_loc; // Enclosure Management Location + uint32 em_ctl; // Enclosure Management Control + uint32 res[31]; // Reserved + uint32 vendor[24]; // Vendor Specific registers + ahci_port port[32]; +} ahci_hba; + +#endif diff --git a/src/add-ons/kernel/drivers/disk/ahci/ahci_sim.c b/src/add-ons/kernel/drivers/disk/ahci/ahci_sim.c new file mode 100644 index 0000000000..64cbfdd77a --- /dev/null +++ b/src/add-ons/kernel/drivers/disk/ahci/ahci_sim.c @@ -0,0 +1,55 @@ +/* + * Copyright 2007, Marcus Overhagen. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#include +#include + +#define TRACE(a...) dprintf("ahci: " a) +#define FLOW(a...) dprintf("ahci: " a) + + + +/* + +// SIM interface +// SCSI controller drivers must provide this interface +typedef struct scsi_sim_interface { + driver_module_info info; + + // execute request + void (*scsi_io)( scsi_sim_cookie cookie, scsi_ccb *ccb ); + // abort request + uchar (*abort)( scsi_sim_cookie cookie, scsi_ccb *ccb_to_abort ); + // reset device + uchar (*reset_device)( scsi_sim_cookie cookie, uchar target_id, uchar target_lun ); + // terminate request + uchar (*term_io)( scsi_sim_cookie cookie, scsi_ccb *ccb_to_terminate ); + + // get information about bus + uchar (*path_inquiry)( scsi_sim_cookie cookie, scsi_path_inquiry *inquiry_data ); + // scan bus + // this is called immediately before the SCSI bus manager scans the bus + uchar (*scan_bus)( scsi_sim_cookie cookie ); + // reset bus + uchar (*reset_bus)( scsi_sim_cookie cookie ); + + // get restrictions of one device + // (used for non-SCSI transport protocols and bug fixes) + void (*get_restrictions)( + scsi_sim_cookie cookie, + uchar target_id, // target id + bool *is_atapi, // set to true if this is an ATAPI device that + // needs some commands emulated + bool *no_autosense, // set to true if there is no autosense; + // the SCSI bus manager will request sense on + // SCSI_REQ_CMP_ERR/SCSI_DEVICE_CHECK_CONDITION + uint32 *max_blocks ); // maximum number of blocks per transfer if > 0; + // used for buggy devices that cannot handle + // large transfers (read: ATAPI ZIP drives) + + status_t (*ioctl)(scsi_sim_cookie, uint8 targetID, uint32 op, void *buffer, size_t length); +} scsi_sim_interface; + +*/