|
From: Andy P. <at...@us...> - 2002-04-10 18:39:53
|
Update of /cvsroot/linux-vax/kernel-2.4/arch/mips64/arc
In directory usw-pr-cvs1:/tmp/cvs-serv18937/mips64/arc
Modified Files:
Makefile cmdline.c console.c env.c file.c identify.c init.c
memory.c misc.c salone.c time.c tree.c
Added Files:
arc_con.c
Removed Files:
printf.c
Log Message:
synch 2.4.15 commit 38
--- NEW FILE ---
/*
* Wrap-around code for a console using the
* ARC io-routines.
*
* Copyright (c) 1998 Harald Koerfgen
* Copyright (c) 2001 Ralf Baechle
*/
#include <linux/tty.h>
#include <linux/major.h>
#include <linux/ptrace.h>
#include <linux/init.h>
#include <linux/console.h>
#include <linux/fs.h>
#include <asm/sgialib.h>
extern void prom_printf (char *, ...);
void prom_putchar(char c)
{
ULONG cnt;
CHAR it = c;
ArcWrite(1, &it, 1, &cnt);
}
static void prom_console_write(struct console *co, const char *s,
unsigned count)
{
unsigned i;
/*
* Now, do each character
*/
for (i = 0; i < count; i++) {
if (*s == 10)
prom_printf("%c", 13);
prom_printf("%c", *s++);
}
}
static int prom_console_wait_key(struct console *co)
{
return 0;
}
static int __init prom_console_setup(struct console *co, char *options)
{
return 0;
}
static kdev_t prom_console_device(struct console *c)
{
return MKDEV(TTY_MAJOR, 64 + c->index);
}
static struct console arc_cons = {
"ttyS",
prom_console_write,
NULL,
prom_console_device,
prom_console_wait_key,
NULL,
prom_console_setup,
CON_PRINTBUFFER,
-1,
0,
NULL
};
/*
* Register console.
*/
void __init arc_console_init(void)
{
register_console(&arc_cons);
}
Index: Makefile
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/arch/mips64/arc/Makefile,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- Makefile 25 Feb 2001 23:15:22 -0000 1.1.1.2
+++ Makefile 10 Apr 2002 14:43:18 -0000 1.2
@@ -3,13 +3,10 @@
#
L_TARGET = arclib.a
-obj-y := init.o printf.o tree.o env.o cmdline.o misc.o time.o file.o \
- identify.o
-
-ifndef CONFIG_SGI_IP27
- obj-y += console.o
-endif
+obj-y := console.o init.o identify.o tree.o env.o cmdline.o misc.o time.o \
+ file.o
obj-$(CONFIG_ARC_MEMORY) += memory.o
+obj-$(CONFIG_ARC_CONSOLE) += arc_con.o
include $(TOPDIR)/Rules.make
Index: cmdline.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/arch/mips64/arc/cmdline.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- cmdline.c 14 Jan 2001 19:53:32 -0000 1.1.1.1
+++ cmdline.c 10 Apr 2002 14:43:19 -0000 1.2
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
@@ -30,10 +29,49 @@
"SystemPartition=",
"OSLoader=",
"OSLoadPartition=",
- "OSLoadFilename="
+ "OSLoadFilename=",
+ "OSLoadOptions="
};
#define NENTS(foo) ((sizeof((foo)) / (sizeof((foo[0])))))
+static char *used_arc[][2] = {
+ { "OSLoadPartition=", "root=" },
+ { "OSLoadOptions=", "" }
+};
+
+static char * __init move_firmware_args(char* cp)
+{
+ char *s;
+ int actr, i;
+
+ actr = 1; /* Always ignore argv[0] */
+
+ while (actr < prom_argc) {
+ for(i = 0; i < NENTS(used_arc); i++) {
+ int len = strlen(used_arc[i][0]);
+
+ if (!strncmp(prom_argv(actr), used_arc[i][0], len)) {
+ /* Ok, we want it. First append the replacement... */
+ strcat(cp, used_arc[i][1]);
+ cp += strlen(used_arc[i][1]);
+ /* ... and now the argument */
+ s = strstr(prom_argv(actr), "=");
+ if (s) {
+ s++;
+ strcpy(cp, s);
+ cp += strlen(s);
+ }
+ *cp++ = ' ';
+ break;
+ }
+ }
+ actr++;
+ }
+
+ return cp;
+}
+
+
void __init prom_init_cmdline(void)
{
char *cp;
@@ -42,11 +80,17 @@
actr = 1; /* Always ignore argv[0] */
cp = &(arcs_cmdline[0]);
- while(actr < prom_argc) {
- for(i = 0; i < NENTS(ignored); i++) {
+ /*
+ * Move ARC variables to the beginning to make sure they can be
+ * overridden by later arguments.
+ */
+ cp = move_firmware_args(cp);
+
+ while (actr < prom_argc) {
+ for (i = 0; i < NENTS(ignored); i++) {
int len = strlen(ignored[i]);
- if(!strncmp(prom_argv(actr), ignored[i], len))
+ if (!strncmp(prom_argv(actr), ignored[i], len))
goto pic_cont;
}
/* Ok, we want it. */
Index: console.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/arch/mips64/arc/console.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- console.c 14 Jan 2001 19:53:32 -0000 1.1.1.1
+++ console.c 10 Apr 2002 14:43:19 -0000 1.2
@@ -6,22 +6,28 @@
* Copyright (C) 1996 David S. Miller (dm...@sg...)
*/
#include <linux/init.h>
+#include <linux/kernel.h>
#include <asm/sgialib.h>
-void prom_putchar(char c)
+static char ppbuf[1024];
+
+void prom_printf(char *fmt, ...)
{
- ULONG cnt;
- CHAR it = c;
+ va_list args;
+ char ch, *bptr;
+ int i;
- ArcWrite(1, &it, 1, &cnt);
-}
+ va_start(args, fmt);
+ i = vsprintf(ppbuf, fmt, args);
-char __init prom_getchar(void)
-{
- ULONG cnt;
- CHAR c;
+ bptr = ppbuf;
- ArcRead(0, &c, 1, &cnt);
+ while((ch = *(bptr++)) != 0) {
+ if(ch == '\n')
+ prom_putchar('\r');
- return c;
+ prom_putchar(ch);
+ }
+ va_end(args);
+ return;
}
Index: env.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/arch/mips64/arc/env.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- env.c 14 Jan 2001 19:53:32 -0000 1.1.1.1
+++ env.c 10 Apr 2002 14:43:19 -0000 1.2
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
Index: file.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/arch/mips64/arc/file.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- file.c 14 Jan 2001 19:53:33 -0000 1.1.1.1
+++ file.c 10 Apr 2002 14:43:19 -0000 1.2
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
Index: identify.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/arch/mips64/arc/identify.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- identify.c 14 Jan 2001 19:53:33 -0000 1.1.1.1
+++ identify.c 10 Apr 2002 14:43:19 -0000 1.2
@@ -42,14 +42,11 @@
{
int i;
- for (i = 0; i < sizeof (mach_table); i++) {
+ for (i = 0; i < (sizeof (mach_table) / sizeof (mach_table[0])); i++) {
if(!strcmp(s, mach_table[i].name))
return &mach_table[i];
}
- prom_printf("\nYeee, could not determine architecture type <%s>\n", s);
- prom_printf("press a key to reboot\n");
- prom_getchar();
- ArcEnterInteractiveMode();
+ panic("\nYeee, could not determine architecture type <%s>", s);
return NULL;
}
Index: init.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/arch/mips64/arc/init.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- init.c 14 Jan 2001 19:53:33 -0000 1.1.1.1
+++ init.c 10 Apr 2002 14:43:19 -0000 1.2
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
Index: memory.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/arch/mips64/arc/memory.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- memory.c 14 Jan 2001 19:53:34 -0000 1.1.1.1
+++ memory.c 10 Apr 2002 14:43:19 -0000 1.2
@@ -1,11 +1,9 @@
-/* $Id$
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
+/*
+ * memory.c: PROM library functions for acquiring/using memory descriptors
+ * given to us from the ARCS firmware.
*
* Copyright (C) 1996 by David S. Miller
- * Copyright (C) 1999, 2000 by Ralf Baechle
+ * Copyright (C) 1999, 2000, 2001 by Ralf Baechle
* Copyright (C) 1999, 2000 by Silicon Graphics, Inc.
*
* PROM library functions for acquiring/using memory descriptors given to us
@@ -41,7 +39,7 @@
"Free/Contig RAM",
"Generic Free RAM",
"Bad Memory",
- "Standlong Program Pages",
+ "Standalone Program Pages",
"ARCS Temp Storage Area",
"ARCS Permanent Storage Area"
};
@@ -54,31 +52,26 @@
"LoadedProgram",
"FirmwareTemporary",
"FirmwarePermanent",
- "FreeContigiuous"
+ "FreeContiguous"
};
-#define mtypes(a) (prom_flags & PROM_FLAG_ARCS) ? arcs_mtypes[a.arcs] : arc_mtypes[a.arc]
+#define mtypes(a) (prom_flags & PROM_FLAG_ARCS) ? arcs_mtypes[a.arcs] \
+ : arc_mtypes[a.arc]
#endif
-static struct prom_pmemblock pblocks[PROM_MAX_PMEMBLOCKS];
-
-#define MEMTYPE_DONTUSE 0
-#define MEMTYPE_PROM 1
-#define MEMTYPE_FREE 2
-
static inline int memtype_classify_arcs (union linux_memtypes type)
{
switch (type.arcs) {
case arcs_fcontig:
case arcs_free:
- return MEMTYPE_FREE;
+ return BOOT_MEM_RAM;
case arcs_atmp:
- return MEMTYPE_PROM;
+ return BOOT_MEM_ROM_DATA;
case arcs_eblock:
case arcs_rvpage:
case arcs_bmem:
case arcs_prog:
case arcs_aperm:
- return MEMTYPE_DONTUSE;
+ return BOOT_MEM_RESERVED;
default:
BUG();
}
@@ -90,15 +83,15 @@
switch (type.arc) {
case arc_free:
case arc_fcontig:
- return MEMTYPE_FREE;
+ return BOOT_MEM_RAM;
case arc_atmp:
- return MEMTYPE_PROM;
+ return BOOT_MEM_ROM_DATA;
case arc_eblock:
case arc_rvpage:
case arc_bmem:
case arc_prog:
case arc_aperm:
- return MEMTYPE_DONTUSE;
+ return BOOT_MEM_RESERVED;
default:
BUG();
}
@@ -113,52 +106,18 @@
return memtype_classify_arc(type);
}
-static inline unsigned long find_max_low_pfn(void)
-{
- struct prom_pmemblock *p, *highest;
- unsigned long pfn;
-
- p = pblocks;
- highest = 0;
- while (p->size != 0) {
- if (!highest || p->base > highest->base)
- highest = p;
- p++;
- }
-
- pfn = (highest->base + highest->size) >> PAGE_SHIFT;
-#ifdef DEBUG
- prom_printf("find_max_low_pfn: 0x%lx pfns.\n", pfn);
-#endif
- return pfn;
-}
-
-static inline struct prom_pmemblock *find_largest_memblock(void)
-{
- struct prom_pmemblock *p, *largest;
-
- p = pblocks;
- largest = 0;
- while (p->size != 0) {
- if (!largest || p->size > largest->size)
- largest = p;
- p++;
- }
-
- return largest;
-}
-
void __init prom_meminit(void)
{
- struct prom_pmemblock *largest;
- unsigned long bootmap_size;
struct linux_mdesc *p;
- int totram;
- int i = 0;
#ifdef DEBUG
+ int i = 0;
+
prom_printf("ARCS MEMORY DESCRIPTOR dump:\n");
+ i=0;
+ prom_printf ("i=%d\n", i);
p = ArcGetMemoryDescriptor(PROM_NULL_MDESC);
+ prom_printf ("i=%d\n", i);
while(p) {
prom_printf("[%d,%p]: base<%08lx> pages<%08lx> type<%s>\n",
i, p, p->base, p->pages, mtypes(p->type));
@@ -167,78 +126,38 @@
}
#endif
- totram = 0;
- i = 0;
p = PROM_NULL_MDESC;
while ((p = ArcGetMemoryDescriptor(p))) {
- pblocks[i].type = prom_memtype_classify(p->type);
- pblocks[i].base = p->base << PAGE_SHIFT;
- pblocks[i].size = p->pages << PAGE_SHIFT;
-
- switch (pblocks[i].type) {
- case MEMTYPE_FREE:
- totram += pblocks[i].size;
-#ifdef DEBUG
- prom_printf("free_chunk[%d]: base=%08lx size=%x\n",
- i, pblocks[i].base,
- pblocks[i].size);
-#endif
- i++;
- break;
- case MEMTYPE_PROM:
-#ifdef DEBUG
- prom_printf("prom_chunk[%d]: base=%08lx size=%x\n",
- i, pblocks[i].base,
- pblocks[i].size);
-#endif
- i++;
- break;
- default:
- break;
- }
- }
- pblocks[i].size = 0;
+ unsigned long base, size;
+ long type;
- max_low_pfn = find_max_low_pfn();
- largest = find_largest_memblock();
- bootmap_size = init_bootmem(largest->base >> PAGE_SHIFT, max_low_pfn);
-
- for (i = 0; pblocks[i].size; i++)
- if (pblocks[i].type == MEMTYPE_FREE)
- free_bootmem(pblocks[i].base, pblocks[i].size);
-
- /* This test is simpleminded. It will fail if the bootmem bitmap
- falls into multiple adjacent ARC memory areas. */
- if (bootmap_size > largest->size) {
- prom_printf("CRITIAL: overwriting PROM data.\n");
- BUG();
- }
- reserve_bootmem(largest->base, bootmap_size);
+ base = p->base << PAGE_SHIFT;
+ size = p->pages << PAGE_SHIFT;
+ type = prom_memtype_classify(p->type);
- printk("PROMLIB: Total free ram %dK / %dMB.\n",
- totram >> 10, totram >> 20);
+ add_memory_region(base, size, type);
+ }
}
-void __init
-prom_free_prom_memory (void)
+void __init prom_free_prom_memory (void)
{
- struct prom_pmemblock *p;
unsigned long freed = 0;
- unsigned long addr, end;
+ unsigned long addr;
+ int i;
- for (p = pblocks; p->size != 0; p++) {
- if (p->type != MEMTYPE_PROM)
+ for (i = 0; i < boot_mem_map.nr_map; i++) {
+ if (boot_mem_map.map[i].type != BOOT_MEM_ROM_DATA)
continue;
- addr = PAGE_OFFSET + (unsigned long) (long) p->base;
- end = addr + (unsigned long) (long) p->size;
- while (addr < end) {
- ClearPageReserved(virt_to_page(addr));
- set_page_count(virt_to_page(addr), 1);
- free_page(addr);
+ addr = boot_mem_map.map[i].addr;
+ while (addr < boot_mem_map.map[i].addr
+ + boot_mem_map.map[i].size) {
+ ClearPageReserved(virt_to_page(__va(addr)));
+ set_page_count(virt_to_page(__va(addr)), 1);
+ free_page((unsigned long)__va(addr));
addr += PAGE_SIZE;
freed += PAGE_SIZE;
}
}
- printk("Freeing prom memory: %ldkb freed\n", freed >> 10);
+ printk(KERN_INFO "Freeing prom memory: %ldkb freed\n", freed >> 10);
}
Index: misc.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/arch/mips64/arc/misc.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- misc.c 14 Jan 2001 19:53:34 -0000 1.1.1.1
+++ misc.c 10 Apr 2002 14:43:19 -0000 1.2
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
Index: salone.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/arch/mips64/arc/salone.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- salone.c 14 Jan 2001 19:53:34 -0000 1.1.1.1
+++ salone.c 10 Apr 2002 14:43:19 -0000 1.2
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
* Routines to load into memory and execute stand-along program images using
* ARCS PROM firmware.
*
Index: time.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/arch/mips64/arc/time.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- time.c 14 Jan 2001 19:53:34 -0000 1.1.1.1
+++ time.c 10 Apr 2002 14:43:19 -0000 1.2
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
Index: tree.c
===================================================================
RCS file: /cvsroot/linux-vax/kernel-2.4/arch/mips64/arc/tree.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- tree.c 14 Jan 2001 19:53:35 -0000 1.1.1.1
+++ tree.c 10 Apr 2002 14:43:19 -0000 1.2
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
@@ -123,8 +122,6 @@
dump_component(p);
p = ArcGetPeer(p);
}
- prom_printf("press a key\n");
- prom_getchar();
}
#endif /* DEBUG_PROM_TREE */
--- printf.c DELETED ---
|