Changes in kernel/test/mm/mapping1.c [5df1963:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/mm/mapping1.c
r5df1963 r9d58539 41 41 const char *test_mapping1(void) 42 42 { 43 uintptr_t frame = frame_alloc(1, FRAME_NONE, 0); 43 uintptr_t page0, page1; 44 uintptr_t frame; 45 uint32_t v; 46 int i; 44 47 45 uintptr_t page0 = km_map(frame, FRAME_SIZE, 48 frame = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_NONE); 49 50 page0 = km_map(frame, FRAME_SIZE, 46 51 PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE); 47 52 TPRINTF("Virtual address %p mapped to physical address %p.\n", 48 53 (void *) page0, (void *) frame); 49 50 uintptr_t page1 = km_map(frame, FRAME_SIZE, 54 page1 = km_map(frame, FRAME_SIZE, 51 55 PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE); 52 56 TPRINTF("Virtual address %p mapped to physical address %p.\n", 53 57 (void *) page1, (void *) frame); 54 58 55 for ( unsigned inti = 0; i < 2; i++) {59 for (i = 0; i < 2; i++) { 56 60 TPRINTF("Writing magic using the first virtual address.\n"); 57 61 58 62 *((uint32_t *) page0) = TEST_MAGIC; 59 63 60 64 TPRINTF("Reading magic using the second virtual address.\n"); 61 62 uint32_tv = *((uint32_t *) page1);63 65 66 v = *((uint32_t *) page1); 67 64 68 if (v != TEST_MAGIC) { 65 69 km_unmap(page0, PAGE_SIZE); 66 70 km_unmap(page1, PAGE_SIZE); 67 frame_free(frame , 1);71 frame_free(frame); 68 72 return "Criss-cross read does not match the value written."; 69 73 } 70 74 71 75 TPRINTF("Writing zero using the second virtual address.\n"); 72 76 73 77 *((uint32_t *) page1) = 0; 74 78 75 79 TPRINTF("Reading zero using the first virtual address.\n"); 76 80 77 81 v = *((uint32_t *) page0); 78 82 79 83 if (v != 0) { 80 84 km_unmap(page0, PAGE_SIZE); 81 85 km_unmap(page1, PAGE_SIZE); 82 frame_free(frame , 1);86 frame_free(frame); 83 87 return "Criss-cross read does not match the value written."; 84 88 } 85 89 } 86 90 87 91 km_unmap(page0, PAGE_SIZE); 88 92 km_unmap(page1, PAGE_SIZE); 89 frame_free(frame , 1);93 frame_free(frame); 90 94 91 95 return NULL;
Note:
See TracChangeset
for help on using the changeset viewer.