home *** CD-ROM | disk | FTP | other *** search
- ;---------------------------- PORT & IO FUNCTIONS --------------------------
- ;
- ; Functions for creating and deleting MsgPort's and IORequest's.
-
- far
-
- include 'exec/types.i'
- include 'exec/memory.i'
- include 'exec/ports.i'
- include 'exec/lists.i'
- include 'exec/io.i'
-
- include 'macros.i'
-
- xdef CreatePort
- xdef CreateExtPort
- xdef DeletePort
- xdef CreateStdIO
- xdef CreateExtIO
- xdef DeleteIO
-
-
- CreatePort: ; ( Name:a0, Pri:d0 )
- move.l #MP_SIZE,d1
-
- CreateExtPort: ; ( Name:a0, Pri:d0, Size:d1 )
- movem.l d2-d5/a2/a6,-(sp)
- move.l a0,d3
- move.b d0,d4
- move.l d1,d5
-
- moveq #-1,d0
- exec AllocSignal
- cmpi.b #-1,d0
- beq CreatePort_Err
- move.b d0,d2
-
- move.l d5,d0
- move.l #MEMF_PUBLIC!MEMF_CLEAR,d1
- exec AllocMem
- tst.l d0
- beq CreatePort_Err
- move.l d0,a2
-
- move.l d3,LN_NAME(a2)
- move.b d4,LN_PRI(a2)
- move.b #NT_MSGPORT,LN_TYPE(a2)
- move.b #PA_SIGNAL,MP_FLAGS(a2)
- move.b d2,MP_SIGBIT(a2)
- sub.l a1,a1
- exec FindTask
- move.l d0,MP_SIGTASK(a2)
-
- tst.l d3
- beq CreatePortNoName
- move.l a2,a1
- exec AddPort
- move.l a2,d0
- bra CreatePort_End
-
- CreatePortNoName:
- lea MP_MSGLIST(a2),a1
- NEWLIST a1
- move.l a2,d0
-
- CreatePort_End:
- tst.l d0
- movem.l (sp)+,d2-d5/a2/a6
- rts
-
- CreatePort_Err:
- moveq #0,d0
- bra CreatePort_End
-
-
- ; DeletePort() - delete a port created with either CreatePort() OR
- ; CreateExtPort() above.
- ;
- ; DeletePort (port)
- ; a1
- ;
-
- xdef DeletePort
- DeletePort
- push a2/a6
-
- move.l a1,a2
- tst.l LN_NAME(a2)
- beq 1$
- exec RemPort
-
- 1$ move.b MP_SIGBIT(a2),d0
- exec FreeSignal
-
- move.l a2,a1
- move.l #MP_SIZE,d0
- exec FreeMem
-
- pop a2/a6
- rts
-
-
- CreateStdIO: ; ( ReplyPort:a0 )
- moveq #IOSTD_SIZE,d0
-
- CreateExtIO: ; ( ReplyPort:a0, Size:d0 )
- movem.l d2-d3,-(sp)
- move.l a0,d3
- beq CreateExtIO_Err
- move.l d0,d2
-
- move.l #MEMF_PUBLIC!MEMF_CLEAR,d1
- exec AllocMem
- tst.l d0
- beq CreateExtIO_End
- move.l d0,a1
-
- move.b #NT_MESSAGE,LN_TYPE(a1)
- move.w d2,MN_LENGTH(a1)
- move.l d3,MN_REPLYPORT(a1)
-
- CreateExtIO_End:
- tst.l d0
- movem.l (sp)+,d2-d3
- rts
-
- CreateExtIO_Err:
- moveq #0,d0
- bra CreateExtIO_End
-
-
-
- ; DeleteIO() - delete either a standard IO request block or an extended
- ; IO request block allocated with CreateStdIO() or
- ; CreateExtIO() above.
- ;
- ; DeleteIO (req)
- ; a1
- ;
-
- xdef DeleteIO
- DeleteIO
- moveq #0,d0
- move.w MN_LENGTH(a1),d0
- exec FreeMem
- rts
-
-
- END
-
-