Rev 2257 | Rev 2339 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2257 | Rev 2323 | ||
---|---|---|---|
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 | ||
29 | /** @addtogroup arm32boot |
30 | /** @addtogroup arm32boot |
30 | * @{ |
31 | * @{ |
31 | */ |
32 | */ |
32 | /** @file |
33 | /** @file |
33 | */ |
34 | */ |
34 | 35 | ||
- | 36 | ||
35 | #include "mm.h" |
37 | #include "mm.h" |
36 | 38 | ||
37 | 39 | ||
38 | /** Initializes section page table entry. |
40 | /** Initializes "section" page table entry. |
39 | * |
41 | * |
40 | * Will be readable/writable by kernel with no access from user mode. |
42 | * Will be readable/writable by kernel with no access from user mode. |
41 | * Will belong to domain 0. No cache or buffering is enabled. |
43 | * Will belong to domain 0. No cache or buffering is enabled. |
42 | * |
44 | * |
43 | * \param pte page table entry to set |
45 | * @param pte Section entry to initialize. |
44 | * \param frame first frame in the section (frame number) |
46 | * @param frame First frame in the section (frame number). |
- | 47 | * |
|
45 | * \note If frame is not 1MB aligned, first lower 1MB aligned frame will be used. |
48 | * @note If #frame is not 1MB aligned, first lower 1MB aligned frame will be used. |
46 | */ |
49 | */ |
47 | static void init_pte_level0_section(pte_level0_section_t* pte, unsigned frame) |
50 | static void init_pte_level0_section(pte_level0_section_t* pte, unsigned frame) |
48 | { |
51 | { |
49 | pte->descriptor_type = PTE_DESCRIPTOR_SECTION; |
52 | pte->descriptor_type = PTE_DESCRIPTOR_SECTION; |
50 | pte->bufferable = 0; |
53 | pte->bufferable = 0; |
Line 56... | Line 59... | ||
56 | pte->should_be_zero_2 = 0; |
59 | pte->should_be_zero_2 = 0; |
57 | pte->section_base_addr = (frame << FRAME_WIDTH) >> 20; |
60 | pte->section_base_addr = (frame << FRAME_WIDTH) >> 20; |
58 | } |
61 | } |
59 | 62 | ||
60 | 63 | ||
- | 64 | /** Initializes page table used while booting the kernel. */ |
|
61 | static void init_page_table(void) |
65 | static void init_page_table(void) |
62 | { |
66 | { |
63 | int i; |
67 | int i; |
64 | - | ||
65 | const unsigned int first_kernel_section = ADDR2PFN(PA2KA(0)) / FRAMES_PER_SECTION; |
68 | const unsigned int first_kernel_section = ADDR2PFN(PA2KA(0)) / FRAMES_PER_SECTION; |
- | 69 | ||
66 | // create 1:1 mapping virtual-physical (in lower 2GB) |
70 | // create 1:1 virtual-physical mapping (in lower 2GB) |
67 | for(i = 0; i < first_kernel_section; i++) { |
71 | for (i = 0; i < first_kernel_section; i++) { |
68 | init_pte_level0_section(&page_table[i], i * FRAMES_PER_SECTION); |
72 | init_pte_level0_section(&page_table[i], i * FRAMES_PER_SECTION); |
69 | } |
73 | } |
70 | 74 | ||
- | 75 | // create 1:1 virtual-physical mapping in kernel space (upper 2GB), |
|
71 | // create kernel mapping (in upper 2GB), physical addresses starting from 0 |
76 | // physical addresses start from 0 |
72 | for(i = first_kernel_section; i < PTL0_ENTRIES_ARCH; i++) { |
77 | for (i = first_kernel_section; i < PTL0_ENTRIES; i++) { |
73 | init_pte_level0_section(&page_table[i], (i - first_kernel_section) * FRAMES_PER_SECTION); |
78 | init_pte_level0_section(&page_table[i], (i - first_kernel_section) * FRAMES_PER_SECTION); |
74 | } |
79 | } |
75 | } |
80 | } |
76 | 81 | ||
77 | 82 | ||
- | 83 | /** Starts the MMU - initializes page table and enables paging. |
|
- | 84 | */ |
|
78 | void mmu_start() { |
85 | void mmu_start() { |
79 | init_page_table(); |
86 | init_page_table(); |
80 | set_ptl0_address(page_table); |
87 | set_ptl0_address(page_table); |
81 | enable_paging(); |
88 | enable_paging(); |
82 | } |
89 | } |
83 | 90 | ||
- | 91 | ||
84 | /** @} |
92 | /** @} |
85 | */ |
93 | */ |
86 | 94 |