~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/dec/prom/memory.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * memory.c: memory initialisation code.
  4  *
  5  * Copyright (C) 1998 Harald Koerfgen, Frieder Streffer and Paul M. Antoine
  6  * Copyright (C) 2000, 2002  Maciej W. Rozycki
  7  */
  8 #include <linux/init.h>
  9 #include <linux/kernel.h>
 10 #include <linux/mm.h>
 11 #include <linux/memblock.h>
 12 #include <linux/types.h>
 13 
 14 #include <asm/addrspace.h>
 15 #include <asm/dec/machtype.h>
 16 #include <asm/dec/prom.h>
 17 #include <asm/page.h>
 18 #include <asm/sections.h>
 19 
 20 
 21 volatile unsigned long mem_err;         /* So we know an error occurred */
 22 
 23 /*
 24  * Probe memory in 4MB chunks, waiting for an error to tell us we've fallen
 25  * off the end of real memory.  Only suitable for the 2100/3100's (PMAX).
 26  */
 27 
 28 #define CHUNK_SIZE 0x400000
 29 
 30 static __init void pmax_setup_memory_region(void)
 31 {
 32         volatile unsigned char *memory_page, dummy;
 33         char old_handler[0x80];
 34         extern char genexcept_early;
 35 
 36         /* Install exception handler */
 37         memcpy(&old_handler, (void *)(CKSEG0 + 0x80), 0x80);
 38         memcpy((void *)(CKSEG0 + 0x80), &genexcept_early, 0x80);
 39 
 40         /* read unmapped and uncached (KSEG1)
 41          * DECstations have at least 4MB RAM
 42          * Assume less than 480MB of RAM, as this is max for 5000/2xx
 43          * FIXME this should be replaced by the first free page!
 44          */
 45         for (memory_page = (unsigned char *)CKSEG1 + CHUNK_SIZE;
 46              mem_err == 0 && memory_page < (unsigned char *)CKSEG1 + 0x1e00000;
 47              memory_page += CHUNK_SIZE) {
 48                 dummy = *memory_page;
 49         }
 50         memcpy((void *)(CKSEG0 + 0x80), &old_handler, 0x80);
 51 
 52         memblock_add(0, (unsigned long)memory_page - CKSEG1 - CHUNK_SIZE);
 53 }
 54 
 55 /*
 56  * Use the REX prom calls to get hold of the memory bitmap, and thence
 57  * determine memory size.
 58  */
 59 static __init void rex_setup_memory_region(void)
 60 {
 61         int i, bitmap_size;
 62         unsigned long mem_start = 0, mem_size = 0;
 63         memmap *bm;
 64 
 65         /* some free 64k */
 66         bm = (memmap *)CKSEG0ADDR(0x28000);
 67 
 68         bitmap_size = rex_getbitmap(bm);
 69 
 70         for (i = 0; i < bitmap_size; i++) {
 71                 /* FIXME: very simplistically only add full sets of pages */
 72                 if (bm->bitmap[i] == 0xff)
 73                         mem_size += (8 * bm->pagesize);
 74                 else if (!mem_size)
 75                         mem_start += (8 * bm->pagesize);
 76                 else {
 77                         memblock_add(mem_start, mem_size);
 78                         mem_start += mem_size + (8 * bm->pagesize);
 79                         mem_size = 0;
 80                 }
 81         }
 82         if (mem_size)
 83                 memblock_add(mem_start, mem_size);
 84 }
 85 
 86 void __init prom_meminit(u32 magic)
 87 {
 88         if (!prom_is_rex(magic))
 89                 pmax_setup_memory_region();
 90         else
 91                 rex_setup_memory_region();
 92 }
 93 
 94 void __init prom_free_prom_memory(void)
 95 {
 96         unsigned long end;
 97 
 98         /*
 99          * Free everything below the kernel itself but leave
100          * the first page reserved for the exception handlers.
101          */
102 
103 #if IS_ENABLED(CONFIG_DECLANCE)
104         /*
105          * Leave 128 KB reserved for Lance memory for
106          * IOASIC DECstations.
107          *
108          * XXX: save this address for use in dec_lance.c?
109          */
110         if (IOASIC)
111                 end = __pa(&_text) - 0x00020000;
112         else
113 #endif
114                 end = __pa(&_text);
115 
116         free_init_pages("unused PROM memory", PAGE_SIZE, end);
117 }
118 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php