Deleted Added
full compact
ipmi.c (184949) ipmi.c (200666)
1/*-
2 * Copyright (c) 2006 IronPort Systems Inc. <ambrisko@ironport.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2006 IronPort Systems Inc. <ambrisko@ironport.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/ipmi/ipmi.c 184949 2008-11-14 01:53:10Z obrien $");
28__FBSDID("$FreeBSD: head/sys/dev/ipmi/ipmi.c 200666 2009-12-18 12:10:42Z ru $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bus.h>
33#include <sys/condvar.h>
34#include <sys/conf.h>
35#include <sys/kernel.h>
36#include <sys/malloc.h>

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

583 cv_signal(&sc->ipmi_request_added);
584 return (0);
585}
586
587/*
588 * Watchdog event handler.
589 */
590
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bus.h>
33#include <sys/condvar.h>
34#include <sys/conf.h>
35#include <sys/kernel.h>
36#include <sys/malloc.h>

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

583 cv_signal(&sc->ipmi_request_added);
584 return (0);
585}
586
587/*
588 * Watchdog event handler.
589 */
590
591static void
592ipmi_set_watchdog(struct ipmi_softc *sc, int sec)
591static int
592ipmi_set_watchdog(struct ipmi_softc *sc, unsigned int sec)
593{
594 struct ipmi_request *req;
595 int error;
596
593{
594 struct ipmi_request *req;
595 int error;
596
597 if (sec > 0xffff / 10)
598 return (EINVAL);
599
597 req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
598 IPMI_SET_WDOG, 6, 0);
599
600 if (sec) {
601 req->ir_request[0] = IPMI_SET_WD_TIMER_DONT_STOP
602 | IPMI_SET_WD_TIMER_SMS_OS;
603 req->ir_request[1] = IPMI_SET_WD_ACTION_RESET;
604 req->ir_request[2] = 0;
605 req->ir_request[3] = 0; /* Timer use */
606 req->ir_request[4] = (sec * 10) & 0xff;
600 req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
601 IPMI_SET_WDOG, 6, 0);
602
603 if (sec) {
604 req->ir_request[0] = IPMI_SET_WD_TIMER_DONT_STOP
605 | IPMI_SET_WD_TIMER_SMS_OS;
606 req->ir_request[1] = IPMI_SET_WD_ACTION_RESET;
607 req->ir_request[2] = 0;
608 req->ir_request[3] = 0; /* Timer use */
609 req->ir_request[4] = (sec * 10) & 0xff;
607 req->ir_request[5] = (sec * 10) / 2550;
610 req->ir_request[5] = (sec * 10) >> 8;
608 } else {
609 req->ir_request[0] = IPMI_SET_WD_TIMER_SMS_OS;
610 req->ir_request[1] = 0;
611 req->ir_request[2] = 0;
612 req->ir_request[3] = 0; /* Timer use */
613 req->ir_request[4] = 0;
614 req->ir_request[5] = 0;
615 }
616
617 error = ipmi_submit_driver_request(sc, req, 0);
618 if (error)
619 device_printf(sc->ipmi_dev, "Failed to set watchdog\n");
611 } else {
612 req->ir_request[0] = IPMI_SET_WD_TIMER_SMS_OS;
613 req->ir_request[1] = 0;
614 req->ir_request[2] = 0;
615 req->ir_request[3] = 0; /* Timer use */
616 req->ir_request[4] = 0;
617 req->ir_request[5] = 0;
618 }
619
620 error = ipmi_submit_driver_request(sc, req, 0);
621 if (error)
622 device_printf(sc->ipmi_dev, "Failed to set watchdog\n");
620
621 if (error == 0 && sec) {
623 else if (sec) {
622 ipmi_free_request(req);
623
624 req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
625 IPMI_RESET_WDOG, 0, 0);
626
627 error = ipmi_submit_driver_request(sc, req, 0);
628 if (error)
629 device_printf(sc->ipmi_dev,
630 "Failed to reset watchdog\n");
631 }
632
633 ipmi_free_request(req);
624 ipmi_free_request(req);
625
626 req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
627 IPMI_RESET_WDOG, 0, 0);
628
629 error = ipmi_submit_driver_request(sc, req, 0);
630 if (error)
631 device_printf(sc->ipmi_dev,
632 "Failed to reset watchdog\n");
633 }
634
635 ipmi_free_request(req);
636 return (error);
634 /*
635 dump_watchdog(sc);
636 */
637}
638
639static void
640ipmi_wd_event(void *arg, unsigned int cmd, int *error)
641{
642 struct ipmi_softc *sc = arg;
643 unsigned int timeout;
637 /*
638 dump_watchdog(sc);
639 */
640}
641
642static void
643ipmi_wd_event(void *arg, unsigned int cmd, int *error)
644{
645 struct ipmi_softc *sc = arg;
646 unsigned int timeout;
647 int e;
644
645 cmd &= WD_INTERVAL;
646 if (cmd > 0 && cmd <= 63) {
648
649 cmd &= WD_INTERVAL;
650 if (cmd > 0 && cmd <= 63) {
647 timeout = ((uint64_t)1 << cmd) / 1800000000;
648 ipmi_set_watchdog(sc, timeout);
649 *error = 0;
651 timeout = ((uint64_t)1 << cmd) / 1000000000;
652 if (timeout == 0)
653 timeout = 1;
654 e = ipmi_set_watchdog(sc, timeout);
655 if (e == 0)
656 *error = 0;
657 else
658 (void)ipmi_set_watchdog(sc, 0);
650 } else {
659 } else {
651 ipmi_set_watchdog(sc, 0);
660 e = ipmi_set_watchdog(sc, 0);
661 if (e != 0 && cmd == 0)
662 *error = EOPNOTSUPP;
652 }
653}
654
655static void
656ipmi_startup(void *arg)
657{
658 struct ipmi_softc *sc = arg;
659 struct ipmi_request *req;

--- 247 unchanged lines hidden ---
663 }
664}
665
666static void
667ipmi_startup(void *arg)
668{
669 struct ipmi_softc *sc = arg;
670 struct ipmi_request *req;

--- 247 unchanged lines hidden ---