Rev 1888 | Rev 1918 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1888 | Rev 1903 | ||
---|---|---|---|
Line 38... | Line 38... | ||
38 | #include <mm/frame.h> |
38 | #include <mm/frame.h> |
39 | #include <arch/mm/frame.h> |
39 | #include <arch/mm/frame.h> |
40 | #include <bitops.h> |
40 | #include <bitops.h> |
41 | #include <debug.h> |
41 | #include <debug.h> |
42 | #include <align.h> |
42 | #include <align.h> |
- | 43 | #include <config.h> |
|
43 | 44 | ||
- | 45 | #ifdef CONFIG_SMP |
|
- | 46 | /** Entries locked in DTLB of BSP. |
|
- | 47 | * |
|
- | 48 | * Application processors need to have the same locked entries |
|
- | 49 | * in their DTLBs as the bootstrap processor. |
|
- | 50 | */ |
|
- | 51 | static struct { |
|
- | 52 | uintptr_t virt_page; |
|
- | 53 | uintptr_t phys_page; |
|
- | 54 | int pagesize_code; |
|
- | 55 | } bsp_locked_dtlb_entry[DTLB_ENTRY_COUNT]; |
|
- | 56 | ||
- | 57 | /** Number of entries in bsp_locked_dtlb_entry array. */ |
|
- | 58 | static count_t bsp_locked_dtlb_entries = 0; |
|
- | 59 | #endif /* CONFIG_SMP */ |
|
- | 60 | ||
- | 61 | /** Perform sparc64 specific initialization of paging. */ |
|
44 | void page_arch_init(void) |
62 | void page_arch_init(void) |
45 | { |
63 | { |
- | 64 | if (config.cpu_active == 1) { |
|
46 | page_mapping_operations = &ht_mapping_operations; |
65 | page_mapping_operations = &ht_mapping_operations; |
- | 66 | } else { |
|
- | 67 | ||
- | 68 | #ifdef CONFIG_SMP |
|
- | 69 | int i; |
|
- | 70 | ||
- | 71 | /* |
|
- | 72 | * Copy locked DTLB entries from the BSP. |
|
- | 73 | */ |
|
- | 74 | for (i = 0; i < bsp_locked_dtlb_entries; i++) { |
|
- | 75 | dtlb_insert_mapping(bsp_locked_dtlb_entry[i].virt_page, |
|
- | 76 | bsp_locked_dtlb_entry[i].phys_page, bsp_locked_dtlb_entry[i].pagesize_code, |
|
- | 77 | true, false); |
|
- | 78 | } |
|
- | 79 | #endif |
|
- | 80 | ||
- | 81 | } |
|
47 | } |
82 | } |
48 | 83 | ||
49 | /** Map memory-mapped device into virtual memory. |
84 | /** Map memory-mapped device into virtual memory. |
50 | * |
85 | * |
51 | * So far, only DTLB is used to map devices into memory. |
86 | * So far, only DTLB is used to map devices into memory. |
Line 65... | Line 100... | ||
65 | uintptr_t hw_map(uintptr_t physaddr, size_t size) |
100 | uintptr_t hw_map(uintptr_t physaddr, size_t size) |
66 | { |
101 | { |
67 | unsigned int order; |
102 | unsigned int order; |
68 | int i; |
103 | int i; |
69 | 104 | ||
- | 105 | ASSERT(config.cpu_active == 1); |
|
- | 106 | ||
70 | struct { |
107 | struct { |
71 | int pagesize; |
108 | int pagesize_code; |
72 | size_t increment; |
109 | size_t increment; |
73 | count_t count; |
110 | count_t count; |
74 | } sizemap[] = { |
111 | } sizemap[] = { |
75 | { PAGESIZE_8K, 0, 1 }, /* 8K */ |
112 | { PAGESIZE_8K, 0, 1 }, /* 8K */ |
76 | { PAGESIZE_8K, PAGE_SIZE, 2 }, /* 16K */ |
113 | { PAGESIZE_8K, PAGE_SIZE, 2 }, /* 16K */ |
Line 99... | Line 136... | ||
99 | */ |
136 | */ |
100 | ASSERT(last_frame); |
137 | ASSERT(last_frame); |
101 | uintptr_t virtaddr = ALIGN_UP(last_frame, 1<<(order + FRAME_WIDTH)); |
138 | uintptr_t virtaddr = ALIGN_UP(last_frame, 1<<(order + FRAME_WIDTH)); |
102 | last_frame = ALIGN_UP(virtaddr + size, 1<<(order + FRAME_WIDTH)); |
139 | last_frame = ALIGN_UP(virtaddr + size, 1<<(order + FRAME_WIDTH)); |
103 | 140 | ||
104 | for (i = 0; i < sizemap[order].count; i++) |
141 | for (i = 0; i < sizemap[order].count; i++) { |
- | 142 | /* |
|
- | 143 | * First, insert the mapping into DTLB. |
|
- | 144 | */ |
|
105 | dtlb_insert_mapping(virtaddr + i*sizemap[order].increment, |
145 | dtlb_insert_mapping(virtaddr + i*sizemap[order].increment, |
106 | physaddr + i*sizemap[order].increment, |
146 | physaddr + i*sizemap[order].increment, |
107 | sizemap[order].pagesize, true, false); |
147 | sizemap[order].pagesize_code, true, false); |
- | 148 | ||
- | 149 | #ifdef CONFIG_SMP |
|
- | 150 | /* |
|
- | 151 | * Second, save the information about the mapping for APs. |
|
- | 152 | */ |
|
- | 153 | bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].virt_page = virtaddr + i*sizemap[order].increment; |
|
- | 154 | bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].phys_page = physaddr + i*sizemap[order].increment; |
|
- | 155 | bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].pagesize_code = sizemap[order].pagesize_code; |
|
- | 156 | bsp_locked_dtlb_entries++; |
|
- | 157 | #endif |
|
- | 158 | } |
|
108 | 159 | ||
109 | return virtaddr; |
160 | return virtaddr; |
110 | } |
161 | } |
111 | 162 | ||
112 | /** @} |
163 | /** @} |