From owner-p4-projects@FreeBSD.ORG Mon Aug 7 19:05:01 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4A64416A4E1; Mon, 7 Aug 2006 19:05:01 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2679A16A4DA for ; Mon, 7 Aug 2006 19:05:01 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id CA82C43D46 for ; Mon, 7 Aug 2006 19:05:00 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k77J50pn054592 for ; Mon, 7 Aug 2006 19:05:00 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k77J50o7054589 for perforce@freebsd.org; Mon, 7 Aug 2006 19:05:00 GMT (envelope-from imp@freebsd.org) Date: Mon, 7 Aug 2006 19:05:00 GMT Message-Id: <200608071905.k77J50o7054589@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 103389 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2006 19:05:01 -0000 http://perforce.freebsd.org/chv.cgi?CH=103389 Change 103389 by imp@imp_bugs on 2006/08/07 19:04:23 Implement watchdog. The OS has 30s to load and get to the point of disabling the watchdog before we reboot. 64s is the absolute max, and 30s seemed a good number. Usually it takes like 5s-10s. Affected files ... .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/lib.h#13 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/reset.c#2 edit Differences ... ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/lib.h#13 (text) ==== @@ -40,7 +40,8 @@ /* XMODEM protocol */ int xmodem_rx(char *dst); -/* Reboot! Reset! */ +/* */ +void start_wdog(void); void reset(void); /* Delay us */ ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/reset.c#2 (text+ko) ==== @@ -28,10 +28,11 @@ #include "lib.h" /* - * int getc(int seconds) + * void reset() * - * Reads a character from the DBGU port, if one is available within about - * seconds seconds. It assumes that DBGU has already been initialized. + * Forces a reset of the system. Uses watchdog timer of '1', which + * corresponds to 128 / SLCK seconds (SLCK is 32,768 Hz, so 128/32768 is + * 1 / 256 ~= 5.4ms */ void reset(void) @@ -40,3 +41,17 @@ AT91C_BASE_ST->ST_WDMR = 1 | AT91C_ST_RSTEN; AT91C_BASE_ST->ST_CR = AT91C_ST_WDRST; } + +/* + * void start_wdog() + * + * Starts a watchdog timer. We force the boot process to get to the point + * it can kick the watch dog part of the ST part for the OS's driver. + */ +void +start_wdog(void) +{ + // The following should effect a reset after 30 seconds. + AT91C_BASE_ST->ST_WDMR = (30 * (32768 / 128)) | AT91C_ST_RSTEN; + AT91C_BASE_ST->ST_CR = AT91C_ST_WDRST; +}