patch-1.3.44 linux/arch/sparc/mm/init.c

Next file: linux/arch/sparc/mm/loadmmu.c
Previous file: linux/arch/sparc/mm/fault.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.43/linux/arch/sparc/mm/init.c linux/arch/sparc/mm/init.c
@@ -1,4 +1,4 @@
-/*
+/*  $Id: init.c,v 1.26 1995/11/25 00:59:22 davem Exp $
  *  linux/arch/sparc/mm/init.c
  *
  *  Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
@@ -23,29 +23,10 @@
 #include <asm/pgtable.h>
 #include <asm/vaddrs.h>
 
-extern void scsi_mem_init(unsigned long);
-extern void sound_mem_init(void);
-extern void die_if_kernel(char *,struct pt_regs *,long);
 extern void show_net_buffers(void);
 
 struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
 
-/* The following number keeps track of which page table is to
- * next be allocated in a page.  This is necessary since there
- * are 16 page tables per page on the space.
- */
-unsigned long ptr_in_current_pgd;
-
-/* This keeps track of which physical segments are in use right now. */
-unsigned int phys_seg_map[PSEG_ENTRIES];
-unsigned int phys_seg_life[PSEG_ENTRIES];
-
-/* Context allocation. */
-struct task_struct *ctx_tasks[MAX_CTXS];
-int ctx_tasks_last_frd;
-
-extern int invalid_segment, num_segmaps, num_contexts;
-
 /*
  * BAD_PAGE is the page that is used for page faults when linux
  * is out-of-memory. Older versions of linux just did a
@@ -82,18 +63,18 @@
 	int i,free = 0,total = 0,reserved = 0;
 	int shared = 0;
 
-	printk("Mem-info:\n");
+	printk("\nMem-info:\n");
 	show_free_areas();
 	printk("Free swap:       %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10));
-	i = high_memory >> PAGE_SHIFT;
+	i = MAP_NR(high_memory);
 	while (i-- > 0) {
 		total++;
-		if (mem_map[i] & MAP_PAGE_RESERVED)
+		if (mem_map[i].reserved)
 			reserved++;
-		else if (!mem_map[i])
+		else if (!mem_map[i].count)
 			free++;
 		else
-			shared += mem_map[i]-1;
+			shared += mem_map[i].count-1;
 	}
 	printk("%d pages of RAM\n",total);
 	printk("%d free pages\n",free);
@@ -105,7 +86,6 @@
 #endif
 }
 
-extern unsigned long free_area_init(unsigned long, unsigned long);
 extern pgprot_t protection_map[16];
 
 /*
@@ -119,57 +99,51 @@
 
 unsigned long paging_init(unsigned long start_mem, unsigned long end_mem)
 {
-	int i;
-
 	switch(sparc_cpu_model) {
 	case sun4c:
+	case sun4e:
 		start_mem = sun4c_paging_init(start_mem, end_mem);
 		break;
 	case sun4m:
 	case sun4d:
-	case sun4e:
 		start_mem = srmmu_paging_init(start_mem, end_mem);
 		break;
 	default:
 		printk("paging_init: Cannot init paging on this Sparc\n");
 		printk("paging_init: sparc_cpu_model = %d\n", sparc_cpu_model);
 		printk("paging_init: Halting...\n");
-		halt();
+		panic("paging_init");
 	};
 
-	/* Initialize context map. */
-	for(i=0; i<MAX_CTXS; i++) ctx_tasks[i] = NULL;
-
-	/* Initialize the protection map */
-	protection_map[0] = __P000;
-	protection_map[1] = __P001;
-	protection_map[2] = __P010;
-	protection_map[3] = __P011;
-	protection_map[4] = __P100;
-	protection_map[5] = __P101;
-	protection_map[6] = __P110;
-	protection_map[7] = __P111;
-	protection_map[8] = __S000;
-	protection_map[9] = __S001;
-	protection_map[10] = __S010;
-	protection_map[11] = __S011;
-	protection_map[12] = __S100;
-	protection_map[13] = __S101;
-	protection_map[14] = __S110;
-	protection_map[15] = __S111;
-
-	start_mem = probe_devices(start_mem);
-
-	return start_mem;
+	/* Initialize the protection map with non-constant values
+	 * MMU dependant values.
+	 */
+	protection_map[0] = PAGE_NONE;
+	protection_map[1] = PAGE_READONLY;
+	protection_map[2] = PAGE_COPY;
+	protection_map[3] = PAGE_COPY;
+	protection_map[4] = PAGE_READONLY;
+	protection_map[5] = PAGE_READONLY;
+	protection_map[6] = PAGE_COPY;
+	protection_map[7] = PAGE_COPY;
+	protection_map[8] = PAGE_NONE;
+	protection_map[9] = PAGE_READONLY;
+	protection_map[10] = PAGE_SHARED;
+	protection_map[11] = PAGE_SHARED;
+	protection_map[12] = PAGE_READONLY;
+	protection_map[13] = PAGE_READONLY;
+	protection_map[14] = PAGE_SHARED;
+	protection_map[15] = PAGE_SHARED;
+	return probe_devices(start_mem);
 }
 
