2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2004-2005 HighPoint Technologies, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 /* OS provided function, call only at initialization time */
33 extern void * HPTLIBAPI os_alloc_page(_VBUS_ARG0); /* may be cached memory */
34 extern void * HPTLIBAPI os_alloc_dma_page(_VBUS_ARG0); /* must be non-cached memory */
35 /* implement if the driver can be unloaded */
36 void HPTLIBAPI os_free_page(_VBUS_ARG void *p);
37 void HPTLIBAPI os_free_dma_page(_VBUS_ARG void *p);
39 typedef void (* HPTLIBAPI xfer_done_fn)(_VBUS_ARG void *tag, int result);
42 #define DATAXFER_STACK_VAR
43 #define DATAXFER_INIT_ARG 0
45 #define dataxfer_init(arg) 0
46 #define dataxfer_add_item(handle, host, cache, bytes, tocache) \
47 if (tocache) memcpy((PUCHAR)(cache), (PUCHAR)(host), bytes); \
48 else memcpy((PUCHAR)(host), (PUCHAR)(cache), bytes)
49 #define dataxfer_exec(handle, done, tag) done(_VBUS_P tag, 0)
50 #define dataxfer_poll()
53 typedef void (* HPTLIBAPI xor_done_fn)(_VBUS_ARG void *tag, int result);
57 #define XOR_INIT_ARG 0
59 /* DoXor1, DoXor2 provided by platform dependent code */
60 void HPTLIBAPI DoXor1(ULONG *p0, ULONG *p1, ULONG *p2, UINT nBytes);
61 void HPTLIBAPI DoXor2(ULONG *p0, ULONG *p2, UINT nBytes);
63 #define xor_init(arg) 0
64 #define xor_add_item(handle, dest, src, nsrc, bytes) \
66 if (((void**)(src))[0]==dest)\
67 DoXor2((PULONG)(dest), ((PULONG *)(src))[1], bytes);\
69 DoXor1((PULONG)(dest), ((PULONG *)(src))[0], ((PULONG *)(src))[1], bytes);\
71 #define xor_exec(handle, done, tag) done(_VBUS_P tag, 0)
75 /* set before calling init_raid5_memory */
76 extern UINT num_raid5_pages;
78 /* called by init.c */
79 extern void HPTLIBAPI init_raid5_memory(_VBUS_ARG0);
80 extern void HPTLIBAPI free_raid5_memory(_VBUS_ARG0);
82 /* asynchronous flush, may be called periodly */
83 extern void HPTLIBAPI flush_stripe_cache(_VBUS_ARG0);
84 extern void HPTLIBAPI flush_raid5_async(PVDevice pArray, DPC_PROC done, void *arg);
86 /* synchronous function called at shutdown */
87 extern int HPTLIBAPI flush_raid5(PVDevice pArray);
89 extern void HPTLIBAPI raid5_free(_VBUS_ARG PVDevice pArray);
91 struct free_heap_block {
92 struct free_heap_block *next;
95 #ifndef LIST_H_INCLUDED
97 struct list_head *next, *prev;
102 struct free_page *link;
105 struct r5_global_data {
106 int enable_write_back;
107 struct list_head inactive_list;
108 struct list_head dirty_list;
109 struct list_head active_list;
110 #ifdef R5_CONTIG_CACHE
111 BUS_ADDR page_base_phys;
112 PUCHAR page_base_virt;
115 struct free_heap_block *free_heap_slots[10];
116 struct free_page *free_pages;
120 PCommand cache_wait_list;
122 LBA_T __start[MAX_MEMBERS];
123 USHORT __sectors[MAX_MEMBERS];