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 $");
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;
985 }
986 }
987
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);
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
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 ---
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 $");
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;
985 }
986 }
987
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);
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
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 ---