<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18702"></HEAD>
<BODY>
<DIV><FONT size=2 face=Arial>This patches moves shutter.h from
hw/mlx4/kernel/inc/ to inc/kernel<BR>Signed-off by: Alexander Naslednikov (xalex
at mellanox.com), <BR> Tzachi Dar (tzachid at
mellanox.com)<BR>Index:
hw/mlx4/kernel/inc/shutter.h<BR>===================================================================<BR>---
hw/mlx4/kernel/inc/shutter.h (revision 5435)<BR>+++
hw/mlx4/kernel/inc/shutter.h (working copy)<BR>@@ -1,119 +0,0
@@<BR>-/*<BR>- * Copyright (c) 2005 SilverStorm Technologies. All rights
reserved.<BR>- *<BR>- * This software is available to you under the OpenIB.org
BSD license<BR>- * below:<BR>- *<BR>- * Redistribution
and use in source and binary forms, with or<BR>- *
without modification, are permitted provided that the following<BR>-
* conditions are met:<BR>- *<BR>-
* - Redistributions of source code must retain the
above<BR>- * copyright notice, this
list of conditions and the following<BR>-
* disclaimer.<BR>- *<BR>-
* - Redistributions in binary form must reproduce
the above<BR>- * copyright notice,
this list of conditions and the following<BR>-
* disclaimer in the documentation
and/or other materials<BR>- * provided
with the distribution.<BR>- *<BR>- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT
WARRANTY OF ANY KIND,<BR>- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE WARRANTIES OF<BR>- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
AND<BR>- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS<BR>- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN<BR>- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN<BR>-
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<BR>- *
SOFTWARE.<BR>- *<BR>- * $Id: shutter.h 1611 2006-08-20 14:48:55Z sleybo $<BR>-
*/<BR>-<BR>-<BR>-#pragma once<BR>-<BR>-<BR>-// Define the max numbers of
operations that can be simultaniously done<BR>-#define
MAX_OPERATIONS 0x10000000<BR>-<BR>-typedef struct _shutter_t
{<BR>- long cnt;<BR>- KEVENT
event;<BR>-<BR>-} shutter_t;<BR>-<BR>-static inline void
shutter_init(shutter_t* p_shutter)<BR>-{<BR>- p_shutter->cnt =
0;<BR>- KeInitializeEvent( &p_shutter->event, SynchronizationEvent,
FALSE );<BR>-}<BR>-<BR>-<BR>-static inline void shutter_sub(shutter_t *
p_shutter,long Val)<BR>-{<BR>- long res =
0;<BR>- ASSERT(Val < 0);<BR>- res =
InterlockedExchangeAdd( &p_shutter->cnt,Val );<BR>- if ((res+Val) ==
-MAX_OPERATIONS)<BR>- KeSetEvent( &p_shutter->event, 0, FALSE
);<BR>-}<BR>-<BR>-// if RC == true, one can proceed<BR>-static inline BOOLEAN
shutter_add(shutter_t * p_shutter,long Val)<BR>-{<BR>- long
res = 0;<BR>- ASSERT(Val > 0);<BR>- res =
InterlockedExchangeAdd(&p_shutter->cnt,Val); <BR>- ASSERT(res <=
MAX_OPERATIONS);<BR>- if (res < 0
)<BR>- {
<BR>- shutter_sub(p_shutter, -Val);<BR>- return
FALSE;<BR>- }<BR>- return TRUE;<BR>-}<BR>-<BR>-static inline void
shutter_loose(shutter_t * p_shutter)<BR>-{<BR>- long res =
InterlockedDecrement( &p_shutter->cnt );<BR>- if (res ==
-MAX_OPERATIONS)<BR>- KeSetEvent( &p_shutter->event, 0, FALSE
);<BR>-}<BR>-<BR>-// if RC > 0, one can proceed<BR>-static inline int
shutter_use(shutter_t * p_shutter)<BR>-{<BR>- long res =
InterlockedIncrement( &p_shutter->cnt ); <BR>- ASSERT(res <=
MAX_OPERATIONS);<BR>- if (res <= 0 ) <BR>- shutter_loose(
p_shutter ); // The object is in shutdown<BR>- return
res;<BR>-}<BR>-<BR>-<BR>-static inline void shutter_shut(shutter_t *
p_shutter)<BR>-{<BR>- long res = 0;<BR>-
//<BR>- // ASSERT not calling shu
twice.<BR>- //<BR>- ASSERT(p_shutter->cnt
- MAX_OPERATIONS >= (-MAX_OPERATIONS));<BR>-
<BR>- // Mark the counter as locked<BR>- res =
InterlockedExchangeAdd(&p_shutter->cnt,
-MAX_OPERATIONS);<BR>- ASSERT(res >= 0);<BR>- if (res)
<BR>- // We are now waiting for the object to reach
-MAX_OPERATIONS<BR>- KeWaitForSingleObject( &p_shutter->event,
Executive, KernelMode, FALSE, NULL );<BR>-}<BR>-<BR>-static inline void
shutter_alive(shutter_t * p_shutter)<BR>-{<BR>- long res =
0;<BR>- <BR>- // Mark the counter as alive<BR>- res
= InterlockedExchangeAdd(&p_shutter->cnt,
MAX_OPERATIONS);<BR>- ASSERT(res <
0);<BR>-}<BR>-<BR>-<BR></FONT></DIV></BODY></HTML>