Rev 2465 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2465 | Rev 2468 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
- | 2 | * Copyright (c) 2007 Pavel Jancik |
|
2 | * Copyright (c) 2007 Pavel Jancik, Michal Kebrt |
3 | * Copyright (c) 2007 Michal Kebrt |
3 | * All rights reserved. |
4 | * All rights reserved. |
4 | * |
5 | * |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
7 | * modification, are permitted provided that the following conditions |
7 | * are met: |
8 | * are met: |
Line 31... | Line 32... | ||
31 | * @{ |
32 | * @{ |
32 | */ |
33 | */ |
33 | /** @file |
34 | /** @file |
34 | * @brief Memory management used while booting the kernel. |
35 | * @brief Memory management used while booting the kernel. |
35 | * |
36 | * |
36 | * So called "section" paging is used while booting the kernel. The term "section" |
37 | * So called "section" paging is used while booting the kernel. The term |
37 | * comes from the ARM architecture specification and stands for the following: |
38 | * "section" comes from the ARM architecture specification and stands for the |
38 | * one-level paging, 1MB sized pages, 4096 entries in the page table. |
39 | * following: one-level paging, 1MB sized pages, 4096 entries in the page |
- | 40 | * table. |
|
39 | */ |
41 | */ |
40 | 42 | ||
41 | 43 | ||
42 | #ifndef BOOT_arm32__MM_H |
44 | #ifndef BOOT_arm32__MM_H |
43 | #define BOOT_arm32__MM_H |
45 | #define BOOT_arm32__MM_H |
Line 52... | Line 54... | ||
52 | #define FRAME_WIDTH 20 |
54 | #define FRAME_WIDTH 20 |
53 | 55 | ||
54 | /** Frame size. */ |
56 | /** Frame size. */ |
55 | #define FRAME_SIZE (1 << FRAME_WIDTH) |
57 | #define FRAME_SIZE (1 << FRAME_WIDTH) |
56 | 58 | ||
57 | /** Page size in 2-level paging which is switched on later after the kernel initialization. */ |
59 | /** Page size in 2-level paging which is switched on later after the kernel |
- | 60 | * initialization. |
|
- | 61 | */ |
|
58 | #define KERNEL_PAGE_SIZE (1 << 12) |
62 | #define KERNEL_PAGE_SIZE (1 << 12) |
59 | 63 | ||
60 | 64 | ||
61 | #ifndef __ASM__ |
65 | #ifndef __ASM__ |
62 | /** Converts kernel address to physical address. */ |
66 | /** Converts kernel address to physical address. */ |
Line 86... | Line 90... | ||
86 | 90 | ||
87 | 91 | ||
88 | #ifndef __ASM__ |
92 | #ifndef __ASM__ |
89 | 93 | ||
90 | 94 | ||
91 | /** Page table level 0 entry - "section" format is used (one-level paging, 1MB sized |
95 | /** Page table level 0 entry - "section" format is used (one-level paging, 1MB |
92 | * pages). Used only while booting the kernel. |
96 | * sized pages). Used only while booting the kernel. |
93 | */ |
97 | */ |
94 | typedef struct { |
98 | typedef struct { |
95 | unsigned descriptor_type : 2; |
99 | unsigned descriptor_type : 2; |
96 | unsigned bufferable : 1; |
100 | unsigned bufferable : 1; |
97 | unsigned cacheable : 1; |
101 | unsigned cacheable : 1; |
Line 102... | Line 106... | ||
102 | unsigned should_be_zero_2 : 8; |
106 | unsigned should_be_zero_2 : 8; |
103 | unsigned section_base_addr : 12; |
107 | unsigned section_base_addr : 12; |
104 | } __attribute__ ((packed)) pte_level0_section_t; |
108 | } __attribute__ ((packed)) pte_level0_section_t; |
105 | 109 | ||
106 | 110 | ||
107 | /** Page table that holds 1:1 virtual to physical mapping used while booting the kernel. */ |
111 | /** Page table that holds 1:1 virtual to physical mapping used while booting the |
- | 112 | * kernel. |
|
- | 113 | */ |
|
108 | extern pte_level0_section_t page_table[PTL0_ENTRIES]; |
114 | extern pte_level0_section_t page_table[PTL0_ENTRIES]; |
109 | 115 | ||
110 | extern void mmu_start(void); |
116 | extern void mmu_start(void); |
111 | 117 | ||
112 | 118 | ||
Line 115... | Line 121... | ||
115 | { |
121 | { |
116 | /* c3 - each two bits controls access to the one of domains (16) |
122 | /* c3 - each two bits controls access to the one of domains (16) |
117 | * 0b01 - behave as a client (user) of a domain |
123 | * 0b01 - behave as a client (user) of a domain |
118 | */ |
124 | */ |
119 | asm volatile ( |
125 | asm volatile ( |
120 | // behave as a client of domains |
126 | /* behave as a client of domains */ |
121 | "ldr r0, =0x55555555 \n" |
127 | "ldr r0, =0x55555555\n" |
122 | "mcr p15, 0, r0, c3, c0, 0 \n" |
128 | "mcr p15, 0, r0, c3, c0, 0\n" |
123 | 129 | ||
124 | // current settings |
130 | /* current settings */ |
125 | "mrc p15, 0, r0, c1, c0, 0 \n" |
131 | "mrc p15, 0, r0, c1, c0, 0\n" |
126 | 132 | ||
127 | // mask to enable paging |
133 | /* mask to enable paging */ |
128 | "ldr r1, =0x00000001 \n" |
134 | "ldr r1, =0x00000001\n" |
129 | "orr r0, r0, r1 \n" |
135 | "orr r0, r0, r1\n" |
130 | 136 | ||
131 | // store settings |
137 | /* store settings */ |
132 | "mcr p15, 0, r0, c1, c0, 0 \n" |
138 | "mcr p15, 0, r0, c1, c0, 0\n" |
133 | : |
139 | : |
134 | : |
140 | : |
135 | : "r0", "r1" |
141 | : "r0", "r1" |
136 | ); |
142 | ); |