home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / internet / netlite / DCI / s / irqs
Text File  |  1992-03-03  |  4KB  |  147 lines

  1. ; Assembler function to enable podule irqs
  2.  
  3.         GET     &.Hdr.ListOpts
  4.         GET     &.Hdr.Macros
  5.         GET     &.Hdr.System
  6.         GET     &.Hdr.EnvNumbers
  7.         GET     &.Hdr.ModHand 
  8.  
  9.         EXPORT  enable_podule_irqs
  10.         EXPORT  disable_podule_irqs
  11.         EXPORT  disable_irqs
  12.         EXPORT  enable_irqs
  13.         EXPORT  splet
  14.         EXPORT  splimp
  15.         EXPORT  splnet
  16.         EXPORT  splx
  17.         EXPORT  set_irqsareoff
  18.         EXPORT  clear_irqsareoff
  19.         EXPORT  ensure_irqs_off
  20.         EXPORT  restore_irqs
  21.         EXPORT  ensure_irqs_on
  22.         ^       0
  23.  
  24.         AREA    poduleirqs,PIC,CODE,REL
  25.  
  26.         ALIGN
  27.  
  28. irqsareoff  
  29.         DCD     0
  30.  
  31. memc_type
  32.         DCD     0
  33.  
  34. ; os_error *enable_podule_irqs();
  35. enable_podule_irqs ROUT
  36.         Push    "r0-r1,lr"
  37.  
  38.  
  39.         MOV  R14,PC                      ;Hold current I_bit & F_bit & Mode
  40.         SWI  XOS_EnterOS                  ;Set SVC Mode.
  41.         TEQP PC,#I_bit+F_bit+SVC_mode    ;Disable IRQs & FIRQs
  42.         MOV  R0,#IOC                     ;whilst enabling Podule IRQs
  43.         LDRB R1,[R0,#IOCIRQMSKB]         ;in IOC
  44.         ORR  R1,R1,#podule_IRQ_bit
  45.         STRB R1,[R0,#IOCIRQMSKB]
  46.         TEQP PC,R14                      ;Restore original I_bit & F_bit
  47.         NOP                              ;And the Mode.
  48.  
  49.         ; Exit with no recovery
  50.         Pull    "r0-r1,pc",,^
  51.  
  52. ; os_error *disable_podule_irqs();
  53. disable_podule_irqs ROUT
  54.         Push    "r0-r1,lr"
  55.  
  56.  
  57.         MOV  R14,PC                      ;Hold current I_bit & F_bit &Mode
  58.         SWI  XOS_EnterOS                  ;Set SVC Mode.
  59.         TEQP PC,#I_bit+F_bit+SVC_mode    ;Disable IRQs & FIRQs
  60.         MOV  R0,#IOC                     ; whilst disabling Podule IRQs
  61.         LDRB R1,[R0,#IOCIRQMSKB]         ; in IOC
  62.         AND  R1,R1,#(&FF-podule_IRQ_bit)
  63.         STRB R1,[R0,#IOCIRQMSKB]
  64.         TEQP PC,R14                      ;Restore original I_bit & F_bit
  65.         NOP                              ;And mode. 
  66.  
  67.         ; Exit with no recovery
  68.         Pull    "r0-r1,pc",,^
  69.  
  70. ;int  disable_irqs();
  71. ; returns:
  72. ;         1 - If IRQs were already disabled.
  73. ;         0 - If this call disabled IRQs.
  74. ;
  75. disable_irqs ROUT
  76. splet
  77. splnet
  78. splimp
  79.         LDR    r0,irqsareoff
  80.         MOVS   r0,r0
  81.         MOVNE  pc,lr
  82.         B      disable_podule_irqs
  83.  
  84. ;void  enable_irqs();
  85. ;  irqsareoff
  86. ;         1 - Just return.
  87. ;         0 - Enable podule IRQs.
  88. ;
  89. enable_irqs ROUT 
  90. splx
  91.         LDR   r0,irqsareoff 
  92.         MOVS  r0,r0
  93.         MOVNE pc,lr                 ;If so, return.
  94.         B     enable_podule_irqs
  95.  
  96. set_irqsareoff
  97.         MOV   r0,#1
  98.         STR   r0,irqsareoff
  99.         MOV   pc,lr
  100.  
  101. clear_irqsareoff
  102.         MOV   r0,#0
  103.         STR   r0,irqsareoff
  104.         MOV   pc,lr
  105.  
  106. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  107. ;
  108. ; ensure_irqs_off:
  109. ;
  110. ; Disables interrupts up to the level of the ethernet driver (for RISC OS,
  111. ; this is just disable IRQs). Once IRQs are disabled, we cannot/must not
  112. ; be reentered.
  113. ;
  114. ; Returns a value indicating the state of interrupts prior to calling here.
  115. ;
  116.  
  117. ensure_irqs_off 
  118.         AND     r0, lr, # I_bit
  119.         ORRS    pc, lr, # I_bit
  120.  
  121. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  122. ;
  123. ; restore_irqs:
  124. ;
  125. ; Restore interrupts to the state they were in prior to a call to
  126. ; ensure_irqs_off, using the value returned by ensure_irqs_off.
  127. ;
  128.  
  129. restore_irqs    
  130.         BIC     lr, lr, # I_bit
  131.         ORRS    pc, lr, r0
  132.  
  133. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  134. ;
  135. ; ensure_irqs_on:
  136. ;
  137. ; Ensure that interrupts are enabled. Returns a value that, when passed
  138. ; to restore_irqs, will restore the state prior to enabling interrupts.
  139. ;
  140.  
  141. ensure_irqs_on
  142.         AND     r0, lr, # I_bit
  143.         BICS    pc, lr, # I_bit
  144.  
  145.  
  146.         END
  147.