From owner-freebsd-hackers@FreeBSD.ORG Mon Jan 23 05:39:52 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 966E0106566B; Mon, 23 Jan 2012 05:39:52 +0000 (UTC) (envelope-from doconnor@gsoft.com.au) Received: from cain.gsoft.com.au (cain.gsoft.com.au [203.31.81.10]) by mx1.freebsd.org (Postfix) with ESMTP id DD60F8FC16; Mon, 23 Jan 2012 05:39:51 +0000 (UTC) Received: from ur.gsoft.com.au (Ur.gsoft.com.au [203.31.81.55]) (authenticated bits=0) by cain.gsoft.com.au (8.14.4/8.14.3) with ESMTP id q0N56OsW093166 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Mon, 23 Jan 2012 15:36:30 +1030 (CST) (envelope-from doconnor@gsoft.com.au) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: "Daniel O'Connor" In-Reply-To: Date: Mon, 23 Jan 2012 15:36:24 +1030 Content-Transfer-Encoding: quoted-printable Message-Id: References: <4F1CC6A8.3010007@freebsd.org> To: Andrew Davis X-Mailer: Apple Mail (2.1251.1) X-Spam-Score: -2.51 () ALL_TRUSTED,BAYES_00,T_RP_MATCHES_RCVD X-Scanned-By: MIMEDefang 2.67 on 203.31.81.10 Cc: freebsd-hackers@freebsd.org Subject: Re: Rebooting/Halting system from kernel module X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jan 2012 05:39:52 -0000 On 23/01/2012, at 13:33, Andrew Davis wrote: >> do you want to sync the disks first? of just hard reset? >=20 > Why would anyone ever want to do that, you're a kernel mod, if you = want to > do that just triple-fault. You can call cpu_reset(). I wrote a KLD which did this because we had a driver issue where the = system wouldn't reboot if you did shutdown -r (it would hang). =3D=3D=3D=3D reset.c =3D=3D=3D=3D #include #include #include #include #include #include static int reset_handler(module_t mod, int /*modeventtype_t*/ what, void *arg); static moduledata_t mod_data=3D { "reset", reset_handler, 0 }; MODULE_VERSION(reset, 1); DECLARE_MODULE(reset, mod_data, SI_SUB_EXEC, SI_ORDER_ANY); static int=20 reset_handler(module_t mod, int /*modeventtype_t*/ what, void *arg) { switch (what) { case MOD_LOAD: printf("Forced reboot\n"); DELAY(1000000); /* wait 1 sec for printf's to complete and = be read */ /* cpu_boot(howto); */ /* doesn't do anything at the moment = */ cpu_reset(); printf("Reset failed!\n"); /* NOTREACHED */ /* assuming reset worked */ break; =20 default: return(EOPNOTSUPP); break; } return(ENXIO); } =3D=3D=3D=3D =3D=3D=3D=3D Makefile =3D=3D=3D=3D KMOD =3D reset SRCS =3D reset.c .include =3D=3D=3D=3D > On Sun, Jan 22, 2012 at 9:32 PM, Julian Elischer = wrote: >=20 >> On 1/22/12 2:19 AM, geoffrey levand wrote: >>=20 >>> Hi, >>>=20 >>> how would i reboot/halt the system from a kernel module ? >>>=20 >>=20 >> the answer is "that depends".. >>=20 >> do you want to sync the disks first? of just hard reset? >>=20 >>=20 >>=20 >> ______________________________**_________________ >> freebsd-hackers@freebsd.org mailing list >> = http://lists.freebsd.org/**mailman/listinfo/freebsd-**hackers >> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@** >> freebsd.org " >>=20 > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to = "freebsd-hackers-unsubscribe@freebsd.org" >=20 -- Daniel O'Connor software and network engineer for Genesis Software - http://www.gsoft.com.au "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C