summaryrefslogtreecommitdiffstats
path: root/arch/mips64/arc
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2001-03-18 04:20:23 +0000
committerRalf Baechle <ralf@linux-mips.org>2001-03-18 04:20:23 +0000
commite62014c38d171383c54eb1fee183f14f592521fc (patch)
tree4b7633718336d145b6173478d26a39cb9dcfe088 /arch/mips64/arc
parentc66599c66b70d522363bceb2dec263e76470a3c8 (diff)
Lots of cleanup from Keith with additional tweaks by me. More to
come. Stay frightened :-)
Diffstat (limited to 'arch/mips64/arc')
-rw-r--r--arch/mips64/arc/Makefile9
-rw-r--r--arch/mips64/arc/arc_con.c69
-rw-r--r--arch/mips64/arc/console.c26
-rw-r--r--arch/mips64/arc/identify.c5
-rw-r--r--arch/mips64/arc/memory.c120
-rw-r--r--arch/mips64/arc/printf.c37
6 files changed, 117 insertions, 149 deletions
diff --git a/arch/mips64/arc/Makefile b/arch/mips64/arc/Makefile
index be0f04984..6217a1bdb 100644
--- a/arch/mips64/arc/Makefile
+++ b/arch/mips64/arc/Makefile
@@ -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
diff --git a/arch/mips64/arc/arc_con.c b/arch/mips64/arc/arc_con.c
new file mode 100644
index 000000000..6fe94a6c7
--- /dev/null
+++ b/arch/mips64/arc/arc_con.c
@@ -0,0 +1,69 @@
+/*
+ * Wrap-around code for a console using the
+ * ARC io-routines.
+ *
+ * Copyright (c) 1998 Harald Koerfgen
+ */
+
+#include <linux/tty.h>
+#include <linux/major.h>
+#include <linux/ptrace.h>
+#include <linux/init.h>
+#include <linux/console.h>
+#include <linux/fs.h>
+
+extern char prom_getchar (void);
+extern void prom_printf (char *, ...);
+
+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 prom_getchar();
+}
+
+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);
+}
diff --git a/arch/mips64/arc/console.c b/arch/mips64/arc/console.c
index 31af388dc..2edda7fff 100644
--- a/arch/mips64/arc/console.c
+++ b/arch/mips64/arc/console.c
@@ -6,9 +6,10 @@
* Copyright (C) 1996 David S. Miller (dm@sgi.com)
*/
#include <linux/init.h>
+#include <linux/kernel.h>
#include <asm/sgialib.h>
-void prom_putchar(char c)
+static inline void prom_putchar(char c)
{
ULONG cnt;
CHAR it = c;
@@ -16,12 +17,25 @@ void prom_putchar(char c)
ArcWrite(1, &it, 1, &cnt);
}
-char __init prom_getchar(void)
+static char ppbuf[1024];
+
+void prom_printf(char *fmt, ...)
{
- ULONG cnt;
- CHAR c;
+ va_list args;
+ char ch, *bptr;
+ int i;
+
+ va_start(args, fmt);
+ i = vsprintf(ppbuf, fmt, args);
+
+ 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;
}
diff --git a/arch/mips64/arc/identify.c b/arch/mips64/arc/identify.c
index 732d6db5e..4556418ac 100644
--- a/arch/mips64/arc/identify.c
+++ b/arch/mips64/arc/identify.c
@@ -46,10 +46,7 @@ string_to_mach(const char *s)
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;
}
diff --git a/arch/mips64/arc/memory.c b/arch/mips64/arc/memory.c
index 95051fde4..024cce786 100644
--- a/arch/mips64/arc/memory.c
+++ b/arch/mips64/arc/memory.c
@@ -89,15 +89,15 @@ static inline int memtype_classify_arc (union linux_memtypes type)
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();
}
@@ -112,52 +112,18 @@ static int __init prom_memtype_classify (union linux_memtypes type)
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));
@@ -166,56 +132,17 @@ void __init prom_meminit(void)
}
#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);
+ base = p->base << PAGE_SHIFT;
+ size = p->pages << PAGE_SHIFT;
+ type = prom_memtype_classify(p->type);
- 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();
+ add_memory_region(base, size, type);
}
- reserve_bootmem(largest->base, bootmap_size);
-
- printk("PROMLIB: Total free ram %dK / %dMB.\n",
- totram >> 10, totram >> 20);
}
void __init
@@ -223,18 +150,19 @@ 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;
}
diff --git a/arch/mips64/arc/printf.c b/arch/mips64/arc/printf.c
deleted file mode 100644
index 664bb270b..000000000
--- a/arch/mips64/arc/printf.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* $Id: printf.c,v 1.1 1999/08/20 21:13:33 ralf Exp $
- *
- * 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.
- *
- * Putting things on the screen using SGI arcs PROM facilities.
- *
- * Copyright (C) 1996 David S. Miller (dm@sgi.com)
- */
-#include <linux/init.h>
-#include <linux/kernel.h>
-
-#include <asm/sgialib.h>
-
-static char ppbuf[1024];
-
-void prom_printf(char *fmt, ...)
-{
- va_list args;
- char ch, *bptr;
- int i;
-
- va_start(args, fmt);
- i = vsprintf(ppbuf, fmt, args);
-
- bptr = ppbuf;
-
- while((ch = *(bptr++)) != 0) {
- if(ch == '\n')
- prom_putchar('\r');
-
- prom_putchar(ch);
- }
- va_end(args);
- return;
-}