home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 4.ddi / C / ISISRSTK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  1.5 KB  |  60 lines

  1. /**
  2. *
  3. * Name        isisrstk -- Allocate stack space for all C-TOOLS-2-style
  4. *                interrupt service routines
  5. *        (Formerly called PCISRSTK.)
  6. *
  7. * Synopsis    ercode = isisrstk(stksize);
  8. *
  9. *        int  ercode      Error return code
  10. *        int  stksize      Desired stack size in bytes.
  11. *
  12. * Description    Interrupt service routines require their own stack.
  13. *        This function must be called before any C-TOOLS-2-style
  14. *        ISR is set up so that stack space can be allocated.  The
  15. *        stksize, which must accommodate all C-TOOLS-2-style
  16. *        ISRs, is allocated from the heap, and its segment and
  17. *        offset address are stored in the global variable
  18. *        b_isrstk.  These values are used by the ISR setup
  19. *        function, ISSETISR, and the ISR function dispatcher,
  20. *        ISDISPAT.
  21. *
  22. *        Note:  This function and ISSETISR (formerly called
  23. *        PCSETISR) are supplied for compatibility with C TOOLS 2.
  24. *        ISINSTAL is to be preferred for new programs.
  25. *
  26. * Returns    ercode          Returned error code:
  27. *                  0 if successful,
  28. *                  1 if insufficient memory.
  29. *        b_isrstk      Physical address of allocated space.
  30. *        b_istksize      Size of stack area in bytes.
  31. *
  32. * Version    3.0  (C)Copyright Blaise Computing Inc.  1983, 1984, 1986
  33. *
  34. **/
  35.  
  36. #include <bisr.h>
  37.  
  38. #if LAT300
  39. #include <stdlib.h>
  40. #endif
  41. #if MSC300
  42. #include <malloc.h>
  43. #endif
  44.  
  45. ADS b_isrstk    = {0,0};
  46. char *b_isrpstk = NIL;
  47. int b_istksize    = 0;
  48.  
  49. int isisrstk(stksize)
  50. int stksize;
  51. {
  52.     if ((b_isrpstk = malloc((unsigned int) stksize)) == NIL)
  53.     return(1);
  54.  
  55.     utabsptr(b_isrpstk,&b_isrstk);
  56.     b_istksize = stksize;
  57.  
  58.     return(0);
  59. }
  60.