BOOL IPC_PutMsg( struct MsgPort *destino, IPCACT_T action, APTR udata ) { struct MsgPort *replyport = NULL; BOOL error = TRUE; ENTER(); DBG_POINTER(destino); if(destino && (replyport = CreateMsgPort())) { struct IPCMsg ipcmsg; APTR xMsg; ipcmsg.ipc_msg.mn_ReplyPort = replyport; ipcmsg.ipc_msg.mn_Length = sizeof(struct IPCMsg); ipcmsg.ipc_ID = IPC_MAGIC; ipcmsg.ipc_action = action; ipcmsg.ipc_result = IPCR_ABORTED; ipcmsg.ipc_data = udata; DBG("Sending action '%ld' from %lx to %lx\n", action, replyport, destino); Forbid(); PutMsg( destino, &ipcmsg.ipc_msg); WaitPort(replyport); while((xMsg = GetMsg( replyport ))) { DBG("Got reply...\n"); switch(((struct IPCMsg *)xMsg)->ipc_result) { // TODO case IPCR_ABORTED: DBG("IPCR_ABORTED\n"); break; case IPCR_FAIL: DBG("IPCR_FAIL\n"); break; case IPCR_OK: DBG("IPCR_OK\n"); break; default: break; } } Permit(); DeleteMsgPort(replyport); error = FALSE; } LEAVE(); return !error; }
void cleanup(LONG rc) { if(!AHIDevice) CloseDevice((struct IORequest *)AHIio); DeleteIORequest((struct IORequest *)AHIio); FreeMem(AHIiocopy,sizeof(struct AHIRequest)); DeleteMsgPort(AHImp); exit(rc); }
void sdcard_CloseTimer(struct IORequest *tmr) { if (NULL != tmr) { struct MsgPort *p = tmr->io_Message.mn_ReplyPort; CloseDevice(tmr); DeleteIORequest(tmr); DeleteMsgPort(p); } }
void __cleanupselect(void) { if (_treq) { DeleteIORequest(_treq); _treq=NULL; } if (_tport) { DeleteMsgPort(_tport); _tport=NULL; } }
void Sys_Thread_DeleteThread(struct SysThread *thread) { SetTaskPri(&thread->process->pr_Task, 0); while(!GetMsg(thread->msgport)) WaitPort(thread->msgport); DeleteMsgPort(thread->msgport); FreeVec(thread); }
void closeBlockDevice(struct AFSBase *afsbase, struct IOHandle *ioh) { remChangeInt(afsbase, ioh); if (ioh->iochangeint != NULL) closeDevice(afsbase, ioh->iochangeint); if (ioh->ioreq != NULL) closeDevice(afsbase, ioh->ioreq); if (ioh->mp != NULL) DeleteMsgPort(ioh->mp); }
void SAVEDS handler(void) { struct Process *me = (struct Process *)FindTask(NULL); struct startMsg *smsg; struct MsgPort *port; BOOL res = FALSE; ENTER(); WaitPort(&me->pr_MsgPort); smsg = (struct startMsg *)GetMsg(&me->pr_MsgPort); #if defined(__amigaos4__) port = AllocSysObject(ASOT_PORT, TAG_DONE); #else port = CreateMsgPort(); #endif if(port != NULL) res = localSendRexxMsg(port, smsg->port, smsg->cmd); smsg->res = res; ReplyMsg((struct Message *)smsg); if(res == TRUE) { struct RexxMsg *rxmsg; WaitPort(port); rxmsg = (struct RexxMsg *)GetMsg(port); DeleteArgstring((APTR)rxmsg->rm_Args[0]); DeleteRexxMsg(rxmsg); } if(port != NULL) { #if defined(__amigaos4__) FreeSysObject(ASOT_PORT, port); #else DeleteMsgPort(port); #endif } ObtainSemaphore(&OpenURLBase->libSem); OpenURLBase->rexx_use--; ReleaseSemaphore(&OpenURLBase->libSem); #if !defined(__amigaos4__) // all systems except OS4 should leave this function in forbidden state Forbid(); #endif LEAVE(); }
void cleanup(int kod,char *text) { shutdownnode(NODSER); CloseIO(); if(NiKwind) CloseWindow(NiKwind); if(RexxSysBase) CloseLibrary((struct Library *)RexxSysBase); if(nikomnodeport) { RemPort(nikomnodeport); DeleteMsgPort(nikomnodeport); } if(rexxport) { RemPort(rexxport); DeleteMsgPort(rexxport); } if(NiKomBase) CloseLibrary(NiKomBase); if(UtilityBase) CloseLibrary(UtilityBase); if(IntuitionBase) CloseLibrary((struct Library *)IntuitionBase); printf("%s",text); exit(kod); }
static void ai_exit(void) { if (CTX != NULL) { AIN_DeleteContext(CTX); CTX = NULL; } if (ai_port != NULL) { DeleteMsgPort(ai_port); ai_port = NULL; } }
// Send an ARexx command long __asm __saveds HookRexxCommand( register __a0 char *command, register __a1 char *result, register __d0 long length, register __a2 struct MsgPort *replyport, register __d1 ULONG flags) { struct MsgPort *rexx,*reply; struct RexxMsg *msg; long rc=-1; // Clear result if (result) *result=0; // Get rexx port if (!GUI->rexx_proc || !(rexx=(struct MsgPort *)IPCDATA(GUI->rexx_proc))) return -1; // Create reply port if needed if ((reply=replyport) || (reply=CreateMsgPort())) { // Create message if (msg=BuildRexxMsgExTags( reply, ".dopus5", rexx->mp_Node.ln_Name, RexxTag_Arg0,command, TAG_END)) { // Initialise message msg->rm_Action|=1|RXCOMM; if (result) msg->rm_Action|=RXFF_RESULT; // Send the message and wait for reply PutMsg(rexx,(struct Message *)msg); WaitPort(reply); GetMsg(reply); // String reply? if (msg->rm_Result2 && result) stccpy(result,(char *)msg->rm_Result2,length); rc=msg->rm_Result1; // Free message FreeRexxMsgEx(msg); } // Free message port if (reply!=replyport) DeleteMsgPort(reply); } return rc; }
void FreeRocket(struct NepClassRocket *nch) { APTR pab; psdGetAttrs(PGA_DEVICE, nch->nch_Device, DA_Binding, &pab, TAG_END); psdReleaseAppBinding(pab); psdFreePipe(nch->nch_EP0Pipe); DeleteMsgPort(nch->nch_TaskMsgPort); psdFreeVec(nch); }
cdrom_interface::~cdrom_interface(void) { if (cd_error == 0) { CloseDevice((struct IORequest *)CDIO); } if (CDIO != NULL) { DeleteIORequest((struct IORequest *)CDIO); } if (CDMP != NULL) { DeleteMsgPort(CDMP); } }
void CleanupTimer(void) { D(bug("[fat] Cleaning up timer\n")); if (glob->timer_active) { D(bug("[fat] Terminating active request\n")); AbortIO((struct IORequest *)glob->timereq); WaitIO((struct IORequest *)glob->timereq); } CloseDevice((struct IORequest *)glob->timereq); DeleteIORequest((struct IORequest *)glob->timereq); DeleteMsgPort(glob->timerport); }
void arexx_cleanup(void) { if (arexx_port) { RemPort(arexx_port); DeleteMsgPort(arexx_port); } while (arexx_execute_out) { struct RexxMsg *rxmsg; WaitPort(arexx_execute_port); while ((rxmsg = (struct RexxMsg *)GetMsg(arexx_execute_port))) { arexx_execute_out--; ClearRexxMsg(rxmsg,1); DeleteRexxMsg(rxmsg); } } if (arexx_execute_port) DeleteMsgPort(arexx_execute_port); }
void cleanup( int rc ) { if( AHIDevice == 0 ) { CloseDevice( (struct IORequest *) AHIio ); } DeleteIORequest( (struct IORequest *) AHIio); DeleteMsgPort( AHImp ); exit( rc ); }
void CleanUp(void) { if(!AHIDevice) CloseDevice((struct IORequest *)AHIio); DeleteIORequest((struct IORequest *)AHIio); DeleteMsgPort(AHImp); AHIBase = NULL; AHImp = NULL; AHIio = NULL; AHIDevice = -1; CloseahiprefsCatalog(); CloseLibrary(LocaleBase); LocaleBase = NULL; }
void cleanup(int kod,char *fel) { shutdownnode(NODCON); freealiasmem(); freeeditlist(); CloseIO(); if(NiKwind) CloseWindow(NiKwind); if(RexxSysBase) CloseLibrary((struct Library *)RexxSysBase); if(nikomnodeport) { RemPort(nikomnodeport); DeleteMsgPort(nikomnodeport); } if(rexxport) { RemPort(rexxport); DeleteMsgPort(rexxport); } if(NiKomBase) CloseLibrary(NiKomBase); if(UtilityBase) CloseLibrary(UtilityBase); if(IntuitionBase) CloseLibrary((struct Library *)IntuitionBase); printf("%s",fel); exit(kod); }
int uae_start_thread (const TCHAR *name, void *(*f)(void *), void *arg, uae_thread_id *tid) { struct MsgPort *replyport; struct Process *newtask = NULL; struct TagItem procTags[] = { { NP_Name, (IPTR) NULL}, { NP_StackSize, (IPTR)(64 * 1024)}, { NP_Entry, (IPTR) do_thread}, //{ NP_Output, Output ()}, //{ NP_Input, Input ()}, //{ NP_CloseOutput, FALSE}, //{ NP_CloseInput, FALSE}, { TAG_DONE, 0} }; #warning Do we need to care for priorities here? WinUAE does.. if(!name) procTags[0].ti_Data = (IPTR)default_name; else procTags[0].ti_Data = (IPTR)name; bug("[JUAE:PX] %s('%s', f %lx, arg %lx, tid %lx)\n", __PRETTY_FUNCTION__, procTags[0].ti_Data, f, arg, tid); replyport = CreateMsgPort(); if(!replyport) { write_log("ERROR: Unable to create MsgPort!\n"); } newtask = CreateNewProc (procTags); bug("[JUAE:PX] %s: Process @ %p, MsgPort @ %p\n", __PRETTY_FUNCTION__, newtask, newtask->pr_MsgPort); if(newtask) { struct startupmsg msg; msg.msg.mn_ReplyPort = replyport; msg.msg.mn_Length = sizeof msg; msg.func = f; msg.arg = arg; PutMsg (&newtask->pr_MsgPort, (struct Message*)&msg); WaitPort (replyport); } DeleteMsgPort (replyport); if(tid) { *tid=newtask; } return (newtask != 0); }
void cleanup( void ) { if( AHIDevice == 0 ) { CloseDevice( (struct IORequest *) AHIio ); } DeleteIORequest( (struct IORequest *) AHIio); DeleteMsgPort( AHImp ); CloseLibrary( (struct Library*) IntuitionBase ); CloseLibrary( (struct Library*) GfxBase ); }
void cleanup(int kod,char *text) { CloseCatalog(g_Catalog); freealiasmem(); freeeditlist(); CloseIO(); if(NiKwind) CloseWindow(NiKwind); if(RexxSysBase) CloseLibrary((struct Library *)RexxSysBase); if(nikomnodeport) { RemPort(nikomnodeport); DeleteMsgPort(nikomnodeport); } if(rexxport) { RemPort(rexxport); DeleteMsgPort(rexxport); } shutdownnode(NODSPAWNED); if(NiKomBase) CloseLibrary(NiKomBase); if(UtilityBase) CloseLibrary(UtilityBase); if(LocaleBase) CloseLibrary(LocaleBase); if(IntuitionBase) CloseLibrary((struct Library *)IntuitionBase); printf("%s",text); exit(kod); }
int main( int argc, char* argv[] ) { int rc = RETURN_OK; if( argc != 1 ) { fprintf( stderr, "Usage: %s\n", argv[ 0 ] ); rc = RETURN_ERROR; } else { struct MsgPort* mp = CreateMsgPort(); if( mp != NULL ) { struct AHIRequest* io = (struct AHIRequest *) CreateIORequest( mp, sizeof( struct AHIRequest ) ); if( io != NULL ) { // We use 32 bit samples, so we need version 6. io->ahir_Version = 6; if( OpenDevice( AHINAME, AHI_NO_UNIT, (struct IORequest *) io, 0 ) == 0 ) { AHIBase = (struct Library *) io->ahir_Std.io_Device; rc = PlaySineEverywhere(); CloseDevice( (struct IORequest *) io ); } else { fprintf( stderr, "Unable to open '" AHINAME "' version 6.\n" ); rc = RETURN_FAIL; } DeleteIORequest( (struct IORequest *) io ); } else { fprintf( stderr, "Unable to create IO request.\n" ); rc = RETURN_FAIL; } DeleteMsgPort( mp ); } else { fprintf( stderr, "Unable to create message port.\n" ); rc = RETURN_FAIL; } } return rc; }
/* virtual */ void Join() { struct OTTDThreadStartupMessage *reply; /* You cannot join yourself */ assert(!IsCurrent()); KPutStr("[OpenTTD] Join threads...\n"); KPutStr("[OpenTTD] Wait for child to quit...\n"); WaitPort(m_replyport); GetMsg(m_replyport); DeleteMsgPort(m_replyport); m_thr = 0; }
void ether_exit(void) { // Stop process if (net_proc) { SetSignal(0, SIGF_SINGLE); Signal(&net_proc->pr_Task, SIGBREAKF_CTRL_C); Wait(SIGF_SINGLE); } // Delete reply port if (reply_port) { DeleteMsgPort(reply_port); reply_port = NULL; } }
struct NepClassUPS * AllocUPS(struct NepClassUPS *nch) { nch->nch_Task = FindTask(NULL); if((nch->nch_TaskMsgPort = CreateMsgPort())) { if((nch->nch_EP0Pipe = psdAllocPipe(nch->nch_Device, nch->nch_TaskMsgPort, NULL))) { return(nch); } else { PutStr("Couldn't allocate default pipe\n"); } DeleteMsgPort(nch->nch_TaskMsgPort); } return(NULL); }
static void cleanup(char *msg, ULONG retcode) { if (msg && !args[ARG_QUIET]) { fprintf(stderr, "CopyToPAR: %s\n", msg); } if (fh) Close(fh); if (myargs) FreeArgs(myargs); if (ParOpen) CloseDevice((struct IORequest *)ParIO); if (ParIO) DeleteIORequest((struct IORequest *)ParIO); if (ParMP) DeleteMsgPort(ParMP); exit(retcode); }
int16 ASERDPort::close() { // Stop process if (serial_proc) { SetSignal(0, SIGF_SINGLE); Signal(&serial_proc->pr_Task, SIGBREAKF_CTRL_C); Wait(SIGF_SINGLE); } // Delete reply port if (reply_port) { DeleteMsgPort(reply_port); reply_port = NULL; } return noErr; }
int main(int argc, char* argv[]) { int rc = RETURN_OK; if (argc != 4) { fprintf(stderr, "Usage: %s <audio mode id> <mix_freq> <player_freq>\n", argv[0]); rc = RETURN_ERROR; } else { struct MsgPort* mp = CreateMsgPort(); if (mp != NULL) { struct AHIRequest* io = (struct AHIRequest *) CreateIORequest(mp, sizeof(struct AHIRequest)); if (io != NULL) { io->ahir_Version = 4; if (OpenDevice(AHINAME, AHI_NO_UNIT, (struct IORequest *) io, 0) == 0) { AHIBase = (struct Library *) io->ahir_Std.io_Device; rc = MaxPlaySamples(atol(argv[1]), atol(argv[2]), atol(argv[3])); CloseDevice((struct IORequest *) io); } else { fprintf(stderr, "Unable to open '" AHINAME "' version 4.\n"); rc = RETURN_FAIL; } DeleteIORequest((struct IORequest *) io); } else { fprintf(stderr, "Unable to create IO request.\n"); rc = RETURN_FAIL; } DeleteMsgPort(mp); } else { fprintf(stderr, "Unable to create message port.\n"); rc = RETURN_FAIL; } } return rc; }
int16 ASERDPort::open(uint16 config) { // Don't open NULL name devices if (device_name == NULL) return openErr; // Init variables err_mask = 0; // Create message port reply_port = CreateMsgPort(); if (reply_port == NULL) goto open_error; // Start process proc_error = false; proc_arg = this; SetSignal(0, SIGF_SINGLE); serial_proc = CreateNewProcTags( NP_Entry, (ULONG)serial_func, NP_Name, (ULONG)"Basilisk II Serial Task", NP_Priority, 1, TAG_END ); if (serial_proc == NULL) goto open_error; // Wait for signal from process Wait(SIGF_SINGLE); // Initialization error? Then bail out if (proc_error) goto open_error; // Configure port configure(config); return noErr; open_error: serial_proc = NULL; if (reply_port) { DeleteMsgPort(reply_port); reply_port = NULL; } return openErr; }
bool ether_init(void) { // Do nothing if no Ethernet device specified if (PrefsFindString("ether") == NULL) return false; // Initialize protocol list NewList(&prot_list); // Create message port reply_port = CreateMsgPort(); if (reply_port == NULL) goto open_error; D(bug("signal mask %08lx\n", 1 << reply_port->mp_SigBit)); // Start process proc_error = false; SetSignal(0, SIGF_SINGLE); net_proc = CreateNewProcTags( NP_Entry, (ULONG)net_func, NP_Name, (ULONG)"Basilisk II Ethernet Task", NP_Priority, 1, TAG_END ); if (net_proc == NULL) goto open_error; // Wait for signal from process Wait(SIGF_SINGLE); // Initialization error? Then bail out if (proc_error) goto open_error; // Everything OK return true; open_error: net_proc = NULL; if (reply_port) { DeleteMsgPort(reply_port); reply_port = NULL; } return false; }
void AtaTaskFini (void) { if (ata_isr14_enabled == TRUE) { ISRHandlerRemove (ata_isr14_handler); FreeSignal (ata_isr14_signal); } if (ata_isr15_enabled == TRUE) { ISRHandlerRemove (ata_isr15_handler); FreeSignal (ata_isr15_signal); } DeleteMsgPort (ata_msgport); FreeSignal (ata_alarm_signal); Exit (0); }