diff options
Diffstat (limited to 'arch/mips/sgi/prom')
-rw-r--r-- | arch/mips/sgi/prom/.cvsignore | 1 | ||||
-rw-r--r-- | arch/mips/sgi/prom/Makefile | 23 | ||||
-rw-r--r-- | arch/mips/sgi/prom/cmdline.c | 60 | ||||
-rw-r--r-- | arch/mips/sgi/prom/console.c | 24 | ||||
-rw-r--r-- | arch/mips/sgi/prom/env.c | 20 | ||||
-rw-r--r-- | arch/mips/sgi/prom/file.c | 58 | ||||
-rw-r--r-- | arch/mips/sgi/prom/init.c | 59 | ||||
-rw-r--r-- | arch/mips/sgi/prom/memory.c | 129 | ||||
-rw-r--r-- | arch/mips/sgi/prom/misc.c | 109 | ||||
-rw-r--r-- | arch/mips/sgi/prom/printf.c | 34 | ||||
-rw-r--r-- | arch/mips/sgi/prom/salone.c | 24 | ||||
-rw-r--r-- | arch/mips/sgi/prom/tags.c | 67 | ||||
-rw-r--r-- | arch/mips/sgi/prom/time.c | 17 | ||||
-rw-r--r-- | arch/mips/sgi/prom/tree.c | 107 |
14 files changed, 732 insertions, 0 deletions
diff --git a/arch/mips/sgi/prom/.cvsignore b/arch/mips/sgi/prom/.cvsignore new file mode 100644 index 000000000..4671378ae --- /dev/null +++ b/arch/mips/sgi/prom/.cvsignore @@ -0,0 +1 @@ +.depend diff --git a/arch/mips/sgi/prom/Makefile b/arch/mips/sgi/prom/Makefile new file mode 100644 index 000000000..8dbfedf80 --- /dev/null +++ b/arch/mips/sgi/prom/Makefile @@ -0,0 +1,23 @@ +# $Id: Makefile,v 1.6 1996/06/08 04:48:41 dm Exp $ +# 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 tags.o env.o \ + cmdline.o misc.o time.o file.o + +all: promlib.a + +promlib.a: $(OBJS) + $(AR) rcs promlib.a $(OBJS) + sync + +dep: + $(CPP) -M *.c > .depend + +include $(TOPDIR)/Rules.make diff --git a/arch/mips/sgi/prom/cmdline.c b/arch/mips/sgi/prom/cmdline.c new file mode 100644 index 000000000..4c7da5e43 --- /dev/null +++ b/arch/mips/sgi/prom/cmdline.c @@ -0,0 +1,60 @@ +/* $Id: cmdline.c,v 1.1 1996/06/08 03:23:10 dm Exp $ + * cmdline.c: Kernel command line creation using ARCS argc/argv. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ + +#include <linux/kernel.h> +#include <linux/string.h> + +#include <asm/sgialib.h> +#include <asm/bootinfo.h> + +/* #define DEBUG_CMDLINE */ + +extern char arcs_cmdline[CL_SIZE]; + +char *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 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++; + } + *cp = '\0'; + +#ifdef DEBUG_CMDLINE + prom_printf("prom_init_cmdline: %s\n", &(arcs_cmdline[0])); +#endif +} diff --git a/arch/mips/sgi/prom/console.c b/arch/mips/sgi/prom/console.c new file mode 100644 index 000000000..3f4d69f45 --- /dev/null +++ b/arch/mips/sgi/prom/console.c @@ -0,0 +1,24 @@ +/* $Id: console.c,v 1.1 1996/06/04 00:57:05 dm Exp $ + * console.c: SGI arcs console code. + * + * Copyright (C) 1996 David S. Miller (dm@sgi.com) + */ + +#include <asm/sgialib.h> + +void prom_putchar(char c) +{ + long cnt; + char it = c; + + romvec->write(1, &it, 1, &cnt); +} + +char prom_getchar(void) +{ + long cnt; + char c; + + romvec->read(0, &c, 1, &cnt); + return c; +} diff --git a/arch/mips/sgi/prom/env.c b/arch/mips/sgi/prom/env.c new file mode 100644 index 000000000..5aff47efd --- /dev/null +++ b/arch/mips/sgi/prom/env.c @@ -0,0 +1,20 @@ +/* $Id: env.c,v 1.2 1996/06/08 04:48:41 dm Exp $ + * env.c: ARCS environment variable routines. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ + +#include <linux/kernel.h> +#include <linux/string.h> + +#include <asm/sgialib.h> + +char *prom_getenv(char *name) +{ + return romvec->get_evar(name); +} + +long prom_setenv(char *name, char *value) +{ + return romvec->set_evar(name, value); +} diff --git a/arch/mips/sgi/prom/file.c b/arch/mips/sgi/prom/file.c new file mode 100644 index 000000000..b62d33dda --- /dev/null +++ b/arch/mips/sgi/prom/file.c @@ -0,0 +1,58 @@ +/* $Id: file.c,v 1.1 1996/06/08 04:47:22 dm Exp $ + * file.c: ARCS firmware interface to files. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ + +#include <asm/sgialib.h> + +long prom_getvdirent(unsigned long fd, struct linux_vdirent *ent, unsigned long num, + unsigned long *cnt) +{ + return romvec->get_vdirent(fd, ent, num, cnt); +} + +long prom_open(char *name, enum linux_omode md, unsigned long *fd) +{ + return romvec->open(name, md, fd); +} + +long prom_close(unsigned long fd) +{ + return romvec->close(fd); +} + +long prom_read(unsigned long fd, void *buf, unsigned long num, unsigned long *cnt) +{ + return romvec->read(fd, buf, num, cnt); +} + +long prom_getrstatus(unsigned long fd) +{ + return romvec->get_rstatus(fd); +} + +long prom_write(unsigned long fd, void *buf, unsigned long num, unsigned long *cnt) +{ + return romvec->write(fd, buf, num, cnt); +} + +long prom_seek(unsigned long fd, struct linux_bigint *off, enum linux_seekmode sm) +{ + return romvec->seek(fd, off, sm); +} + +long prom_mount(char *name, enum linux_mountops op) +{ + return romvec->mount(name, op); +} + +long prom_getfinfo(unsigned long fd, struct linux_finfo *buf) +{ + return romvec->get_finfo(fd, buf); +} + +long prom_setfinfo(unsigned long fd, unsigned long flags, unsigned long msk) +{ + return romvec->set_finfo(fd, flags, msk); +} diff --git a/arch/mips/sgi/prom/init.c b/arch/mips/sgi/prom/init.c new file mode 100644 index 000000000..6b6167efd --- /dev/null +++ b/arch/mips/sgi/prom/init.c @@ -0,0 +1,59 @@ +/* $Id: init.c,v 1.6 1996/06/10 16:38:33 dm Exp $ + * init.c: PROM library initialisation code. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ + +#include <linux/kernel.h> + +#include <asm/sgialib.h> + +/* #define 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 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; + printk("PROMLIB: SGI ARCS firmware Version %d Revision %d\n", + prom_vers, prom_rev); + prom_meminit(); + prom_setup_archtags(); + +#if 0 + prom_testtree(); +#endif + +#ifdef DEBUG_PROM_INIT + { + prom_printf("Press a key to reboot\n"); + (void) prom_getchar(); + romvec->imode(); + } +#endif + return 0; +} diff --git a/arch/mips/sgi/prom/memory.c b/arch/mips/sgi/prom/memory.c new file mode 100644 index 000000000..cb392a805 --- /dev/null +++ b/arch/mips/sgi/prom/memory.c @@ -0,0 +1,129 @@ +/* $Id: memory.c,v 1.5 1996/06/10 16:38:33 dm Exp $ + * 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/kernel.h> +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/mm.h> +#include <linux/swap.h> + +#include <asm/sgialib.h> +#include <asm/page.h> +#include <asm/pgtable.h> +#include <asm/bootinfo.h> + +/* #define DEBUG */ + +struct linux_mdesc *prom_getmdesc(struct linux_mdesc *curr) +{ + return romvec->get_mdesc(curr); +} + +#ifdef DEBUG /* convenient for debugging */ +static char *mtypes[8] = { + "Exception Block", + "ARCS Romvec Page", + "Free/Contig RAM", + "Generic Free RAM", + "Bad Memory", + "Standlong Program Pages", + "ARCS Temp Storage Area", + "ARCS Permanent Storage Area" +}; +#endif + +static struct prom_pmemblock prom_pblocks[PROM_MAX_PMEMBLOCKS]; + +struct prom_pmemblock *prom_getpblock_array(void) +{ + return &prom_pblocks[0]; +} + +static void 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 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) { + if(p->type == free || p->type == fcontig) { + prom_pblocks[i].base = + ((p->base<<PAGE_SHIFT) + 0x80000000); + prom_pblocks[i].size = p->pages << PAGE_SHIFT; + 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++; + } + 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 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; + while(start < end) { + for(i = 0; i < nents; i++) { + if((start >= (p[i].base)) && + (start < (p[i].base + p[i].size))) { + start = p[i].base + p[i].size; + start &= PAGE_MASK; + continue; + } + } + set_bit(PG_reserved, &mem_map[MAP_NR(start)].flags); + start += PAGE_SIZE; + } +} diff --git a/arch/mips/sgi/prom/misc.c b/arch/mips/sgi/prom/misc.c new file mode 100644 index 000000000..47051a1b3 --- /dev/null +++ b/arch/mips/sgi/prom/misc.c @@ -0,0 +1,109 @@ +/* $Id: misc.c,v 1.3 1996/08/07 02:54:12 dm Exp $ + * misc.c: Miscellaneous ARCS PROM routines. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ + +#include <linux/kernel.h> + +#include <asm/sgialib.h> +#include <asm/bootinfo.h> +#include <asm/system.h> + +extern unsigned long mips_cputype; +extern int initialize_kbd(void); +extern void *sgiwd93_host; +extern void reset_wd33c93(void *instance); + +static inline void shutoff_r4600_cache(void) +{ + unsigned long tmp1, tmp2, tmp3; + + if(mips_cputype != CPU_R4600 && + mips_cputype != CPU_R4640 && + mips_cputype != CPU_R4700) + return; + printk("Disabling R4600 SCACHE\n"); + __asm__ __volatile__(" + .set noreorder + .set mips3 + li %0, 0x1 + dsll %0, 31 + lui %1, 0x9000 + dsll32 %1, 0 + or %0, %1, %0 + mfc0 %2, $12 + nop; nop; nop; nop; + li %1, 0x80 + mtc0 %1, $12 + nop; nop; nop; nop; + sh $0, 0(%0) + mtc0 $0, $12 + nop; nop; nop; nop; + mtc0 %2, $12 + nop; nop; nop; nop; + .set mips2 + .set reorder + " : "=r" (tmp1), "=r" (tmp2), "=r" (tmp3)); +} + +void prom_halt(void) +{ + shutoff_r4600_cache(); + initialize_kbd(); + reset_wd33c93(sgiwd93_host); + cli(); + romvec->halt(); +} + +void prom_powerdown(void) +{ + shutoff_r4600_cache(); + initialize_kbd(); + reset_wd33c93(sgiwd93_host); + cli(); + romvec->pdown(); +} + +/* XXX is this a soft reset basically? XXX */ +void prom_restart(void) +{ + shutoff_r4600_cache(); + initialize_kbd(); + reset_wd33c93(sgiwd93_host); + cli(); + romvec->restart(); +} + +void prom_reboot(void) +{ + shutoff_r4600_cache(); + initialize_kbd(); + reset_wd33c93(sgiwd93_host); + cli(); + romvec->reboot(); +} + +void prom_imode(void) +{ + shutoff_r4600_cache(); + initialize_kbd(); + reset_wd33c93(sgiwd93_host); + cli(); + romvec->imode(); +} + +long prom_cfgsave(void) +{ + return romvec->cfg_save(); +} + +struct linux_sysid *prom_getsysid(void) +{ + return romvec->get_sysid(); +} + +void prom_cacheflush(void) +{ + romvec->cache_flush(); +} diff --git a/arch/mips/sgi/prom/printf.c b/arch/mips/sgi/prom/printf.c new file mode 100644 index 000000000..02e7e4734 --- /dev/null +++ b/arch/mips/sgi/prom/printf.c @@ -0,0 +1,34 @@ +/* $Id: printf.c,v 1.1 1996/06/04 00:57:06 dm Exp $ + * printf.c: Putting things on the screen using SGI arcs + * PROM facilities. + * + * Copyright (C) 1996 David S. Miller (dm@sgi.com) + */ + +#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; +} diff --git a/arch/mips/sgi/prom/salone.c b/arch/mips/sgi/prom/salone.c new file mode 100644 index 000000000..4f120af3a --- /dev/null +++ b/arch/mips/sgi/prom/salone.c @@ -0,0 +1,24 @@ +/* $Id: salone.c,v 1.1 1996/06/08 04:47:22 dm Exp $ + * salone.c: 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 <asm/sgialib.h> + +long prom_load(char *name, unsigned long end, unsigned long *pc, unsigned long *eaddr) +{ + return romvec->load(name, end, pc, eaddr); +} + +long prom_invoke(unsigned long pc, unsigned long sp, long argc, + char **argv, char **envp) +{ + return romvec->invoke(pc, sp, argc, argv, envp); +} + +long prom_exec(char *name, long argc, char **argv, char **envp) +{ + return romvec->exec(name, argc, argv, envp); +} diff --git a/arch/mips/sgi/prom/tags.c b/arch/mips/sgi/prom/tags.c new file mode 100644 index 000000000..4a9fe0b2b --- /dev/null +++ b/arch/mips/sgi/prom/tags.c @@ -0,0 +1,67 @@ +/* $Id: tags.c,v 1.5 1996/06/24 07:12:22 dm Exp $ + * tags.c: Initialize the arch tags the way the MIPS kernel setup + * expects. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ + +#include <linux/kernel.h> +#include <linux/string.h> + +#include <asm/segment.h> +#include <asm/sgialib.h> +#include <asm/bootinfo.h> +#include <asm/sgimc.h> + +/* XXX This tag thing is a fucking rats nest, I'm very inclined to completely + * XXX rework the MIPS people's multi-arch code _NOW_. + */ + +static unsigned long machtype_SGI_INDY = MACH_SGI_INDY; +static unsigned long machgroup_SGI = MACH_GROUP_SGI; +static unsigned long memlower_SGI_INDY = (KSEG0 + SGIMC_SEG0_BADDR); +static unsigned long cputype_SGI_INDY = CPU_R4400SC; +static unsigned long tlb_entries_SGI_INDY = 48; +static unsigned long dummy_SGI_INDY = 0; +static struct drive_info_struct dummy_dinfo_SGI_INDY = { { 0, }, }; +char arcs_cmdline[CL_SIZE]; + +#define TAG(t,l) {tag_##t,(l)} /* XXX RATS NEST CODE!!! XXX */ +#define TAGVAL(v) (void*)&(v) /* XXX FUCKING LOSING!!! XXX */ + +tag_def taglist_sgi_indy[] = { + {TAG(machtype, ULONGSIZE), TAGVAL(machtype_SGI_INDY)}, + {TAG(machgroup, ULONGSIZE), TAGVAL(machgroup_SGI)}, + {TAG(memlower, ULONGSIZE), TAGVAL(memlower_SGI_INDY)}, + {TAG(cputype, ULONGSIZE), TAGVAL(cputype_SGI_INDY)}, + {TAG(tlb_entries, ULONGSIZE), TAGVAL(tlb_entries_SGI_INDY)}, + {TAG(vram_base, ULONGSIZE), TAGVAL(dummy_SGI_INDY)}, + {TAG(drive_info, DRVINFOSIZE), TAGVAL(dummy_dinfo_SGI_INDY)}, + {TAG(mount_root_rdonly, ULONGSIZE), TAGVAL(dummy_SGI_INDY)}, + {TAG(command_line, CL_SIZE), TAGVAL(arcs_cmdline[0])}, + {TAG(dummy, 0), NULL} + /* XXX COLOSTOMY BAG!!!! XXX */ +}; + +void prom_setup_archtags(void) +{ + tag_def *tdp = &taglist_sgi_indy[0]; + tag *tp; + + tp = (tag *) (mips_memory_upper - sizeof(tag)); + while(tdp->t.tag != tag_dummy) { + unsigned long size; + char *d; + + *tp = tdp->t; + size = tp->size; + d = (char *) tdp->d; + tp = (tag *)(((unsigned long)tp) - (tp->size)); + if(size) + memcpy(tp, d, size); + + tp--; + tdp++; + } + *tp = tdp->t; /* copy last dummy element over */ +} diff --git a/arch/mips/sgi/prom/time.c b/arch/mips/sgi/prom/time.c new file mode 100644 index 000000000..9a836b810 --- /dev/null +++ b/arch/mips/sgi/prom/time.c @@ -0,0 +1,17 @@ +/* $Id: time.c,v 1.1 1996/06/08 04:47:23 dm Exp $ + * time.c: Extracting time information from ARCS prom. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ + +#include <asm/sgialib.h> + +struct linux_tinfo *prom_gettinfo(void) +{ + return romvec->get_tinfo(); +} + +unsigned long prom_getrtime(void) +{ + return romvec->get_rtime(); +} diff --git a/arch/mips/sgi/prom/tree.c b/arch/mips/sgi/prom/tree.c new file mode 100644 index 000000000..1cefd4964 --- /dev/null +++ b/arch/mips/sgi/prom/tree.c @@ -0,0 +1,107 @@ +/* $Id: tree.c,v 1.4 1996/06/08 04:48:41 dm Exp $ + * tree.c: PROM component device tree code. + * + * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) + */ + +#include <asm/sgialib.h> + +#define DEBUG_PROM_TREE + +pcomponent *prom_getsibling(pcomponent *this) +{ + if(this == PROM_NULL_COMPONENT) + return PROM_NULL_COMPONENT; + return romvec->next_component(this); +} + +pcomponent *prom_getchild(pcomponent *this) +{ + return romvec->child_component(this); +} + +pcomponent *prom_getparent(pcomponent *child) +{ + if(child == PROM_NULL_COMPONENT) + return PROM_NULL_COMPONENT; + return romvec->parent_component(child); +} + +long prom_getcdata(void *buffer, pcomponent *this) +{ + return romvec->component_data(buffer, this); +} + +pcomponent *prom_childadd(pcomponent *this, pcomponent *tmp, void *data) +{ + return romvec->child_add(this, tmp, data); +} + +long prom_delcomponent(pcomponent *this) +{ + return romvec->comp_del(this); +} + +pcomponent *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 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 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 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 |