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

  1. /* FAS Final Async Solution driver for 386 versions of system V UNIX */
  2.  
  3. /* Originally written by
  4. Jim Murray              encore!cloud9!jjmhome!jjm
  5. 2 Mohawk Circle         harvard!m2c!jjmhome!jjm
  6. Westboro Mass 01581     jjm%jjmhome@m2c.m2c.org
  7. USA                     voice (508) 366-2813
  8. */
  9.  
  10. /* Current author:
  11. Uwe Doering             Domain   : gemini@geminix.in-berlin.de
  12. Billstedter Pfad 17 b   Bangpath : ...!unido!fub!tmpmbx!geminix!gemini
  13. 1000 Berlin 20
  14. Germany
  15. */
  16.  
  17. #ident    "@(#)fas.c    2.07"
  18.  
  19. /* Note: This source code was quite heavily optimized for speed. You
  20.          may wonder that register variables aren't used everywhere.
  21.          This is because there is an overhead in memory accesses
  22.          when using register variables. As you may know data accesses
  23.          usually need much more wait states on the memory bus than
  24.          code accesses (because of page or cache misses). Therefore
  25.          saving some data accesses has higher priority than saving
  26.          code accesses.
  27.  
  28.          You may also note some not very elegant constructions that
  29.          may be intentional because they are faster. If you want to
  30.          make style improvements you should check the assembler output
  31.          whether this wouldn't slow things down.
  32.  
  33.          Decisions for speed optimization were based on assembler
  34.          listings produced by the standard UNIX V 3.X/386 C compiler.
  35. */
  36.  
  37. #if defined (XENIX)
  38. #include "fas.h"
  39. #else
  40. #include <sys/fas.h>
  41. #include <sys/inline.h>
  42. #endif
  43.  
  44. #if defined (SCO) || defined (XENIX)
  45. #define asyputchar sioputchar
  46. #define asygetchar siogetchar
  47. #endif
  48.  
  49. #if defined (XENIX)
  50. #define intr_disable()    old_level = SPLINT ()
  51. #define intr_restore()    (void) splx (old_level)
  52. #define REGVAR
  53.  
  54. /*
  55. **    Union for use by all device handler ioctl routines.
  56. */
  57. union ioctl_arg {
  58.     struct termio    *stparg;    /* ptr to termio struct */
  59.     char        *cparg;        /* ptr to character */
  60.     char        carg;        /* character */
  61.     int        *iparg;        /* ptr to integer */
  62.     int        iarg;        /* integer */
  63.     long            *lparg;         /* ptr to long */
  64.     long            larg;           /* long */
  65. };
  66. #else
  67. /* This is a terrible ugly kludge to speed up the `inb' and `outb'
  68.    functions. I.e., originally, the `outb' inline function had an
  69.    overhead of four data memory accesses for parameter passing. This
  70.    parameter passing actually consumed more clock cycles than the
  71.    assembler `outb' command itself. Although this solution can't
  72.    prevent unnessessary register moves it limits them at least to
  73.    register to register moves that are much faster. You need a
  74.    line like the following in the declaration part of every
  75.    function that uses `inb' or `outb' calls:
  76.  
  77.     REGVAR;
  78.  
  79.    This hack should work with every compiler that knows about the
  80.    UNIX V 3.X/386 standard compiler's inline assembler directives.
  81. */
  82.  
  83. asm    void loadal (val)
  84.