raid5n.h revision 136849
1136849Sscottl/* 2136849Sscottl * Copyright (c) 2003-2004 HighPoint Technologies, Inc. 3136849Sscottl * All rights reserved. 4136849Sscottl * 5136849Sscottl * Redistribution and use in source and binary forms, with or without 6136849Sscottl * modification, are permitted provided that the following conditions 7136849Sscottl * are met: 8136849Sscottl * 1. Redistributions of source code must retain the above copyright 9136849Sscottl * notice, this list of conditions and the following disclaimer. 10136849Sscottl * 2. Redistributions in binary form must reproduce the above copyright 11136849Sscottl * notice, this list of conditions and the following disclaimer in the 12136849Sscottl * documentation and/or other materials provided with the distribution. 13136849Sscottl * 14136849Sscottl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15136849Sscottl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16136849Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17136849Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18136849Sscottl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19136849Sscottl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20136849Sscottl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21136849Sscottl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22136849Sscottl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23136849Sscottl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24136849Sscottl * SUCH DAMAGE. 25136849Sscottl */ 26136849Sscottl#ifdef _RAID5N_ 27136849Sscottl 28136849Sscottl/* OS provided function, call only at initialization time */ 29136849Sscottlextern void * HPTLIBAPI os_alloc_page(_VBUS_ARG0); /* may be cached memory */ 30136849Sscottlextern void * HPTLIBAPI os_alloc_dma_page(_VBUS_ARG0); /* must be non-cached memory */ 31136849Sscottl/* implement if the driver can be unloaded */ 32136849Sscottlvoid HPTLIBAPI os_free_page(_VBUS_ARG void *p); 33136849Sscottlvoid HPTLIBAPI os_free_dma_page(_VBUS_ARG void *p); 34136849Sscottl 35136849Sscottltypedef void (* HPTLIBAPI xfer_done_fn)(_VBUS_ARG void *tag, int result); 36136849Sscottl 37136849Sscottl 38136849Sscottl#define DATAXFER_STACK_VAR 39136849Sscottl#define DATAXFER_INIT_ARG 0 40136849Sscottl 41136849Sscottl#define dataxfer_init(arg) 0 42136849Sscottl#define dataxfer_add_item(handle, host, cache, bytes, tocache) \ 43136849Sscottl if (tocache) memcpy((PUCHAR)(cache), (PUCHAR)(host), bytes); \ 44136849Sscottl else memcpy((PUCHAR)(host), (PUCHAR)(cache), bytes) 45136849Sscottl#define dataxfer_exec(handle, done, tag) done(_VBUS_P tag, 0) 46136849Sscottl#define dataxfer_poll() 47136849Sscottl 48136849Sscottl 49136849Sscottltypedef void (* HPTLIBAPI xor_done_fn)(_VBUS_ARG void *tag, int result); 50136849Sscottl 51136849Sscottl 52136849Sscottl#define XOR_STACK_VAR 53136849Sscottl#define XOR_INIT_ARG 0 54136849Sscottl 55136849Sscottl/* DoXor1, DoXor2 provided by platform dependent code */ 56136849Sscottlvoid HPTLIBAPI DoXor1(ULONG *p0, ULONG *p1, ULONG *p2, UINT nBytes); 57136849Sscottlvoid HPTLIBAPI DoXor2(ULONG *p0, ULONG *p2, UINT nBytes); 58136849Sscottl#define max_xor_way 2 59136849Sscottl#define xor_init(arg) 0 60136849Sscottl#define xor_add_item(handle, dest, src, nsrc, bytes) \ 61136849Sscottl do {\ 62136849Sscottl if (((void**)src)[0]==dest)\ 63136849Sscottl DoXor2((PULONG)(dest), ((PULONG *)src)[1], bytes);\ 64136849Sscottl else\ 65136849Sscottl DoXor1((PULONG)(dest), ((PULONG *)src)[0], ((PULONG *)src)[1], bytes);\ 66136849Sscottl } while(0) 67136849Sscottl#define xor_exec(handle, done, tag) done(_VBUS_P tag, 0) 68136849Sscottl#define xor_poll() 69136849Sscottl 70136849Sscottl 71136849Sscottl/* set before calling init_raid5_memory */ 72136849Sscottlextern UINT num_raid5_pages; 73136849Sscottl 74136849Sscottl/* called by init.c */ 75136849Sscottlextern void HPTLIBAPI init_raid5_memory(_VBUS_ARG0); 76136849Sscottlextern void HPTLIBAPI free_raid5_memory(_VBUS_ARG0); 77136849Sscottl 78136849Sscottl/* asynchronous flush, may be called periodly */ 79136849Sscottlextern void HPTLIBAPI flush_stripe_cache(_VBUS_ARG0); 80136849Sscottlextern void HPTLIBAPI flush_raid5_async(PVDevice pArray, DPC_PROC done, void *arg); 81136849Sscottl 82136849Sscottl/* synchronous function called at shutdown */ 83136849Sscottlextern int HPTLIBAPI flush_raid5(PVDevice pArray); 84136849Sscottl 85136849Sscottlextern void HPTLIBAPI raid5_free(_VBUS_ARG PVDevice pArray); 86136849Sscottl 87136849Sscottlstruct free_heap_block { 88136849Sscottl struct free_heap_block *next; 89136849Sscottl}; 90136849Sscottl 91136849Sscottl#ifndef LIST_H_INCLUDED 92136849Sscottlstruct list_head { 93136849Sscottl struct list_head *next, *prev; 94136849Sscottl}; 95136849Sscottl#endif 96136849Sscottl 97136849Sscottlstruct free_page { 98136849Sscottl struct free_page *link; 99136849Sscottl}; 100136849Sscottl 101136849Sscottlstruct r5_global_data { 102136849Sscottl int enable_write_back; 103136849Sscottl struct list_head inactive_list; 104136849Sscottl struct list_head dirty_list; 105136849Sscottl struct list_head active_list; 106136849Sscottl#ifdef R5_CONTIG_CACHE 107136849Sscottl BUS_ADDR page_base_phys; 108136849Sscottl PUCHAR page_base_virt; 109136849Sscottl PUCHAR page_current; 110136849Sscottl#endif 111136849Sscottl struct free_heap_block *free_heap_slots[8]; 112136849Sscottl struct free_page *free_pages; 113136849Sscottl UINT num_free_pages; 114136849Sscottl UINT active_stripes; 115136849Sscottl UINT num_flushing; 116136849Sscottl PCommand cache_wait_list; 117136849Sscottl}; 118136849Sscottl 119136849Sscottl 120136849Sscottl#endif 121