root/arch/sparc/prom/console.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. prom_nbgetchar
  2. prom_nbputchar
  3. prom_getchar
  4. prom_putchar

   1 /* console.c: Routines that deal with sending and receiving IO
   2  *            to/from the current console device using the PROM.
   3  *
   4  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
   5  */
   6 
   7 #include <asm/openprom.h>
   8 #include <asm/oplib.h>
   9 
  10 /* Non blocking get character from console input device, returns -1
  11  * if no input was taken.  This can be used for polling.
  12  */
  13 int
  14 prom_nbgetchar(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  15 {
  16         static char inc;
  17 
  18         switch(prom_vers) {
  19         case PROM_V0:
  20                 return (*(romvec->pv_nbgetchar))();
  21                 break;
  22         case PROM_V2:
  23         case PROM_V3:
  24         case PROM_P1275:
  25                 if( (*(romvec->pv_v2devops).v2_dev_read)(*romvec->pv_v2bootargs.fd_stdin , &inc, 0x1) == 1)
  26                         return inc;
  27                 return -1;
  28                 break;
  29         };
  30         return 0; /* Ugh, we could spin forever on unsupported proms ;( */
  31 }
  32 
  33 /* Non blocking put character to console device, returns -1 if
  34  * unsuccessful.
  35  */
  36 int
  37 prom_nbputchar(char c)
     /* [previous][next][first][last][top][bottom][index][help] */
  38 {
  39         static char outc;
  40 
  41         switch(prom_vers) {
  42         case PROM_V0:
  43                 return (*(romvec->pv_nbputchar))(c);
  44                 break;
  45         case PROM_V2:
  46         case PROM_V3:
  47         case PROM_P1275:
  48                 outc = c;
  49                 if( (*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout, &outc, 0x1) == 1)
  50                         return 0;
  51                 return -1;
  52                 break;
  53         };
  54         return 0; /* Ugh, we could spin forever on unsupported proms ;( */
  55 }
  56 
  57 /* Blocking version of get character routine above. */
  58 char
  59 prom_getchar(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  60 {
  61         int character;
  62         while((character = prom_nbgetchar()) == -1) ;
  63         return (char) character;
  64 }
  65 
  66 /* Blocking version of put character routine above. */
  67 void
  68 prom_putchar(char c)
     /* [previous][next][first][last][top][bottom][index][help] */
  69 {
  70         while(prom_nbputchar(c) == -1) ;
  71         return;
  72 }
  73 

/* [previous][next][first][last][top][bottom][index][help] */