Rev 2198 | Rev 2236 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2198 | Rev 2234 | ||
---|---|---|---|
Line 31... | Line 31... | ||
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | #include "mm.h" |
34 | #include "mm.h" |
35 | 35 | ||
- | 36 | /** Set page table entry to point no frame, be read/write by kernel, |
|
- | 37 | * no access by user, become to domain 0, no cache or buffer |
|
- | 38 | * \param pte page table entry to set |
|
- | 39 | * \param frame frame number of first frame 1MB section |
|
- | 40 | * Note: If frame not aligned it's used first lower 1MB aligned frame |
|
- | 41 | */ |
|
36 | void init_pte_level0_section_entry( pte_level0_section* pte, unsigned frame){ |
42 | static void init_pte_level0_section_entry( pte_level0_section* pte, unsigned frame){ |
37 | pte->descriptor_type = pte_descriptor_section; |
43 | pte->descriptor_type = PTE_DESCRIPTOR_SECTION; |
38 | pte->bufferable = 0; // disable |
44 | pte->bufferable = 0; // disable |
39 | pte->cacheable = 0; |
45 | pte->cacheable = 0; |
40 | pte->machine_depend = 0; |
46 | pte->machine_depend = 0; |
41 | pte->domain = 0; |
47 | pte->domain = 0; |
42 | pte->should_be_zero_1 = 0; |
48 | pte->should_be_zero_1 = 0; |
43 | pte->access_permission = pte_ap_user_no_kernel_rw; |
49 | pte->access_permission = PTE_AP_USER_NO_KERNEL_RW; |
44 | pte->should_be_zero_2 = 0; |
50 | pte->should_be_zero_2 = 0; |
45 | pte->section_base_addr = (frame << FRAME_WIDTH) >> 20; |
51 | pte->section_base_addr = (frame << FRAME_WIDTH) >> 20; |
46 | }; |
52 | }; |
47 | 53 | ||
48 | 54 | ||
49 | // set memory mapping for kernel |
- | |
50 | void mm_kernel_mapping(void) { |
55 | void mm_kernel_mapping(void) { |
51 | int i; |
56 | int i; |
52 | // Create 1:1 mapping |
57 | // Create 1:1 mapping |
53 | for( i=0; i < 4096; i++) |
58 | for( i=0; i < PTL0_ENTRIES_ARCH; i++) { |
54 | init_pte_level0_section_entry(&page_table[i+0000], i * FRAMES_PER_SECTION); |
59 | init_pte_level0_section_entry(&page_table[i], i * FRAMES_PER_SECTION); |
- | 60 | } |
|
55 | 61 | ||
56 | // Create Kernel mapping |
62 | // Create kernel mapping |
57 | const unsigned int offset = ADDR2PFN(PA2KA(0)) / FRAMES_PER_SECTION; |
63 | const unsigned int offset = ADDR2PFN(PA2KA(0)) / FRAMES_PER_SECTION; |
58 | for( i = offset; i < 4096; i++) |
64 | for( i = offset; i < PTL0_ENTRIES_ARCH; i++) { |
59 | init_pte_level0_section_entry(&page_table[i], (i - offset) * FRAMES_PER_SECTION); |
65 | init_pte_level0_section_entry(&page_table[i], (i - offset) * FRAMES_PER_SECTION); |
- | 66 | } |
|
60 | 67 | ||
61 | SET_PTL0_ADDRESS_ARCH( page_table); |
68 | SET_PTL0_ADDRESS_ARCH( page_table); |
62 | 69 | ||
63 | // enable paging |
70 | // Enable paging |
64 | asm volatile ( |
71 | asm volatile ( |
65 | "ldr r0, =0x55555555 \n" |
72 | "ldr r0, =0x55555555 \n" |
66 | "mcr p15, 0, r0, c3, c0, 0 \n" //set domain acces rights to client <==> take rights from page tables |
73 | "mcr p15, 0, r0, c3, c0, 0 \n" // Set domain acces rights to client <==> take rights from page tables |
67 | "mrc p15, 0, r0, c1, c0, 0 \n" // get current setting of system ... register 1 isn't only for memmory management |
74 | "mrc p15, 0, r0, c1, c0, 0 \n" // Get current setting of system ... register 1 isn't only for memmory management |
68 | "ldr r1, =0xFFFFFE8D \n" // mask to disable aligment checks, System, Rom bit disable |
75 | "ldr r1, =0xFFFFFE8D \n" // Mask to disable aligment checks; system & rom bit disable |
69 | "and r0, r0, r1 \n" |
76 | "and r0, r0, r1 \n" |
70 | "ldr r1, =0x00000001 \n" // mask to enable paging |
77 | "ldr r1, =0x00000001 \n" // Mask to enable paging |
71 | "orr r0, r0, r1 \n" |
78 | "orr r0, r0, r1 \n" |
72 | "mcr p15, 0, r0, c1, c0, 0 \n" // store setting |
79 | "mcr p15, 0, r0, c1, c0, 0 \n" // Store setting |
73 | : |
80 | : |
74 | : |
81 | : |
75 | : "r0", "r1" |
82 | : "r0", "r1" |
76 | ); |
83 | ); |
77 | }; |
84 | }; |
78 | 85 | ||
79 | /** @} |
86 | /** @} |
80 | */ |
87 | */ |
81 | 88 |