loader: remove shouting from ORB's variable name
[hvf.git] / cp / include / page.h
blob9a2880ce715ff309dcdd1f63d4ff77372ae0c88f
1 /*
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
5 * details.
6 */
8 #ifndef __PAGE_H
9 #define __PAGE_H
11 #include <list.h>
13 #define PAGE_SHIFT 12
14 #define PAGE_SIZE (1<<PAGE_SHIFT)
15 #define PAGE_MASK (PAGE_SIZE-1)
17 #define PAGE_INFO_BASE ((struct page*) 0x400000)
19 #define ZONE_NORMAL 0
20 #define ZONE_LOW 1
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
28 struct page {
29 union {
30 struct list_head buddy; /* buddy allocator list */
31 struct list_head guest; /* guest storage list */
36 * Externs
38 extern void init_pages(void);
41 * Static inlines
43 static inline struct page *page_num_to_ptr(u64 pnum)
45 struct page *base = PAGE_INFO_BASE;
47 return &base[pnum];
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
81 * is.
83 static inline u32 ADDR31(void *ptr)
85 u64 ip = (u64) ptr;
87 BUG_ON(ip & ~0x7fffffffull);
89 return (u32) ip;
92 static inline u64 ADDR64(void *ptr)
94 return (u64) ptr;
97 #endif