Home | History | Annotate | Line # | Download | only in raidframe
rf_general.h revision 1.11.2.5
      1  1.11.2.5    skrll /*	$NetBSD: rf_general.h,v 1.11.2.5 2005/11/10 14:07:40 skrll Exp $	*/
      2       1.1    oster /*
      3       1.1    oster  * Copyright (c) 1995 Carnegie-Mellon University.
      4       1.1    oster  * All rights reserved.
      5       1.1    oster  *
      6       1.1    oster  * Author: Mark Holland
      7       1.1    oster  *
      8       1.1    oster  * Permission to use, copy, modify and distribute this software and
      9       1.1    oster  * its documentation is hereby granted, provided that both the copyright
     10       1.1    oster  * notice and this permission notice appear in all copies of the
     11       1.1    oster  * software, derivative works or modified versions, and any portions
     12       1.1    oster  * thereof, and that both notices appear in supporting documentation.
     13       1.1    oster  *
     14       1.1    oster  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     15       1.1    oster  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     16       1.1    oster  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     17       1.1    oster  *
     18       1.1    oster  * Carnegie Mellon requests users of this software to return to
     19       1.1    oster  *
     20       1.1    oster  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     21       1.1    oster  *  School of Computer Science
     22       1.1    oster  *  Carnegie Mellon University
     23       1.1    oster  *  Pittsburgh PA 15213-3890
     24       1.1    oster  *
     25       1.1    oster  * any improvements or extensions that they make and grant Carnegie the
     26       1.1    oster  * rights to redistribute these changes.
     27       1.1    oster  */
     28       1.1    oster 
     29       1.1    oster /*
     30       1.1    oster  * rf_general.h -- some general-use definitions
     31       1.1    oster  */
     32       1.1    oster 
     33       1.9    oster /* #define NOASSERT */
     34       1.9    oster 
     35       1.1    oster #ifndef _RF__RF_GENERAL_H_
     36       1.1    oster #define _RF__RF_GENERAL_H_
     37       1.1    oster 
     38       1.8  thorpej #ifdef _KERNEL_OPT
     39       1.8  thorpej #include "opt_raid_diagnostic.h"
     40       1.8  thorpej #endif /* _KERNEL_OPT */
     41       1.8  thorpej 
     42       1.1    oster /* error reporting and handling */
     43       1.1    oster 
     44      1.11  thorpej #include <sys/systm.h>		/* printf, sprintf, and friends */
     45      1.11  thorpej #include <uvm/uvm_extern.h>	/* PAGE_SIZE, PAGE_MASK */
     46       1.1    oster 
     47       1.1    oster #define RF_ERRORMSG(s)            printf((s))
     48       1.1    oster #define RF_ERRORMSG1(s,a)         printf((s),(a))
     49       1.1    oster #define RF_ERRORMSG2(s,a,b)       printf((s),(a),(b))
     50       1.1    oster #define RF_ERRORMSG3(s,a,b,c)     printf((s),(a),(b),(c))
     51       1.5    oster 
     52  1.11.2.5    skrll void rf_print_panic_message(int, const char *);
     53  1.11.2.5    skrll void rf_print_assert_panic_message(int, const char *, const char *);
     54  1.11.2.5    skrll void rf_print_unable_to_init_mutex(const char *, int, int);
     55  1.11.2.5    skrll void rf_print_unable_to_add_shutdown(const char *, int, int);
     56       1.6    oster 
     57  1.11.2.4    skrll 
     58       1.1    oster extern char rf_panicbuf[];
     59       1.6    oster #define RF_PANIC() {rf_print_panic_message(__LINE__,__FILE__); panic(rf_panicbuf);}
     60       1.1    oster 
     61       1.8  thorpej #ifdef RAID_DIAGNOSTIC
     62       1.1    oster #define RF_ASSERT(_x_) { \
     63       1.1    oster   if (!(_x_)) { \
     64       1.6    oster     rf_print_assert_panic_message(__LINE__, __FILE__, #_x_); \
     65       1.1    oster     panic(rf_panicbuf); \
     66       1.1    oster   } \
     67       1.1    oster }
     68       1.8  thorpej #else /* RAID_DIAGNOSTIC */
     69       1.2    oster #define RF_ASSERT(x) {/*noop*/}
     70       1.8  thorpej #endif /* RAID_DIAGNOSTIC */
     71       1.1    oster 
     72       1.1    oster /* random stuff */
     73       1.1    oster #define RF_MAX(a,b) (((a) > (b)) ? (a) : (b))
     74       1.1    oster #define RF_MIN(a,b) (((a) < (b)) ? (a) : (b))
     75       1.1    oster 
     76       1.1    oster /* divide-by-zero check */
     77       1.1    oster #define RF_DB0_CHECK(a,b) ( ((b)==0) ? 0 : (a)/(b) )
     78       1.1    oster 
     79       1.1    oster /* get time of day */
     80       1.1    oster #define RF_GETTIME(_t) microtime(&(_t))
     81       1.1    oster 
     82       1.1    oster #define RF_UL(x)           ((unsigned long) (x))
     83      1.11  thorpej #define RF_PGMASK          PAGE_MASK
     84      1.11  thorpej #define RF_BLIP(x)         (PAGE_SIZE - (RF_UL(x) & RF_PGMASK))	/* bytes left in page */
     85       1.1    oster #define RF_PAGE_ALIGNED(x) ((RF_UL(x) & RF_PGMASK) == 0)
     86       1.1    oster 
     87       1.1    oster #ifdef __STDC__
     88       1.1    oster #define RF_STRING(_str_) #_str_
     89       1.3    oster #else				/* __STDC__ */
     90       1.1    oster #define RF_STRING(_str_) "_str_"
     91       1.3    oster #endif				/* __STDC__ */
     92       1.1    oster 
     93       1.3    oster #endif				/* !_RF__RF_GENERAL_H_ */
     94