Module Name: src Committed By: jakllsch Date: Wed Apr 7 17:51:16 UTC 2010
Modified Files: src/sys/arch/alpha/conf: GENERIC std.alpha src/sys/dev/ata: satafis_subr.c satafisreg.h satafisvar.h src/sys/dev/ic: ahcisata_core.c siisata.c siisatareg.h Log Message: satafis: - Add function to parse RDH FIS for use in implementing AT_READREG. - Correct and clean up some structure definitions. - Sprinkle a bit of const. - Remove dependency on <dev/ic/wdcreg.h>, WDCTL_4BIT doesn't seem to be specified by any recent ATA standard, and it seems to make no difference in practice. - Stop using WDSD_IBM, these bits have been obsolete since before SATA. siisata: - Implement AT_READREG. - Reap now-unneeded <dev/ic/wdcreg.h>. - Whitespace and slight debug code cleanup. - Some possibly-uncessary code reordering. ahcisata: - Implement AT_READREG. - Reap now-unneeded <dev/ic/wdcreg.h>. To generate a diff of this commit: cvs rdiff -u -r1.331 -r1.332 src/sys/arch/alpha/conf/GENERIC cvs rdiff -u -r1.25 -r1.26 src/sys/arch/alpha/conf/std.alpha cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ata/satafis_subr.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ata/satafisreg.h cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ata/satafisvar.h cvs rdiff -u -r1.25 -r1.26 src/sys/dev/ic/ahcisata_core.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ic/siisata.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ic/siisatareg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/alpha/conf/GENERIC diff -u src/sys/arch/alpha/conf/GENERIC:1.331 src/sys/arch/alpha/conf/GENERIC:1.332 --- src/sys/arch/alpha/conf/GENERIC:1.331 Sun Mar 7 09:39:42 2010 +++ src/sys/arch/alpha/conf/GENERIC Wed Apr 7 17:51:16 2010 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.331 2010/03/07 09:39:42 plunky Exp $ +# $NetBSD: GENERIC,v 1.332 2010/04/07 17:51:16 jakllsch Exp $ # # This machine description file is used to generate the default NetBSD # kernel. @@ -19,7 +19,7 @@ options INCLUDE_CONFIG_FILE # embed config file in kernel binary -ident "GENERIC-$Revision: 1.331 $" +ident "GENERIC-$Revision: 1.332 $" maxusers 32 @@ -767,3 +767,5 @@ options PAX_MPROTECT=0 # PaX mprotect(2) restrictions #options PAX_SEGVGUARD=0 # PaX Segmentation fault guard options PAX_ASLR=0 # PaX Address Space Layout Randomization + +ath* at pci? dev ? function? Index: src/sys/arch/alpha/conf/std.alpha diff -u src/sys/arch/alpha/conf/std.alpha:1.25 src/sys/arch/alpha/conf/std.alpha:1.26 --- src/sys/arch/alpha/conf/std.alpha:1.25 Wed Oct 17 19:52:57 2007 +++ src/sys/arch/alpha/conf/std.alpha Wed Apr 7 17:51:16 2010 @@ -1,4 +1,4 @@ -# $NetBSD: std.alpha,v 1.25 2007/10/17 19:52:57 garbled Exp $ +# $NetBSD: std.alpha,v 1.26 2010/04/07 17:51:16 jakllsch Exp $ # # Standard/required configuration info for NetBSD/alpha. @@ -12,3 +12,6 @@ options EXEC_ECOFF # (native) ECOFF binary support options EXEC_ELF64 # (native) ELF64 binary support options EXEC_SCRIPT # shell script support + +# Atheros HAL options +include "external/isc/atheros_hal/conf/std.ath_hal" Index: src/sys/dev/ata/satafis_subr.c diff -u src/sys/dev/ata/satafis_subr.c:1.4 src/sys/dev/ata/satafis_subr.c:1.5 --- src/sys/dev/ata/satafis_subr.c:1.4 Mon Oct 19 18:41:12 2009 +++ src/sys/dev/ata/satafis_subr.c Wed Apr 7 17:51:16 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: satafis_subr.c,v 1.4 2009/10/19 18:41:12 bouyer Exp $ */ +/* $NetBSD: satafis_subr.c,v 1.5 2010/04/07 17:51:16 jakllsch Exp $ */ /*- * Copyright (c) 2009 Jonathan A. Kollasch. @@ -51,7 +51,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.4 2009/10/19 18:41:12 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.5 2010/04/07 17:51:16 jakllsch Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -64,8 +64,6 @@ #include <dev/ata/satafisreg.h> #include <dev/ata/satafisvar.h> -#include <dev/ic/wdcreg.h> /* for WDCTL_4BIT */ - #include "atapibus.h" void @@ -74,7 +72,7 @@ memset(fis, 0, RHD_FISLEN); fis[fis_type] = RHD_FISTYPE; - fis[rhd_cdpmp] = 0x80; /* xxx magic */ + fis[rhd_c] = RHD_C; fis[rhd_command] = ata_c->r_command; fis[rhd_features] = ata_c->r_features; fis[rhd_sector] = ata_c->r_sector; @@ -82,9 +80,6 @@ fis[rhd_cyl_hi] = (ata_c->r_cyl >> 8) & 0xff; fis[rhd_dh] = ata_c->r_head & 0x0f; fis[rhd_seccnt] = ata_c->r_count; - fis[rhd_control] = WDCTL_4BIT; - - return; } void @@ -98,7 +93,7 @@ memset(fis, 0, RHD_FISLEN); fis[fis_type] = RHD_FISTYPE; - fis[rhd_cdpmp] = 0x80; /* xxx magic */ + fis[rhd_c] = RHD_C; if (ata_bio->flags & ATA_LBA48) { fis[rhd_command] = (ata_bio->flags & ATA_READ) ? WDCC_READDMA_EXT : WDCC_WRITEDMA_EXT; @@ -120,8 +115,6 @@ fis[rhd_seccnt] = nblks & 0xff; fis[rhd_seccnt_exp] = (ata_bio->flags & ATA_LBA48) ? ((nblks >> 8) & 0xff) : 0; - fis[rhd_control] = WDCTL_4BIT; - return; } #if NATAPIBUS > 0 @@ -131,26 +124,30 @@ memset(fis, 0, RHD_FISLEN); fis[fis_type] = RHD_FISTYPE; - fis[rhd_cdpmp] = 0x80; /* xxx magic */ + fis[rhd_c] = RHD_C; fis[rhd_command] = ATAPI_PKT_CMD; fis[rhd_features] = (xfer->c_flags & C_DMA) ? ATAPI_PKT_CMD_FTRE_DMA : 0; - fis[rhd_dh] = WDSD_IBM; /* XXX or WDSD_LBA? */ - fis[rhd_control] = WDCTL_4BIT; return; } #endif /* NATAPIBUS */ void -satafis_rdh_parse(struct ata_channel *chp, uint8_t *fis) +satafis_rdh_parse(struct ata_channel *chp, const uint8_t *fis) { -#if 0 - /* siisata doesn't do enough for this to work */ - KASSERT(fis[fis_type] == RDH_FISTYPE); -#endif chp->ch_status = fis[rdh_status]; chp->ch_error = fis[rdh_error]; +} - return; +void +satafis_rdh_cmd_readreg(struct ata_command *ata_c, const uint8_t *fis) +{ + ata_c->r_command = fis[rdh_status]; + ata_c->r_features = fis[rdh_error]; + ata_c->r_error = fis[rdh_error]; + ata_c->r_sector = fis[rdh_sector]; + ata_c->r_cyl = fis[rdh_cyl_hi] << 8 | fis[rdh_cyl_lo]; + ata_c->r_head = fis[rdh_dh]; + ata_c->r_count = fis[rdh_seccnt]; } Index: src/sys/dev/ata/satafisreg.h diff -u src/sys/dev/ata/satafisreg.h:1.1 src/sys/dev/ata/satafisreg.h:1.2 --- src/sys/dev/ata/satafisreg.h:1.1 Wed Jun 17 03:07:51 2009 +++ src/sys/dev/ata/satafisreg.h Wed Apr 7 17:51:16 2010 @@ -1,7 +1,7 @@ -/* $NetBSD: satafisreg.h,v 1.1 2009/06/17 03:07:51 jakllsch Exp $ */ +/* $NetBSD: satafisreg.h,v 1.2 2010/04/07 17:51:16 jakllsch Exp $ */ -/*- - * Copyright (c) 2009 Jonathan A. Kollasch. +/* + * Copyright (c) 2009, 2010 Jonathan A. Kollasch. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,7 +32,8 @@ #define RHD_FISTYPE 0x27 #define RHD_FISLEN 20 -#define rhd_cdpmp 1 /* Command bit and PM port */ +#define rhd_c 1 /* Command bit and PM port */ +#define RHD_C 0x80 #define rhd_command 2 /* wd_command */ #define rhd_features 3 /* wd_precomp */ #define rhd_sector 4 /* wd_sector */ @@ -50,17 +51,18 @@ #define RDH_FISTYPE 0x34 #define RDH_FISLEN 20 #define rdh_i 1 +#define RDH_I 0x40 #define rdh_status 2 #define rdh_error 3 #define rdh_sector 4 /* wd_sector */ #define rdh_cyl_lo 5 /* wd_cyl_lo */ #define rdh_cyl_hi 6 /* wd_cyl_hi */ #define rdh_dh 7 /* wd_sdh */ -#define rhd_sector_exp 8 -#define rhd_cyl_lo_exp 9 -#define rhd_cyl_hi_exp 10 -#define rhd_seccnt 12 -#define rhd_seccnt_exp 13 +#define rdh_sector_exp 8 +#define rdh_cyl_lo_exp 9 +#define rdh_cyl_hi_exp 10 +#define rdh_seccnt 12 +#define rdh_seccnt_exp 13 #define SDB_FISTYPE 0xA1 #define SDB_FISLEN 8 Index: src/sys/dev/ata/satafisvar.h diff -u src/sys/dev/ata/satafisvar.h:1.2 src/sys/dev/ata/satafisvar.h:1.3 --- src/sys/dev/ata/satafisvar.h:1.2 Sat Jul 4 20:57:15 2009 +++ src/sys/dev/ata/satafisvar.h Wed Apr 7 17:51:16 2010 @@ -1,7 +1,7 @@ -/* $NetBSD: satafisvar.h,v 1.2 2009/07/04 20:57:15 jakllsch Exp $ */ +/* $NetBSD: satafisvar.h,v 1.3 2010/04/07 17:51:16 jakllsch Exp $ */ -/*- - * Copyright (c) 2009 Jonathan A. Kollasch. +/* + * Copyright (c) 2009, 2010 Jonathan A. Kollasch. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,6 +33,8 @@ void satafis_rhd_construct_cmd(struct ata_command *, uint8_t *); void satafis_rhd_construct_bio(struct ata_xfer *, uint8_t *); void satafis_rhd_construct_atapi(struct ata_xfer *, uint8_t *); -void satafis_rdh_parse(struct ata_channel *, uint8_t *); + +void satafis_rdh_parse(struct ata_channel *, const uint8_t *); +void satafis_rdh_cmd_readreg(struct ata_command *, const uint8_t *); #endif /* _DEV_ATA_FISVAR_H_ */ Index: src/sys/dev/ic/ahcisata_core.c diff -u src/sys/dev/ic/ahcisata_core.c:1.25 src/sys/dev/ic/ahcisata_core.c:1.26 --- src/sys/dev/ic/ahcisata_core.c:1.25 Fri Mar 12 19:03:14 2010 +++ src/sys/dev/ic/ahcisata_core.c Wed Apr 7 17:51:16 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ahcisata_core.c,v 1.25 2010/03/12 19:03:14 jakllsch Exp $ */ +/* $NetBSD: ahcisata_core.c,v 1.26 2010/04/07 17:51:16 jakllsch Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.25 2010/03/12 19:03:14 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.26 2010/04/07 17:51:16 jakllsch Exp $"); #include <sys/types.h> #include <sys/malloc.h> @@ -39,12 +39,11 @@ #include <uvm/uvm_extern.h> -#include <dev/ic/wdcreg.h> #include <dev/ata/atareg.h> #include <dev/ata/satavar.h> #include <dev/ata/satareg.h> -#include <dev/ata/satafisreg.h> #include <dev/ata/satafisvar.h> +#include <dev/ata/satafisreg.h> #include <dev/ic/ahcisatavar.h> #include <dev/scsipi/scsi_all.h> /* for SCSI status */ @@ -790,6 +789,7 @@ int slot = 0; /* XXX slot */ struct ata_command *ata_c = xfer->c_cmd; struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac; + struct ahci_channel *achp = (struct ahci_channel *)chp; AHCIDEBUG_PRINT(("ahci_cmd_complete channel %d CMD 0x%x CI 0x%x\n", chp->ch_channel, AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)), @@ -809,18 +809,17 @@ wakeup(&chp->ch_queue->active_xfer); return 0; } - if (is) { - ata_c->r_head = 0; - ata_c->r_count = 0; - ata_c->r_sector = 0; - ata_c->r_cyl = 0; - if (chp->ch_status & WDCS_BSY) { - ata_c->flags |= AT_TIMEOU; - } else if (chp->ch_status & WDCS_ERR) { - ata_c->r_error = chp->ch_error; - ata_c->flags |= AT_ERROR; - } + + if (chp->ch_status & WDCS_BSY) { + ata_c->flags |= AT_TIMEOU; + } else if (chp->ch_status & WDCS_ERR) { + ata_c->r_error = chp->ch_error; + ata_c->flags |= AT_ERROR; } + + if (ata_c->flags & AT_READREG) + satafis_rdh_cmd_readreg(ata_c, achp->ahcic_rfis->rfis_rfis); + ahci_cmd_done(chp, xfer, slot); return 0; } Index: src/sys/dev/ic/siisata.c diff -u src/sys/dev/ic/siisata.c:1.9 src/sys/dev/ic/siisata.c:1.10 --- src/sys/dev/ic/siisata.c:1.9 Sat Jan 30 16:16:35 2010 +++ src/sys/dev/ic/siisata.c Wed Apr 7 17:51:16 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: siisata.c,v 1.9 2010/01/30 16:16:35 jakllsch Exp $ */ +/* $NetBSD: siisata.c,v 1.10 2010/04/07 17:51:16 jakllsch Exp $ */ /* from ahcisata_core.c */ @@ -54,7 +54,7 @@ */ /* - * Copyright (c) 2007, 2008, 2009 Jonathan A. Kollasch. + * Copyright (c) 2007, 2008, 2009, 2010 Jonathan A. Kollasch. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -79,7 +79,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.9 2010/01/30 16:16:35 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.10 2010/04/07 17:51:16 jakllsch Exp $"); #include <sys/types.h> #include <sys/malloc.h> @@ -96,20 +96,17 @@ #include <dev/ata/satavar.h> #include <dev/ata/satareg.h> #include <dev/ata/satafisvar.h> +#include <dev/ata/satafisreg.h> #include <dev/ic/siisatavar.h> -#include <dev/ic/wdcreg.h> +#include <dev/ic/siisatareg.h> #include <dev/scsipi/scsi_all.h> /* for SCSI status */ #include "atapibus.h" #ifdef SIISATA_DEBUG -#if 0 -int siisata_debug_mask = 0xffff; -#else int siisata_debug_mask = 0; #endif -#endif #define ATA_DELAY 10000 /* 10s for a drive I/O */ @@ -851,7 +848,7 @@ #ifdef SIISATA_DEBUG struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac; #endif - + SIISATA_DEBUG_PRINT( ("%s: %s\n", SIISATANAME(sc), __func__), DEBUG_FUNCS); @@ -861,39 +858,33 @@ else callout_stop(&chp->ch_callout); + if (chp->ch_status & WDCS_BSY) { + ata_c->flags |= AT_TIMEOU; + } else if (chp->ch_status & WDCS_ERR) { + ata_c->r_error = chp->ch_error; + ata_c->flags |= AT_ERROR; + } + if (chp->ch_drive[xfer->c_drive].drive_flags & DRIVE_WAITDRAIN) { siisata_cmd_kill_xfer(chp, xfer, KILL_GONE); chp->ch_drive[xfer->c_drive].drive_flags &= ~DRIVE_WAITDRAIN; wakeup(&chp->ch_queue->active_xfer); return 0; - } + } else + siisata_cmd_done(chp, xfer, slot); - chp->ch_queue->active_xfer = NULL; - - { - ata_c->r_head = 0; - ata_c->r_count = 0; - ata_c->r_sector = 0; - ata_c->r_cyl = 0; - if (chp->ch_status & WDCS_BSY) { - ata_c->flags |= AT_TIMEOU; - } else if (chp->ch_status & WDCS_ERR) { - ata_c->r_error = chp->ch_error; - ata_c->flags |= AT_ERROR; - } - } - siisata_cmd_done(chp, xfer, slot); return 0; } void siisata_cmd_done(struct ata_channel *chp, struct ata_xfer *xfer, int slot) { + uint32_t fis[howmany(RDH_FISLEN,sizeof(uint32_t))]; struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac; struct siisata_channel *schp = (struct siisata_channel *)chp; struct ata_command *ata_c = xfer->c_cmd; - int i; uint16_t *idwordbuf; + int i; SIISATA_DEBUG_PRINT( ("%s: %s.\n", SIISATANAME(sc), __func__), DEBUG_FUNCS); @@ -908,11 +899,17 @@ bus_dmamap_unload(sc->sc_dmat, schp->sch_datad[slot]); } - idwordbuf = xfer->c_databuf; + if (ata_c->flags & AT_READREG) { + bus_space_read_region_stream_4(sc->sc_prt, sc->sc_prh, + PRSX(chp->ch_channel, slot, PRSO_FIS), + fis, __arraycount(fis)); + satafis_rdh_cmd_readreg(ata_c, (uint8_t *)fis); + } /* correct the endianess of IDENTIFY data */ if (ata_c->r_command == WDCC_IDENTIFY || ata_c->r_command == ATAPI_IDENTIFY_DEVICE) { + idwordbuf = xfer->c_databuf; for (i = 0; i < (xfer->c_bcount / sizeof(*idwordbuf)); i++) { idwordbuf[i] = le16toh(idwordbuf[i]); } @@ -922,6 +919,7 @@ if (PRREAD(sc, PRSX(chp->ch_channel, slot, PRSO_RTC))) ata_c->flags |= AT_XFDONE; + chp->ch_queue->active_xfer = NULL; ata_free_xfer(chp, xfer); if (ata_c->flags & AT_WAIT) wakeup(ata_c); @@ -1071,8 +1069,6 @@ ata_bio->error = NOERROR; } - chp->ch_queue->active_xfer = NULL; - bus_dmamap_sync(sc->sc_dmat, schp->sch_datad[slot], 0, schp->sch_datad[slot]->dm_mapsize, (ata_bio->flags & ATA_READ) ? BUS_DMASYNC_POSTREAD : @@ -1085,6 +1081,8 @@ wakeup(&chp->ch_queue->active_xfer); return 0; } + + chp->ch_queue->active_xfer = NULL; ata_free_xfer(chp, xfer); ata_bio->flags |= ATA_ITSDONE; if (chp->ch_status & WDCS_DWF) { @@ -1611,7 +1609,6 @@ chp->ch_queue->active_xfer = NULL; ata_free_xfer(chp, xfer); - sc_xfer->resid = sc_xfer->datalen; sc_xfer->resid -= PRREAD(sc, PRSX(chp->ch_channel, slot, PRSO_RTC)); SIISATA_DEBUG_PRINT(("%s: %s datalen %d resid %d\n", SIISATANAME(sc), Index: src/sys/dev/ic/siisatareg.h diff -u src/sys/dev/ic/siisatareg.h:1.5 src/sys/dev/ic/siisatareg.h:1.6 --- src/sys/dev/ic/siisatareg.h:1.5 Sun Jul 19 06:28:08 2009 +++ src/sys/dev/ic/siisatareg.h Wed Apr 7 17:51:16 2010 @@ -1,7 +1,7 @@ -/* $NetBSD: siisatareg.h,v 1.5 2009/07/19 06:28:08 kiyohara Exp $ */ +/* $NetBSD: siisatareg.h,v 1.6 2010/04/07 17:51:16 jakllsch Exp $ */ -/*- - * Copyright (c) 2007, 2008, 2009 Jonathan A. Kollasch. +/* + * Copyright (c) 2007, 2008, 2009, 2010 Jonathan A. Kollasch. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,6 +26,9 @@ * */ +#ifndef _IC_SIISATAREG_H_ +#define _IC_SIISATAREG_H_ + /* Silicon Image SATA 2 controller register defines */ #include <sys/cdefs.h> @@ -250,3 +253,5 @@ #define PR_PSS_ATTENTION __BIT(31) #define PR_PSS_SLOT_MASK __BITS(30, 0) #define PR_PXSS(n) __SHIFTIN(__BIT(n), PR_PSS_SLOT_MASK) + +#endif /* !_IC_SIISATAREG_H_ */