From 093a713df2e9cf464741c78b3e8bc37df8d0a2b1 Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Sat, 1 Sep 2007 14:29:10 +0000 Subject: [PATCH] map registers and print some information git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22137 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/busses/scsi/ahci/Jamfile | 1 + .../busses/scsi/ahci/ahci_controller.cpp | 36 ++++++++++++++++++- .../kernel/busses/scsi/ahci/ahci_controller.h | 3 ++ src/add-ons/kernel/busses/scsi/ahci/util.c | 29 +++++---------- src/add-ons/kernel/busses/scsi/ahci/util.h | 28 ++++++--------- 5 files changed, 58 insertions(+), 39 deletions(-) diff --git a/src/add-ons/kernel/busses/scsi/ahci/Jamfile b/src/add-ons/kernel/busses/scsi/ahci/Jamfile index 5efa4eeb50..d0109cb72d 100644 --- a/src/add-ons/kernel/busses/scsi/ahci/Jamfile +++ b/src/add-ons/kernel/busses/scsi/ahci/Jamfile @@ -4,4 +4,5 @@ KernelAddon ahci : ahci.c ahci_controller.cpp ahci_sim.cpp + util.c ; diff --git a/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp b/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp index 40a4c69518..4bad171901 100644 --- a/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp +++ b/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp @@ -4,6 +4,7 @@ */ #include "ahci_controller.h" +#include "util.h" #include #include @@ -61,7 +62,33 @@ AHCIController::Init() TRACE("satacr0 = 0x%08lx, satacr1 = 0x%08lx\n", satacr0, satacr1); } - fDevicePresentMask = (1 << 7) | (1 << 19); + void *addr = (void *)pciInfo.u.h0.base_registers[5]; + size_t size = pciInfo.u.h0.base_register_sizes[5]; + + TRACE("registers at %p, size %#lx\n", addr, size); + + fRegsArea = map_mem((void **)&fRegs, addr, size, 0, "AHCI HBA regs"); + if (fRegsArea < B_OK) { + TRACE("mapping registers failed\n"); + return B_ERROR; + } + + TRACE("cap: Interface Speed Support: %lu\n", (fRegs->cap >> CAP_ISS_SHIFT) & CAP_ISS_MASK); + TRACE("cap: Number of Command Slots: %lu\n", (fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); + TRACE("cap: Number of Ports: %lu\n", (fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK); + TRACE("cap: Supports Port Multiplier: %s\n", (fRegs->cap & CAP_SPM) ? "yes" : "no"); + TRACE("cap: Supports External SATA: %s\n", (fRegs->cap & CAP_SXS) ? "yes" : "no"); + TRACE("cap: Enclosure Management Supported: %s\n", (fRegs->cap & CAP_EMS) ? "yes" : "no"); + TRACE("cap: Supports AHCI mode only: %s\n", (fRegs->cap & CAP_SAM) ? "yes" : "no"); + TRACE("ghc: AHCI Enable: %s\n", (fRegs->ghc & GHC_AE) ? "yes" : "no"); + TRACE("Ports Implemented: %08lx\n", fRegs->pi); + TRACE("AHCI Version %lu.%lu\n", fRegs->vs >> 16, fRegs->vs & 0xff); + + // disable interrupts + fRegs->ghc &= ~GHC_IE; + // clear pending interrupts + fRegs->is = 0xffffffff; + return B_OK; } @@ -72,6 +99,13 @@ AHCIController::Uninit() { TRACE("AHCIController::Uninit\n"); + // disable interrupts + fRegs->ghc &= ~GHC_IE; + // clear pending interrupts + fRegs->is = 0xffffffff; + + delete_area(fRegsArea); + // --- Instance check workaround begin delete_port(fInstanceCheck); // --- Instance check workaround end diff --git a/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h b/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h index 2ea9fba242..27e83339bd 100644 --- a/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h +++ b/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h @@ -33,6 +33,9 @@ private: pci_device_info* fPCIDevice; uint32 fDevicePresentMask; + ahci_hba * fRegs; + area_id fRegsArea; + // --- Instance check workaround begin port_id fInstanceCheck; diff --git a/src/add-ons/kernel/busses/scsi/ahci/util.c b/src/add-ons/kernel/busses/scsi/ahci/util.c index 0ce2b8a2b4..4c4fee4f7c 100644 --- a/src/add-ons/kernel/busses/scsi/ahci/util.c +++ b/src/add-ons/kernel/busses/scsi/ahci/util.c @@ -1,29 +1,16 @@ -/* Realtek RTL8169 Family Driver - * Copyright (C) 2004 Marcus Overhagen . All rights reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies, and that both the - * copyright notice and this permission notice appear in supporting documentation. - * - * Marcus Overhagen makes no representations about the suitability of this software - * for any purpose. It is provided "as is" without express or implied warranty. - * - * MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS - * OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +/* + * Copyright 2004-2007, Marcus Overhagen. All rights reserved. + * Distributed under the terms of the MIT License. */ -#include +#include "util.h" + +#include #include #include -//#define DEBUG -#include "debug.h" -#include "util.h" +#define TRACE(a...) dprintf("\33[34mahci:\33[0m " a) +#define ERROR(a...) dprintf("\33[34mahci:\33[0m " a) static inline uint32 round_to_pagesize(uint32 size) diff --git a/src/add-ons/kernel/busses/scsi/ahci/util.h b/src/add-ons/kernel/busses/scsi/ahci/util.h index da5b892a7c..e06729915e 100644 --- a/src/add-ons/kernel/busses/scsi/ahci/util.h +++ b/src/add-ons/kernel/busses/scsi/ahci/util.h @@ -1,27 +1,21 @@ -/* Realtek RTL8169 Family Driver - * Copyright (C) 2004 Marcus Overhagen . All rights reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies, and that both the - * copyright notice and this permission notice appear in supporting documentation. - * - * Marcus Overhagen makes no representations about the suitability of this software - * for any purpose. It is provided "as is" without express or implied warranty. - * - * MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS - * OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +/* + * Copyright 2004-2007, Marcus Overhagen. All rights reserved. + * Distributed under the terms of the MIT License. */ #ifndef __UTIL_H #define __UTIL_H #include +#ifdef __cplusplus +extern "C" { +#endif + area_id alloc_mem(void **virt, void **phy, size_t size, uint32 protection, const char *name); area_id map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name); +#ifdef __cplusplus +} +#endif + #endif