Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sparc: Pass buffer pointer all the way down to prom_{get,put}char().

This gets us closer to being able to eliminate the use
of dynamic and stack based buffers, so that we can adhere
to the "no buffer addresses above 4GB" rule for PROM calls.

Signed-off-by: David S. Miller <davem@davemloft.net>

+55 -54
+1 -1
arch/sparc/include/asm/openprom.h
··· 39 39 int (*v2_dev_open)(char *devpath); 40 40 void (*v2_dev_close)(int d); 41 41 int (*v2_dev_read)(int d, char *buf, int nbytes); 42 - int (*v2_dev_write)(int d, char *buf, int nbytes); 42 + int (*v2_dev_write)(int d, const char *buf, int nbytes); 43 43 int (*v2_dev_seek)(int d, int hi, int lo); 44 44 45 45 /* Never issued (multistage load support) */
+2 -2
arch/sparc/include/asm/oplib_32.h
··· 105 105 /* Character operations to/from the console.... */ 106 106 107 107 /* Blocking get character from console. */ 108 - extern char prom_getchar(void); 108 + extern void prom_getchar(char *buf); 109 109 110 110 /* Blocking put character to console. */ 111 - extern void prom_putchar(char character); 111 + extern void prom_putchar(const char *buf); 112 112 113 113 /* Prom's internal routines, don't use in kernel/boot code. */ 114 114 extern void prom_printf(const char *fmt, ...);
+2 -2
arch/sparc/include/asm/oplib_64.h
··· 97 97 /* Character operations to/from the console.... */ 98 98 99 99 /* Blocking get character from console. */ 100 - extern char prom_getchar(void); 100 + extern void prom_getchar(char *buf); 101 101 102 102 /* Blocking put character to console. */ 103 - extern void prom_putchar(char character); 103 + extern void prom_putchar(const char *buf); 104 104 105 105 /* Prom's internal routines, don't use in kernel/boot code. */ 106 106 extern void prom_printf(const char *fmt, ...);
+25 -25
arch/sparc/prom/console_32.c
··· 19 19 /* Non blocking get character from console input device, returns -1 20 20 * if no input was taken. This can be used for polling. 21 21 */ 22 - static int prom_nbgetchar(void) 22 + static int prom_nbgetchar(char *buf) 23 23 { 24 - static char inc; 25 - int i = -1; 26 24 unsigned long flags; 25 + int i = -1; 27 26 28 27 spin_lock_irqsave(&prom_lock, flags); 29 28 switch(prom_vers) { 30 29 case PROM_V0: 31 30 i = (*(romvec->pv_nbgetchar))(); 31 + if (i != -1) { 32 + *buf = i; 33 + i = 0; 34 + } 32 35 break; 33 36 case PROM_V2: 34 37 case PROM_V3: 35 - if( (*(romvec->pv_v2devops).v2_dev_read)(*romvec->pv_v2bootargs.fd_stdin , &inc, 0x1) == 1) { 36 - i = inc; 37 - } else { 38 - i = -1; 39 - } 38 + if ((*(romvec->pv_v2devops).v2_dev_read)(*romvec->pv_v2bootargs.fd_stdin, 39 + buf, 0x1) == 1) 40 + i = 0; 40 41 break; 41 42 default: 42 - i = -1; 43 43 break; 44 44 }; 45 45 restore_current(); ··· 50 50 /* Non blocking put character to console device, returns -1 if 51 51 * unsuccessful. 52 52 */ 53 - static int prom_nbputchar(char c) 53 + static int prom_nbputchar(const char *buf) 54 54 { 55 - static char outc; 56 55 unsigned long flags; 57 56 int i = -1; 58 57 59 58 spin_lock_irqsave(&prom_lock, flags); 60 59 switch(prom_vers) { 61 60 case PROM_V0: 62 - i = (*(romvec->pv_nbputchar))(c); 61 + i = (*(romvec->pv_nbputchar))(*buf); 63 62 break; 64 63 case PROM_V2: 65 64 case PROM_V3: 66 - outc = c; 67 - if( (*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout, &outc, 0x1) == 1) 65 + if ((*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout, 66 + buf, 0x1) == 1) 68 67 i = 0; 69 - else 70 - i = -1; 71 68 break; 72 69 default: 73 - i = -1; 74 70 break; 75 71 }; 76 72 restore_current(); ··· 75 79 } 76 80 77 81 /* Blocking version of get character routine above. */ 78 - char 79 - prom_getchar(void) 82 + void prom_getchar(char *buf) 80 83 { 81 - int character; 82 - while((character = prom_nbgetchar()) == -1) ; 83 - return (char) character; 84 + while (1) { 85 + int err = prom_nbgetchar(buf); 86 + if (!err) 87 + break; 88 + } 84 89 } 85 90 86 91 /* Blocking version of put character routine above. */ 87 - void 88 - prom_putchar(char c) 92 + void prom_putchar(const char *buf) 89 93 { 90 - while(prom_nbputchar(c) == -1) ; 94 + while (1) { 95 + int err = prom_nbputchar(buf); 96 + if (!err) 97 + break; 98 + } 91 99 }
+17 -17
arch/sparc/prom/console_64.c
··· 18 18 /* Non blocking get character from console input device, returns -1 19 19 * if no input was taken. This can be used for polling. 20 20 */ 21 - static int prom_nbgetchar(void) 21 + static int prom_nbgetchar(char *buf) 22 22 { 23 23 unsigned long args[7]; 24 - char inc; 25 24 26 25 args[0] = (unsigned long) "read"; 27 26 args[1] = 3; 28 27 args[2] = 1; 29 28 args[3] = (unsigned int) prom_stdin; 30 - args[4] = (unsigned long) &inc; 29 + args[4] = (unsigned long) buf; 31 30 args[5] = 1; 32 31 args[6] = (unsigned long) -1; 33 32 34 33 p1275_cmd_direct(args); 35 34 36 35 if (args[6] == 1) 37 - return inc; 36 + return 0; 38 37 return -1; 39 38 } 40 39 41 40 /* Non blocking put character to console device, returns -1 if 42 41 * unsuccessful. 43 42 */ 44 - static int prom_nbputchar(char c) 43 + static int prom_nbputchar(const char *buf) 45 44 { 46 45 unsigned long args[7]; 47 - char outc; 48 - 49 - outc = c; 50 46 51 47 args[0] = (unsigned long) "write"; 52 48 args[1] = 3; 53 49 args[2] = 1; 54 50 args[3] = (unsigned int) prom_stdout; 55 - args[4] = (unsigned long) &outc; 51 + args[4] = (unsigned long) buf; 56 52 args[5] = 1; 57 53 args[6] = (unsigned long) -1; 58 54 ··· 61 65 } 62 66 63 67 /* Blocking version of get character routine above. */ 64 - char 65 - prom_getchar(void) 68 + void prom_getchar(char *buf) 66 69 { 67 - int character; 68 - while((character = prom_nbgetchar()) == -1) ; 69 - return (char) character; 70 + while (1) { 71 + int err = prom_nbgetchar(buf); 72 + if (!err) 73 + break; 74 + } 70 75 } 71 76 72 77 /* Blocking version of put character routine above. */ 73 - void 74 - prom_putchar(char c) 78 + void prom_putchar(const char *buf) 75 79 { 76 - prom_nbputchar(c); 80 + while (1) { 81 + int err = prom_nbputchar(buf); 82 + if (!err) 83 + break; 84 + } 77 85 }
+8 -7
arch/sparc/prom/printf.c
··· 23 23 24 24 void notrace prom_write(const char *buf, unsigned int n) 25 25 { 26 - char ch; 27 - 28 - while (n != 0) { 29 - --n; 30 - if ((ch = *buf++) == '\n') 31 - prom_putchar('\r'); 32 - prom_putchar(ch); 26 + while (n-- != 0) { 27 + char ch = *buf; 28 + if (ch == '\n') { 29 + char tmp = '\r'; 30 + prom_putchar(&tmp); 31 + } 32 + prom_putchar(buf); 33 + buf++; 33 34 } 34 35 } 35 36