Subversion Repositories HelenOS

Rev

Rev 977 | Rev 1064 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 977 Rev 1063
Line 24... Line 24...
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
-
 
29
/** Paging on AMD64
-
 
30
 *
-
 
31
 * The space is divided in positive numbers - userspace and
-
 
32
 * negative numbers - kernel space. The 'negative' space starting
-
 
33
 * with 0xffff800000000000 and ending with 0xffffffff80000000
-
 
34
 * (-2GB) is identically mapped physical memory. The area
-
 
35
 * (0xffffffff80000000 ... 0xffffffffffffffff is again identically
-
 
36
 * mapped first 2GB.
-
 
37
 *
-
 
38
 * ATTENTION - PA2KA(KA2PA(x)) != x if 'x' is in kernel
-
 
39
 */
-
 
40
 
29
#ifndef __amd64_PAGE_H__
41
#ifndef __amd64_PAGE_H__
30
#define __amd64_PAGE_H__
42
#define __amd64_PAGE_H__
31
 
43
 
32
#include <arch/mm/frame.h>
44
#include <arch/mm/frame.h>
33
 
45
 
Line 40... Line 52...
40
#  include <mm/page.h>
52
#  include <mm/page.h>
41
#  include <arch/types.h>
53
#  include <arch/types.h>
42
#endif
54
#endif
43
 
55
 
44
#ifndef __ASM__
56
#ifndef __ASM__
-
 
57
static inline __address ka2pa(__address x)
-
 
58
{
-
 
59
    if (x > 0xffffffff80000000)
-
 
60
        return x - 0xffffffff80000000;
-
 
61
    else
-
 
62
        return x - 0xffff800000000000;
-
 
63
}
-
 
64
/* Linker symbol */
-
 
65
extern int ktext_start;
-
 
66
extern int kdata_end;
-
 
67
static inline __address pa2ka(__address x)
-
 
68
{
-
 
69
    if (x >= ka2pa((__address)(&kdata_end)) || \
-
 
70
        x <= ka2pa((__address)&ktext_start))
-
 
71
        return x + 0xffff800000000000;
-
 
72
    else
-
 
73
        return x + 0xffffffff80000000;
-
 
74
}
-
 
75
# define KA2PA(x)      ka2pa((__address)x)
-
 
76
# define PA2KA(x)      pa2ka((__address)x)
45
# define KA2PA(x)      (((__address) (x)) - 0xffffffff80000000)
77
# define PA2KA_IDENT(x)      (((__address) (x)) + 0xffff800000000000)
46
# define PA2KA(x)      (((__address) (x)) + 0xffffffff80000000)
78
# define PA2KA_CODE(x)      (((__address) (x)) + 0xffffffff80000000)
47
#else
79
#else
48
# define KA2PA(x)      ((x) - 0xffffffff80000000)
80
# define KA2PA(x)      ((x) - 0xffffffff80000000)
49
# define PA2KA(x)      ((x) + 0xffffffff80000000)
81
# define PA2KA(x)      ((x) + 0xffffffff80000000)
-
 
82
# define PA2KA_DATA(x)      ((x) + 0xffff800000000000)
50
#endif
83
#endif
51
 
84
 
52
#define PTL0_ENTRIES_ARCH   512
85
#define PTL0_ENTRIES_ARCH   512
53
#define PTL1_ENTRIES_ARCH   512
86
#define PTL1_ENTRIES_ARCH   512
54
#define PTL2_ENTRIES_ARCH   512
87
#define PTL2_ENTRIES_ARCH   512