home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / EFFO / forum16.lzh / SOFTWARE / ASSEMBLER / EXIT_HANDLER / uacct.a < prev    next >
Text File  |  1991-01-09  |  4KB  |  143 lines

  1. ******************************************************************
  2. **
  3. **   OS-9 EXIT HANDLER HOOK
  4. **   A. Miotto - P. Mato
  5. **
  6. **---
  7. ** Edition history
  8. **  #   Date    Changes made                                    by
  9. ** -- -------- ------------------------------------------------ --
  10. ** 00 88-12-01 first edition                                    am
  11. ** 01 89-01-06 problem on F$DExit corrected                     pm
  12. ** 02 89-07-23 version 2                                        am
  13. ** 03 90-10-12 this version is installed automatically at boot  am
  14. **---
  15. Edition    equ     3
  16.  
  17.     use    <oskdefs.d>
  18.     use    uacct.d
  19.  
  20. Typ_Lang set    (Systm<<8)+Objct system module, object code
  21. Attr_Rev set    ((ReEnt+SupStat+Ghost)<<8)+3 supervisor state, sharable
  22.  
  23.     psect    uacct,Typ_Lang,Attr_Rev,Edition,0,Init
  24.  
  25. ********************
  26. * Entry Point
  27. *
  28. * Passed:  (a3) = vsect data ptr
  29. *          (a6) = system global data ptr
  30. *          (sp) = (system) stack ptr
  31. *
  32. * Returns:  nothing
  33. *
  34. * Error Return:  d1.w = error code
  35. *                (cc) = carry set
  36. *
  37. * Destroys:  only d1 and cc may be modified.
  38. *
  39. Init:     move.l    a1,-(sp)    save reg
  40.     lea.l    SvcTbl(pc),a1    get address of service table
  41.     OS9    F$SSvc        install F$UAcct system call
  42.     movea.l    (sp)+,a1    restore reg (retain Carry)
  43.     rts            return status
  44.  
  45. SvcTbl:
  46.     dc.w    F$UAcct,UAcct-*-4
  47.     dc.w    F$ExhLnk,ExhLnk-*-4
  48.     dc.w    F$ExhUlk,ExhUlk-*-4
  49.     dc.w    -1
  50.  
  51. *------------------------------------------------------------*
  52. * Call exit routine before process completion
  53. *
  54. * input: d0.w function code
  55. *        (a0) process descriptor pointer
  56. *        (a3) static storage (NULL)
  57. *        (a4) process descriptor pointer
  58. *        (a6) system global data pointer
  59. *---
  60. * variable used in the process descriptor:
  61. *    P$Acct    first entry in the list
  62. *    P$Acct+4  last entry in the list
  63. *
  64. UAcct:
  65.     cmp.w    #F$Fork,d0        is it a fork?    
  66.     bne.s    UA10
  67.     lea    P$Acct(a0),a4        initialise P$Acct pointers
  68.     move.l    a4,Exh_Next(a4)
  69.     move.l    a4,Exh_Prev(a4)
  70.     bra.s    UA99
  71. UA10    cmp.w    #F$Exit,d0        no action on F$Chain
  72.     bne.s    UA99
  73.     movem.l    d0-d7/a0-a6,-(a7)
  74.     lea    P$Acct(a0),a4
  75.     bra.s    UAwhile
  76. UAloop    move.l    Exh_Next(a4),a1
  77.     bsr.s    unlink
  78.     bcs.s    UA90
  79.     move.l    Exh_Entry(a1),a0
  80.     move.l    Exh_a6(a1),a6
  81.     move.l    Exh_d0(a1),d0
  82.     move.l    Exh_d1(a1),d1
  83.     jsr    (a0)
  84. UAwhile    cmpa.l    Exh_Next(a4),a4
  85.     bne.s    UAloop
  86. UA90    movem.l    (a7)+,d0-d7/a0-a6
  87. UA99    tst.l    d0
  88.     rts
  89.  
  90. *------------------------------------------------------------*
  91. * Link software package to the exit routine list
  92. *
  93. * input: (a1) 4 longword structure pointer
  94. * offset 0: reserved for next entry in the list
  95. *        4: reserved for previous entry in the list
  96. *        8: entry point of exit routine
  97. *       12: a6 to be passed to the exit routine
  98. *       16: d0 to be passed to the exit routine (optional)
  99. *       20: d1 to be passed to the exit routine (optional)
  100. *
  101. ExhLnk:    movem.l    a2/a4,-(sp)
  102.     lea    P$Acct(a4),a4
  103.     move.l    Exh_Next(a4),a2
  104.     move.l    a2,Exh_Next(a1)
  105.     move.l    a4,Exh_Prev(a1)
  106.     move.l    a1,Exh_Next(a4)
  107.     move.l    a1,Exh_Prev(a2)
  108.     movem.l    (sp)+,a2/a4
  109.     rts
  110.  
  111. *------------------------------------------------------------*
  112. * Unlink software package from the exit routine list
  113. *
  114. * input: (a1) 4 longword structure pointer
  115. *
  116. ExhUlk:
  117.     bsr.s    unlink
  118.     bcc.s    EU99
  119.     move.w    #E$Param,R$d1(a5)
  120.     ori    #Carry,ccr
  121. EU99    rts
  122.  
  123. *------------------------------------------------------------*
  124. * Unlink entry from list
  125. *
  126. * input: (a1) entry pointer
  127. *
  128. unlink:    movem.l    a2-a3,-(a7)
  129.     move.l    Exh_Next(a1),a2
  130.     move.l    Exh_Prev(a1),a3
  131.     cmpa.l    Exh_Prev(a2),a1
  132.     bne.s    ulk90
  133.     cmpa.l    Exh_Next(a3),a1
  134.     bne.s    ulk90
  135.     move.l    a3,Exh_Prev(a2)
  136.     move.l    a2,Exh_Next(a3)
  137.     bra.s    ulk99
  138. ulk90    ori    #Carry,ccr
  139. ulk99    movem.l    (a7)+,a2-a3
  140.     rts
  141.  
  142.     ends
  143.