diff options
Diffstat (limited to 'arch/sparc/prom')
| -rw-r--r-- | arch/sparc/prom/Makefile | 4 | ||||
| -rw-r--r-- | arch/sparc/prom/bootstr_32.c | 15 | ||||
| -rw-r--r-- | arch/sparc/prom/console_32.c | 71 | ||||
| -rw-r--r-- | arch/sparc/prom/console_64.c | 84 | ||||
| -rw-r--r-- | arch/sparc/prom/devmap.c | 53 | ||||
| -rw-r--r-- | arch/sparc/prom/devops_32.c | 87 | ||||
| -rw-r--r-- | arch/sparc/prom/devops_64.c | 67 | ||||
| -rw-r--r-- | arch/sparc/prom/init_32.c | 11 | ||||
| -rw-r--r-- | arch/sparc/prom/init_64.c | 11 | ||||
| -rw-r--r-- | arch/sparc/prom/misc_32.c | 7 | ||||
| -rw-r--r-- | arch/sparc/prom/misc_64.c | 22 | ||||
| -rw-r--r-- | arch/sparc/prom/mp.c | 80 | ||||
| -rw-r--r-- | arch/sparc/prom/p1275.c | 2 | ||||
| -rw-r--r-- | arch/sparc/prom/palloc.c | 43 | ||||
| -rw-r--r-- | arch/sparc/prom/printf.c | 35 | ||||
| -rw-r--r-- | arch/sparc/prom/ranges.c | 7 | ||||
| -rw-r--r-- | arch/sparc/prom/segment.c | 28 | ||||
| -rw-r--r-- | arch/sparc/prom/tree_32.c | 83 | ||||
| -rw-r--r-- | arch/sparc/prom/tree_64.c | 52 | 
19 files changed, 116 insertions, 646 deletions
diff --git a/arch/sparc/prom/Makefile b/arch/sparc/prom/Makefile index 1b8c073adb4..020300b18c0 100644 --- a/arch/sparc/prom/Makefile +++ b/arch/sparc/prom/Makefile @@ -5,15 +5,11 @@ asflags := -ansi  ccflags := -Werror  lib-y                 := bootstr_$(BITS).o -lib-$(CONFIG_SPARC32) += devmap.o -lib-y                 += devops_$(BITS).o  lib-y                 += init_$(BITS).o  lib-$(CONFIG_SPARC32) += memory.o  lib-y                 += misc_$(BITS).o  lib-$(CONFIG_SPARC32) += mp.o -lib-$(CONFIG_SPARC32) += palloc.o  lib-$(CONFIG_SPARC32) += ranges.o -lib-$(CONFIG_SPARC32) += segment.o  lib-y                 += console_$(BITS).o  lib-y                 += printf.o  lib-y                 += tree_$(BITS).o diff --git a/arch/sparc/prom/bootstr_32.c b/arch/sparc/prom/bootstr_32.c index 916831da7e6..d2b49d2365e 100644 --- a/arch/sparc/prom/bootstr_32.c +++ b/arch/sparc/prom/bootstr_32.c @@ -23,22 +23,25 @@ prom_getbootargs(void)  		return barg_buf;  	} -	switch(prom_vers) { +	switch (prom_vers) {  	case PROM_V0:  		cp = barg_buf;  		/* Start from 1 and go over fd(0,0,0)kernel */ -		for(iter = 1; iter < 8; iter++) { +		for (iter = 1; iter < 8; iter++) {  			arg = (*(romvec->pv_v0bootargs))->argv[iter]; -			if(arg == 0) break; -			while(*arg != 0) { +			if (arg == NULL) +				break; +			while (*arg != 0) {  				/* Leave place for space and null. */ -				if(cp >= barg_buf + BARG_LEN-2){ +				if (cp >= barg_buf + BARG_LEN - 2)  					/* We might issue a warning here. */  					break; -				}  				*cp++ = *arg++;  			}  			*cp++ = ' '; +			if (cp >= barg_buf + BARG_LEN - 1) +				/* We might issue a warning here. */ +				break;  		}  		*cp = 0;  		break; diff --git a/arch/sparc/prom/console_32.c b/arch/sparc/prom/console_32.c index 5340264b78f..1cfb50f4cb9 100644 --- a/arch/sparc/prom/console_32.c +++ b/arch/sparc/prom/console_32.c @@ -11,87 +11,46 @@  #include <linux/sched.h>  #include <asm/openprom.h>  #include <asm/oplib.h> -#include <asm/system.h>  #include <linux/string.h>  extern void restore_current(void); -/* Non blocking get character from console input device, returns -1 - * if no input was taken.  This can be used for polling. - */ -int -prom_nbgetchar(void) -{ -	static char inc; -	int i = -1; -	unsigned long flags; - -	spin_lock_irqsave(&prom_lock, flags); -	switch(prom_vers) { -	case PROM_V0: -		i = (*(romvec->pv_nbgetchar))(); -		break; -	case PROM_V2: -	case PROM_V3: -		if( (*(romvec->pv_v2devops).v2_dev_read)(*romvec->pv_v2bootargs.fd_stdin , &inc, 0x1) == 1) { -			i = inc; -		} else { -			i = -1; -		} -		break; -	default: -		i = -1; -		break; -	}; -	restore_current(); -	spin_unlock_irqrestore(&prom_lock, flags); -	return i; /* Ugh, we could spin forever on unsupported proms ;( */ -} -  /* Non blocking put character to console device, returns -1 if   * unsuccessful.   */ -int -prom_nbputchar(char c) +static int prom_nbputchar(const char *buf)  { -	static char outc;  	unsigned long flags;  	int i = -1;  	spin_lock_irqsave(&prom_lock, flags);  	switch(prom_vers) {  	case PROM_V0: -		i = (*(romvec->pv_nbputchar))(c); +		if ((*(romvec->pv_nbputchar))(*buf)) +			i = 1;  		break;  	case PROM_V2:  	case PROM_V3: -		outc = c; -		if( (*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout, &outc, 0x1) == 1) -			i = 0; -		else -			i = -1; +		if ((*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout, +							  buf, 0x1) == 1) +			i = 1;  		break;  	default: -		i = -1;  		break; -	}; +	}  	restore_current();  	spin_unlock_irqrestore(&prom_lock, flags);  	return i; /* Ugh, we could spin forever on unsupported proms ;( */  } -/* Blocking version of get character routine above. */ -char -prom_getchar(void) +void prom_console_write_buf(const char *buf, int len)  { -	int character; -	while((character = prom_nbgetchar()) == -1) ; -	return (char) character; +	while (len) { +		int n = prom_nbputchar(buf); +		if (n < 0) +			continue; +		len--; +		buf++; +	}  } -/* Blocking version of put character routine above. */ -void -prom_putchar(char c) -{ -	while(prom_nbputchar(c) == -1) ; -} diff --git a/arch/sparc/prom/console_64.c b/arch/sparc/prom/console_64.c index 10322dc2f55..f95edcc54fd 100644 --- a/arch/sparc/prom/console_64.c +++ b/arch/sparc/prom/console_64.c @@ -10,90 +10,36 @@  #include <linux/sched.h>  #include <asm/openprom.h>  #include <asm/oplib.h> -#include <asm/system.h>  #include <linux/string.h> -extern int prom_stdin, prom_stdout; - -/* Non blocking get character from console input device, returns -1 - * if no input was taken.  This can be used for polling. - */ -inline int -prom_nbgetchar(void) +static int __prom_console_write_buf(const char *buf, int len)  {  	unsigned long args[7]; -	char inc; - -	args[0] = (unsigned long) "read"; -	args[1] = 3; -	args[2] = 1; -	args[3] = (unsigned int) prom_stdin; -	args[4] = (unsigned long) &inc; -	args[5] = 1; -	args[6] = (unsigned long) -1; - -	p1275_cmd_direct(args); - -	if (args[6] == 1) -		return inc; -	return -1; -} - -/* Non blocking put character to console device, returns -1 if - * unsuccessful. - */ -inline int -prom_nbputchar(char c) -{ -	unsigned long args[7]; -	char outc; -	 -	outc = c; +	int ret;  	args[0] = (unsigned long) "write";  	args[1] = 3;  	args[2] = 1;  	args[3] = (unsigned int) prom_stdout; -	args[4] = (unsigned long) &outc; -	args[5] = 1; +	args[4] = (unsigned long) buf; +	args[5] = (unsigned int) len;  	args[6] = (unsigned long) -1;  	p1275_cmd_direct(args); -	if (args[6] == 1) -		return 0; -	else +	ret = (int) args[6]; +	if (ret < 0)  		return -1; +	return ret;  } -/* Blocking version of get character routine above. */ -char -prom_getchar(void) +void prom_console_write_buf(const char *buf, int len)  { -	int character; -	while((character = prom_nbgetchar()) == -1) ; -	return (char) character; -} - -/* Blocking version of put character routine above. */ -void -prom_putchar(char c) -{ -	prom_nbputchar(c); -} - -void -prom_puts(const char *s, int len) -{ -	unsigned long args[7]; - -	args[0] = (unsigned long) "write"; -	args[1] = 3; -	args[2] = 1; -	args[3] = (unsigned int) prom_stdout; -	args[4] = (unsigned long) s; -	args[5] = len; -	args[6] = (unsigned long) -1; - -	p1275_cmd_direct(args); +	while (len) { +		int n = __prom_console_write_buf(buf, len); +		if (n < 0) +			continue; +		len -= n; +		buf += len; +	}  } diff --git a/arch/sparc/prom/devmap.c b/arch/sparc/prom/devmap.c deleted file mode 100644 index 46157d2aba0..00000000000 --- a/arch/sparc/prom/devmap.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * promdevmap.c:  Map device/IO areas to virtual addresses. - * - * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) - */ - -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/sched.h> - -#include <asm/openprom.h> -#include <asm/oplib.h> - -extern void restore_current(void); - -/* Just like the routines in palloc.c, these should not be used - * by the kernel at all.  Bootloader facility mainly.  And again, - * this is only available on V2 proms and above. - */ - -/* Map physical device address 'paddr' in IO space 'ios' of size - * 'num_bytes' to a virtual address, with 'vhint' being a hint to - * the prom as to where you would prefer the mapping.  We return - * where the prom actually mapped it. - */ -char * -prom_mapio(char *vhint, int ios, unsigned int paddr, unsigned int num_bytes) -{ -	unsigned long flags; -	char *ret; - -	spin_lock_irqsave(&prom_lock, flags); -	if((num_bytes == 0) || (paddr == 0)) ret = (char *) 0x0; -	else -	ret = (*(romvec->pv_v2devops.v2_dumb_mmap))(vhint, ios, paddr, -						    num_bytes); -	restore_current(); -	spin_unlock_irqrestore(&prom_lock, flags); -	return ret; -} - -/* Unmap an IO/device area that was mapped using the above routine. */ -void -prom_unmapio(char *vaddr, unsigned int num_bytes) -{ -	unsigned long flags; - -	if(num_bytes == 0x0) return; -	spin_lock_irqsave(&prom_lock, flags); -	(*(romvec->pv_v2devops.v2_dumb_munmap))(vaddr, num_bytes); -	restore_current(); -	spin_unlock_irqrestore(&prom_lock, flags); -} diff --git a/arch/sparc/prom/devops_32.c b/arch/sparc/prom/devops_32.c deleted file mode 100644 index 9c5d4687242..00000000000 --- a/arch/sparc/prom/devops_32.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * devops.c:  Device operations using the PROM. - * - * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) - */ -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/sched.h> - -#include <asm/openprom.h> -#include <asm/oplib.h> - -extern void restore_current(void); - -/* Open the device described by the string 'dstr'.  Returns the handle - * to that device used for subsequent operations on that device. - * Returns -1 on failure. - */ -int -prom_devopen(char *dstr) -{ -	int handle; -	unsigned long flags; -	spin_lock_irqsave(&prom_lock, flags); -	switch(prom_vers) { -	case PROM_V0: -		handle = (*(romvec->pv_v0devops.v0_devopen))(dstr); -		if(handle == 0) handle = -1; -		break; -	case PROM_V2: -	case PROM_V3: -		handle = (*(romvec->pv_v2devops.v2_dev_open))(dstr); -		break; -	default: -		handle = -1; -		break; -	}; -	restore_current(); -	spin_unlock_irqrestore(&prom_lock, flags); - -	return handle; -} - -/* Close the device described by device handle 'dhandle'. */ -int -prom_devclose(int dhandle) -{ -	unsigned long flags; -	spin_lock_irqsave(&prom_lock, flags); -	switch(prom_vers) { -	case PROM_V0: -		(*(romvec->pv_v0devops.v0_devclose))(dhandle); -		break; -	case PROM_V2: -	case PROM_V3: -		(*(romvec->pv_v2devops.v2_dev_close))(dhandle); -		break; -	default: -		break; -	}; -	restore_current(); -	spin_unlock_irqrestore(&prom_lock, flags); -	return 0; -} - -/* Seek to specified location described by 'seekhi' and 'seeklo' - * for device 'dhandle'. - */ -void -prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo) -{ -	unsigned long flags; -	spin_lock_irqsave(&prom_lock, flags); -	switch(prom_vers) { -	case PROM_V0: -		(*(romvec->pv_v0devops.v0_seekdev))(dhandle, seekhi, seeklo); -		break; -	case PROM_V2: -	case PROM_V3: -		(*(romvec->pv_v2devops.v2_dev_seek))(dhandle, seekhi, seeklo); -		break; -	default: -		break; -	}; -	restore_current(); -	spin_unlock_irqrestore(&prom_lock, flags); -} diff --git a/arch/sparc/prom/devops_64.c b/arch/sparc/prom/devops_64.c deleted file mode 100644 index a017119e7ef..00000000000 --- a/arch/sparc/prom/devops_64.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * devops.c:  Device operations using the PROM. - * - * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) - * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) - */ -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/sched.h> - -#include <asm/openprom.h> -#include <asm/oplib.h> - -/* Open the device described by the string 'dstr'.  Returns the handle - * to that device used for subsequent operations on that device. - * Returns 0 on failure. - */ -int -prom_devopen(const char *dstr) -{ -	unsigned long args[5]; - -	args[0] = (unsigned long) "open"; -	args[1] = 1; -	args[2] = 1; -	args[3] = (unsigned long) dstr; -	args[4] = (unsigned long) -1; - -	p1275_cmd_direct(args); - -	return (int) args[4]; -} - -/* Close the device described by device handle 'dhandle'. */ -int -prom_devclose(int dhandle) -{ -	unsigned long args[4]; - -	args[0] = (unsigned long) "close"; -	args[1] = 1; -	args[2] = 0; -	args[3] = (unsigned int) dhandle; - -	p1275_cmd_direct(args); - -	return 0; -} - -/* Seek to specified location described by 'seekhi' and 'seeklo' - * for device 'dhandle'. - */ -void -prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo) -{ -	unsigned long args[7]; - -	args[0] = (unsigned long) "seek"; -	args[1] = 3; -	args[2] = 1; -	args[3] = (unsigned int) dhandle; -	args[4] = seekhi; -	args[5] = seeklo; -	args[6] = (unsigned long) -1; - -	p1275_cmd_direct(args); -} diff --git a/arch/sparc/prom/init_32.c b/arch/sparc/prom/init_32.c index d342dba4dd5..9ac30c2b7db 100644 --- a/arch/sparc/prom/init_32.c +++ b/arch/sparc/prom/init_32.c @@ -27,13 +27,10 @@ EXPORT_SYMBOL(prom_root_node);  struct linux_nodeops *prom_nodeops;  /* You must call prom_init() before you attempt to use any of the - * routines in the prom library.  It returns 0 on success, 1 on - * failure.  It gets passed the pointer to the PROM vector. + * routines in the prom library. + * It gets passed the pointer to the PROM vector.   */ -extern void prom_meminit(void); -extern void prom_ranges_init(void); -  void __init prom_init(struct linux_romvec *rp)  {  	romvec = rp; @@ -53,14 +50,14 @@ void __init prom_init(struct linux_romvec *rp)  			    romvec->pv_romvers);  		prom_halt();  		break; -	}; +	}  	prom_rev = romvec->pv_plugin_revision;  	prom_prev = romvec->pv_printrev;  	prom_nodeops = romvec->pv_nodeops;  	prom_root_node = prom_getsibling(0); -	if((prom_root_node == 0) || (prom_root_node == -1)) +	if ((prom_root_node == 0) || ((s32)prom_root_node == -1))  		prom_halt();  	if((((unsigned long) prom_nodeops) == 0) ||  diff --git a/arch/sparc/prom/init_64.c b/arch/sparc/prom/init_64.c index 3ff911e7d25..d95db755828 100644 --- a/arch/sparc/prom/init_64.c +++ b/arch/sparc/prom/init_64.c @@ -18,12 +18,12 @@  char prom_version[80];  /* The root node of the prom device tree. */ -int prom_stdin, prom_stdout; +int prom_stdout;  phandle prom_chosen_node;  /* You must call prom_init() before you attempt to use any of the - * routines in the prom library.  It returns 0 on success, 1 on - * failure.  It gets passed the pointer to the PROM vector. + * routines in the prom library. + * It gets passed the pointer to the PROM vector.   */  extern void prom_cif_init(void *, void *); @@ -35,14 +35,13 @@ void __init prom_init(void *cif_handler, void *cif_stack)  	prom_cif_init(cif_handler, cif_stack);  	prom_chosen_node = prom_finddevice(prom_chosen_path); -	if (!prom_chosen_node || prom_chosen_node == -1) +	if (!prom_chosen_node || (s32)prom_chosen_node == -1)  		prom_halt(); -	prom_stdin = prom_getint(prom_chosen_node, "stdin");  	prom_stdout = prom_getint(prom_chosen_node, "stdout");  	node = prom_finddevice("/openprom"); -	if (!node || node == -1) +	if (!node || (s32)node == -1)  		prom_halt();  	prom_getstring(node, "version", prom_version, sizeof(prom_version)); diff --git a/arch/sparc/prom/misc_32.c b/arch/sparc/prom/misc_32.c index 4d61c540bb3..8dc0b6b271e 100644 --- a/arch/sparc/prom/misc_32.c +++ b/arch/sparc/prom/misc_32.c @@ -13,7 +13,6 @@  #include <asm/openprom.h>  #include <asm/oplib.h>  #include <asm/auxio.h> -#include <asm/system.h>  extern void restore_current(void); @@ -54,15 +53,11 @@ EXPORT_SYMBOL(prom_feval);  void  prom_cmdline(void)  { -	extern void install_obp_ticker(void); -	extern void install_linux_ticker(void);  	unsigned long flags;  	spin_lock_irqsave(&prom_lock, flags); -	install_obp_ticker();  	(*(romvec->pv_abort))();  	restore_current(); -	install_linux_ticker();  	spin_unlock_irqrestore(&prom_lock, flags);  	set_auxio(AUXIO_LED, 0);  } @@ -70,7 +65,7 @@ prom_cmdline(void)  /* Drop into the prom, but completely terminate the program.   * No chance of continuing.   */ -void +void __noreturn  prom_halt(void)  {  	unsigned long flags; diff --git a/arch/sparc/prom/misc_64.c b/arch/sparc/prom/misc_64.c index d24bc44e361..53a696d3eb3 100644 --- a/arch/sparc/prom/misc_64.c +++ b/arch/sparc/prom/misc_64.c @@ -15,10 +15,9 @@  #include <asm/openprom.h>  #include <asm/oplib.h> -#include <asm/system.h>  #include <asm/ldc.h> -int prom_service_exists(const char *service_name) +static int prom_service_exists(const char *service_name)  {  	unsigned long args[5]; @@ -82,11 +81,6 @@ void prom_feval(const char *fstring)  }  EXPORT_SYMBOL(prom_feval); -#ifdef CONFIG_SMP -extern void smp_capture(void); -extern void smp_release(void); -#endif -  /* Drop into the prom, with the chance to continue with the 'go'   * prom command.   */ @@ -150,20 +144,6 @@ void prom_halt_power_off(void)  	prom_halt();  } -/* Set prom sync handler to call function 'funcp'. */ -void prom_setcallback(callback_func_t funcp) -{ -	unsigned long args[5]; -	if (!funcp) -		return; -	args[0] = (unsigned long) "set-callback"; -	args[1] = 1; -	args[2] = 1; -	args[3] = (unsigned long) funcp; -	args[4] = (unsigned long) -1; -	p1275_cmd_direct(args); -} -  /* Get the idprom and stuff it into buffer 'idbuf'.  Returns the   * format type.  'num_bytes' is the number of bytes that your idbuf   * has space for.  Returns 0xff on error. diff --git a/arch/sparc/prom/mp.c b/arch/sparc/prom/mp.c index 4c4dc79f65a..0da8256cf76 100644 --- a/arch/sparc/prom/mp.c +++ b/arch/sparc/prom/mp.c @@ -35,85 +35,7 @@ prom_startcpu(int cpunode, struct linux_prom_registers *ctable_reg, int ctx, cha  	case PROM_V3:  		ret = (*(romvec->v3_cpustart))(cpunode, (int) ctable_reg, ctx, pc);  		break; -	}; -	restore_current(); -	spin_unlock_irqrestore(&prom_lock, flags); - -	return ret; -} - -/* Stop CPU with device prom-tree node 'cpunode'. - * XXX Again, what does the return value really mean? XXX - */ -int -prom_stopcpu(int cpunode) -{ -	int ret; -	unsigned long flags; - -	spin_lock_irqsave(&prom_lock, flags); -	switch(prom_vers) { -	case PROM_V0: -	case PROM_V2: -	default: -		ret = -1; -		break; -	case PROM_V3: -		ret = (*(romvec->v3_cpustop))(cpunode); -		break; -	}; -	restore_current(); -	spin_unlock_irqrestore(&prom_lock, flags); - -	return ret; -} - -/* Make CPU with device prom-tree node 'cpunode' idle. - * XXX Return value, anyone? XXX - */ -int -prom_idlecpu(int cpunode) -{ -	int ret; -	unsigned long flags; - -	spin_lock_irqsave(&prom_lock, flags); -	switch(prom_vers) { -	case PROM_V0: -	case PROM_V2: -	default: -		ret = -1; -		break; -	case PROM_V3: -		ret = (*(romvec->v3_cpuidle))(cpunode); -		break; -	}; -	restore_current(); -	spin_unlock_irqrestore(&prom_lock, flags); - -	return ret; -} - -/* Resume the execution of CPU with nodeid 'cpunode'. - * XXX Come on, somebody has to know... XXX - */ -int -prom_restartcpu(int cpunode) -{ -	int ret; -	unsigned long flags; - -	spin_lock_irqsave(&prom_lock, flags); -	switch(prom_vers) { -	case PROM_V0: -	case PROM_V2: -	default: -		ret = -1; -		break; -	case PROM_V3: -		ret = (*(romvec->v3_cpuresume))(cpunode); -		break; -	}; +	}  	restore_current();  	spin_unlock_irqrestore(&prom_lock, flags); diff --git a/arch/sparc/prom/p1275.c b/arch/sparc/prom/p1275.c index d9850c2b9bf..e58b8172631 100644 --- a/arch/sparc/prom/p1275.c +++ b/arch/sparc/prom/p1275.c @@ -5,7 +5,6 @@   */  #include <linux/kernel.h> -#include <linux/init.h>  #include <linux/sched.h>  #include <linux/smp.h>  #include <linux/string.h> @@ -13,7 +12,6 @@  #include <asm/openprom.h>  #include <asm/oplib.h> -#include <asm/system.h>  #include <asm/spitfire.h>  #include <asm/pstate.h>  #include <asm/ldc.h> diff --git a/arch/sparc/prom/palloc.c b/arch/sparc/prom/palloc.c deleted file mode 100644 index 2e2a88b211f..00000000000 --- a/arch/sparc/prom/palloc.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * palloc.c:  Memory allocation from the Sun PROM. - * - * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) - */ - -#include <asm/openprom.h> -#include <asm/oplib.h> - -/* You should not call these routines after memory management - * has been initialized in the kernel, if fact you should not - * use these if at all possible in the kernel.  They are mainly - * to be used for a bootloader for temporary allocations which - * it will free before jumping into the kernel it has loaded. - * - * Also, these routines don't work on V0 proms, only V2 and later. - */ - -/* Allocate a chunk of memory of size 'num_bytes' giving a suggestion - * of virtual_hint as the preferred virtual base address of this chunk. - * There are no guarantees that you will get the allocation, or that - * the prom will abide by your "hint".  So check your return value. - */ -char * -prom_alloc(char *virtual_hint, unsigned int num_bytes) -{ -	if(prom_vers == PROM_V0) return (char *) 0x0; -	if(num_bytes == 0x0) return (char *) 0x0; -	return (*(romvec->pv_v2devops.v2_dumb_mem_alloc))(virtual_hint, num_bytes); -} - -/* Free a previously allocated chunk back to the prom at virtual address - * 'vaddr' of size 'num_bytes'.  NOTE: This vaddr is not the hint you - * used for the allocation, but the virtual address the prom actually - * returned to you.  They may be have been the same, they may have not, - * doesn't matter. - */ -void -prom_free(char *vaddr, unsigned int num_bytes) -{ -	if((prom_vers == PROM_V0) || (num_bytes == 0x0)) return; -	(*(romvec->pv_v2devops.v2_dumb_mem_free))(vaddr, num_bytes); -} diff --git a/arch/sparc/prom/printf.c b/arch/sparc/prom/printf.c index ca869266b9f..d9682f06b3b 100644 --- a/arch/sparc/prom/printf.c +++ b/arch/sparc/prom/printf.c @@ -15,22 +15,45 @@  #include <linux/kernel.h>  #include <linux/compiler.h> +#include <linux/spinlock.h>  #include <asm/openprom.h>  #include <asm/oplib.h> +#define CONSOLE_WRITE_BUF_SIZE	1024 +  static char ppbuf[1024]; +static char console_write_buf[CONSOLE_WRITE_BUF_SIZE]; +static DEFINE_RAW_SPINLOCK(console_write_lock);  void notrace prom_write(const char *buf, unsigned int n)  { -	char ch; +	unsigned int dest_len; +	unsigned long flags; +	char *dest; + +	dest = console_write_buf; +	raw_spin_lock_irqsave(&console_write_lock, flags); -	while (n != 0) { -		--n; -		if ((ch = *buf++) == '\n') -			prom_putchar('\r'); -		prom_putchar(ch); +	dest_len = 0; +	while (n-- != 0) { +		char ch = *buf++; +		if (ch == '\n') { +			*dest++ = '\r'; +			dest_len++; +		} +		*dest++ = ch; +		dest_len++; +		if (dest_len >= CONSOLE_WRITE_BUF_SIZE - 1) { +			prom_console_write_buf(console_write_buf, dest_len); +			dest = console_write_buf; +			dest_len = 0; +		}  	} +	if (dest_len) +		prom_console_write_buf(console_write_buf, dest_len); + +	raw_spin_unlock_irqrestore(&console_write_lock, flags);  }  void notrace prom_printf(const char *fmt, ...) diff --git a/arch/sparc/prom/ranges.c b/arch/sparc/prom/ranges.c index 541fc829c20..ad143c13bdc 100644 --- a/arch/sparc/prom/ranges.c +++ b/arch/sparc/prom/ranges.c @@ -11,10 +11,9 @@  #include <asm/openprom.h>  #include <asm/oplib.h>  #include <asm/types.h> -#include <asm/system.h> -struct linux_prom_ranges promlib_obio_ranges[PROMREG_MAX]; -int num_obio_ranges; +static struct linux_prom_ranges promlib_obio_ranges[PROMREG_MAX]; +static int num_obio_ranges;  /* Adjust register values based upon the ranges parameters. */  static void @@ -35,7 +34,7 @@ prom_adjust_regs(struct linux_prom_registers *regp, int nregs,  	}  } -void +static void  prom_adjust_ranges(struct linux_prom_ranges *ranges1, int nranges1,  		   struct linux_prom_ranges *ranges2, int nranges2)  { diff --git a/arch/sparc/prom/segment.c b/arch/sparc/prom/segment.c deleted file mode 100644 index 86a663f1d3c..00000000000 --- a/arch/sparc/prom/segment.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * segment.c:  Prom routine to map segments in other contexts before - *             a standalone is completely mapped.  This is for sun4 and - *             sun4c architectures only. - * - * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) - */ - -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/sched.h> -#include <asm/openprom.h> -#include <asm/oplib.h> - -extern void restore_current(void); - -/* Set physical segment 'segment' at virtual address 'vaddr' in - * context 'ctx'. - */ -void -prom_putsegment(int ctx, unsigned long vaddr, int segment) -{ -	unsigned long flags; -	spin_lock_irqsave(&prom_lock, flags); -	(*(romvec->pv_setctxt))(ctx, (char *) vaddr, segment); -	restore_current(); -	spin_unlock_irqrestore(&prom_lock, flags); -} diff --git a/arch/sparc/prom/tree_32.c b/arch/sparc/prom/tree_32.c index 63e08e14977..f30e8d038f0 100644 --- a/arch/sparc/prom/tree_32.c +++ b/arch/sparc/prom/tree_32.c @@ -20,7 +20,7 @@ extern void restore_current(void);  static char promlib_buf[128];  /* Internal version of prom_getchild that does not alter return values. */ -phandle __prom_getchild(phandle node) +static phandle __prom_getchild(phandle node)  {  	unsigned long flags;  	phandle cnode; @@ -40,11 +40,11 @@ phandle prom_getchild(phandle node)  {  	phandle cnode; -	if (node == -1) +	if ((s32)node == -1)  		return 0;  	cnode = __prom_getchild(node); -	if (cnode == 0 || cnode == -1) +	if (cnode == 0 || (s32)cnode == -1)  		return 0;  	return cnode; @@ -52,7 +52,7 @@ phandle prom_getchild(phandle node)  EXPORT_SYMBOL(prom_getchild);  /* Internal version of prom_getsibling that does not alter return values. */ -phandle __prom_getsibling(phandle node) +static phandle __prom_getsibling(phandle node)  {  	unsigned long flags;  	phandle cnode; @@ -72,11 +72,11 @@ phandle prom_getsibling(phandle node)  {  	phandle sibnode; -	if (node == -1) +	if ((s32)node == -1)  		return 0;  	sibnode = __prom_getsibling(node); -	if (sibnode == 0 || sibnode == -1) +	if (sibnode == 0 || (s32)sibnode == -1)  		return 0;  	return sibnode; @@ -177,20 +177,6 @@ void prom_getstring(phandle node, char *prop, char *user_buf, int ubuf_size)  EXPORT_SYMBOL(prom_getstring); -/* Does the device at node 'node' have name 'name'? - * YES = 1   NO = 0 - */ -int prom_nodematch(phandle node, char *name) -{ -	int error; - -	static char namebuf[128]; -	error = prom_getproperty(node, "name", namebuf, sizeof(namebuf)); -	if (error == -1) return 0; -	if(strcmp(namebuf, name) == 0) return 1; -	return 0; -} -  /* Search siblings at 'node_start' for a node with name   * 'nodename'.  Return node if successful, zero if not.   */ @@ -214,7 +200,7 @@ phandle prom_searchsiblings(phandle node_start, char *nodename)  EXPORT_SYMBOL(prom_searchsiblings);  /* Interal version of nextprop that does not alter return values. */ -char *__prom_nextprop(phandle node, char * oprop) +static char *__prom_nextprop(phandle node, char * oprop)  {  	unsigned long flags;  	char *prop; @@ -227,24 +213,13 @@ char *__prom_nextprop(phandle node, char * oprop)  	return prop;  } -/* Return the first property name for node 'node'. */ -/* buffer is unused argument, but as v9 uses it, we need to have the same interface */ -char *prom_firstprop(phandle node, char *bufer) -{ -	if (node == 0 || node == -1) -		return ""; - -	return __prom_nextprop(node, ""); -} -EXPORT_SYMBOL(prom_firstprop); -  /* Return the property type string after property type 'oprop'   * at node 'node' .  Returns empty string if no more   * property types for this node.   */  char *prom_nextprop(phandle node, char *oprop, char *buffer)  { -	if (node == 0 || node == -1) +	if (node == 0 || (s32)node == -1)  		return "";  	return __prom_nextprop(node, oprop); @@ -278,7 +253,7 @@ phandle prom_finddevice(char *name)  				if (d != s + 3 && (!*d || *d == '/')  				    && d <= s + 3 + 8) {  					node2 = node; -					while (node2 && node2 != -1) { +					while (node2 && (s32)node2 != -1) {  						if (prom_getproperty (node2, "reg", (char *)reg, sizeof (reg)) > 0) {  							if (which_io == reg[0].which_io && phys_addr == reg[0].phys_addr) {  								node = node2; @@ -286,7 +261,7 @@ phandle prom_finddevice(char *name)  							}  						}  						node2 = prom_getsibling(node2); -						if (!node2 || node2 == -1) +						if (!node2 || (s32)node2 == -1)  							break;  						node2 = prom_searchsiblings(prom_getsibling(node2), nbuf);  					} @@ -299,19 +274,6 @@ phandle prom_finddevice(char *name)  }  EXPORT_SYMBOL(prom_finddevice); -int prom_node_has_property(phandle node, char *prop) -{ -	char *current_property = ""; - -	do { -		current_property = prom_nextprop(node, current_property, NULL); -		if(!strcmp(current_property, prop)) -		   return 1; -	} while (*current_property); -	return 0; -} -EXPORT_SYMBOL(prom_node_has_property); -  /* Set property 'pname' at node 'node' to value 'value' which has a length   * of 'size' bytes.  Return the number of bytes the prom accepted.   */ @@ -320,8 +282,10 @@ int prom_setprop(phandle node, const char *pname, char *value, int size)  	unsigned long flags;  	int ret; -	if(size == 0) return 0; -	if((pname == 0) || (value == 0)) return 0; +	if (size == 0) +		return 0; +	if ((pname == NULL) || (value == NULL)) +		return 0;  	spin_lock_irqsave(&prom_lock, flags);  	ret = prom_nodeops->no_setprop(node, pname, value, size);  	restore_current(); @@ -339,22 +303,7 @@ phandle prom_inst2pkg(int inst)  	node = (*romvec->pv_v2devops.v2_inst2pkg)(inst);  	restore_current();  	spin_unlock_irqrestore(&prom_lock, flags); -	if (node == -1) return 0; -	return node; -} - -/* Return 'node' assigned to a particular prom 'path' - * FIXME: Should work for v0 as well - */ -phandle prom_pathtoinode(char *path) -{ -	phandle node; -	int inst; -	 -	inst = prom_devopen (path); -	if (inst == -1) return 0; -	node = prom_inst2pkg (inst); -	prom_devclose (inst); -	if (node == -1) return 0; +	if ((s32)node == -1) +		return 0;  	return node;  } diff --git a/arch/sparc/prom/tree_64.c b/arch/sparc/prom/tree_64.c index 691be68932f..bd1b2a3ac34 100644 --- a/arch/sparc/prom/tree_64.c +++ b/arch/sparc/prom/tree_64.c @@ -39,14 +39,14 @@ inline phandle __prom_getchild(phandle node)  	return prom_node_to_node("child", node);  } -inline phandle prom_getchild(phandle node) +phandle prom_getchild(phandle node)  {  	phandle cnode; -	if (node == -1) +	if ((s32)node == -1)  		return 0;  	cnode = __prom_getchild(node); -	if (cnode == -1) +	if ((s32)cnode == -1)  		return 0;  	return cnode;  } @@ -56,10 +56,10 @@ inline phandle prom_getparent(phandle node)  {  	phandle cnode; -	if (node == -1) +	if ((s32)node == -1)  		return 0;  	cnode = prom_node_to_node("parent", node); -	if (cnode == -1) +	if ((s32)cnode == -1)  		return 0;  	return cnode;  } @@ -72,14 +72,14 @@ inline phandle __prom_getsibling(phandle node)  	return prom_node_to_node(prom_peer_name, node);  } -inline phandle prom_getsibling(phandle node) +phandle prom_getsibling(phandle node)  {  	phandle sibnode; -	if (node == -1) +	if ((s32)node == -1)  		return 0;  	sibnode = __prom_getsibling(node); -	if (sibnode == -1) +	if ((s32)sibnode == -1)  		return 0;  	return sibnode; @@ -89,7 +89,7 @@ EXPORT_SYMBOL(prom_getsibling);  /* Return the length in bytes of property 'prop' at node 'node'.   * Return -1 on error.   */ -inline int prom_getproplen(phandle node, const char *prop) +int prom_getproplen(phandle node, const char *prop)  {  	unsigned long args[6]; @@ -113,8 +113,8 @@ EXPORT_SYMBOL(prom_getproplen);   * 'buffer' which has a size of 'bufsize'.  If the acquisition   * was successful the length will be returned, else -1 is returned.   */ -inline int prom_getproperty(phandle node, const char *prop, -			    char *buffer, int bufsize) +int prom_getproperty(phandle node, const char *prop, +		     char *buffer, int bufsize)  {  	unsigned long args[8];  	int plen; @@ -141,7 +141,7 @@ EXPORT_SYMBOL(prom_getproperty);  /* Acquire an integer property and return its value.  Returns -1   * on failure.   */ -inline int prom_getint(phandle node, const char *prop) +int prom_getint(phandle node, const char *prop)  {  	int intprop; @@ -235,12 +235,12 @@ static const char *prom_nextprop_name = "nextprop";  /* Return the first property type for node 'node'.   * buffer should be at least 32B in length   */ -inline char *prom_firstprop(phandle node, char *buffer) +char *prom_firstprop(phandle node, char *buffer)  {  	unsigned long args[7];  	*buffer = 0; -	if (node == -1) +	if ((s32)node == -1)  		return buffer;  	args[0] = (unsigned long) prom_nextprop_name; @@ -261,12 +261,12 @@ EXPORT_SYMBOL(prom_firstprop);   * at node 'node' .  Returns NULL string if no more   * property types for this node.   */ -inline char *prom_nextprop(phandle node, const char *oprop, char *buffer) +char *prom_nextprop(phandle node, const char *oprop, char *buffer)  {  	unsigned long args[7];  	char buf[32]; -	if (node == -1) { +	if ((s32)node == -1) {  		*buffer = 0;  		return buffer;  	} @@ -369,25 +369,7 @@ inline phandle prom_inst2pkg(int inst)  	p1275_cmd_direct(args);  	node = (int) args[4]; -	if (node == -1) -		return 0; -	return node; -} - -/* Return 'node' assigned to a particular prom 'path' - * FIXME: Should work for v0 as well - */ -phandle prom_pathtoinode(const char *path) -{ -	phandle node; -	int inst; - -	inst = prom_devopen (path); -	if (inst == 0) -		return 0; -	node = prom_inst2pkg(inst); -	prom_devclose(inst); -	if (node == -1) +	if ((s32)node == -1)  		return 0;  	return node;  }  | 
