2 * (C) Copyright 2007-2011 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * This file is released under the GPLv2. See the COPYING file for more
14 #define PAGE_SIZE (1<<PAGE_SHIFT)
15 #define PAGE_MASK (PAGE_SIZE-1)
17 #define PAGE_INFO_BASE ((struct page*) 0x400000)
22 #define ZONE_NORMAL_MAX_ORDER (64-PAGE_SHIFT)
23 #define ZONE_LOW_MAX_ORDER (31-PAGE_SHIFT)
26 * This structure describes a page of memory
30 struct list_head buddy
; /* buddy allocator list */
31 struct list_head guest
; /* guest storage list */
38 extern void init_pages(void);
43 static inline struct page
*page_num_to_ptr(u64 pnum
)
45 struct page
*base
= PAGE_INFO_BASE
;
50 static inline void *page_to_addr(struct page
*page
)
52 u64 pagenum
= (((u64
) page
) - ((u64
) PAGE_INFO_BASE
)) / sizeof(struct page
);
54 return (void*) (pagenum
<< PAGE_SHIFT
);
57 static inline struct page
*addr_to_page(void *addr
)
59 struct page
*base
= PAGE_INFO_BASE
;
61 return &base
[((u64
) addr
) >> PAGE_SHIFT
];
64 static inline int IS_LOW_ZONE(struct page
*page
)
66 return ((u64
) page_to_addr(page
)) < (2UL*1024*1024*1024);
69 static inline int ZONE_TYPE(struct page
*page
)
71 return IS_LOW_ZONE(page
) ? ZONE_LOW
: ZONE_NORMAL
;
75 * This should be as simple as a cast, but unfortunately, the BUG_ON check
76 * is there to make sure we never submit a truncated address to the channels
78 * In the future, the io code should check if IDA is necessary, and in that
79 * case allocate an IDAL & set the IDA ccw flag. Other parts of the system
80 * that require 31-bit address should do whatever their equivalent action
83 static inline u32
ADDR31(void *ptr
)
87 BUG_ON(ip
& ~0x7fffffffull
);
92 static inline u64
ADDR64(void *ptr
)