]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/hv/osd.h
staging/hv/osd: don't reimplement ALIGN macro
[karo-tx-linux.git] / drivers / staging / hv / 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 #include <linux/kernel.h>
29 #include <linux/workqueue.h>
30
31 /* Defines */
32 #define NUM_PAGES_SPANNED(addr, len)    ((PAGE_ALIGN(addr + len) >> PAGE_SHIFT) - \
33                                         (addr >> PAGE_SHIFT))
34
35 #define LOWORD(dw)      ((unsigned short)(dw))
36 #define HIWORD(dw)      ((unsigned short)(((unsigned int) (dw) >> 16) & 0xFFFF))
37
38 struct hv_guid {
39         unsigned char data[16];
40 };
41
42 struct osd_waitevent {
43         int condition;
44         wait_queue_head_t event;
45 };
46
47 /* Osd routines */
48
49 extern void *osd_virtual_alloc_exec(unsigned int size);
50
51 extern void *osd_page_alloc(unsigned int count);
52 extern void osd_page_free(void *page, unsigned int count);
53
54 extern struct osd_waitevent *osd_waitevent_create(void);
55 extern void osd_waitevent_set(struct osd_waitevent *wait_event);
56 extern int osd_waitevent_wait(struct osd_waitevent *wait_event);
57
58 /* If >0, wait_event got signaled. If ==0, timeout. If < 0, error */
59 extern int osd_waitevent_waitex(struct osd_waitevent *wait_event,
60                                u32 timeout_in_ms);
61
62 #endif /* _OSD_H_ */