diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1999-08-20 21:58:59 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1999-08-20 21:58:59 +0000 |
commit | 892bf98f0c04e9297979936d973c85e62a3f0b96 (patch) | |
tree | 3f9570013732b9472502e71b25d5a76591eaed9a /arch/mips64/arc | |
parent | d4339ea6c6ab0bdf909d587bd9c5a754e362833d (diff) |
More MIPS64 chainsawing.
Diffstat (limited to 'arch/mips64/arc')
-rw-r--r-- | arch/mips64/arc/.cvsignore | 2 | ||||
-rw-r--r-- | arch/mips64/arc/Makefile | 23 | ||||
-rw-r--r-- | arch/mips64/arc/cmdline.c | 67 | ||||
-rw-r--r-- | arch/mips64/arc/console.c | 29 | ||||
-rw-r--r-- | arch/mips64/arc/env.c | 25 | ||||
-rw-r--r-- | arch/mips64/arc/file.c | 68 | ||||
-rw-r--r-- | arch/mips64/arc/identify.c | 71 | ||||
-rw-r--r-- | arch/mips64/arc/init.c | 61 | ||||
-rw-r--r-- | arch/mips64/arc/memory.c | 212 | ||||
-rw-r--r-- | arch/mips64/arc/misc.c | 93 | ||||
-rw-r--r-- | arch/mips64/arc/printf.c | 37 | ||||
-rw-r--r-- | arch/mips64/arc/salone.c | 26 | ||||
-rw-r--r-- | arch/mips64/arc/time.c | 22 | ||||
-rw-r--r-- | arch/mips64/arc/tree.c | 113 |
14 files changed, 849 insertions, 0 deletions
diff --git a/arch/mips64/arc/.cvsignore b/arch/mips64/arc/.cvsignore new file mode 100644 index 000000000..857dd22e9 --- /dev/null +++ b/arch/mips64/arc/.cvsignore @@ -0,0 +1,2 @@ +.depend +.*.flags diff --git a/arch/mips64/arc/Makefile b/arch/mips64/arc/Makefile new file mode 100644 index 000000000..86a5ad8f2 --- /dev/null +++ b/arch/mips64/arc/Makefile @@ -0,0 +1,23 @@ +# $Id$ +# Makefile for the SGI arcs prom monitor library routines +# under Linux. +# +# Note! Dependencies are done automagically by 'make dep', which also +# removes any old dependencies. DON'T put your own dependencies here +# unless it's something special (ie not a .c file). +# +# Note 2! The CFLAGS definitions are now in the main makefile... + +OBJS = console.o init.o printf.o memory.o tree.o env.o \ + cmdline.o misc.o time.o file.o identify.o + +all: arclib.a + +arclib.a: $(OBJS) + $(AR) rcs arclib.a $(OBJS) + sync + +dep: + $(CPP) -M *.c > .depend + +include $(TOPDIR)/Rules.make diff --git a/arch/mips64/arc/cmdline.c b/arch/mips64/arc/cmdline.c new file mode 100644 index 000000000..7e58e8f7e --- /dev/null +++ b/arch/mips64/arc/cmdline.c @@ -0,0 +1,67 @@ +/* $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. + * + * cmdline.c: Kernel command line creation using ARCS argc/argv. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/string.h> + +#include <asm/sgialib.h> +#include <asm/bootinfo.h> + +/* #define DEBUG_CMDLINE */ + +char arcs_cmdline[CL_SIZE]; + +char * __init prom_getcmdline(void) +{ + return &(arcs_cmdline[0]); +} + +static char *ignored[] = { + "ConsoleIn=", + "ConsoleOut=", + "SystemPartition=", + "OSLoader=", + "OSLoadPartition=", + "OSLoadFilename=" +}; +#define NENTS(foo) ((sizeof((foo)) / (sizeof((foo[0]))))) + +void __init prom_init_cmdline(void) +{ + char *cp; + int actr, i; + + actr = 1; /* Always ignore argv[0] */ + + cp = &(arcs_cmdline[0]); + while(actr < prom_argc) { + for(i = 0; i < NENTS(ignored); i++) { + int len = strlen(ignored[i]); + + if(!strncmp(prom_argv[actr], ignored[i], len)) + goto pic_cont; + } + /* Ok, we want it. */ + strcpy(cp, prom_argv[actr]); + cp += strlen(prom_argv[actr]); + *cp++ = ' '; + + pic_cont: + actr++; + } + if (cp != &(arcs_cmdline[0])) /* get rid of trailing space */ + --cp; + *cp = '\0'; + +#ifdef DEBUG_CMDLINE + prom_printf("prom_init_cmdline: %s\n", &(arcs_cmdline[0])); +#endif +} diff --git a/arch/mips64/arc/console.c b/arch/mips64/arc/console.c new file mode 100644 index 000000000..f16d2a766 --- /dev/null +++ b/arch/mips64/arc/console.c @@ -0,0 +1,29 @@ +/* $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. + * + * console.c: SGI arcs console code. + * + * Copyright (C) 1996 David S. Miller (dm@sgi.com) + */ +#include <linux/init.h> +#include <asm/sgialib.h> + +void __init prom_putchar(char c) +{ + long cnt; + char it = c; + + romvec->write(1, &it, 1, &cnt); +} + +char __init prom_getchar(void) +{ + long cnt; + char c; + + romvec->read(0, &c, 1, &cnt); + return c; +} diff --git a/arch/mips64/arc/env.c b/arch/mips64/arc/env.c new file mode 100644 index 000000000..55a250047 --- /dev/null +++ b/arch/mips64/arc/env.c @@ -0,0 +1,25 @@ +/* $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. + * + * env.c: ARCS environment variable routines. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/string.h> + +#include <asm/sgialib.h> + +char * __init prom_getenv(char *name) +{ + return romvec->get_evar(name); +} + +long __init prom_setenv(char *name, char *value) +{ + return romvec->set_evar(name, value); +} diff --git a/arch/mips64/arc/file.c b/arch/mips64/arc/file.c new file mode 100644 index 000000000..f609e7846 --- /dev/null +++ b/arch/mips64/arc/file.c @@ -0,0 +1,68 @@ +/* $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. + * + * ARC firmware interface. + * + * Copyright (C) 1994, 1995, 1996, 1999 Ralf Baechle + * Copyright (C) 1999 Silicon Graphics, Inc. + */ +#include <linux/init.h> +#include <asm/sgialib.h> + +long __init prom_getvdirent(unsigned long fd, struct linux_vdirent *ent, + unsigned long num, unsigned long *cnt) +{ + return ARC_CALL4(get_vdirent, fd, ent, num, cnt); +} + +long __init prom_open(char *name, enum linux_omode md, unsigned long *fd) +{ + return ARC_CALL3(open, name, md, fd); +} + +long __init prom_close(unsigned long fd) +{ + return ARC_CALL1(close, fd); +} + +long __init prom_read(unsigned long fd, void *buf, unsigned long num, + unsigned long *cnt) +{ + return ARC_CALL4(read, fd, buf, num, cnt); +} + +long __init prom_getrstatus(unsigned long fd) +{ + return ARC_CALL1(get_rstatus, fd); +} + +long __init prom_write(unsigned long fd, void *buf, unsigned long num, + unsigned long *cnt) +{ + return ARC_CALL4(write, fd, buf, num, cnt); +} + +long __init prom_seek(unsigned long fd, struct linux_bigint *off, + enum linux_seekmode sm) +{ + return ARC_CALL3(seek, fd, off, sm); +} + +long __init prom_mount(char *name, enum linux_mountops op) +{ + return ARC_CALL2(mount, name, op); +} + +long __init prom_getfinfo(unsigned long fd, struct linux_finfo *buf) +{ + return ARC_CALL2(get_finfo, fd, buf); +} + +long __init prom_setfinfo(unsigned long fd, unsigned long flags, + unsigned long msk) +{ + return ARC_CALL3(set_finfo, fd, flags, msk); +} diff --git a/arch/mips64/arc/identify.c b/arch/mips64/arc/identify.c new file mode 100644 index 000000000..c2a6809be --- /dev/null +++ b/arch/mips64/arc/identify.c @@ -0,0 +1,71 @@ +/* $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. + * + * identify.c: identify machine by looking up system identifier + * + * Copyright (C) 1998 Thomas Bogendoerfer + * + * This code is based on arch/mips/sgi/kernel/system.c, which is + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/types.h> +#include <linux/string.h> + +#include <asm/sgi/sgi.h> +#include <asm/sgialib.h> +#include <asm/bootinfo.h> + +struct smatch { + char *name; + int group; + int type; + int flags; +}; + +static struct smatch mach_table[] = { + { "SGI-IP22", MACH_GROUP_SGI, MACH_SGI_INDY, PROM_FLAG_ARCS }, + { "Microsoft-Jazz", MACH_GROUP_JAZZ, MACH_MIPS_MAGNUM_4000, 0 }, + { "PICA-61", MACH_GROUP_JAZZ, MACH_ACER_PICA_61, 0 }, + { "RM200PCI", MACH_GROUP_SNI_RM, MACH_SNI_RM200_PCI, 0 } +}; + +int prom_flags; + +static struct smatch * __init string_to_mach(char *s) +{ + int i; + + for (i = 0; i < sizeof (mach_table); 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(); + romvec->imode(); + return NULL; +} + +void __init prom_identify_arch(void) +{ + pcomponent *p; + struct smatch *mach; + + /* The root component tells us what machine architecture we + * have here. + */ + p = prom_getchild(PROM_NULL_COMPONENT); + printk("ARCH: %s\n", p->iname); + mach = string_to_mach(p->iname); + + mips_machgroup = mach->group; + mips_machtype = mach->type; + prom_flags = mach->flags; +} + diff --git a/arch/mips64/arc/init.c b/arch/mips64/arc/init.c new file mode 100644 index 000000000..a94f7da27 --- /dev/null +++ b/arch/mips64/arc/init.c @@ -0,0 +1,61 @@ +/* $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. + * + * PROM library initialisation code. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/config.h> + +#include <asm/sgialib.h> + +#undef DEBUG_PROM_INIT + +/* Master romvec interface. */ +struct linux_romvec *romvec; +struct linux_promblock *sgi_pblock; +int prom_argc; +char **prom_argv, **prom_envp; +unsigned short prom_vers, prom_rev; + +extern void prom_testtree(void); + +int __init prom_init(int argc, char **argv, char **envp) +{ + struct linux_promblock *pb; + + romvec = ROMVECTOR; + pb = sgi_pblock = PROMBLOCK; + prom_argc = argc; + prom_argv = argv; + prom_envp = envp; + + if(pb->magic != 0x53435241) { + prom_printf("Aieee, bad prom vector magic %08lx\n", pb->magic); + while(1) + ; + } + + prom_init_cmdline(); + + prom_vers = pb->ver; + prom_rev = pb->rev; + prom_identify_arch(); + printk("PROMLIB: ARC firmware Version %d Revision %d\n", + prom_vers, prom_rev); + prom_meminit(); + +#ifdef DEBUG_PROM_INIT + { + prom_printf("Press a key to reboot\n"); + (void) prom_getchar(); + romvec->imode(); + } +#endif + return 0; +} diff --git a/arch/mips64/arc/memory.c b/arch/mips64/arc/memory.c new file mode 100644 index 000000000..7212b9e05 --- /dev/null +++ b/arch/mips64/arc/memory.c @@ -0,0 +1,212 @@ +/* $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 David S. Miller (dm@engr.sgi.com) + */ +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/mm.h> +#include <linux/swap.h> +#include <linux/config.h> + +#include <asm/sgialib.h> +#include <asm/page.h> +#include <asm/pgtable.h> +#include <asm/bootinfo.h> + +#undef DEBUG + +struct linux_mdesc * __init prom_getmdesc(struct linux_mdesc *curr) +{ + return romvec->get_mdesc(curr); +} + +#ifdef DEBUG +static char *arcs_mtypes[8] = { /* convenient for debugging */ + "Exception Block", + "ARCS Romvec Page", + "Free/Contig RAM", + "Generic Free RAM", + "Bad Memory", + "Standlong Program Pages", + "ARCS Temp Storage Area", + "ARCS Permanent Storage Area" +}; + +static char *arc_mtypes[8] = { + "Exception Block", + "SystemParameterBlock", + "FreeMemory", + "Bad Memory", + "LoadedProgram", + "FirmwareTemporary", + "FirmwarePermanent", + "FreeContigiuous" +}; +#define mtypes(a) (prom_flags & PROM_FLAG_ARCS) ? arcs_mtypes[a.arcs] : arc_mtypes[a.arc] +#endif + +static struct prom_pmemblock prom_pblocks[PROM_MAX_PMEMBLOCKS]; + +struct prom_pmemblock * __init prom_getpblock_array(void) +{ + return &prom_pblocks[0]; +} + +#define MEMTYPE_DONTUSE 0 +#define MEMTYPE_PROM 1 +#define MEMTYPE_FREE 2 + +static int __init prom_memtype_classify (union linux_memtypes type) +{ + if (prom_flags & PROM_FLAG_ARCS) { + switch (type.arcs) { + case arcs_free: + case arcs_fcontig: + return MEMTYPE_FREE; + case arcs_atmp: + case arcs_aperm: + return MEMTYPE_PROM; + default: + return MEMTYPE_DONTUSE; + } + } else { + switch (type.arc) { + case arc_free: + case arc_fcontig: + return MEMTYPE_FREE; + case arc_rvpage: + case arc_atmp: + case arc_aperm: + return MEMTYPE_PROM; + default: + return MEMTYPE_DONTUSE; + } + } +} + +static void __init prom_setup_memupper(void) +{ + struct prom_pmemblock *p, *highest; + + for(p = prom_getpblock_array(), highest = 0; p->size != 0; p++) { + if(p->base == 0xdeadbeef) + prom_printf("WHEEE, bogus pmemblock\n"); + if(!highest || p->base > highest->base) + highest = p; + } + mips_memory_upper = highest->base + highest->size; +#ifdef DEBUG + prom_printf("prom_setup_memupper: mips_memory_upper = %08lx\n", + mips_memory_upper); +#endif +} + +void __init prom_meminit(void) +{ + struct linux_mdesc *p; + int totram; + int i = 0; + + p = prom_getmdesc(PROM_NULL_MDESC); +#ifdef DEBUG + prom_printf("ARCS MEMORY DESCRIPTOR dump:\n"); + while(p) { + prom_printf("[%d,%p]: base<%08lx> pages<%08lx> type<%s>\n", + i, p, p->base, p->pages, mtypes(p->type)); + p = prom_getmdesc(p); + i++; + } +#endif + p = prom_getmdesc(PROM_NULL_MDESC); + totram = 0; + i = 0; + while(p) { + prom_pblocks[i].type = prom_memtype_classify (p->type); + prom_pblocks[i].base = ((p->base<<PAGE_SHIFT) + 0x80000000); + prom_pblocks[i].size = p->pages << PAGE_SHIFT; + switch (prom_pblocks[i].type) { + case MEMTYPE_FREE: + totram += prom_pblocks[i].size; +#ifdef DEBUG + prom_printf("free_chunk[%d]: base=%08lx size=%d\n", + i, prom_pblocks[i].base, + prom_pblocks[i].size); +#endif + i++; + break; + case MEMTYPE_PROM: +#ifdef DEBUG + prom_printf("prom_chunk[%d]: base=%08lx size=%d\n", + i, prom_pblocks[i].base, + prom_pblocks[i].size); +#endif + i++; + break; + default: + break; + } + p = prom_getmdesc(p); + } + prom_pblocks[i].base = 0xdeadbeef; + prom_pblocks[i].size = 0; /* indicates last elem. of array */ + printk("PROMLIB: Total free ram %d bytes (%dK,%dMB)\n", + totram, (totram/1024), (totram/1024/1024)); + + /* Setup upper physical memory bound. */ + prom_setup_memupper(); +} + +/* Called from mem_init() to fixup the mem_map page settings. */ +void __init prom_fixup_mem_map(unsigned long start, unsigned long end) +{ + struct prom_pmemblock *p; + int i, nents; + + /* Determine number of pblockarray entries. */ + p = prom_getpblock_array(); + for(i = 0; p[i].size; i++) + ; + nents = i; +restart: + while(start < end) { + for(i = 0; i < nents; i++) { + if((p[i].type == MEMTYPE_FREE) && + (start >= (p[i].base)) && + (start < (p[i].base + p[i].size))) { + start = p[i].base + p[i].size; + start &= PAGE_MASK; + goto restart; + } + } + set_bit(PG_reserved, &mem_map[MAP_NR(start)].flags); + start += PAGE_SIZE; + } +} + +void prom_free_prom_memory (void) +{ + struct prom_pmemblock *p; + unsigned long addr; + unsigned long num_pages = 0; + + for(p = prom_getpblock_array(); p->size != 0; p++) { + if (p->type == MEMTYPE_PROM) { + for (addr = p->base; addr < p->base + p->size; addr += PAGE_SIZE) { + mem_map[MAP_NR(addr)].flags &= ~(1 << PG_reserved); + atomic_set(&mem_map[MAP_NR(addr)].count, 1); + free_page(addr); + num_pages++; + } + } + } + printk ("Freeing prom memory: %ldk freed\n", num_pages * PAGE_SIZE); +} diff --git a/arch/mips64/arc/misc.c b/arch/mips64/arc/misc.c new file mode 100644 index 000000000..56945035e --- /dev/null +++ b/arch/mips64/arc/misc.c @@ -0,0 +1,93 @@ +/* $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. + * + * Miscellaneous ARCS PROM routines. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ +#include <linux/config.h> +#include <linux/init.h> +#include <linux/kernel.h> + +#include <asm/bcache.h> +#include <asm/sgialib.h> +#include <asm/bootinfo.h> +#include <asm/system.h> + +extern unsigned long mips_cputype; +extern void *sgiwd93_host; +extern void reset_wd33c93(void *instance); + +void prom_halt(void) +{ + bcops->bc_disable(); + cli(); +#if CONFIG_SCSI_SGIWD93 + reset_wd33c93(sgiwd93_host); +#endif + ARC_CALL0(halt); +never: goto never; +} + +void prom_powerdown(void) +{ + bcops->bc_disable(); + cli(); +#if CONFIG_SCSI_SGIWD93 + reset_wd33c93(sgiwd93_host); +#endif + ARC_CALL0(pdown); +never: goto never; +} + +/* XXX is this a soft reset basically? XXX */ +void prom_restart(void) +{ + bcops->bc_disable(); + cli(); +#if CONFIG_SCSI_SGIWD93 + reset_wd33c93(sgiwd93_host); +#endif + ARC_CALL0(restart); +never: goto never; +} + +void prom_reboot(void) +{ + bcops->bc_disable(); + cli(); +#if CONFIG_SCSI_SGIWD93 + reset_wd33c93(sgiwd93_host); +#endif + ARC_CALL0(reboot); +never: goto never; +} + +void prom_imode(void) +{ + bcops->bc_disable(); + cli(); +#if CONFIG_SCSI_SGIWD93 + reset_wd33c93(sgiwd93_host); +#endif + ARC_CALL0(imode); +never: goto never; +} + +long prom_cfgsave(void) +{ + return ARC_CALL0(cfg_save); +} + +struct linux_sysid *prom_getsysid(void) +{ + return (struct linux_sysid *) ARC_CALL0(get_sysid); +} + +void __init prom_cacheflush(void) +{ + ARC_CALL0(cache_flush); +} diff --git a/arch/mips64/arc/printf.c b/arch/mips64/arc/printf.c new file mode 100644 index 000000000..ccefab0c7 --- /dev/null +++ b/arch/mips64/arc/printf.c @@ -0,0 +1,37 @@ +/* $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. + * + * 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 __init 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; +} diff --git a/arch/mips64/arc/salone.c b/arch/mips64/arc/salone.c new file mode 100644 index 000000000..0635c24a0 --- /dev/null +++ b/arch/mips64/arc/salone.c @@ -0,0 +1,26 @@ +/* $Id$ + * + * Routines to load into memory and execute stand-along program images using + * ARCS PROM firmware. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ +#include <linux/init.h> +#include <asm/sgialib.h> + +long __init prom_load(char *name, unsigned long end, unsigned long *pc, + unsigned long *eaddr) +{ + return romvec->load(name, end, pc, eaddr); +} + +long __init prom_invoke(unsigned long pc, unsigned long sp, long argc, + char **argv, char **envp)) +{ + return romvec->invoke(pc, sp, argc, argv, envp); +} + +long __init prom_exec(char *name, long argc, char **argv, char **envp) +{ + return romvec->exec(name, argc, argv, envp); +} diff --git a/arch/mips64/arc/time.c b/arch/mips64/arc/time.c new file mode 100644 index 000000000..378db5331 --- /dev/null +++ b/arch/mips64/arc/time.c @@ -0,0 +1,22 @@ +/* $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. + * + * Extracting time information from ARCS prom. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ +#include <linux/init.h> +#include <asm/sgialib.h> + +struct __init linux_tinfo *prom_gettinfo(void) +{ + return romvec->get_tinfo(); +} + +unsigned __init long prom_getrtime(void) +{ + return romvec->get_rtime(); +} diff --git a/arch/mips64/arc/tree.c b/arch/mips64/arc/tree.c new file mode 100644 index 000000000..12a88230b --- /dev/null +++ b/arch/mips64/arc/tree.c @@ -0,0 +1,113 @@ +/* $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. + * + * PROM component device tree code. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ +#include <linux/init.h> +#include <asm/sgialib.h> + +#define DEBUG_PROM_TREE + +pcomponent * __init prom_getsibling(pcomponent *this) +{ + if(this == PROM_NULL_COMPONENT) + return PROM_NULL_COMPONENT; + return romvec->next_component(this); +} + +pcomponent * __init prom_getchild(pcomponent *this) +{ + return romvec->child_component(this); +} + +pcomponent * __init prom_getparent(pcomponent *child) +{ + if(child == PROM_NULL_COMPONENT) + return PROM_NULL_COMPONENT; + return romvec->parent_component(child); +} + +long __init prom_getcdata(void *buffer, pcomponent *this) +{ + return romvec->component_data(buffer, this); +} + +pcomponent * __init prom_childadd(pcomponent *this, pcomponent *tmp, + void *data) +{ + return romvec->child_add(this, tmp, data); +} + +long __init prom_delcomponent(pcomponent *this) +{ + return romvec->comp_del(this); +} + +pcomponent * __init prom_componentbypath(char *path) +{ + return romvec->component_by_path(path); +} + +#ifdef DEBUG_PROM_TREE +static char *classes[] = { + "system", "processor", "cache", "adapter", "controller", "peripheral", + "memory" +}; + +static char *types[] = { + "arc", "cpu", "fpu", "picache", "pdcache", "sicache", "sdcache", "sccache", + "memdev", "eisa adapter", "tc adapter", "scsi adapter", "dti adapter", + "multi-func adapter", "disk controller", "tp controller", + "cdrom controller", "worm controller", "serial controller", + "net controller", "display controller", "parallel controller", + "pointer controller", "keyboard controller", "audio controller", + "misc controller", "disk peripheral", "floppy peripheral", + "tp peripheral", "modem peripheral", "monitor peripheral", + "printer peripheral", "pointer peripheral", "keyboard peripheral", + "terminal peripheral", "line peripheral", "net peripheral", + "misc peripheral", "anonymous" +}; + +static char *iflags[] = { + "bogus", "read only", "removable", "console in", "console out", + "input", "output" +}; + +static void __init dump_component(pcomponent *p) +{ + prom_printf("[%p]:class<%s>type<%s>flags<%s>ver<%d>rev<%d>", + p, classes[p->class], types[p->type], + iflags[p->iflags], p->vers, p->rev); + prom_printf("key<%08lx>\n\tamask<%08lx>cdsize<%d>ilen<%d>iname<%s>\n", + p->key, p->amask, (int)p->cdsize, (int)p->ilen, p->iname); +} + +static void __init traverse(pcomponent *p, int op) +{ + dump_component(p); + if(prom_getchild(p)) + traverse(prom_getchild(p), 1); + if(prom_getsibling(p) && op) + traverse(prom_getsibling(p), 1); +} + +void __init prom_testtree(void) +{ + pcomponent *p; + + p = prom_getchild(PROM_NULL_COMPONENT); + dump_component(p); + p = prom_getchild(p); + while(p) { + dump_component(p); + p = prom_getsibling(p); + } + prom_printf("press a key\n"); + prom_getchar(); +} +#endif |