x86: hpet: stop HPET_COUNTER when programming periodic mode
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / md / raid6.h
blob98dcde88470e4c23b8fc204e46587be0243bfa32
1 /* -*- linux-c -*- ------------------------------------------------------- *
3 * Copyright 2003 H. Peter Anvin - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Bostom MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
13 #ifndef LINUX_RAID_RAID6_H
14 #define LINUX_RAID_RAID6_H
16 #ifdef __KERNEL__
18 /* Set to 1 to use kernel-wide empty_zero_page */
19 #define RAID6_USE_EMPTY_ZERO_PAGE 0
21 #include <linux/raid/md.h>
22 #include <linux/raid/raid5.h>
24 typedef raid5_conf_t raid6_conf_t; /* Same configuration */
26 /* Additional compute_parity mode -- updates the parity w/o LOCKING */
27 #define UPDATE_PARITY 4
29 /* We need a pre-zeroed page... if we don't want to use the kernel-provided
30 one define it here */
31 #if RAID6_USE_EMPTY_ZERO_PAGE
32 # define raid6_empty_zero_page empty_zero_page
33 #else
34 extern const char raid6_empty_zero_page[PAGE_SIZE];
35 #endif
37 #else /* ! __KERNEL__ */
38 /* Used for testing in user space */
40 #include <errno.h>
41 #include <inttypes.h>
42 #include <limits.h>
43 #include <stddef.h>
44 #include <sys/mman.h>
45 #include <sys/types.h>
47 /* Not standard, but glibc defines it */
48 #define BITS_PER_LONG __WORDSIZE
50 typedef uint8_t u8;
51 typedef uint16_t u16;
52 typedef uint32_t u32;
53 typedef uint64_t u64;
55 #ifndef PAGE_SIZE
56 # define PAGE_SIZE 4096
57 #endif
58 extern const char raid6_empty_zero_page[PAGE_SIZE];
60 #define __init
61 #define __exit
62 #define __attribute_const__ __attribute__((const))
63 #define noinline __attribute__((noinline))
65 #define preempt_enable()
66 #define preempt_disable()
67 #define cpu_has_feature(x) 1
68 #define enable_kernel_altivec()
69 #define disable_kernel_altivec()
71 #endif /* __KERNEL__ */
73 /* Routine choices */
74 struct raid6_calls {
75 void (*gen_syndrome)(int, size_t, void **);
76 int (*valid)(void); /* Returns 1 if this routine set is usable */
77 const char *name; /* Name of this routine set */
78 int prefer; /* Has special performance attribute */
81 /* Selected algorithm */
82 extern struct raid6_calls raid6_call;
84 /* Algorithm list */
85 extern const struct raid6_calls * const raid6_algos[];
86 int raid6_select_algo(void);
88 /* Return values from chk_syndrome */
89 #define RAID6_OK 0
90 #define RAID6_P_BAD 1
91 #define RAID6_Q_BAD 2
92 #define RAID6_PQ_BAD 3
94 /* Galois field tables */
95 extern const u8 raid6_gfmul[256][256] __attribute__((aligned(256)));
96 extern const u8 raid6_gfexp[256] __attribute__((aligned(256)));
97 extern const u8 raid6_gfinv[256] __attribute__((aligned(256)));
98 extern const u8 raid6_gfexi[256] __attribute__((aligned(256)));
100 /* Recovery routines */
101 void raid6_2data_recov(int disks, size_t bytes, int faila, int failb, void **ptrs);
102 void raid6_datap_recov(int disks, size_t bytes, int faila, void **ptrs);
103 void raid6_dual_recov(int disks, size_t bytes, int faila, int failb, void **ptrs);
105 /* Some definitions to allow code to be compiled for testing in userspace */
106 #ifndef __KERNEL__
108 # define jiffies raid6_jiffies()
109 # define printk printf
110 # define GFP_KERNEL 0
111 # define __get_free_pages(x,y) ((unsigned long)mmap(NULL, PAGE_SIZE << (y), PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0))
112 # define free_pages(x,y) munmap((void *)(x), (y)*PAGE_SIZE)
114 static inline void cpu_relax(void)
116 /* Nothing */
119 #undef HZ
120 #define HZ 1000
121 static inline uint32_t raid6_jiffies(void)
123 struct timeval tv;
124 gettimeofday(&tv, NULL);
125 return tv.tv_sec*1000 + tv.tv_usec/1000;
128 #endif /* ! __KERNEL__ */
130 #endif /* LINUX_RAID_RAID6_H */