]> Pileus Git - ~andy/linux/blob - drivers/staging/hv/include/osd.h
Staging: hv: remove timer wrapper functions
[~andy/linux] / drivers / staging / hv / include / osd.h
1 /*
2  *
3  * Copyright (c) 2009, Microsoft Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16  * Place - Suite 330, Boston, MA 02111-1307 USA.
17  *
18  * Authors:
19  *   Haiyang Zhang <haiyangz@microsoft.com>
20  *   Hank Janssen  <hjanssen@microsoft.com>
21  *
22  */
23
24
25 #ifndef _OSD_H_
26 #define _OSD_H_
27
28
29 /* Defines */
30
31
32
33 #define ALIGN_UP(value, align)                  ( ((value) & (align-1))? ( ((value) + (align-1)) & ~(align-1) ): (value) )
34 #define ALIGN_DOWN(value, align)                ( (value) & ~(align-1) )
35 #define NUM_PAGES_SPANNED(addr, len)    ( (ALIGN_UP(addr+len, PAGE_SIZE) - ALIGN_DOWN(addr, PAGE_SIZE)) >> PAGE_SHIFT )
36
37 #define LOWORD(dw)              ((unsigned short) (dw))
38 #define HIWORD(dw)              ((unsigned short) (((unsigned int) (dw) >> 16) & 0xFFFF))
39
40 typedef struct _DLIST_ENTRY {
41    struct _DLIST_ENTRY *Flink;
42    struct _DLIST_ENTRY *Blink;
43 } DLIST_ENTRY;
44
45
46 /* Other types */
47
48 /* typedef unsigned char                GUID[16]; */
49
50 typedef struct {
51         unsigned char   Data[16];
52 } GUID;
53
54 struct osd_waitevent {
55         int     condition;
56         wait_queue_head_t event;
57 };
58
59 /* Osd routines */
60
61 extern void *osd_VirtualAllocExec(unsigned int size);
62
63 extern void *osd_PageAlloc(unsigned int count);
64 extern void osd_PageFree(void* page, unsigned int count);
65
66 extern struct osd_waitevent *osd_WaitEventCreate(void);
67 extern void osd_WaitEventSet(struct osd_waitevent *waitEvent);
68 extern int osd_WaitEventWait(struct osd_waitevent *waitEvent);
69
70 /* If >0, waitEvent got signaled. If ==0, timeout. If < 0, error */
71 extern int osd_WaitEventWaitEx(struct osd_waitevent *waitEvent, u32 TimeoutInMs);
72
73
74 int osd_schedule_callback(struct workqueue_struct *wq,
75                           void (*func)(void *),
76                           void *data);
77
78 #endif /* _OSD_H_ */