~n-muench/ubuntu/oneiric/open-vm-tools/open-vm-tools.fix-836277

« back to all changes in this revision

Viewing changes to modules/linux/vmci/compat_page.h

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2008-08-15 21:21:40 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080815212140-05fhxj8wroosysmj
Tags: 2008.08.08-109361-1ubuntu1
* Merge from Debian unstable (LP: #258393), remaining Ubuntu change:
  - add ubuntu_toolchain_FTBFS.dpatch patch, fix FTBFS
* Update ubuntu_toolchain_FTBFS.dpatch patch for the new version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*********************************************************
 
2
 * Copyright (C) 2002 VMware, Inc. All rights reserved.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License as published by the
 
6
 * Free Software Foundation version 2 and no later version.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
10
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
11
 * for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License along
 
14
 * with this program; if not, write to the Free Software Foundation, Inc.,
 
15
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
16
 *
 
17
 *********************************************************/
 
18
 
 
19
#ifndef __COMPAT_PAGE_H__
 
20
#   define __COMPAT_PAGE_H__
 
21
 
 
22
 
 
23
#include <linux/mm.h>
 
24
#include <asm/page.h>
 
25
 
 
26
 
 
27
/* The pfn_to_page() API appeared in 2.5.14 and changed to function during 2.6.x */
 
28
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) && !defined(pfn_to_page)
 
29
#   define pfn_to_page(_pfn) (mem_map + (_pfn))
 
30
#   define page_to_pfn(_page) ((_page) - mem_map)
 
31
#endif
 
32
 
 
33
 
 
34
/* The virt_to_page() API appeared in 2.4.0 --hpreg */
 
35
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0) && !defined(virt_to_page)
 
36
#   define virt_to_page(_kvAddr) pfn_to_page(MAP_NR(_kvAddr))
 
37
#endif
 
38
 
 
39
 
 
40
/*
 
41
 * The get_order() API appeared at some point in 2.3.x, and was then backported
 
42
 * in 2.2.17-21mdk and in the stock 2.2.18. Because we can only detect its
 
43
 * definition through makefile tricks, we provide our own for now --hpreg
 
44
 */
 
45
static inline int
 
46
compat_get_order(unsigned long size) // IN
 
47
{
 
48
   int order;
 
49
 
 
50
   size = (size - 1) >> (PAGE_SHIFT - 1);
 
51
   order = -1;
 
52
   do {
 
53
      size >>= 1;
 
54
      order++;
 
55
   } while (size);
 
56
 
 
57
   return order;
 
58
}
 
59
 
 
60
/* 
 
61
 * BUG() was added to <asm/page.h> in 2.2.18, and was moved to <asm/bug.h>
 
62
 * in 2.5.58.
 
63
 * 
 
64
 * XXX: Technically, this belongs in some sort of "compat_asm_page.h" file, but
 
65
 * since our compatibility wrappers don't distinguish between <asm/xxx.h> and
 
66
 * <linux/xxx.h>, putting it here is reasonable.
 
67
 */
 
68
#ifndef BUG
 
69
#define BUG() do {                                                            \
 
70
   printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__);                      \
 
71
  __asm__ __volatile__(".byte 0x0f,0x0b");                                    \
 
72
} while (0)
 
73
#endif
 
74
 
 
75
#endif /* __COMPAT_PAGE_H__ */