1136849Sscottl/* 2149871Sscottl * Copyright (c) 2004-2005 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. 25142988Sscottl * 26142988Sscottl * $FreeBSD: releng/10.2/sys/dev/hptmv/raid5n.h 190809 2009-04-07 16:38:25Z delphij $ 27136849Sscottl */ 28136849Sscottl#ifdef _RAID5N_ 29136849Sscottl 30136849Sscottl/* OS provided function, call only at initialization time */ 31136849Sscottlextern void * HPTLIBAPI os_alloc_page(_VBUS_ARG0); /* may be cached memory */ 32136849Sscottlextern void * HPTLIBAPI os_alloc_dma_page(_VBUS_ARG0); /* must be non-cached memory */ 33136849Sscottl/* implement if the driver can be unloaded */ 34136849Sscottlvoid HPTLIBAPI os_free_page(_VBUS_ARG void *p); 35136849Sscottlvoid HPTLIBAPI os_free_dma_page(_VBUS_ARG void *p); 36136849Sscottl 37136849Sscottltypedef void (* HPTLIBAPI xfer_done_fn)(_VBUS_ARG void *tag, int result); 38136849Sscottl 39136849Sscottl 40136849Sscottl#define DATAXFER_STACK_VAR 41136849Sscottl#define DATAXFER_INIT_ARG 0 42136849Sscottl 43136849Sscottl#define dataxfer_init(arg) 0 44136849Sscottl#define dataxfer_add_item(handle, host, cache, bytes, tocache) \ 45136849Sscottl if (tocache) memcpy((PUCHAR)(cache), (PUCHAR)(host), bytes); \ 46136849Sscottl else memcpy((PUCHAR)(host), (PUCHAR)(cache), bytes) 47136849Sscottl#define dataxfer_exec(handle, done, tag) done(_VBUS_P tag, 0) 48136849Sscottl#define dataxfer_poll() 49136849Sscottl 50136849Sscottl 51136849Sscottltypedef void (* HPTLIBAPI xor_done_fn)(_VBUS_ARG void *tag, int result); 52136849Sscottl 53136849Sscottl 54136849Sscottl#define XOR_STACK_VAR 55136849Sscottl#define XOR_INIT_ARG 0 56136849Sscottl 57136849Sscottl/* DoXor1, DoXor2 provided by platform dependent code */ 58136849Sscottlvoid HPTLIBAPI DoXor1(ULONG *p0, ULONG *p1, ULONG *p2, UINT nBytes); 59136849Sscottlvoid HPTLIBAPI DoXor2(ULONG *p0, ULONG *p2, UINT nBytes); 60136849Sscottl#define max_xor_way 2 61136849Sscottl#define xor_init(arg) 0 62136849Sscottl#define xor_add_item(handle, dest, src, nsrc, bytes) \ 63136849Sscottl do {\ 64190809Sdelphij if (((void**)(src))[0]==dest)\ 65190809Sdelphij DoXor2((PULONG)(dest), ((PULONG *)(src))[1], bytes);\ 66136849Sscottl else\ 67190809Sdelphij DoXor1((PULONG)(dest), ((PULONG *)(src))[0], ((PULONG *)(src))[1], bytes);\ 68136849Sscottl } while(0) 69136849Sscottl#define xor_exec(handle, done, tag) done(_VBUS_P tag, 0) 70136849Sscottl#define xor_poll() 71136849Sscottl 72136849Sscottl 73136849Sscottl/* set before calling init_raid5_memory */ 74136849Sscottlextern UINT num_raid5_pages; 75136849Sscottl 76136849Sscottl/* called by init.c */ 77136849Sscottlextern void HPTLIBAPI init_raid5_memory(_VBUS_ARG0); 78136849Sscottlextern void HPTLIBAPI free_raid5_memory(_VBUS_ARG0); 79136849Sscottl 80136849Sscottl/* asynchronous flush, may be called periodly */ 81136849Sscottlextern void HPTLIBAPI flush_stripe_cache(_VBUS_ARG0); 82136849Sscottlextern void HPTLIBAPI flush_raid5_async(PVDevice pArray, DPC_PROC done, void *arg); 83136849Sscottl 84136849Sscottl/* synchronous function called at shutdown */ 85136849Sscottlextern int HPTLIBAPI flush_raid5(PVDevice pArray); 86136849Sscottl 87136849Sscottlextern void HPTLIBAPI raid5_free(_VBUS_ARG PVDevice pArray); 88136849Sscottl 89136849Sscottlstruct free_heap_block { 90136849Sscottl struct free_heap_block *next; 91136849Sscottl}; 92136849Sscottl 93136849Sscottl#ifndef LIST_H_INCLUDED 94136849Sscottlstruct list_head { 95136849Sscottl struct list_head *next, *prev; 96136849Sscottl}; 97136849Sscottl#endif 98136849Sscottl 99136849Sscottlstruct free_page { 100136849Sscottl struct free_page *link; 101136849Sscottl}; 102136849Sscottl 103136849Sscottlstruct r5_global_data { 104136849Sscottl int enable_write_back; 105136849Sscottl struct list_head inactive_list; 106136849Sscottl struct list_head dirty_list; 107136849Sscottl struct list_head active_list; 108136849Sscottl#ifdef R5_CONTIG_CACHE 109136849Sscottl BUS_ADDR page_base_phys; 110136849Sscottl PUCHAR page_base_virt; 111136849Sscottl PUCHAR page_current; 112136849Sscottl#endif 113149871Sscottl struct free_heap_block *free_heap_slots[10]; 114136849Sscottl struct free_page *free_pages; 115136849Sscottl UINT num_free_pages; 116136849Sscottl UINT active_stripes; 117136849Sscottl UINT num_flushing; 118136849Sscottl PCommand cache_wait_list; 119149871Sscottl 120149871Sscottl LBA_T __start[MAX_MEMBERS]; 121149871Sscottl USHORT __sectors[MAX_MEMBERS]; 122136849Sscottl}; 123136849Sscottl 124136849Sscottl 125136849Sscottl#endif 126