Deleted Added
full compact
amr.c (119418) amr.c (120988)
1/*-
2 * Copyright (c) 1999,2000 Michael Smith
3 * Copyright (c) 2000 BSDi
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 41 unchanged lines hidden (view full) ---

50 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54 * SUCH DAMAGE.
55 */
56
57#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1999,2000 Michael Smith
3 * Copyright (c) 2000 BSDi
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 41 unchanged lines hidden (view full) ---

50 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54 * SUCH DAMAGE.
55 */
56
57#include <sys/cdefs.h>
58__FBSDID("$FreeBSD: head/sys/dev/amr/amr.c 119418 2003-08-24 17:55:58Z obrien $");
58__FBSDID("$FreeBSD: head/sys/dev/amr/amr.c 120988 2003-10-10 22:49:40Z ps $");
59
60/*
61 * Driver for the AMI MegaRaid family of controllers.
62 */
63
64#include <sys/param.h>
65#include <sys/systm.h>
66#include <sys/malloc.h>

--- 905 unchanged lines hidden (view full) ---

972
973 debug_called(2);
974
975 /* now we have a slot, we can map the command (unmapped in amr_complete) */
976 amr_mapcmd(ac);
977
978 s = splbio();
979
59
60/*
61 * Driver for the AMI MegaRaid family of controllers.
62 */
63
64#include <sys/param.h>
65#include <sys/systm.h>
66#include <sys/malloc.h>

--- 905 unchanged lines hidden (view full) ---

972
973 debug_called(2);
974
975 /* now we have a slot, we can map the command (unmapped in amr_complete) */
976 amr_mapcmd(ac);
977
978 s = splbio();
979
980 count=0;
981 while (sc->amr_busyslots){
982 tsleep(sc, PRIBIO | PCATCH, "amrpoll", hz);
983 if(count++>10) {
984 break;
980 if (sc->amr_state & AMR_STATE_INTEN) {
981 count=0;
982 while (sc->amr_busyslots) {
983 tsleep(sc, PRIBIO | PCATCH, "amrpoll", hz);
984 if(count++>10) {
985 break;
986 }
985 }
987 }
986 }
987
988
988 if(sc->amr_busyslots) {
989 device_printf(sc->amr_dev, "adapter is busy\n");
990 splx(s);
991 amr_unmapcmd(ac);
992 ac->ac_status=0;
993 return(1);
989 if(sc->amr_busyslots) {
990 device_printf(sc->amr_dev, "adapter is busy\n");
991 splx(s);
992 amr_unmapcmd(ac);
993 ac->ac_status=0;
994 return(1);
995 }
994 }
995
996 bcopy(&ac->ac_mailbox, (void *)(uintptr_t)(volatile void *)sc->amr_mailbox, AMR_MBOX_CMDSIZE);
997
998 /* clear the poll/ack fields in the mailbox */
999 sc->amr_mailbox->mb_ident = 0xFE;
1000 sc->amr_mailbox->mb_nstatus = 0xFF;
1001 sc->amr_mailbox->mb_status = 0xFF;

--- 772 unchanged lines hidden (view full) ---

1774 } else {
1775 device_printf(sc->amr_dev, "<%s> Firmware %.4s, BIOS %.4s, %dMB RAM\n",
1776 prod, ae->ae_adapter.aa_firmware, ae->ae_adapter.aa_bios,
1777 ae->ae_adapter.aa_memorysize);
1778 }
1779 free(ae, M_DEVBUF);
1780}
1781
996 }
997
998 bcopy(&ac->ac_mailbox, (void *)(uintptr_t)(volatile void *)sc->amr_mailbox, AMR_MBOX_CMDSIZE);
999
1000 /* clear the poll/ack fields in the mailbox */
1001 sc->amr_mailbox->mb_ident = 0xFE;
1002 sc->amr_mailbox->mb_nstatus = 0xFF;
1003 sc->amr_mailbox->mb_status = 0xFF;

--- 772 unchanged lines hidden (view full) ---

1776 } else {
1777 device_printf(sc->amr_dev, "<%s> Firmware %.4s, BIOS %.4s, %dMB RAM\n",
1778 prod, ae->ae_adapter.aa_firmware, ae->ae_adapter.aa_bios,
1779 ae->ae_adapter.aa_memorysize);
1780 }
1781 free(ae, M_DEVBUF);
1782}
1783
1784int
1785amr_dump_blocks(struct amr_softc *sc, int unit, u_int32_t lba, void *data, int blks)
1786{
1787 struct amr_command *ac;
1788 int error = EIO;
1789
1790 debug_called(1);
1791
1792 sc->amr_state &= ~AMR_STATE_INTEN;
1793
1794 /* get ourselves a command buffer */
1795 if ((ac = amr_alloccmd(sc)) == NULL)
1796 goto out;
1797 /* set command flags */
1798 ac->ac_flags |= AMR_CMD_PRIORITY | AMR_CMD_DATAOUT;
1799
1800 /* point the command at our data */
1801 ac->ac_data = data;
1802 ac->ac_length = blks * AMR_BLKSIZE;
1803
1804 /* build the command proper */
1805 ac->ac_mailbox.mb_command = AMR_CMD_LWRITE;
1806 ac->ac_mailbox.mb_blkcount = blks;
1807 ac->ac_mailbox.mb_lba = lba;
1808 ac->ac_mailbox.mb_drive = unit;
1809
1810 /* can't assume that interrupts are going to work here, so play it safe */
1811 if (sc->amr_poll_command(ac))
1812 goto out;
1813 error = ac->ac_status;
1814
1815 out:
1816 if (ac != NULL)
1817 amr_releasecmd(ac);
1818
1819 sc->amr_state |= AMR_STATE_INTEN;
1820 return (error);
1821}
1822
1823
1824
1782#ifdef AMR_DEBUG
1783/********************************************************************************
1784 * Print the command (ac) in human-readable format
1785 */
1786#if 0
1787static void
1788amr_printcommand(struct amr_command *ac)
1789{

--- 20 unchanged lines hidden ---
1825#ifdef AMR_DEBUG
1826/********************************************************************************
1827 * Print the command (ac) in human-readable format
1828 */
1829#if 0
1830static void
1831amr_printcommand(struct amr_command *ac)
1832{

--- 20 unchanged lines hidden ---