^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * linux/arch/m68k/mm/motorola.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Routines specific to the Motorola MMU, originally from:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * linux/arch/m68k/init.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * which are Copyright (C) 1995 Hamish Macdonald
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Moved 8/20/1999 Sam Creasey
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/swap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/memblock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/gfp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <asm/setup.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <asm/pgalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <asm/machdep.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <asm/dma.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #ifdef CONFIG_ATARI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <asm/atari_stram.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <asm/sections.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #undef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #ifndef mm_cachebits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * Bits to add to page descriptors for "normal" caching mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * For 68020/030 this is 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * For 68040, this is _PAGE_CACHE040 (cachable, copyback)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) unsigned long mm_cachebits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) EXPORT_SYMBOL(mm_cachebits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* Prior to calling these routines, the page should have been flushed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * from both the cache and ATC, or the CPU might not notice that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * cache setting for the page has been changed. -jskov
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static inline void nocache_page(void *vaddr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) unsigned long addr = (unsigned long)vaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) if (CPU_IS_040_OR_060) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) pte_t *ptep = virt_to_kpte(addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) *ptep = pte_mknocache(*ptep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static inline void cache_page(void *vaddr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) unsigned long addr = (unsigned long)vaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) if (CPU_IS_040_OR_060) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) pte_t *ptep = virt_to_kpte(addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) *ptep = pte_mkcache(*ptep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * Motorola 680x0 user's manual recommends using uncached memory for address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * translation tables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * Seeing how the MMU can be external on (some of) these chips, that seems like
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * a very important recommendation to follow. Provide some helpers to combat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * 'variation' amongst the users of this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) void mmu_page_ctor(void *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) __flush_page_to_ram(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) flush_tlb_kernel_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) nocache_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) void mmu_page_dtor(void *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) cache_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /* ++andreas: {get,free}_pointer_table rewritten to use unused fields from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) struct page instead of separately kmalloced struct. Stolen from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) arch/sparc/mm/srmmu.c ... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) typedef struct list_head ptable_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static struct list_head ptable_list[2] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) LIST_HEAD_INIT(ptable_list[0]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) LIST_HEAD_INIT(ptable_list[1]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #define PD_PTABLE(page) ((ptable_desc *)&(virt_to_page(page)->lru))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define PD_PAGE(ptable) (list_entry(ptable, struct page, lru))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #define PD_MARKBITS(dp) (*(unsigned int *)&PD_PAGE(dp)->index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static const int ptable_shift[2] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 7+2, /* PGD, PMD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 6+2, /* PTE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define ptable_size(type) (1U << ptable_shift[type])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define ptable_mask(type) ((1U << (PAGE_SIZE / ptable_size(type))) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) void __init init_pointer_table(void *table, int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) ptable_desc *dp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) unsigned long ptable = (unsigned long)table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) unsigned long page = ptable & PAGE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) unsigned int mask = 1U << ((ptable - page)/ptable_size(type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) dp = PD_PTABLE(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) if (!(PD_MARKBITS(dp) & mask)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) PD_MARKBITS(dp) = ptable_mask(type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) list_add(dp, &ptable_list[type]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) PD_MARKBITS(dp) &= ~mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) pr_debug("init_pointer_table: %lx, %x\n", ptable, PD_MARKBITS(dp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /* unreserve the page so it's possible to free that page */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) __ClearPageReserved(PD_PAGE(dp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) init_page_count(PD_PAGE(dp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) void *get_pointer_table(int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) ptable_desc *dp = ptable_list[type].next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) unsigned int mask = list_empty(&ptable_list[type]) ? 0 : PD_MARKBITS(dp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) unsigned int tmp, off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * For a pointer table for a user process address space, a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * table is taken from a page allocated for the purpose. Each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * page can hold 8 pointer tables. The page is remapped in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * virtual address space to be noncacheable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) if (mask == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) void *page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) ptable_desc *new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) if (!(page = (void *)get_zeroed_page(GFP_KERNEL)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (type == TABLE_PTE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * m68k doesn't have SPLIT_PTE_PTLOCKS for not having
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * SMP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) pgtable_pte_page_ctor(virt_to_page(page));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) mmu_page_ctor(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) new = PD_PTABLE(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) PD_MARKBITS(new) = ptable_mask(type) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) list_add_tail(new, dp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) return (pmd_t *)page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) for (tmp = 1, off = 0; (mask & tmp) == 0; tmp <<= 1, off += ptable_size(type))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) PD_MARKBITS(dp) = mask & ~tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) if (!PD_MARKBITS(dp)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /* move to end of list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) list_move_tail(dp, &ptable_list[type]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) return page_address(PD_PAGE(dp)) + off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) int free_pointer_table(void *table, int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) ptable_desc *dp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) unsigned long ptable = (unsigned long)table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) unsigned long page = ptable & PAGE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) unsigned int mask = 1U << ((ptable - page)/ptable_size(type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) dp = PD_PTABLE(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) if (PD_MARKBITS (dp) & mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) panic ("table already free!");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) PD_MARKBITS (dp) |= mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) if (PD_MARKBITS(dp) == ptable_mask(type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) /* all tables in page are free, free page */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) list_del(dp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) mmu_page_dtor((void *)page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (type == TABLE_PTE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) pgtable_pte_page_dtor(virt_to_page(page));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) free_page (page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) } else if (ptable_list[type].next != dp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * move this descriptor to the front of the list, since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * it has one or more free tables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) list_move(dp, &ptable_list[type]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) /* size of memory already mapped in head.S */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) extern __initdata unsigned long m68k_init_mapped_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) extern unsigned long availmem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) static pte_t *last_pte_table __initdata = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) static pte_t * __init kernel_page_table(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) pte_t *pte_table = last_pte_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (PAGE_ALIGNED(last_pte_table)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) pte_table = memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) if (!pte_table) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) panic("%s: Failed to allocate %lu bytes align=%lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) __func__, PAGE_SIZE, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) clear_page(pte_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) mmu_page_ctor(pte_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) last_pte_table = pte_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) last_pte_table += PTRS_PER_PTE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) return pte_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) static pmd_t *last_pmd_table __initdata = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static pmd_t * __init kernel_ptr_table(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) if (!last_pmd_table) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) unsigned long pmd, last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) /* Find the last ptr table that was used in head.S and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * reuse the remaining space in that page for further
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * ptr tables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) last = (unsigned long)kernel_pg_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) for (i = 0; i < PTRS_PER_PGD; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) pud_t *pud = (pud_t *)(&kernel_pg_dir[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) if (!pud_present(*pud))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) pmd = pgd_page_vaddr(kernel_pg_dir[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) if (pmd > last)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) last = pmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) last_pmd_table = (pmd_t *)last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) printk("kernel_ptr_init: %p\n", last_pmd_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) last_pmd_table += PTRS_PER_PMD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) if (PAGE_ALIGNED(last_pmd_table)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) last_pmd_table = memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) if (!last_pmd_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) panic("%s: Failed to allocate %lu bytes align=%lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) __func__, PAGE_SIZE, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) clear_page(last_pmd_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) mmu_page_ctor(last_pmd_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) return last_pmd_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) static void __init map_node(int node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) unsigned long physaddr, virtaddr, size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) pgd_t *pgd_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) p4d_t *p4d_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) pud_t *pud_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) pmd_t *pmd_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) pte_t *pte_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) size = m68k_memory[node].size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) physaddr = m68k_memory[node].addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) virtaddr = (unsigned long)phys_to_virt(physaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) physaddr |= m68k_supervisor_cachemode |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_DIRTY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) if (CPU_IS_040_OR_060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) physaddr |= _PAGE_GLOBAL040;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) while (size > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) if (!(virtaddr & (PMD_SIZE-1)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) printk ("\npa=%#lx va=%#lx ", physaddr & PAGE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) virtaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) pgd_dir = pgd_offset_k(virtaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) if (virtaddr && CPU_IS_020_OR_030) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) if (!(virtaddr & (PGDIR_SIZE-1)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) size >= PGDIR_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) printk ("[very early term]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) pgd_val(*pgd_dir) = physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) size -= PGDIR_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) virtaddr += PGDIR_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) physaddr += PGDIR_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) p4d_dir = p4d_offset(pgd_dir, virtaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) pud_dir = pud_offset(p4d_dir, virtaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) if (!pud_present(*pud_dir)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) pmd_dir = kernel_ptr_table();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) printk ("[new pointer %p]", pmd_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) pud_set(pud_dir, pmd_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) pmd_dir = pmd_offset(pud_dir, virtaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) if (CPU_IS_020_OR_030) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) if (virtaddr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) printk ("[early term]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) pmd_val(*pmd_dir) = physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) physaddr += PMD_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) printk ("[zero map]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) pte_dir = kernel_page_table();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) pmd_set(pmd_dir, pte_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) pte_val(*pte_dir++) = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) physaddr += PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) for (i = 1; i < PTRS_PER_PTE; physaddr += PAGE_SIZE, i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) pte_val(*pte_dir++) = physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) size -= PMD_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) virtaddr += PMD_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) if (!pmd_present(*pmd_dir)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) printk ("[new table]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) pte_dir = kernel_page_table();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) pmd_set(pmd_dir, pte_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) pte_dir = pte_offset_kernel(pmd_dir, virtaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) if (virtaddr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) if (!pte_present(*pte_dir))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) pte_val(*pte_dir) = physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) pte_val(*pte_dir) = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) size -= PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) virtaddr += PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) physaddr += PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) printk("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) * paging_init() continues the virtual memory environment setup which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) * was begun by the code in arch/head.S.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) void __init paging_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) unsigned long min_addr, max_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) unsigned long addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) printk ("start of paging_init (%p, %lx)\n", kernel_pg_dir, availmem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) /* Fix the cache mode in the page descriptors for the 680[46]0. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) if (CPU_IS_040_OR_060) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) #ifndef mm_cachebits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) mm_cachebits = _PAGE_CACHE040;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) for (i = 0; i < 16; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) pgprot_val(protection_map[i]) |= _PAGE_CACHE040;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) min_addr = m68k_memory[0].addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) max_addr = min_addr + m68k_memory[0].size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) memblock_add_node(m68k_memory[0].addr, m68k_memory[0].size, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) for (i = 1; i < m68k_num_memory;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) if (m68k_memory[i].addr < min_addr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) printk("Ignoring memory chunk at 0x%lx:0x%lx before the first chunk\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) m68k_memory[i].addr, m68k_memory[i].size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) printk("Fix your bootloader or use a memfile to make use of this area!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) m68k_num_memory--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) memmove(m68k_memory + i, m68k_memory + i + 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) (m68k_num_memory - i) * sizeof(struct m68k_mem_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) memblock_add_node(m68k_memory[i].addr, m68k_memory[i].size, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) addr = m68k_memory[i].addr + m68k_memory[i].size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) if (addr > max_addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) max_addr = addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) m68k_memoffset = min_addr - PAGE_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) m68k_virt_to_node_shift = fls(max_addr - min_addr - 1) - 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) module_fixup(NULL, __start_fixup, __stop_fixup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) flush_icache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) high_memory = phys_to_virt(max_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) min_low_pfn = availmem >> PAGE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) max_pfn = max_low_pfn = max_addr >> PAGE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) /* Reserve kernel text/data/bss and the memory allocated in head.S */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) memblock_reserve(m68k_memory[0].addr, availmem - m68k_memory[0].addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) * Map the physical memory available into the kernel virtual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) * address space. Make sure memblock will not try to allocate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) * pages beyond the memory we already mapped in head.S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) memblock_set_bottom_up(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) for (i = 0; i < m68k_num_memory; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) m68k_setup_node(i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) map_node(i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) flush_tlb_all();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) * initialize the bad page table and bad page to point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) * to a couple of allocated pages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) if (!empty_zero_page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) __func__, PAGE_SIZE, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) * Set up SFC/DFC registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) set_fs(KERNEL_DS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) printk ("before free_area_init\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) for (i = 0; i < m68k_num_memory; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) if (node_present_pages(i))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) node_set_state(i, N_NORMAL_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) max_zone_pfn[ZONE_DMA] = memblock_end_of_DRAM();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) free_area_init(max_zone_pfn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) }