Rev 1787 | Rev 2028 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1787 | Rev 2021 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | #include <mm/as.h> |
32 | #include <mm/as.h> |
33 | #include <arch/mm/page.h> |
33 | #include <arch/mm/page.h> |
34 | #include <arch/types.h> |
34 | #include <arch/types.h> |
35 | #include <debug.h> |
35 | #include <debug.h> |
36 | 36 | ||
- | 37 | #ifdef CONFIG_BENCH |
|
- | 38 | #include <arch/cycle.h> |
|
- | 39 | #endif |
|
- | 40 | ||
37 | #define PAGE0 0x10000000 |
41 | #define PAGE0 0x10000000 |
38 | #define PAGE1 (PAGE0+PAGE_SIZE) |
42 | #define PAGE1 (PAGE0+PAGE_SIZE) |
39 | 43 | ||
40 | #define VALUE0 0x01234567 |
44 | #define VALUE0 0x01234567 |
41 | #define VALUE1 0x89abcdef |
45 | #define VALUE1 0x89abcdef |
42 | 46 | ||
43 | void test(void) |
47 | void test_mapping1(void) |
44 | { |
48 | { |
- | 49 | #ifdef CONFIG_BENCH |
|
- | 50 | uint64_t t0 = get_cycle(); |
|
- | 51 | #endif |
|
45 | uintptr_t frame0, frame1; |
52 | uintptr_t frame0, frame1; |
46 | uint32_t v0, v1; |
53 | uint32_t v0, v1; |
47 | 54 | ||
48 | printf("Memory management test mapping #1\n"); |
55 | printf("Memory management test mapping #1\n"); |
49 | 56 | ||
50 | frame0 = frame_alloc(ONE_FRAME, FRAME_KA); |
57 | frame0 = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_KA); |
51 | frame1 = frame_alloc(ONE_FRAME, FRAME_KA); |
58 | frame1 = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_KA); |
52 | 59 | ||
53 | printf("Writing %#x to physical address %p.\n", VALUE0, KA2PA(frame0)); |
60 | printf("Writing %#x to physical address %p.\n", VALUE0, KA2PA(frame0)); |
54 | *((uint32_t *) frame0) = VALUE0; |
61 | *((uint32_t *) frame0) = VALUE0; |
55 | printf("Writing %#x to physical address %p.\n", VALUE1, KA2PA(frame1)); |
62 | printf("Writing %#x to physical address %p.\n", VALUE1, KA2PA(frame1)); |
56 | *((uint32_t *) frame1) = VALUE1; |
63 | *((uint32_t *) frame1) = VALUE1; |
Line 79... | Line 86... | ||
79 | 86 | ||
80 | ASSERT(v0 == 0); |
87 | ASSERT(v0 == 0); |
81 | ASSERT(v1 == 0); |
88 | ASSERT(v1 == 0); |
82 | 89 | ||
83 | printf("Test passed.\n"); |
90 | printf("Test passed.\n"); |
- | 91 | #ifdef CONFIG_BENCH |
|
- | 92 | uint64_t dt = get_cycle() - t0; |
|
- | 93 | printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt); |
|
84 | 94 | #endif |
|
85 | } |
95 | } |