Linux Audio

Check our new training course

Loading...
v6.2
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 *  linux/arch/m68k/mm/init.c
  4 *
  5 *  Copyright (C) 1995  Hamish Macdonald
  6 *
  7 *  Contains common initialization routines, specific init code moved
  8 *  to motorola.c and sun3mmu.c
  9 */
 10
 11#include <linux/module.h>
 12#include <linux/signal.h>
 13#include <linux/sched.h>
 14#include <linux/mm.h>
 15#include <linux/swap.h>
 16#include <linux/kernel.h>
 17#include <linux/string.h>
 18#include <linux/types.h>
 19#include <linux/init.h>
 20#include <linux/memblock.h>
 21#include <linux/gfp.h>
 22
 23#include <asm/setup.h>
 24#include <linux/uaccess.h>
 25#include <asm/page.h>
 26#include <asm/pgalloc.h>
 27#include <asm/traps.h>
 28#include <asm/machdep.h>
 29#include <asm/io.h>
 30#ifdef CONFIG_ATARI
 31#include <asm/atari_stram.h>
 32#endif
 33#include <asm/sections.h>
 34#include <asm/tlb.h>
 35
 36/*
 37 * ZERO_PAGE is a special page that is used for zero-initialized
 38 * data and COW.
 39 */
 40void *empty_zero_page;
 41EXPORT_SYMBOL(empty_zero_page);
 42
 
 
 
 
 
 43#ifdef CONFIG_MMU
 44
 
 
 
 45int m68k_virt_to_node_shift;
 46
 
 
 
 
 
 47void __init m68k_setup_node(int node)
 48{
 
 
 
 
 
 
 
 
 
 
 
 
 
 49	node_set_online(node);
 50}
 51
 52#else /* CONFIG_MMU */
 53
 54/*
 55 * paging_init() continues the virtual memory environment setup which
 56 * was begun by the code in arch/head.S.
 57 * The parameters are pointers to where to stick the starting and ending
 58 * addresses of available kernel virtual memory.
 59 */
 60void __init paging_init(void)
 61{
 62	/*
 63	 * Make sure start_mem is page aligned, otherwise bootmem and
 64	 * page_alloc get different views of the world.
 65	 */
 66	unsigned long end_mem = memory_end & PAGE_MASK;
 67	unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, };
 68
 69	high_memory = (void *) end_mem;
 70
 71	empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
 72	if (!empty_zero_page)
 73		panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
 74		      __func__, PAGE_SIZE, PAGE_SIZE);
 75	max_zone_pfn[ZONE_DMA] = end_mem >> PAGE_SHIFT;
 76	free_area_init(max_zone_pfn);
 
 
 
 
 77}
 78
 79#endif /* CONFIG_MMU */
 80
 81void free_initmem(void)
 82{
 83#ifndef CONFIG_MMU_SUN3
 84	free_initmem_default(-1);
 85#endif /* CONFIG_MMU_SUN3 */
 86}
 87
 88#if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE)
 89#define VECTORS	&vectors[0]
 90#else
 91#define VECTORS	_ramvec
 92#endif
 93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 94static inline void init_pointer_tables(void)
 95{
 96#if defined(CONFIG_MMU) && !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
 97	int i, j;
 98
 99	/* insert pointer tables allocated so far into the tablelist */
100	init_pointer_table(kernel_pg_dir, TABLE_PGD);
101	for (i = 0; i < PTRS_PER_PGD; i++) {
102		pud_t *pud = (pud_t *)&kernel_pg_dir[i];
103		pmd_t *pmd_dir;
104
105		if (!pud_present(*pud))
106			continue;
107
108		pmd_dir = (pmd_t *)pgd_page_vaddr(kernel_pg_dir[i]);
109		init_pointer_table(pmd_dir, TABLE_PMD);
110
111		for (j = 0; j < PTRS_PER_PMD; j++) {
112			pmd_t *pmd = &pmd_dir[j];
113			pte_t *pte_dir;
114
115			if (!pmd_present(*pmd))
116				continue;
117
118			pte_dir = (pte_t *)pmd_page_vaddr(*pmd);
119			init_pointer_table(pte_dir, TABLE_PTE);
120		}
121	}
 
 
 
 
122#endif
123}
124
125void __init mem_init(void)
126{
127	/* this will put all memory onto the freelists */
128	memblock_free_all();
129	init_pointer_tables();
 
 
 
 
 
 
 
 
130}
v3.15
 
  1/*
  2 *  linux/arch/m68k/mm/init.c
  3 *
  4 *  Copyright (C) 1995  Hamish Macdonald
  5 *
  6 *  Contains common initialization routines, specific init code moved
  7 *  to motorola.c and sun3mmu.c
  8 */
  9
 10#include <linux/module.h>
 11#include <linux/signal.h>
 12#include <linux/sched.h>
 13#include <linux/mm.h>
 14#include <linux/swap.h>
 15#include <linux/kernel.h>
 16#include <linux/string.h>
 17#include <linux/types.h>
 18#include <linux/init.h>
 19#include <linux/bootmem.h>
 20#include <linux/gfp.h>
 21
 22#include <asm/setup.h>
 23#include <asm/uaccess.h>
 24#include <asm/page.h>
 25#include <asm/pgalloc.h>
 26#include <asm/traps.h>
 27#include <asm/machdep.h>
 28#include <asm/io.h>
 29#ifdef CONFIG_ATARI
 30#include <asm/atari_stram.h>
 31#endif
 32#include <asm/sections.h>
 33#include <asm/tlb.h>
 34
 35/*
 36 * ZERO_PAGE is a special page that is used for zero-initialized
 37 * data and COW.
 38 */
 39void *empty_zero_page;
 40EXPORT_SYMBOL(empty_zero_page);
 41
 42#if !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
 43extern void init_pointer_table(unsigned long ptable);
 44extern pmd_t *zero_pgtable;
 45#endif
 46
 47#ifdef CONFIG_MMU
 48
 49pg_data_t pg_data_map[MAX_NUMNODES];
 50EXPORT_SYMBOL(pg_data_map);
 51
 52int m68k_virt_to_node_shift;
 53
 54#ifndef CONFIG_SINGLE_MEMORY_CHUNK
 55pg_data_t *pg_data_table[65];
 56EXPORT_SYMBOL(pg_data_table);
 57#endif
 58
 59void __init m68k_setup_node(int node)
 60{
 61#ifndef CONFIG_SINGLE_MEMORY_CHUNK
 62	struct m68k_mem_info *info = m68k_memory + node;
 63	int i, end;
 64
 65	i = (unsigned long)phys_to_virt(info->addr) >> __virt_to_node_shift();
 66	end = (unsigned long)phys_to_virt(info->addr + info->size - 1) >> __virt_to_node_shift();
 67	for (; i <= end; i++) {
 68		if (pg_data_table[i])
 69			printk("overlap at %u for chunk %u\n", i, node);
 70		pg_data_table[i] = pg_data_map + node;
 71	}
 72#endif
 73	pg_data_map[node].bdata = bootmem_node_data + node;
 74	node_set_online(node);
 75}
 76
 77#else /* CONFIG_MMU */
 78
 79/*
 80 * paging_init() continues the virtual memory environment setup which
 81 * was begun by the code in arch/head.S.
 82 * The parameters are pointers to where to stick the starting and ending
 83 * addresses of available kernel virtual memory.
 84 */
 85void __init paging_init(void)
 86{
 87	/*
 88	 * Make sure start_mem is page aligned, otherwise bootmem and
 89	 * page_alloc get different views of the world.
 90	 */
 91	unsigned long end_mem = memory_end & PAGE_MASK;
 92	unsigned long zones_size[MAX_NR_ZONES] = { 0, };
 93
 94	high_memory = (void *) end_mem;
 95
 96	empty_zero_page = alloc_bootmem_pages(PAGE_SIZE);
 97	memset(empty_zero_page, 0, PAGE_SIZE);
 98
 99	/*
100	 * Set up SFC/DFC registers (user data space).
101	 */
102	set_fs (USER_DS);
103
104	zones_size[ZONE_DMA] = (end_mem - PAGE_OFFSET) >> PAGE_SHIFT;
105	free_area_init(zones_size);
106}
107
108#endif /* CONFIG_MMU */
109
110void free_initmem(void)
111{
112#ifndef CONFIG_MMU_SUN3
113	free_initmem_default(-1);
114#endif /* CONFIG_MMU_SUN3 */
115}
116
117#if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE)
118#define VECTORS	&vectors[0]
119#else
120#define VECTORS	_ramvec
121#endif
122
123void __init print_memmap(void)
124{
125#define UL(x) ((unsigned long) (x))
126#define MLK(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 10
127#define MLM(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 20
128#define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), 1024)
129
130	pr_notice("Virtual kernel memory layout:\n"
131		"    vector  : 0x%08lx - 0x%08lx   (%4ld KiB)\n"
132		"    kmap    : 0x%08lx - 0x%08lx   (%4ld MiB)\n"
133		"    vmalloc : 0x%08lx - 0x%08lx   (%4ld MiB)\n"
134		"    lowmem  : 0x%08lx - 0x%08lx   (%4ld MiB)\n"
135		"      .init : 0x%p" " - 0x%p" "   (%4d KiB)\n"
136		"      .text : 0x%p" " - 0x%p" "   (%4d KiB)\n"
137		"      .data : 0x%p" " - 0x%p" "   (%4d KiB)\n"
138		"      .bss  : 0x%p" " - 0x%p" "   (%4d KiB)\n",
139		MLK(VECTORS, VECTORS + 256),
140		MLM(KMAP_START, KMAP_END),
141		MLM(VMALLOC_START, VMALLOC_END),
142		MLM(PAGE_OFFSET, (unsigned long)high_memory),
143		MLK_ROUNDUP(__init_begin, __init_end),
144		MLK_ROUNDUP(_stext, _etext),
145		MLK_ROUNDUP(_sdata, _edata),
146		MLK_ROUNDUP(__bss_start, __bss_stop));
147}
148
149static inline void init_pointer_tables(void)
150{
151#if defined(CONFIG_MMU) && !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
152	int i;
153
154	/* insert pointer tables allocated so far into the tablelist */
155	init_pointer_table((unsigned long)kernel_pg_dir);
156	for (i = 0; i < PTRS_PER_PGD; i++) {
157		if (pgd_present(kernel_pg_dir[i]))
158			init_pointer_table(__pgd_page(kernel_pg_dir[i]));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159	}
160
161	/* insert also pointer table that we used to unmap the zero page */
162	if (zero_pgtable)
163		init_pointer_table((unsigned long)zero_pgtable);
164#endif
165}
166
167void __init mem_init(void)
168{
169	/* this will put all memory onto the freelists */
170	free_all_bootmem();
171	init_pointer_tables();
172	mem_init_print_info(NULL);
173	print_memmap();
174}
175
176#ifdef CONFIG_BLK_DEV_INITRD
177void free_initrd_mem(unsigned long start, unsigned long end)
178{
179	free_reserved_area((void *)start, (void *)end, -1, "initrd");
180}
181#endif