-extern unsigned long sun4c_test_wp(unsigned long);
+extern void sun4c_test_wp(void);
+extern void sun4c_lock_entire_kernel(unsigned long start_mem);
 extern void srmmu_test_wp(void);
 
 void mem_init(unsigned long start_mem, unsigned long end_mem)
 {
 	int codepages = 0;
-	int reservedpages = 0;
 	int datapages = 0;
 	unsigned long tmp2, addr;
 	extern char etext;
@@ -181,85 +155,75 @@
 
 	addr = PAGE_OFFSET;
 	while(addr < start_mem) {
-		mem_map[MAP_NR(addr)] = MAP_PAGE_RESERVED;
+		mem_map[MAP_NR(addr)].reserved = 1;
 		addr += PAGE_SIZE;
 	}
 
-	for(addr = start_mem; addr < end_mem; addr += PAGE_SIZE)
-			mem_map[MAP_NR(addr)] = 0;
-
-#ifdef CONFIG_SCSI
-	scsi_mem_init(high_memory);
-#endif
-
+	for(addr = start_mem; addr < end_mem; addr += PAGE_SIZE) {
+		for(tmp2=0; sp_banks[tmp2].num_bytes != 0; tmp2++) {
+			unsigned long phys_addr = (addr - PAGE_OFFSET);
+			unsigned long base = sp_banks[tmp2].base_addr;
+			unsigned long limit = base + sp_banks[tmp2].num_bytes;
+
+			if((phys_addr >= base) && (phys_addr < limit) &&
+			   ((phys_addr + PAGE_SIZE) < limit))
+				mem_map[MAP_NR(addr)].reserved = 0;
+		}
+	}
 	for (addr = PAGE_OFFSET; addr < end_mem; addr += PAGE_SIZE) {
-		if(mem_map[MAP_NR(addr)]) {
+		if(mem_map[MAP_NR(addr)].reserved) {
 			if (addr < (unsigned long) &etext)
 				codepages++;
 			else if(addr < start_mem)
 				datapages++;
-			else
-				reservedpages++;
 			continue;
 		}
-		mem_map[MAP_NR(addr)] = 1;
+		mem_map[MAP_NR(addr)].count = 1;
 		free_page(addr);
 	}
 
 	tmp2 = nr_free_pages << PAGE_SHIFT;
 
-	printk("Memory: %luk/%luk available (%dk kernel code, %dk reserved, %dk data)\n",
+	printk("Memory: %luk available (%dk kernel code, %dk data)\n",
 	       tmp2 >> 10,
-	       (high_memory - PAGE_OFFSET) >> 10,
 	       codepages << (PAGE_SHIFT-10),
-	       reservedpages << (PAGE_SHIFT-10),
 	       datapages << (PAGE_SHIFT-10));
 
-/* Heh, test write protection just like the i386, this is bogus but it is
- * fun to do ;)
- */
 	switch(sparc_cpu_model) {
 	case sun4c:
-		start_mem = sun4c_test_wp(start_mem);
+	case sun4e:
+		sun4c_lock_entire_kernel(start_mem);
+		sun4c_test_wp();
 		break;
 	case sun4m:
 	case sun4d:
-	case sun4e:
 		srmmu_test_wp();
 		break;
 	default:
 		printk("mem_init: Could not test WP bit on this machine.\n");
 		printk("mem_init: sparc_cpu_model = %d\n", sparc_cpu_model);
 		printk("mem_init: Halting...\n");
-		halt();
+		panic("mem_init()");
 	};
-
-#ifdef DEBUG_MEMINIT
-	printk("Breaker breaker...Roger roger.... Over and out...\n");
-#endif
-	invalidate();
-
-	return;
 }
 
 void si_meminfo(struct sysinfo *val)
 {
 	int i;
 
-	i = high_memory >> PAGE_SHIFT;
+	i = MAP_NR(high_memory);
 	val->totalram = 0;
 	val->sharedram = 0;
 	val->freeram = nr_free_pages << PAGE_SHIFT;
 	val->bufferram = buffermem;
 	while (i-- > 0)  {
-		if (mem_map[i] & MAP_PAGE_RESERVED)
+		if (mem_map[i].reserved)
 			continue;
 		val->totalram++;
-		if (!mem_map[i])
+		if (!mem_map[i].count)
 			continue;
-		val->sharedram += mem_map[i]-1;
+		val->sharedram += mem_map[i].count-1;
 	}
 	val->totalram <<= PAGE_SHIFT;
 	val->sharedram <<= PAGE_SHIFT;
-	return;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this