2 * Copyright 2004-2009 Analog Devices Inc.
4 * Licensed under the GPL-2 or later.
8 #include <linux/swap.h>
9 #include <linux/bootmem.h>
10 #include <linux/uaccess.h>
11 #include <linux/export.h>
12 #include <asm/bfin-global.h>
14 #include <asm/cplbinit.h>
15 #include <asm/early_printk.h>
16 #include "blackfin_sram.h"
19 * ZERO_PAGE is a special page that is used for zero-initialized data and COW.
20 * Let the bss do its zero-init magic so we don't have to do it ourselves.
22 char empty_zero_page
[PAGE_SIZE
] __attribute__((aligned(PAGE_SIZE
)));
23 EXPORT_SYMBOL(empty_zero_page
);
25 #ifndef CONFIG_EXCEPTION_L1_SCRATCH
26 #if defined CONFIG_SYSCALL_TAB_L1
27 __attribute__((l1_data
))
29 static unsigned long exception_stack
[NR_CPUS
][1024];
32 struct blackfin_pda cpu_pda
[NR_CPUS
];
33 EXPORT_SYMBOL(cpu_pda
);
36 * paging_init() continues the virtual memory environment setup which
37 * was begun by the code in arch/head.S.
38 * The parameters are pointers to where to stick the starting and ending
39 * addresses of available kernel virtual memory.
41 void __init
paging_init(void)
44 * make sure start_mem is page aligned, otherwise bootmem and
45 * page_alloc get different views of the world
47 unsigned long end_mem
= memory_end
& PAGE_MASK
;
49 unsigned long zones_size
[MAX_NR_ZONES
] = {
51 [ZONE_DMA
] = (end_mem
- CONFIG_PHY_RAM_BASE_ADDRESS
) >> PAGE_SHIFT
,
58 /* Set up SFC/DFC registers (user data space) */
61 pr_debug("free_area_init -> start_mem is %#lx virtual_end is %#lx\n",
62 PAGE_ALIGN(memory_start
), end_mem
);
63 free_area_init_node(0, zones_size
,
64 CONFIG_PHY_RAM_BASE_ADDRESS
>> PAGE_SHIFT
, NULL
);
67 asmlinkage
void __init
init_pda(void)
69 unsigned int cpu
= raw_smp_processor_id();
73 /* Initialize the PDA fields holding references to other parts
74 of the memory. The content of such memory is still
75 undefined at the time of the call, we are only setting up
76 valid pointers to it. */
77 memset(&cpu_pda
[cpu
], 0, sizeof(cpu_pda
[cpu
]));
79 #ifdef CONFIG_EXCEPTION_L1_SCRATCH
80 cpu_pda
[cpu
].ex_stack
= (unsigned long *)(L1_SCRATCH_START
+ \
83 cpu_pda
[cpu
].ex_stack
= exception_stack
[cpu
+ 1];
87 cpu_pda
[cpu
].imask
= 0x1f;
91 void __init
mem_init(void)
95 high_memory
= (void *)(memory_end
& PAGE_MASK
);
96 max_mapnr
= MAP_NR(high_memory
);
97 printk(KERN_DEBUG
"Kernel managed physical pages: %lu\n", max_mapnr
);
99 /* This will put all low memory onto the freelists. */
102 snprintf(buf
, sizeof(buf
) - 1, "%uK DMA", DMA_UNCACHED_REGION
>> 10);
103 mem_init_print_info(buf
);
106 #ifdef CONFIG_BLK_DEV_INITRD
107 void __init
free_initrd_mem(unsigned long start
, unsigned long end
)
110 free_reserved_area((void *)start
, (void *)end
, -1, "initrd");
115 void __ref
free_initmem(void)
117 #if defined CONFIG_RAMKERNEL && !defined CONFIG_MPU
118 free_initmem_default(-1);
119 if (memory_start
== (unsigned long)(&__init_end
))
120 memory_start
= (unsigned long)(&__init_begin
);