Skip to content

Commit 324f40f

Browse files
author
Chen Liqin
committed
score: add MEMORY_START and MEMORY_SIZE define, to make the code clear
1 parent ffa818b commit 324f40f

2 files changed

Lines changed: 19 additions & 16 deletions

File tree

‎arch/score/include/asm/setup.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#define _ASM_SCORE_SETUP_H
33

44
#define COMMAND_LINE_SIZE 256
5-
#define MEM_SIZE 0x2000000
5+
#define MEMORY_START 0
6+
#define MEMORY_SIZE 0x2000000
67

78
#ifdef __KERNEL__
89

‎arch/score/kernel/setup.c‎

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
#include <linux/bootmem.h>
2727
#include <linux/initrd.h>
2828
#include <linux/ioport.h>
29+
#include <linux/mm.h>
2930
#include <linux/seq_file.h>
3031
#include <linux/screen_info.h>
3132

3233
#include <asm-generic/sections.h>
34+
#include <asm/setup.h>
3335

3436
struct screen_info screen_info;
3537
unsigned long kernelsp;
@@ -40,25 +42,25 @@ static struct resource data_resource = { .name = "Kernel data",};
4042

4143
static void __init bootmem_init(void)
4244
{
43-
unsigned long reserved_end, bootmap_size;
45+
unsigned long start_pfn, bootmap_size;
4446
unsigned long size = initrd_end - initrd_start;
4547

46-
reserved_end = (unsigned long)_end;
48+
start_pfn = PFN_UP(__pa(&_end));
4749

48-
min_low_pfn = 0;
49-
max_low_pfn = MEM_SIZE / PAGE_SIZE;
50+
min_low_pfn = PFN_UP(MEMORY_START);
51+
max_low_pfn = PFN_UP(MEMORY_START + MEMORY_SIZE);
5052

5153
/* Initialize the boot-time allocator with low memory only. */
52-
bootmap_size = init_bootmem_node(NODE_DATA(0), reserved_end,
54+
bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
5355
min_low_pfn, max_low_pfn);
5456
add_active_range(0, min_low_pfn, max_low_pfn);
5557

56-
free_bootmem(PFN_PHYS(reserved_end),
57-
(max_low_pfn - reserved_end) << PAGE_SHIFT);
58-
memory_present(0, reserved_end, max_low_pfn);
58+
free_bootmem(PFN_PHYS(start_pfn),
59+
(max_low_pfn - start_pfn) << PAGE_SHIFT);
60+
memory_present(0, start_pfn, max_low_pfn);
5961

6062
/* Reserve space for the bootmem bitmap. */
61-
reserve_bootmem(PFN_PHYS(reserved_end), bootmap_size, BOOTMEM_DEFAULT);
63+
reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size, BOOTMEM_DEFAULT);
6264

6365
if (size == 0) {
6466
printk(KERN_INFO "Initrd not found or empty");
@@ -87,15 +89,15 @@ static void __init resource_init(void)
8789
{
8890
struct resource *res;
8991

90-
code_resource.start = (unsigned long)_text;
91-
code_resource.end = (unsigned long)_etext - 1;
92-
data_resource.start = (unsigned long)_etext;
93-
data_resource.end = (unsigned long)_edata - 1;
92+
code_resource.start = __pa(&_text);
93+
code_resource.end = __pa(&_etext) - 1;
94+
data_resource.start = __pa(&_etext);
95+
data_resource.end = __pa(&_edata) - 1;
9496

9597
res = alloc_bootmem(sizeof(struct resource));
9698
res->name = "System RAM";
97-
res->start = 0;
98-
res->end = MEM_SIZE - 1;
99+
res->start = MEMORY_START;
100+
res->end = MEMORY_START + MEMORY_SIZE - 1;
99101
res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
100102
request_resource(&iomem_resource, res);
101103

0 commit comments

Comments
 (0)