driver interface for ahci

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22033 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Marcus Overhagen 2007-08-21 20:11:32 +00:00
parent f7deaad7ee
commit 1bb5a6b3d3
6 changed files with 242 additions and 3 deletions

View File

@ -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

View File

@ -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 ;

View File

@ -0,0 +1,7 @@
SubDir HAIKU_TOP src add-ons kernel drivers disk ahci ;
KernelAddon ahci :
ahci.c
ahci_sim.c
;

View File

@ -0,0 +1,125 @@
/*
* Copyright 2007, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <KernelExport.h>
#include <device_manager.h>
#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
};

View File

@ -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 <SupportDefs.h>
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

View File

@ -0,0 +1,55 @@
/*
* Copyright 2007, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <KernelExport.h>
#include <bus/SCSI.h>
#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;
*/