1
2
3
4
5
6
7#include <linux/gfp.h>
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>
13#include <asm/pda.h>
14#include <asm/cplbinit.h>
15#include <asm/early_printk.h>
16#include "blackfin_sram.h"
17
18
19
20
21
22char empty_zero_page[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
23EXPORT_SYMBOL(empty_zero_page);
24
25#ifndef CONFIG_EXCEPTION_L1_SCRATCH
26#if defined CONFIG_SYSCALL_TAB_L1
27__attribute__((l1_data))
28#endif
29static unsigned long exception_stack[NR_CPUS][1024];
30#endif
31
32struct blackfin_pda cpu_pda[NR_CPUS];
33EXPORT_SYMBOL(cpu_pda);
34
35
36
37
38
39
40
41void __init paging_init(void)
42{
43
44
45
46
47 unsigned long end_mem = memory_end & PAGE_MASK;
48
49 unsigned long zones_size[MAX_NR_ZONES] = {
50 [0] = 0,
51 [ZONE_DMA] = (end_mem - CONFIG_PHY_RAM_BASE_ADDRESS) >> PAGE_SHIFT,
52 [ZONE_NORMAL] = 0,
53#ifdef CONFIG_HIGHMEM
54 [ZONE_HIGHMEM] = 0,
55#endif
56 };
57
58
59 set_fs(KERNEL_DS);
60
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);
65}
66
67asmlinkage void __init init_pda(void)
68{
69 unsigned int cpu = raw_smp_processor_id();
70
71 early_shadow_stamp();
72
73
74
75
76
77 memset(&cpu_pda[cpu], 0, sizeof(cpu_pda[cpu]));
78
79#ifdef CONFIG_EXCEPTION_L1_SCRATCH
80 cpu_pda[cpu].ex_stack = (unsigned long *)(L1_SCRATCH_START + \
81 L1_SCRATCH_LENGTH);
82#else
83 cpu_pda[cpu].ex_stack = exception_stack[cpu + 1];
84#endif
85
86#ifdef CONFIG_SMP
87 cpu_pda[cpu].imask = 0x1f;
88#endif
89}
90
91void __init mem_init(void)
92{
93 char buf[64];
94
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);
98
99
100 free_all_bootmem();
101
102 snprintf(buf, sizeof(buf) - 1, "%uK DMA", DMA_UNCACHED_REGION >> 10);
103 mem_init_print_info(buf);
104}
105
106#ifdef CONFIG_BLK_DEV_INITRD
107void __init free_initrd_mem(unsigned long start, unsigned long end)
108{
109#ifndef CONFIG_MPU
110 free_reserved_area((void *)start, (void *)end, -1, "initrd");
111#endif
112}
113#endif
114
115void __init_refok free_initmem(void)
116{
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);
121#endif
122}
123