home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / config / m68k-native / disable.s < prev    next >
Encoding:
Text File  |  1997-01-08  |  2.3 KB  |  87 lines

  1. /*
  2.      (C) 1995-96 AROS - The Amiga Replacement OS
  3.      $Id: disable.s,v 1.7 1997/01/08 04:14:25 ldp Exp $
  4.  
  5.      Desc:
  6.      Lang:
  7. */
  8.  
  9. /*****************************************************************************
  10.  
  11.     NAME
  12.  
  13.      AROS_LH0(void, Disable,
  14.  
  15.     LOCATION
  16.      struct ExecBase *, SysBase, 20, Exec)
  17.  
  18.     FUNCTION
  19.      This function disables the delivery of all interrupts until a matching
  20.      call to Enable() is done. This implies a Forbid(). Since the system
  21.      needs the regular delivery of all interrupts it is forbidden to disable
  22.      them for longer than ~250 microseconds.
  23.  
  24.      THIS CALL IS VERY DANGEROUS!!!
  25.  
  26.      Do not use it without thinking very well about it or better do not use
  27.      it at all. Most of the time you can live without it by using semaphores
  28.      or similar.
  29.  
  30.      Calls to Disable() nest, i.e. for each call to Disable() you need one
  31.      call to Enable().
  32.  
  33.     INPUTS
  34.  
  35.     RESULT
  36.  
  37.     NOTES
  38.      This function preserves all registers.
  39.  
  40.      This function may be used from interrupts to disable all higher
  41.      priority interrupts. Lower priority interrupts are disabled anyway.
  42.  
  43.      To prevent deadlocks calling Wait() in disabled state breaks the
  44.      disable - thus interrupts and taskswitches may happen again.
  45.  
  46.     EXAMPLE
  47.  
  48.     BUGS
  49.  
  50.     SEE ALSO
  51.      Forbid(), Permit(), Enable(), Wait()
  52.  
  53.     INTERNALS
  54.      For old exec Disable() there exists an assembler macro replacement
  55.      that is (of course) unportable. Using a Disable() implementation
  56.      equal to this macro would not only have some impact on Disable()
  57.      itself but also on other functions (e.g. Signal()).
  58.      Therefore I decided to drop support for this macro to a certain
  59.      extent. The difference is only minuscule:
  60.      If a task uses the assembler macro and activates some higher priority
  61.      task he cannot expect this task to be awakened immediately at Enable()
  62.      but only at the next context switch. But I do not think that this
  63.      poses any problems.
  64.  
  65.     HISTORY
  66.  
  67. ******************************************************************************/
  68.  
  69.     INTENA        =    0xdff09a
  70.     INTEN        =    0x4000
  71.     SET        =    0x8000
  72.  
  73.     #include "machine.i"
  74.  
  75.     .text
  76.     .balign 16
  77.     .globl    AROS_SLIB_ENTRY(Disable,Exec)
  78.     .type    AROS_SLIB_ENTRY(Disable,Exec),@function
  79. AROS_SLIB_ENTRY(Disable,Exec):
  80.     /* disable interrupts */
  81.     move.w    #INTEN,INTENA
  82.  
  83.     /* increment nesting count and return */
  84.     addq.b    #1,IDNestCnt(a6)
  85.     rts
  86.  
  87.