home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1742 / Space.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  3.0 KB  |  106 lines

  1. /*
  2.     $Id: space.c,v 2.6 90/08/24 11:48:45 sw Exp $
  3. */
  4.  
  5. /*
  6.     "Copyright 1990 Piercarlo Grandi. All rights reserved.";
  7. */
  8.  
  9. /*
  10.     This driver is free software; you can redistribute it and/or
  11.     modify it under the terms of the GNU General Public License as
  12.     published by the Free Software Foundation; either version 1, or
  13.     (at your option) any later version.
  14.  
  15.     As a special case, this driver may be incorporated in any OS kernel,
  16.     whether the GNU General Public License applies to it or not.
  17.  
  18.     This driver is distributed in the hope that it will be useful,
  19.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.     GNU General Public License for more details.
  22.  
  23.     You may have received a copy of the GNU General Public License
  24.     along with this driver; if not, write to the Free Software
  25.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26. */
  27.  
  28. #include "config.h"
  29.  
  30. #ifdef PP
  31.  
  32. #include "sys/types.h"
  33. #include "sys/param.h"
  34. #include "sys/buf.h"
  35. #include "sys/pp.h"
  36.  
  37. struct pp_config    pp_config[] =
  38. {
  39.     /*    data,        status,        control */
  40. #if PP_CNTLS >= 1
  41.     {    PP_0_SIOA,  PP_0_SIOA+1,    PP_0_EIOA    },    /* /dev/pp0    */
  42. #endif
  43. #if PP_CNTLS >= 2
  44.     {    PP_1_SIOA,  PP_1_SIOA+1,    PP_2_EIOA    },    /* /dev/pp0    */
  45. #endif
  46. #if PP_CNTLS >= 3
  47.     {    PP_2_SIOA,  PP_2_SIOA+1,    PP_2_EIOA    },    /* /dev/pp0    */
  48. #endif
  49. };
  50.  
  51. #define ppMAX        (sizeof pp_config / sizeof (struct pp_config))
  52.  
  53. #if ppSTATICSZ != 0
  54. char            pp_sbuf[ppMAX][ppSTATICSZ];
  55. #endif
  56.  
  57. short            pp_max = ppMAX;
  58.  
  59. /*
  60.     The exit conditions from the two polling loops here are a bit funny,
  61.     my printer (EPSON SQ850) and parallel port give the following statuses:
  62.  
  63.                 NOTBUSY NOTACK  NOPAPER ONLINE  NOTERROR
  64.  
  65.     port missing        1    1    1    1    1
  66.     printer power off    1    0    0    0    0
  67.     printer not there    1    1    0    1    0
  68.     offline            0    1    0    1    0
  69.     online            1    1    0    1    1
  70.  
  71.     The printer puts NOTBUSY low while we strobe the character in,
  72.     then strobes NOTACK low for 10 usecs afterwards to signal we can
  73.     strobe again. The relationship between the two is to say the
  74.     last bizarre.
  75.  
  76.     Our problem is that we want to distinguish between long term and
  77.     short term busy, where short term busy is defined as the time taken
  78.     by the interface to read a character, and long term busy as paper
  79.     end, offline, power off, interface buffer full.
  80. */
  81.  
  82. struct pp_guard        pp_guard =
  83. {
  84.     {
  85.     (ppONLINE|ppNOTERROR|ppNOPAPER),        /* pause.mask    */
  86.     (ppONLINE|ppNOTERROR)                /* pause.done    */
  87.     },
  88.     {
  89.     (ppNOTACK|ppNOTBUSY),                /* spin.mask    */
  90.     (ppNOTACK|ppNOTBUSY)                /* spin.done    */
  91.     },
  92. };
  93.  
  94. /*
  95.     These are the number of clock ticks in a long pause, the number of clock
  96.     ticks in a short pause, and the maximum # of times we busy wait, after
  97.     which we sleep wait; this should be a bit larger than the usual inter
  98.     character processing time of the interface.
  99. */
  100.  
  101. short unsigned        pp_longpause    = HZ/2;
  102. short unsigned        pp_shortpause    = HZ/4;
  103. short unsigned        pp_maxspins    = 7;    /* in 10 usec units    */
  104.  
  105. #endif /* PP */
  106.