/*****************************************************************************
 * Copyright (c) 1988-95 Digi International Inc., All Rights Reserved
 * 
 * This  software  contains  proprietary  and  confidential   information   of
 * Digi International  Inc.   By  accepting  transfer  of this copy, Recipient
 * agrees to retain this software in  confidence,  to  prevent  disclosure  to
 * others,  and  to make no  use of this software other than that for which it
 * was delivered.  This is an unpublished copyright work  Digi   International
 * Inc.    Except   as   permitted   by  federal  law,  17 USC 117, copying is
 * strictly prohibited.
 * 
 * Digi  International  Inc.  CONFIDENTIAL  -   (Digi    International    Inc.
 * Confidential  when   combined   with   the   aggregated  modules  for  this
 * product) OBJECT CODE ONLY SOURCE MATERIALS
 * 
 * (C) COPYRIGHT Digi International Inc. 1995
 * 
 * All Rights Reserved
 * 
 * US   Government   Users   Restricted   Rights   -   Use,   duplication   or
 * disclosure  restricted by GSA ADP Schedule Contract with Digi International
 * Inc.
 * 
 *****************************************************************************/


/********************************************************
 *
 *	 /projects/common/PBRAIN/SCCS/pbrainF/dev/embed/common/71/s.timer.h
 *	@(#)timer.h	1.1
 *
 *	Copyright (c) 1991 Spider Systems Limited
 *
 *	TIMER.H -   Multiple timer module header
 *
 *	Last delta created	12:49:09 6/25/92
 *	This file extracted	12:55:13 10/29/92
 *
 *	Modifications:
 *
 *
 ********************************************************/

#ifndef _SNET_TIMER

/* Lock out clock ISR */
#define splclock()   splhi()

/* Timers header, used to process expiries */
typedef struct thead
{
    void         (*th_expfunc)();
    caddr_t        th_exparg;
    struct timer  *th_expired;
} thead_t;

/* Individual timer */
typedef struct timer
{
    unchar         tm_id;
    unchar         tm_offset;
    ushort         tm_left;
    struct timer  *tm_next;
    struct timer **tm_back;
} timer_t;

#define _SNET_TIMER
#endif /* _SNET_TIMER */

unsigned long curtime() ;

/*
 * Timer comparison macros.. These macros are based on unsigned 32 bit
 * objects.
 */
#define TIMER_WRAP	0x80000000

#define	EARLIER_THAN(x)	((curtime() - (x)) > TIMER_WRAP)
#define	LATER_THAN(x)	((curtime() - (x)) < TIMER_WRAP)


// Prototypes
void set_timer(timer_t *, unsigned short);
void attach_timer(timer_t *, timer_t **);
void activate_timer(timer_t *, ushort);
