Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 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 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 28 | |
| 29 | /* Defines */ |
Greg Kroah-Hartman | 0ccafb3 | 2009-08-19 16:16:21 -0700 | [diff] [blame] | 30 | #define ALIGN_UP(value, align) (((value) & (align-1)) ? \ |
| 31 | (((value) + (align-1)) & ~(align-1)) : \ |
| 32 | (value)) |
| 33 | #define ALIGN_DOWN(value, align) ((value) & ~(align-1)) |
| 34 | #define NUM_PAGES_SPANNED(addr, len) ((ALIGN_UP(addr+len, PAGE_SIZE) - \ |
| 35 | ALIGN_DOWN(addr, PAGE_SIZE)) >> \ |
| 36 | PAGE_SHIFT) |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 37 | |
Greg Kroah-Hartman | 0ccafb3 | 2009-08-19 16:16:21 -0700 | [diff] [blame] | 38 | #define LOWORD(dw) ((unsigned short)(dw)) |
| 39 | #define HIWORD(dw) ((unsigned short)(((unsigned int) (dw) >> 16) & 0xFFFF)) |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 40 | |
Greg Kroah-Hartman | caf26a3 | 2009-08-19 16:17:03 -0700 | [diff] [blame] | 41 | struct hv_guid { |
| 42 | unsigned char data[16]; |
| 43 | }; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 44 | |
Bill Pemberton | aedb444 | 2009-07-28 13:46:24 -0400 | [diff] [blame] | 45 | struct osd_waitevent { |
Greg Kroah-Hartman | 0ccafb3 | 2009-08-19 16:16:21 -0700 | [diff] [blame] | 46 | int condition; |
Bill Pemberton | aedb444 | 2009-07-28 13:46:24 -0400 | [diff] [blame] | 47 | wait_queue_head_t event; |
| 48 | }; |
| 49 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 50 | /* Osd routines */ |
| 51 | |
Greg Kroah-Hartman | bfc30aa | 2009-07-29 15:40:18 -0700 | [diff] [blame] | 52 | extern void *osd_VirtualAllocExec(unsigned int size); |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 53 | |
Greg Kroah-Hartman | bfc30aa | 2009-07-29 15:40:18 -0700 | [diff] [blame] | 54 | extern void *osd_PageAlloc(unsigned int count); |
Greg Kroah-Hartman | 0ccafb3 | 2009-08-19 16:16:21 -0700 | [diff] [blame] | 55 | extern void osd_PageFree(void *page, unsigned int count); |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 56 | |
Greg Kroah-Hartman | bfc30aa | 2009-07-29 15:40:18 -0700 | [diff] [blame] | 57 | extern struct osd_waitevent *osd_WaitEventCreate(void); |
| 58 | extern void osd_WaitEventSet(struct osd_waitevent *waitEvent); |
| 59 | extern int osd_WaitEventWait(struct osd_waitevent *waitEvent); |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 60 | |
Bill Pemberton | aedb444 | 2009-07-28 13:46:24 -0400 | [diff] [blame] | 61 | /* If >0, waitEvent got signaled. If ==0, timeout. If < 0, error */ |
Greg Kroah-Hartman | 0ccafb3 | 2009-08-19 16:16:21 -0700 | [diff] [blame] | 62 | extern int osd_WaitEventWaitEx(struct osd_waitevent *waitEvent, |
| 63 | u32 TimeoutInMs); |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 64 | |
Bill Pemberton | de65a38 | 2009-07-29 17:00:09 -0400 | [diff] [blame] | 65 | int osd_schedule_callback(struct workqueue_struct *wq, |
| 66 | void (*func)(void *), |
| 67 | void *data); |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 68 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 69 | #endif /* _OSD_H_ */ |