blob: ce064e8ea644dd1acb3c2dd6a948e450266ba82f [file] [log] [blame]
Hank Janssenab057782009-07-13 15:19:28 -07001/*
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
Milan Dadok9fcfeab2009-10-28 23:23:50 +010028#include <linux/workqueue.h>
Bill Pemberton454f18a2009-07-27 16:47:24 -040029
30/* Defines */
Greg Kroah-Hartman0ccafb32009-08-19 16:16:21 -070031#define ALIGN_UP(value, align) (((value) & (align-1)) ? \
32 (((value) + (align-1)) & ~(align-1)) : \
33 (value))
34#define ALIGN_DOWN(value, align) ((value) & ~(align-1))
35#define NUM_PAGES_SPANNED(addr, len) ((ALIGN_UP(addr+len, PAGE_SIZE) - \
36 ALIGN_DOWN(addr, PAGE_SIZE)) >> \
37 PAGE_SHIFT)
Bill Pemberton454f18a2009-07-27 16:47:24 -040038
Greg Kroah-Hartman0ccafb32009-08-19 16:16:21 -070039#define LOWORD(dw) ((unsigned short)(dw))
40#define HIWORD(dw) ((unsigned short)(((unsigned int) (dw) >> 16) & 0xFFFF))
Hank Janssenab057782009-07-13 15:19:28 -070041
Greg Kroah-Hartmancaf26a32009-08-19 16:17:03 -070042struct hv_guid {
43 unsigned char data[16];
44};
Hank Janssenab057782009-07-13 15:19:28 -070045
Bill Pembertonaedb4442009-07-28 13:46:24 -040046struct osd_waitevent {
Greg Kroah-Hartman0ccafb32009-08-19 16:16:21 -070047 int condition;
Bill Pembertonaedb4442009-07-28 13:46:24 -040048 wait_queue_head_t event;
49};
50
Bill Pemberton454f18a2009-07-27 16:47:24 -040051/* Osd routines */
52
Greg Kroah-Hartmanbfc30aa2009-07-29 15:40:18 -070053extern void *osd_VirtualAllocExec(unsigned int size);
Hank Janssenab057782009-07-13 15:19:28 -070054
Greg Kroah-Hartmanbfc30aa2009-07-29 15:40:18 -070055extern void *osd_PageAlloc(unsigned int count);
Greg Kroah-Hartman0ccafb32009-08-19 16:16:21 -070056extern void osd_PageFree(void *page, unsigned int count);
Hank Janssenab057782009-07-13 15:19:28 -070057
Greg Kroah-Hartmanbfc30aa2009-07-29 15:40:18 -070058extern struct osd_waitevent *osd_WaitEventCreate(void);
59extern void osd_WaitEventSet(struct osd_waitevent *waitEvent);
60extern int osd_WaitEventWait(struct osd_waitevent *waitEvent);
Hank Janssenab057782009-07-13 15:19:28 -070061
Bill Pembertonaedb4442009-07-28 13:46:24 -040062/* If >0, waitEvent got signaled. If ==0, timeout. If < 0, error */
Greg Kroah-Hartman0ccafb32009-08-19 16:16:21 -070063extern int osd_WaitEventWaitEx(struct osd_waitevent *waitEvent,
64 u32 TimeoutInMs);
Hank Janssenab057782009-07-13 15:19:28 -070065
Bill Pembertonde65a382009-07-29 17:00:09 -040066int osd_schedule_callback(struct workqueue_struct *wq,
67 void (*func)(void *),
68 void *data);
Hank Janssenab057782009-07-13 15:19:28 -070069
Bill Pemberton454f18a2009-07-27 16:47:24 -040070#endif /* _OSD_H_ */