1718cf2ccSPedro F. Giffuni /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3718cf2ccSPedro F. Giffuni * 4d2bd3ab9SScott Long * Copyright (c) 2004-2005 HighPoint Technologies, Inc. 51713e81bSScott Long * All rights reserved. 61713e81bSScott Long * 71713e81bSScott Long * Redistribution and use in source and binary forms, with or without 81713e81bSScott Long * modification, are permitted provided that the following conditions 91713e81bSScott Long * are met: 101713e81bSScott Long * 1. Redistributions of source code must retain the above copyright 111713e81bSScott Long * notice, this list of conditions and the following disclaimer. 121713e81bSScott Long * 2. Redistributions in binary form must reproduce the above copyright 131713e81bSScott Long * notice, this list of conditions and the following disclaimer in the 141713e81bSScott Long * documentation and/or other materials provided with the distribution. 151713e81bSScott Long * 161713e81bSScott Long * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 171713e81bSScott Long * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 181713e81bSScott Long * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 191713e81bSScott Long * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 201713e81bSScott Long * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 211713e81bSScott Long * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 221713e81bSScott Long * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 231713e81bSScott Long * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 241713e81bSScott Long * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 251713e81bSScott Long * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 261713e81bSScott Long * SUCH DAMAGE. 271713e81bSScott Long */ 281713e81bSScott Long #ifdef _RAID5N_ 291713e81bSScott Long 301713e81bSScott Long /* OS provided function, call only at initialization time */ 311713e81bSScott Long extern void * HPTLIBAPI os_alloc_page(_VBUS_ARG0); /* may be cached memory */ 321713e81bSScott Long extern void * HPTLIBAPI os_alloc_dma_page(_VBUS_ARG0); /* must be non-cached memory */ 331713e81bSScott Long /* implement if the driver can be unloaded */ 341713e81bSScott Long void HPTLIBAPI os_free_page(_VBUS_ARG void *p); 351713e81bSScott Long void HPTLIBAPI os_free_dma_page(_VBUS_ARG void *p); 361713e81bSScott Long 371713e81bSScott Long typedef void (* HPTLIBAPI xfer_done_fn)(_VBUS_ARG void *tag, int result); 381713e81bSScott Long 391713e81bSScott Long 401713e81bSScott Long #define DATAXFER_STACK_VAR 411713e81bSScott Long #define DATAXFER_INIT_ARG 0 421713e81bSScott Long 431713e81bSScott Long #define dataxfer_init(arg) 0 441713e81bSScott Long #define dataxfer_add_item(handle, host, cache, bytes, tocache) \ 451713e81bSScott Long if (tocache) memcpy((PUCHAR)(cache), (PUCHAR)(host), bytes); \ 461713e81bSScott Long else memcpy((PUCHAR)(host), (PUCHAR)(cache), bytes) 471713e81bSScott Long #define dataxfer_exec(handle, done, tag) done(_VBUS_P tag, 0) 481713e81bSScott Long #define dataxfer_poll() 491713e81bSScott Long 501713e81bSScott Long 511713e81bSScott Long typedef void (* HPTLIBAPI xor_done_fn)(_VBUS_ARG void *tag, int result); 521713e81bSScott Long 531713e81bSScott Long 541713e81bSScott Long #define XOR_STACK_VAR 551713e81bSScott Long #define XOR_INIT_ARG 0 561713e81bSScott Long 571713e81bSScott Long /* DoXor1, DoXor2 provided by platform dependent code */ 581713e81bSScott Long void HPTLIBAPI DoXor1(ULONG *p0, ULONG *p1, ULONG *p2, UINT nBytes); 591713e81bSScott Long void HPTLIBAPI DoXor2(ULONG *p0, ULONG *p2, UINT nBytes); 601713e81bSScott Long #define max_xor_way 2 611713e81bSScott Long #define xor_init(arg) 0 621713e81bSScott Long #define xor_add_item(handle, dest, src, nsrc, bytes) \ 631713e81bSScott Long do {\ 6464470755SXin LI if (((void**)(src))[0]==dest)\ 6564470755SXin LI DoXor2((PULONG)(dest), ((PULONG *)(src))[1], bytes);\ 661713e81bSScott Long else\ 6764470755SXin LI DoXor1((PULONG)(dest), ((PULONG *)(src))[0], ((PULONG *)(src))[1], bytes);\ 681713e81bSScott Long } while(0) 691713e81bSScott Long #define xor_exec(handle, done, tag) done(_VBUS_P tag, 0) 701713e81bSScott Long #define xor_poll() 711713e81bSScott Long 721713e81bSScott Long 731713e81bSScott Long /* set before calling init_raid5_memory */ 741713e81bSScott Long extern UINT num_raid5_pages; 751713e81bSScott Long 761713e81bSScott Long /* called by init.c */ 771713e81bSScott Long extern void HPTLIBAPI init_raid5_memory(_VBUS_ARG0); 781713e81bSScott Long extern void HPTLIBAPI free_raid5_memory(_VBUS_ARG0); 791713e81bSScott Long 801713e81bSScott Long /* asynchronous flush, may be called periodly */ 811713e81bSScott Long extern void HPTLIBAPI flush_stripe_cache(_VBUS_ARG0); 821713e81bSScott Long extern void HPTLIBAPI flush_raid5_async(PVDevice pArray, DPC_PROC done, void *arg); 831713e81bSScott Long 841713e81bSScott Long /* synchronous function called at shutdown */ 851713e81bSScott Long extern int HPTLIBAPI flush_raid5(PVDevice pArray); 861713e81bSScott Long 871713e81bSScott Long extern void HPTLIBAPI raid5_free(_VBUS_ARG PVDevice pArray); 881713e81bSScott Long 891713e81bSScott Long struct free_heap_block { 901713e81bSScott Long struct free_heap_block *next; 911713e81bSScott Long }; 921713e81bSScott Long 931713e81bSScott Long #ifndef LIST_H_INCLUDED 941713e81bSScott Long struct list_head { 951713e81bSScott Long struct list_head *next, *prev; 961713e81bSScott Long }; 971713e81bSScott Long #endif 981713e81bSScott Long 991713e81bSScott Long struct free_page { 1001713e81bSScott Long struct free_page *link; 1011713e81bSScott Long }; 1021713e81bSScott Long 1031713e81bSScott Long struct r5_global_data { 1041713e81bSScott Long int enable_write_back; 1051713e81bSScott Long struct list_head inactive_list; 1061713e81bSScott Long struct list_head dirty_list; 1071713e81bSScott Long struct list_head active_list; 1081713e81bSScott Long #ifdef R5_CONTIG_CACHE 1091713e81bSScott Long BUS_ADDR page_base_phys; 1101713e81bSScott Long PUCHAR page_base_virt; 1111713e81bSScott Long PUCHAR page_current; 1121713e81bSScott Long #endif 113d2bd3ab9SScott Long struct free_heap_block *free_heap_slots[10]; 1141713e81bSScott Long struct free_page *free_pages; 1151713e81bSScott Long UINT num_free_pages; 1161713e81bSScott Long UINT active_stripes; 1171713e81bSScott Long UINT num_flushing; 1181713e81bSScott Long PCommand cache_wait_list; 119d2bd3ab9SScott Long 120d2bd3ab9SScott Long LBA_T __start[MAX_MEMBERS]; 121d2bd3ab9SScott Long USHORT __sectors[MAX_MEMBERS]; 1221713e81bSScott Long }; 1231713e81bSScott Long 1241713e81bSScott Long 1251713e81bSScott Long #endif 126