diff options
author | David S. Miller <davem@davemloft.net> | 2010-11-30 17:33:29 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-11-30 17:33:29 -0500 |
commit | e62cac1fd035b4cde707285008499dbe71955a86 (patch) | |
tree | 214447e9efd4dc49f5bb707c7c1c0073a3df9803 /arch/sparc/prom | |
parent | 91921fef7c658b12de53376b312d071d757f7770 (diff) |
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>
Diffstat (limited to 'arch/sparc/prom')
-rw-r--r-- | arch/sparc/prom/console_32.c | 50 | ||||
-rw-r--r-- | arch/sparc/prom/console_64.c | 34 | ||||
-rw-r--r-- | arch/sparc/prom/printf.c | 15 |
3 files changed, 50 insertions, 49 deletions
diff --git a/arch/sparc/prom/console_32.c b/arch/sparc/prom/console_32.c index 2ce5acb45f2d..69c16bbf1f48 100644 --- a/arch/sparc/prom/console_32.c +++ b/arch/sparc/prom/console_32.c | |||
@@ -19,27 +19,27 @@ extern void restore_current(void); | |||
19 | /* Non blocking get character from console input device, returns -1 | 19 | /* Non blocking get character from console input device, returns -1 |
20 | * if no input was taken. This can be used for polling. | 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 | unsigned long flags; | 24 | unsigned long flags; |
25 | int i = -1; | ||
27 | 26 | ||
28 | spin_lock_irqsave(&prom_lock, flags); | 27 | spin_lock_irqsave(&prom_lock, flags); |
29 | switch(prom_vers) { | 28 | switch(prom_vers) { |
30 | case PROM_V0: | 29 | case PROM_V0: |
31 | i = (*(romvec->pv_nbgetchar))(); | 30 | i = (*(romvec->pv_nbgetchar))(); |
31 | if (i != -1) { | ||
32 | *buf = i; | ||
33 | i = 0; | ||
34 | } | ||
32 | break; | 35 | break; |
33 | case PROM_V2: | 36 | case PROM_V2: |
34 | case PROM_V3: | 37 | case PROM_V3: |
35 | if( (*(romvec->pv_v2devops).v2_dev_read)(*romvec->pv_v2bootargs.fd_stdin , &inc, 0x1) == 1) { | 38 | if ((*(romvec->pv_v2devops).v2_dev_read)(*romvec->pv_v2bootargs.fd_stdin, |
36 | i = inc; | 39 | buf, 0x1) == 1) |
37 | } else { | 40 | i = 0; |
38 | i = -1; | ||
39 | } | ||
40 | break; | 41 | break; |
41 | default: | 42 | default: |
42 | i = -1; | ||
43 | break; | 43 | break; |
44 | }; | 44 | }; |
45 | restore_current(); | 45 | restore_current(); |
@@ -50,27 +50,23 @@ static int prom_nbgetchar(void) | |||
50 | /* Non blocking put character to console device, returns -1 if | 50 | /* Non blocking put character to console device, returns -1 if |
51 | * unsuccessful. | 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 | unsigned long flags; | 55 | unsigned long flags; |
57 | int i = -1; | 56 | int i = -1; |
58 | 57 | ||
59 | spin_lock_irqsave(&prom_lock, flags); | 58 | spin_lock_irqsave(&prom_lock, flags); |
60 | switch(prom_vers) { | 59 | switch(prom_vers) { |
61 | case PROM_V0: | 60 | case PROM_V0: |
62 | i = (*(romvec->pv_nbputchar))(c); | 61 | i = (*(romvec->pv_nbputchar))(*buf); |
63 | break; | 62 | break; |
64 | case PROM_V2: | 63 | case PROM_V2: |
65 | case PROM_V3: | 64 | case PROM_V3: |
66 | outc = c; | 65 | if ((*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout, |
67 | if( (*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout, &outc, 0x1) == 1) | 66 | buf, 0x1) == 1) |
68 | i = 0; | 67 | i = 0; |
69 | else | ||
70 | i = -1; | ||
71 | break; | 68 | break; |
72 | default: | 69 | default: |
73 | i = -1; | ||
74 | break; | 70 | break; |
75 | }; | 71 | }; |
76 | restore_current(); | 72 | restore_current(); |
@@ -79,17 +75,21 @@ static int prom_nbputchar(char c) | |||
79 | } | 75 | } |
80 | 76 | ||
81 | /* Blocking version of get character routine above. */ | 77 | /* Blocking version of get character routine above. */ |
82 | char | 78 | void prom_getchar(char *buf) |
83 | prom_getchar(void) | ||
84 | { | 79 | { |
85 | int character; | 80 | while (1) { |
86 | while((character = prom_nbgetchar()) == -1) ; | 81 | int err = prom_nbgetchar(buf); |
87 | return (char) character; | 82 | if (!err) |
83 | break; | ||
84 | } | ||
88 | } | 85 | } |
89 | 86 | ||
90 | /* Blocking version of put character routine above. */ | 87 | /* Blocking version of put character routine above. */ |
91 | void | 88 | void prom_putchar(const char *buf) |
92 | prom_putchar(char c) | ||
93 | { | 89 | { |
94 | while(prom_nbputchar(c) == -1) ; | 90 | while (1) { |
91 | int err = prom_nbputchar(buf); | ||
92 | if (!err) | ||
93 | break; | ||
94 | } | ||
95 | } | 95 | } |
diff --git a/arch/sparc/prom/console_64.c b/arch/sparc/prom/console_64.c index 33a8b275d6af..a9a575433ce9 100644 --- a/arch/sparc/prom/console_64.c +++ b/arch/sparc/prom/console_64.c | |||
@@ -18,41 +18,37 @@ extern int prom_stdin, prom_stdout; | |||
18 | /* Non blocking get character from console input device, returns -1 | 18 | /* Non blocking get character from console input device, returns -1 |
19 | * if no input was taken. This can be used for polling. | 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 | unsigned long args[7]; | 23 | unsigned long args[7]; |
24 | char inc; | ||
25 | 24 | ||
26 | args[0] = (unsigned long) "read"; | 25 | args[0] = (unsigned long) "read"; |
27 | args[1] = 3; | 26 | args[1] = 3; |
28 | args[2] = 1; | 27 | args[2] = 1; |
29 | args[3] = (unsigned int) prom_stdin; | 28 | args[3] = (unsigned int) prom_stdin; |
30 | args[4] = (unsigned long) &inc; | 29 | args[4] = (unsigned long) buf; |
31 | args[5] = 1; | 30 | args[5] = 1; |
32 | args[6] = (unsigned long) -1; | 31 | args[6] = (unsigned long) -1; |
33 | 32 | ||
34 | p1275_cmd_direct(args); | 33 | p1275_cmd_direct(args); |
35 | 34 | ||
36 | if (args[6] == 1) | 35 | if (args[6] == 1) |
37 | return inc; | 36 | return 0; |
38 | return -1; | 37 | return -1; |
39 | } | 38 | } |
40 | 39 | ||
41 | /* Non blocking put character to console device, returns -1 if | 40 | /* Non blocking put character to console device, returns -1 if |
42 | * unsuccessful. | 41 | * unsuccessful. |
43 | */ | 42 | */ |
44 | static int prom_nbputchar(char c) | 43 | static int prom_nbputchar(const char *buf) |
45 | { | 44 | { |
46 | unsigned long args[7]; | 45 | unsigned long args[7]; |
47 | char outc; | ||
48 | |||
49 | outc = c; | ||
50 | 46 | ||
51 | args[0] = (unsigned long) "write"; | 47 | args[0] = (unsigned long) "write"; |
52 | args[1] = 3; | 48 | args[1] = 3; |
53 | args[2] = 1; | 49 | args[2] = 1; |
54 | args[3] = (unsigned int) prom_stdout; | 50 | args[3] = (unsigned int) prom_stdout; |
55 | args[4] = (unsigned long) &outc; | 51 | args[4] = (unsigned long) buf; |
56 | args[5] = 1; | 52 | args[5] = 1; |
57 | args[6] = (unsigned long) -1; | 53 | args[6] = (unsigned long) -1; |
58 | 54 | ||
@@ -65,17 +61,21 @@ static int prom_nbputchar(char c) | |||
65 | } | 61 | } |
66 | 62 | ||
67 | /* Blocking version of get character routine above. */ | 63 | /* Blocking version of get character routine above. */ |
68 | char | 64 | void prom_getchar(char *buf) |
69 | prom_getchar(void) | ||
70 | { | 65 | { |
71 | int character; | 66 | while (1) { |
72 | while((character = prom_nbgetchar()) == -1) ; | 67 | int err = prom_nbgetchar(buf); |
73 | return (char) character; | 68 | if (!err) |
69 | break; | ||
70 | } | ||
74 | } | 71 | } |
75 | 72 | ||
76 | /* Blocking version of put character routine above. */ | 73 | /* Blocking version of put character routine above. */ |
77 | void | 74 | void prom_putchar(const char *buf) |
78 | prom_putchar(char c) | ||
79 | { | 75 | { |
80 | prom_nbputchar(c); | 76 | while (1) { |
77 | int err = prom_nbputchar(buf); | ||
78 | if (!err) | ||
79 | break; | ||
80 | } | ||
81 | } | 81 | } |
diff --git a/arch/sparc/prom/printf.c b/arch/sparc/prom/printf.c index ca869266b9f3..24031971f806 100644 --- a/arch/sparc/prom/printf.c +++ b/arch/sparc/prom/printf.c | |||
@@ -23,13 +23,14 @@ static char ppbuf[1024]; | |||
23 | 23 | ||
24 | void notrace prom_write(const char *buf, unsigned int n) | 24 | void notrace prom_write(const char *buf, unsigned int n) |
25 | { | 25 | { |
26 | char ch; | 26 | while (n-- != 0) { |
27 | 27 | char ch = *buf; | |
28 | while (n != 0) { | 28 | if (ch == '\n') { |
29 | --n; | 29 | char tmp = '\r'; |
30 | if ((ch = *buf++) == '\n') | 30 | prom_putchar(&tmp); |
31 | prom_putchar('\r'); | 31 | } |
32 | prom_putchar(ch); | 32 | prom_putchar(buf); |
33 | buf++; | ||
33 | } | 34 | } |
34 | } | 35 | } |
35 | 36 | ||