hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/nios2/kernel/setup.c
....@@ -16,7 +16,7 @@
1616 #include <linux/sched.h>
1717 #include <linux/sched/task.h>
1818 #include <linux/console.h>
19
-#include <linux/bootmem.h>
19
+#include <linux/memblock.h>
2020 #include <linux/initrd.h>
2121 #include <linux/of_fdt.h>
2222 #include <linux/screen_info.h>
....@@ -123,7 +123,7 @@
123123 dtb_passed = r6;
124124
125125 if (r7)
126
- strncpy(cmdline_passed, (char *)r7, COMMAND_LINE_SIZE);
126
+ strlcpy(cmdline_passed, (char *)r7, COMMAND_LINE_SIZE);
127127 }
128128 #endif
129129
....@@ -131,10 +131,10 @@
131131
132132 #ifndef CONFIG_CMDLINE_FORCE
133133 if (cmdline_passed[0])
134
- strncpy(boot_command_line, cmdline_passed, COMMAND_LINE_SIZE);
134
+ strlcpy(boot_command_line, cmdline_passed, COMMAND_LINE_SIZE);
135135 #ifdef CONFIG_NIOS2_CMDLINE_IGNORE_DTB
136136 else
137
- strncpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
137
+ strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
138138 #endif
139139 #endif
140140
....@@ -143,10 +143,12 @@
143143
144144 void __init setup_arch(char **cmdline_p)
145145 {
146
- int bootmap_size;
146
+ int dram_start;
147147
148148 console_verbose();
149149
150
+ dram_start = memblock_start_of_DRAM();
151
+ memory_size = memblock_phys_mem_size();
150152 memory_start = PAGE_ALIGN((unsigned long)__pa(_end));
151153 memory_end = (unsigned long) CONFIG_NIOS2_MEM_BASE + memory_size;
152154
....@@ -163,39 +165,11 @@
163165 max_low_pfn = PFN_DOWN(memory_end);
164166 max_mapnr = max_low_pfn;
165167
166
- /*
167
- * give all the memory to the bootmap allocator, tell it to put the
168
- * boot mem_map at the start of memory
169
- */
170
- pr_debug("init_bootmem_node(?,%#lx, %#x, %#lx)\n",
171
- min_low_pfn, PFN_DOWN(PHYS_OFFSET), max_low_pfn);
172
- bootmap_size = init_bootmem_node(NODE_DATA(0),
173
- min_low_pfn, PFN_DOWN(PHYS_OFFSET),
174
- max_low_pfn);
175
-
176
- /*
177
- * free the usable memory, we have to make sure we do not free
178
- * the bootmem bitmap so we then reserve it after freeing it :-)
179
- */
180
- pr_debug("free_bootmem(%#lx, %#lx)\n",
181
- memory_start, memory_end - memory_start);
182
- free_bootmem(memory_start, memory_end - memory_start);
183
-
184
- /*
185
- * Reserve the bootmem bitmap itself as well. We do this in two
186
- * steps (first step was init_bootmem()) because this catches
187
- * the (very unlikely) case of us accidentally initializing the
188
- * bootmem allocator with an invalid RAM area.
189
- *
190
- * Arguments are start, size
191
- */
192
- pr_debug("reserve_bootmem(%#lx, %#x)\n", memory_start, bootmap_size);
193
- reserve_bootmem(memory_start, bootmap_size, BOOTMEM_DEFAULT);
194
-
168
+ memblock_reserve(dram_start, memory_start - dram_start);
195169 #ifdef CONFIG_BLK_DEV_INITRD
196170 if (initrd_start) {
197
- reserve_bootmem(virt_to_phys((void *)initrd_start),
198
- initrd_end - initrd_start, BOOTMEM_DEFAULT);
171
+ memblock_reserve(virt_to_phys((void *)initrd_start),
172
+ initrd_end - initrd_start);
199173 }
200174 #endif /* CONFIG_BLK_DEV_INITRD */
201175
....@@ -222,8 +196,4 @@
222196 * get kmalloc into gear
223197 */
224198 paging_init();
225
-
226
-#if defined(CONFIG_VT) && defined(CONFIG_DUMMY_CONSOLE)
227
- conswitchp = &dummy_con;
228
-#endif
229199 }