home *** CD-ROM | disk | FTP | other *** search
/ Between Heaven & Hell 2 / BetweenHeavenHell.cdr / 500 / 471 / rccl146 < prev    next >
Text File  |  1987-03-02  |  5KB  |  225 lines

  1. / modified to add asleep function which allowes one to turn off
  2. / the clock interrupt fifo service sept 84
  3. / Stand alone C runtime startoff
  4. / Trap handler for system calls
  5. / Clock interrupt handler
  6.  
  7. .globl  _end            / data space addresses generated by the loader
  8. .globl  _edata
  9.  
  10. .globl  __trap          / system call simulator in Unix kernel code
  11. .globl  _zexit          / system exit
  12.  
  13. .globl  _main           / user entry point
  14.  
  15. .globl  _tick           / interrupt enable and disable
  16. .globl  _onclk          / addresse of clock interrupt routine
  17. .globl  _asleep        / serial port control of clock interrupt enable/disable
  18.  
  19.  
  20. .globl  start           / startoff entry point
  21. .globl  _wait           / wait for bus interrupt
  22. .globl  _halt           / halt processor
  23.  
  24. .globl  savr5           / C run time save area
  25.  
  26.             / interrupt vectors
  27.     timeout=4
  28.     illegal=10
  29.     break=14
  30.     iott=20
  31.     pwr=24
  32.     emtt=30
  33.     trap=34
  34.     clock=100
  35.     vax=200
  36.  
  37.     halt=0          / halt instruction
  38.     wait=1          / wait for bus interrupt
  39.     rti=2           / return from interrupt
  40.     bpt=3           / break point
  41.  
  42.     .=timeout^.     / bus timeout
  43.     panic1
  44.     340
  45.  
  46.     .=illegal^.     / illegal instructions
  47.     panic2
  48.     340
  49.  
  50.     .=break^.       / break point
  51.     panic3
  52.     340
  53.  
  54.     .=iott^.        / iot trap
  55.     panic4
  56.     340
  57.  
  58.     .=pwr^.         / power fail
  59.     panic5
  60.     340
  61.  
  62.     .=emtt^.        / emt instruction
  63.     panic6
  64.     340
  65.  
  66.     .=trap^.        /trap handler
  67.     traph
  68.     0
  69.  
  70.     .=clock^.       /clock
  71.     clock+2
  72.     rti
  73.  
  74.     .=vax^.
  75.     panic7
  76.     340
  77.     panic8
  78.     340
  79.  
  80.     .=2000^.    /start address
  81. start:
  82.     0106427        /mtps
  83.     0340        /max priority
  84.     mov    $2000,sp    /set up stack
  85.  
  86.     clr     _tick
  87.     mov    $60,_asleep
  88.     clr     inserf
  89.     mov     $340,*$clock+2          /set up clock interrupt vector
  90.     mov     $service,*$clock
  91.  
  92.     mov     $_edata,r0      /clear bss area
  93. 2:      cmp     r0,$_end
  94.     beq     3f
  95.     clrb    (r0)+
  96.     br      2b
  97. 3:
  98.     mov     $-1,-(sp)
  99.     mov     $sname,-(sp)    /simulate exec with dummy name
  100.     mov     $1,-(sp)
  101.  
  102.     mov    sp,r0
  103.     mov    (r0),-(sp)
  104.     tst    (r0)+
  105.     mov    r0,2(sp)
  106.  
  107.     0106427            /mtps
  108.     0            /low priority
  109.     jsr    pc,_main
  110.     clr     (sp)            / code 0
  111.     jsr     pc,_zexit
  112.     cmp    (sp)+,(sp)+
  113.     mov    r0,(sp)
  114. _halt:
  115.     halt
  116.  
  117. traph:                          /trap handler
  118.     mov     r0,-(sp)
  119.     mov     r1,-(sp)
  120.     jsr     pc,__trap
  121.     mov     (sp)+,r1
  122.     mov     (sp)+,r0
  123.     rti
  124.  
  125. service:
  126.     bit    $2000,*$-1300    / (DLV1->rcsr & READY)
  127.     jne    L4        / == 0 then L4
  128.     mov    *$-1276,_asleep    / else _asleep = DLV1->rbuf
  129. L4:    cmp    $60,_asleep    / asleep??
  130.     bne    1f        / NO then interrupt
  131.     rti            / YES then return
  132. 1:
  133.     tst     _tick           / if tick is set equal to
  134.     bne     1f              / zero,ignor interrupt
  135.     rti
  136. 1:
  137.     inc     tcount          / check for the proper no. of
  138.     cmp     _tick,tcount    / ticks before servicing the
  139.     beq     1f              / interrupt
  140.     rti
  141. 1:
  142.     tst     inserf          / if routine still in service
  143.     beq     1f
  144.     mov     $9,code
  145.     mov     $_zexit,_onclk
  146. 1:
  147.     0106427            /mtps
  148.     0            /low priority
  149.     inc     inserf
  150.     clr     tcount
  151.     mov     r0,-(sp)        / save
  152.     mov     r1,-(sp)        /   regs
  153.     mov     r2,-(sp)
  154.     mov     r3,-(sp)
  155.     mov     r4,-(sp)
  156.     mov     r5,-(sp)
  157.     mov     code,-(sp)
  158.     jsr     pc,*_onclk      /  call   routine
  159.     tst     (sp)+
  160.     mov     (sp)+,r5        /   restore
  161.     mov     (sp)+,r4        /   regs
  162.     mov     (sp)+,r3
  163.     mov     (sp)+,r2
  164.     mov     (sp)+,r1
  165.     mov     (sp)+,r0
  166.     clr     inserf
  167.     clr     code
  168. clkrti: rti
  169.  
  170.  
  171.  
  172. _wait:                          / wait for bus interrupt and return
  173.     wait
  174.     rts   pc
  175.  
  176. panic1: mov     $1,code
  177.     br      1f
  178. panic2: mov     $2,code
  179.     br      1f
  180. panic3: mov     $3,code
  181.     br      1f
  182. panic4: mov     $4,code
  183.     br      1f
  184. panic5: mov     $5,code
  185.     br      1f
  186. panic6: mov     $6,code
  187.     br      1f
  188. panic7: mov     $7,code
  189.     br      1f
  190. panic8: mov     $8,code
  191.  
  192. 1:      0106427                 /mtps
  193.     0            /low priority
  194.     mov     r0,-(sp)        / save
  195.     mov     r1,-(sp)        /   regs
  196.     mov     r2,-(sp)
  197.     mov     r3,-(sp)
  198.     mov     r4,-(sp)
  199.     mov     r5,-(sp)
  200.     mov     code,-(sp)
  201.     jsr     pc,_zexit
  202.     tst     (sp)+
  203.     mov     (sp)+,r5        /   restore
  204.     mov     (sp)+,r4        /   regs
  205.     mov     (sp)+,r3
  206.     mov     (sp)+,r2
  207.     mov     (sp)+,r1
  208.     mov     (sp)+,r0
  209.     clr     code
  210.     rti
  211.  
  212. retu:   rts     pc
  213.  
  214. .bss
  215. savr5:    .=.+2
  216. .data
  217.     .=.+2        / loc 0 for I/D; null ptr points here.
  218. sname:  <dummy\0>
  219. inserf: 0               / int routine in service
  220. tcount: 0               / tick count
  221. code  : 0
  222. _tick : 0               / global tick number
  223. _onclk: retu            / address of clock interupt routine
  224. _asleep: 1
  225.