home *** CD-ROM | disk | FTP | other *** search
- ; **************
- ; * INTMGR.asm *
- ; *******************************************
- ; * Copyright TimeSlice, Inc. 1985, 86, 87. *
- ; *******************************************
- ;
- ;
- include ts.inc
- ;
- start_data ;to define DGROUP properly
- end_data
- ;
- start_code
- ;
- ;***
- ;* INTMGR is called automatically when an interrupt has a function attached
- ;* to it thru INTATT(). It saves all registers, then call the attached
- ;* function with two arguments :
- ;* 1> a ptr to the intlst
- ;* 2> a ptr to the intstate
- ;* and returns to an IRET or a JUMP to the original interrupt vector.
- ;***
- public intmgr
- routine intmgr
- pusha ;save all registers
- cli ;to compensate for the lack of cli in int86
- imgr0: mov ax,DGROUP ;load ds and es with dgroup
- mov ds,ax
- inc _sslev ;disable slicer (simulate ssleep)
- ;
- ; set di to INTLST structure
- ;
- mov bp,sp ;[bp] <-- return address of intmgr
- mov di,[bp].isimrip ;es:[di] <-- intlist->dummy2
- mov ax,[bp].isimrcs
- mov es,ax
- sub di,dummy2 - next ;[di] <-- intlist
- ;
- ; set stack for func
- ;
- mov bx,ss ;bx <-- interrupted code's ss
- mov dx,sp ;dx <-- interrupted code's sp
- ;
- ; update _istop and ss and sp
- ;
- ifdef stkset
- mov si,_istop.off ;SI <-- offset ptr to top of istack
- mov sp,es:[di].stksiz ;load sp with size of stack (cannonized ptr to top of stack)
- sub si,sp ;compute offset of new istop
- mov _istop.off,si ;update _istop
- mov cl,4 ;translate offset of new istop in segment
- shr si,cl
- mov ax,ds
- add ax,si
- mov ss,ax ;SS:SP now contains pointer to cannonized stack
- else
- mov si,_istop.off ;SI <-- offset ptr to top of istack
- mov ax,ds ;static data is also stack seg.
- mov ss,ax
- mov sp,si
- sub si,es:[di].stksiz ;compute new _istop below stack for func
- mov _istop.off,si ;update _istop
- push stk_base ;save current _base
- mov stk_base,si ;set it to bottom of ISR stack
- endif
- push bx ;pass segment of interupted CPU Registers
- push dx ;pass offset of interupted CPU Registers
- ;
- ; push intlst address as argument and call function
- ;
- if ldata
- push es
- endif
- push di ;pass it to func
- fncall es:[di].func ;execute function attached to interrupt
- pop di ;pop func's argument
- cli ;make sure to hold int while changing sp,bp
- dec _sslev ;decrement level of slicer sleep (simulate swake)
- ;
- ; restore interrupt service stack
- ;
- if ldata
- pop es
- else
- mov ax,dgroup
- mov es,ax
- endif
- pop dx ;dx <-- interrupted code's sp
- pop cx ;cx <-- interrupted code's ss
- ifndef stkset
- pop stk_base ;restore _base
- endif
- mov ss,cx ;restore interrupted code's ss & sp
- mov sp,dx
- mov ax,es:[di].stksiz ;ES:DI -> INTLST
- add _istop.off,ax
- ;
- ; restore flags (CLIed)
- ;
- mov bp,sp
- mov ax,[bp+1CH]
- and ax,0FDFFH
- push ax
- popf
- ;
- ; retore interupted code's stack
- ;
- popa ;restore all registers
- return intmgr
- ;
- end_code
-