OLD | NEW |
1 /* $OpenBSD: wdc.c,v 1.114 2011/05/08 17:33:56 matthew Exp $ */ | 1 /* $OpenBSD: wdc.c,v 1.114 2011/05/08 17:33:56 matthew Exp $ */ |
2 /* $NetBSD: wdc.c,v 1.68 1999/06/23 19:00:17 bouyer Exp $ */ | 2 /* $NetBSD: wdc.c,v 1.68 1999/06/23 19:00:17 bouyer Exp $ */ |
3 /* | 3 /* |
4 * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. | 4 * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 } | 690 } |
691 wdc_enable_intr(chp); | 691 wdc_enable_intr(chp); |
692 } | 692 } |
693 | 693 |
694 #ifdef WDCDEBUG | 694 #ifdef WDCDEBUG |
695 wdcdebug_mask = savedmask; | 695 wdcdebug_mask = savedmask; |
696 #endif | 696 #endif |
697 return (ret_value); | 697 return (ret_value); |
698 } | 698 } |
699 | 699 |
| 700 struct channel_queue * |
| 701 wdc_alloc_queue(void) |
| 702 { |
| 703 static int inited = 0; |
| 704 struct channel_queue *queue; |
| 705 |
| 706 /* Initialize global data. */ |
| 707 if (inited == 0) { |
| 708 /* Initialize the wdc_xfer pool. */ |
| 709 pool_init(&wdc_xfer_pool, sizeof(struct wdc_xfer), 0, |
| 710 0, 0, "wdcspl", NULL); |
| 711 inited = 1; |
| 712 } |
| 713 |
| 714 queue = malloc(sizeof(*queue), M_DEVBUF, M_NOWAIT); |
| 715 if (queue != NULL) { |
| 716 TAILQ_INIT(&queue->sc_xfer); |
| 717 } |
| 718 return (queue); |
| 719 } |
| 720 |
| 721 void |
| 722 wdc_free_queue(struct channel_queue *queue) |
| 723 { |
| 724 free(queue, M_DEVBUF); |
| 725 } |
| 726 |
700 void | 727 void |
701 wdcattach(struct channel_softc *chp) | 728 wdcattach(struct channel_softc *chp) |
702 { | 729 { |
703 int channel_flags, ctrl_flags, i; | 730 int channel_flags, ctrl_flags, i; |
704 struct ata_atapi_attach aa_link; | 731 struct ata_atapi_attach aa_link; |
705 static int inited = 0, s; | |
706 #ifdef WDCDEBUG | 732 #ifdef WDCDEBUG |
707 int savedmask = wdcdebug_mask; | 733 int savedmask = wdcdebug_mask; |
708 #endif | 734 #endif |
709 | 735 |
710 if (!cold) | 736 if (!cold) |
711 at_poll = AT_WAIT; | 737 at_poll = AT_WAIT; |
712 | 738 |
713 if (chp->wdc->reset == NULL) | 739 if (chp->wdc->reset == NULL) |
714 chp->wdc->reset = wdc_do_reset; | 740 chp->wdc->reset = wdc_do_reset; |
715 | 741 |
(...skipping 19 matching lines...) Expand all Loading... |
735 #ifdef WDCDEBUG | 761 #ifdef WDCDEBUG |
736 if (chp->wdc->sc_dev.dv_cfdata->cf_flags & WDC_OPTION_PROBE_VERBOSE) | 762 if (chp->wdc->sc_dev.dv_cfdata->cf_flags & WDC_OPTION_PROBE_VERBOSE) |
737 wdcdebug_mask |= DEBUG_PROBE; | 763 wdcdebug_mask |= DEBUG_PROBE; |
738 | 764 |
739 if ((chp->ch_drive[0].drive_flags & DRIVE_ATAPI) || | 765 if ((chp->ch_drive[0].drive_flags & DRIVE_ATAPI) || |
740 (chp->ch_drive[1].drive_flags & DRIVE_ATAPI)) { | 766 (chp->ch_drive[1].drive_flags & DRIVE_ATAPI)) { |
741 wdcdebug_mask = DEBUG_PROBE; | 767 wdcdebug_mask = DEBUG_PROBE; |
742 } | 768 } |
743 #endif /* WDCDEBUG */ | 769 #endif /* WDCDEBUG */ |
744 | 770 |
745 /* initialise global data */ | |
746 s = splbio(); | |
747 if (inited == 0) { | |
748 /* Initialize the wdc_xfer pool. */ | |
749 pool_init(&wdc_xfer_pool, sizeof(struct wdc_xfer), 0, | |
750 0, 0, "wdcspl", NULL); | |
751 inited++; | |
752 } | |
753 TAILQ_INIT(&chp->ch_queue->sc_xfer); | |
754 splx(s); | |
755 | |
756 for (i = 0; i < 2; i++) { | 771 for (i = 0; i < 2; i++) { |
757 struct ata_drive_datas *drvp = &chp->ch_drive[i]; | 772 struct ata_drive_datas *drvp = &chp->ch_drive[i]; |
758 | 773 |
759 drvp->chnl_softc = chp; | 774 drvp->chnl_softc = chp; |
760 drvp->drive = i; | 775 drvp->drive = i; |
761 /* If controller can't do 16bit flag the drives as 32bit */ | 776 /* If controller can't do 16bit flag the drives as 32bit */ |
762 if ((chp->wdc->cap & | 777 if ((chp->wdc->cap & |
763 (WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32)) == | 778 (WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32)) == |
764 WDC_CAPABILITY_DATA32) | 779 WDC_CAPABILITY_DATA32) |
765 drvp->drive_flags |= DRIVE_CAP32; | 780 drvp->drive_flags |= DRIVE_CAP32; |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2115 } | 2130 } |
2116 | 2131 |
2117 default: | 2132 default: |
2118 error = ENOTTY; | 2133 error = ENOTTY; |
2119 goto exit; | 2134 goto exit; |
2120 } | 2135 } |
2121 | 2136 |
2122 exit: | 2137 exit: |
2123 return (error); | 2138 return (error); |
2124 } | 2139 } |
OLD | NEW |