Rev 2234 | Rev 2239 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2234 | Rev 2236 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | * Copyright (c) 2003-2004 Jakub Jermar |
2 | * Copyright (c) 2007 Pavel Jancik, Michal Kebrt |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
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 | /** @addtogroup arm32mm |
29 | /** @addtogroup arm32boot |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
35 | 35 | ||
36 | #ifndef __MM_H__ |
36 | #ifndef __MM_H__ |
37 | #define __MM_H__ |
37 | #define __MM_H__ |
38 | 38 | ||
- | 39 | #ifndef __ASM__ |
|
39 | #include "types.h" |
40 | #include "types.h" |
- | 41 | #endif |
|
40 | 42 | ||
41 | 43 | ||
42 | #define FRAME_WIDTH 12 /* 4KB frames */ |
44 | #define FRAME_WIDTH 12 /* 4KB frames */ |
43 | #define FRAME_SIZE (1 << FRAME_WIDTH) |
45 | #define FRAME_SIZE (1 << FRAME_WIDTH) |
44 | 46 | ||
Line 51... | Line 53... | ||
51 | #else |
53 | #else |
52 | # define KA2PA(x) ((x) - 0x80000000) |
54 | # define KA2PA(x) ((x) - 0x80000000) |
53 | # define PA2KA(x) ((x) + 0x80000000) |
55 | # define PA2KA(x) ((x) + 0x80000000) |
54 | #endif |
56 | #endif |
55 | 57 | ||
- | 58 | /** Number of entries in PTL0 */ |
|
56 | #define PTL0_ENTRIES_ARCH (2<<12) /* 4096 */ |
59 | #define PTL0_ENTRIES_ARCH (2<<12) /* 4096 */ |
57 | #define SET_PTL0_ADDRESS_ARCH(ptl0) ( set_ptl0_addr((pte_level0_section *)(ptl0)) ) |
- | |
58 | 60 | ||
59 | /** Frames per 1MB section */ |
61 | /** Frames per 1MB section */ |
60 | #define FRAMES_PER_SECTION ( ( 1 << 20 ) / FRAME_SIZE ) |
62 | #define FRAMES_PER_SECTION ( ( 1 << 20 ) / FRAME_SIZE ) |
61 | 63 | ||
62 | /** Converts adress to frame */ |
64 | /** Converts adress to frame number */ |
63 | #define ADDR2PFN( addr ) ( ((uintptr_t)(addr))>>FRAME_WIDTH ) |
65 | #define ADDR2PFN( addr ) ( ((uintptr_t)(addr))>>FRAME_WIDTH ) |
64 | 66 | ||
65 | /** Value of descriptor_type in page table entry that signals |
67 | /** Descriptor type that signs "section" page table entry |
66 | * that this entry describe section |
68 | * (one-level paging with 1MB sized pages) */ |
67 | */ |
- | |
68 | #define PTE_DESCRIPTOR_SECTION 2 |
69 | #define PTE_DESCRIPTOR_SECTION 2 |
69 | 70 | ||
70 | /** Rights: user-no acess, kernel-read/write */ |
71 | /** Access rights to page table: user-no access, kernel-read/write */ |
71 | #define PTE_AP_USER_NO_KERNEL_RW 1 |
72 | #define PTE_AP_USER_NO_KERNEL_RW 1 |
72 | 73 | ||
- | 74 | #ifndef __ASM__ |
|
73 | 75 | ||
74 | /** Page table level 0 entry - section format */ |
76 | /** Page table level 0 entry - "section" format (one-level paging, 1MB sized |
- | 77 | * pages). Used only for booting the kernel. */ |
|
75 | typedef struct { |
78 | typedef struct { |
76 | unsigned descriptor_type : 2; // should be 2 |
79 | unsigned descriptor_type : 2; // PTE_DESCRIPTOR_SECTION |
77 | unsigned bufferable : 1; |
80 | unsigned bufferable : 1; |
78 | unsigned cacheable : 1; |
81 | unsigned cacheable : 1; |
79 | unsigned machine_depend : 1; |
82 | unsigned machine_depend : 1; |
80 | unsigned domain : 4; |
83 | unsigned domain : 4; |
81 | unsigned should_be_zero_1 : 1; |
84 | unsigned should_be_zero_1 : 1; |
Line 83... | Line 86... | ||
83 | unsigned should_be_zero_2 : 8; |
86 | unsigned should_be_zero_2 : 8; |
84 | unsigned section_base_addr : 12; |
87 | unsigned section_base_addr : 12; |
85 | } __attribute__ ((packed)) pte_level0_section; |
88 | } __attribute__ ((packed)) pte_level0_section; |
86 | 89 | ||
87 | 90 | ||
88 | /** Set adress of paging level 0 table |
91 | /** Sets the address of level 0 page table. |
89 | * \param pt pointer to page table to set |
92 | * \param pt pointer to the page table to set |
90 | */ |
93 | */ |
91 | static inline void set_ptl0_addr( pte_level0_section* pt) { |
94 | static inline void set_ptl0_address( pte_level0_section* pt) { |
92 | asm volatile ( "mcr p15, 0, %0, c2, c0, 0 \n" |
95 | asm volatile ( "mcr p15, 0, %0, c2, c0, 0 \n" |
93 | : |
96 | : |
94 | : "r"(pt) |
97 | : "r"(pt) |
95 | ); |
98 | ); |
96 | 99 | ||
97 | } |
100 | } |
98 | 101 | ||
99 | /** Page table that holds 1:1 mapping for kernel starting */ |
102 | /** Page table that holds 1:1 mapping for booting the kernel. */ |
100 | extern pte_level0_section page_table[PTL0_ENTRIES_ARCH]; |
103 | extern pte_level0_section page_table[PTL0_ENTRIES_ARCH]; |
101 | 104 | ||
102 | /** Sets memory mapping for kernel */ |
105 | /** Sets memory mapping for kernel */ |
103 | void mm_kernel_mapping(void); |
106 | void mm_kernel_mapping(void); |
- | 107 | ||
- | 108 | #endif |
|
104 | 109 | ||
105 | #endif |
110 | #endif |
106 | 111 | ||
107 | /** @} |
112 | /** @} |
108 | */ |
113 | */ |