long __saveds __regargs nik_sflush(void) { long ret; serchangereq->IOSer.io_Command=CMD_CLEAR; DoIO((struct IORequest *)serchangereq); serchangereq->IOSer.io_Command=CMD_FLUSH; ret=(long)DoIO((struct IORequest *)serchangereq); return(ret); }
main() { ulong i; Enable_Abort = 0; td_mp = CreatePort(0L,0L); if(!td_mp) exit(99); td_iob = CreateStdIO(td_mp); if(!td_iob) { DeletePort(td_mp); exit(99); } if(OpenDevice("trackdisk.device",0L,td_iob,0L)) { printf("Unable to open floppy device driver.\n"); DeleteStdIO(td_iob); DeletePort(td_mp); exit(99); } diskbuf = AllocMem(TD_BUFSIZE,MEMF_PUBLIC|MEMF_CHIP); if(!diskbuf) { printf("Unable to obtain %ld byte buffer in chip memory.\n",TD_BUFSIZE); CloseDevice(td_iob); DeleteStdIO(td_iob); DeletePort(td_mp); exit(99); } for(i=0;i<80;i+=NUMTRKS) { printf("Reading tracks %ld to %ld.\n",i,i+NUMTRKS-1); td_iob->io_Command = CMD_READ; td_iob->io_Data = (APTR) diskbuf; td_iob->io_Length = TD_BUFSIZE; td_iob->io_Offset = 11L * 1024L * i; DoIO(td_iob); if(td_iob->io_Error) { printf("Floppy read failed, error number %d.\n",td_iob->io_Error); break; } } td_iob->io_Command = TD_MOTOR; td_iob->io_Length = 0; DoIO(td_iob); FreeMem(diskbuf,TD_BUFSIZE); CloseDevice(td_iob); DeleteStdIO(td_iob); DeletePort(td_mp); }
int main (int argc, char **argv) { struct timerequest *timereq = 0; struct MsgPort *timeport; int result = calltrap (0, 0); if (result == 1) fprintf (stderr, "timehack already running.\n"); else if (result == 2) fprintf (stderr, "timehack not supported with this version of UAE.\n"); if (result != 0) exit (5); timeport = CreatePort (0, 0); if (timeport) timereq = CreateStdIO(timeport); if (timereq == 0) goto fail; if (OpenDevice ("timer.device", UNIT_VBLANK, timereq, 0) != 0) goto fail; SetTaskPri (FindTask (NULL), 20); /* same as input.device */ for (;;) { struct timeval cur_sys_time; timereq->tr_node.io_Command = TR_GETSYSTIME; DoIO(timereq); cur_sys_time = timereq->tr_time; calltrap (1, &timereq->tr_time); if (timereq->tr_time.tv_secs > cur_sys_time.tv_secs || (timereq->tr_time.tv_secs == cur_sys_time.tv_secs && timereq->tr_time.tv_micro > cur_sys_time.tv_micro)) { timereq->tr_node.io_Command = TR_SETSYSTIME; DoIO(timereq); } timereq->tr_time.tv_secs = 1; timereq->tr_time.tv_micro = 0; timereq->tr_node.io_Command = TR_ADDREQUEST; DoIO(timereq); } fail: fprintf (stderr, "Couldn't start timehack (that's bad!)\n"); exit (5); }
static ULONG readwriteDisk ( struct AFSBase *afsbase, struct Volume *volume, ULONG start, ULONG count, APTR mem, ULONG cmd ) { LONG retval; struct IOHandle *ioh = &volume->ioh; UQUAD offset; if (start + count <= volume->countblocks) { ioh->ioreq->iotd_Req.io_Command = cmd; ioh->ioreq->iotd_Req.io_Length = count*BLOCK_SIZE(volume); ioh->ioreq->iotd_Req.io_Data = mem; offset = (UQUAD)volume->startblock * volume->sectorsize + (UQUAD)start * BLOCK_SIZE(volume); ioh->ioreq->iotd_Req.io_Offset = 0xFFFFFFFF & offset; ioh->ioreq->iotd_Req.io_Actual = offset>>32; retval = DoIO((struct IORequest *)&ioh->ioreq->iotd_Req); ioh->flags |= IOHF_MOTOR_OFF; }
void dotimer(ULONG unit,ULONG timercmd,struct timeval *t) { struct PortIO { struct timerequest treq; struct MsgPort port; } *portio; if ((portio = lib_AllocMem(sizeof(*portio), MEMF_CLEAR | MEMF_PUBLIC))) { portio->port.mp_Node.ln_Type = NT_MSGPORT; if ((BYTE)(portio->port.mp_SigBit = AllocSignal(-1)) >= 0) { portio->port.mp_SigTask = FindTask(NULL); NEWLIST(&portio->port.mp_MsgList); portio->treq.tr_node.io_Message.mn_Node.ln_Type = NT_REPLYMSG; portio->treq.tr_node.io_Message.mn_ReplyPort = &portio->port; if (!(OpenDevice(TIMERNAME, unit, &portio->treq.tr_node, 0))) { portio->treq.tr_node.io_Command = timercmd; portio->treq.tr_time.tv_secs = t->tv_secs; portio->treq.tr_time.tv_micro = t->tv_micro; if (!DoIO(&portio->treq.tr_node)) { t->tv_secs = portio->treq.tr_time.tv_secs; t->tv_micro = portio->treq.tr_time.tv_micro; } CloseDevice(&portio->treq.tr_node); } FreeSignal(portio->port.mp_SigBit); } lib_FreeMem(portio,sizeof(struct PortIO)); } }
void MH2Int_MakeMenusInactive(struct Window *win, UWORD menupick, struct IntuitionBase *IntuitionBase) { struct InputEvent ie; struct IOStdReq ior; struct MsgPort replyport; memset( &replyport, 0, sizeof( replyport ) ); ie.ie_NextEvent = 0; ie.ie_Class = IECLASS_MENU; ie.ie_SubClass = IESUBCLASS_MENUSTOP; ie.ie_Code = menupick; ie.ie_EventAddress = win; replyport.mp_Node.ln_Type = NT_MSGPORT; replyport.mp_Flags = PA_SIGNAL; replyport.mp_SigBit = SIGB_INTUITION; replyport.mp_SigTask = FindTask(NULL); NEWLIST(&replyport.mp_MsgList); ior = *(GetPrivIBase(IntuitionBase)->InputIO); ior.io_Message.mn_ReplyPort = &replyport; ior.io_Command = IND_WRITEEVENT; ior.io_Data = &ie; ior.io_Length = sizeof(struct InputEvent); DoIO((struct IORequest *)&ior); }
void SendEvent(LONG event) { struct IOStdReq *InputRequest; struct MsgPort *InputPort; struct InputEvent *ie; if ((InputPort = (struct MsgPort*)CreateMsgPort())) { if ((InputRequest = (struct IOStdReq*)CreateIORequest(InputPort, sizeof(struct IOStdReq)))) { if (!OpenDevice("input.device", 0, (struct IORequest*)InputRequest, 0)) { if ((ie = AllocVec(sizeof(struct InputEvent), MEMF_PUBLIC | MEMF_CLEAR))) { ie->ie_Class = event; InputRequest->io_Command = IND_WRITEEVENT; InputRequest->io_Data = ie; InputRequest->io_Length = sizeof(struct InputEvent); DoIO((struct IORequest*)InputRequest); FreeVec(ie); } CloseDevice((struct IORequest*)InputRequest); } DeleteIORequest((struct IORequest *)InputRequest); } DeleteMsgPort (InputPort); } }
int DoSCSI(UBYTE *data, int datasize, Bit8u *cmd,int cmdsize, UBYTE direction) { struct SCSICmd scmd; CDIO->iotd_Req.io_Command = HD_SCSICMD; CDIO->iotd_Req.io_Data = &scmd; CDIO->iotd_Req.io_Length = sizeof(scmd); scmd.scsi_Data = (UWORD *)data; scmd.scsi_Length = datasize; scmd.scsi_SenseActual = 0; scmd.scsi_SenseData = sensebuf; scmd.scsi_SenseLength = SENSELEN; scmd.scsi_Command = cmd; scmd.scsi_CmdLength = cmdsize; scmd.scsi_Flags = SCSIF_AUTOSENSE | direction; DoIO((struct IORequest *)CDIO); if (CDIO->iotd_Req.io_Error != 0) { BX_PANIC(("DoSCSI: error %d", CDIO->iotd_Req.io_Error)); } return CDIO->iotd_Req.io_Error; }
bx_bool cdrom_interface::insert_cdrom(char *dev) { Bit8u cdb[6]; Bit8u buf[2*BX_CD_FRAMESIZE]; Bit8u i = 0; memset(cdb,0,sizeof(cdb)); cdb[0] = SCSI_DA_START_STOP_UNIT; cdb[4] = 1 | 2; DoSCSI(0, 0,cdb,sizeof(cdb),SCSIF_READ); /*Check if there's a valid media present in the drive*/ CDIO->iotd_Req.io_Data = buf; CDIO->iotd_Req.io_Command = CMD_READ; CDIO->iotd_Req.io_Length = BX_CD_FRAMESIZE; CDIO->iotd_Req.io_Offset = BX_CD_FRAMESIZE; for(i = 0; i < 200; i++) /*it takes a while for the cdrom to validate*/ { DoIO((struct IORequest *)CDIO); if (CDIO->iotd_Req.io_Error == 0) break; Delay (10); } if (CDIO->iotd_Req.io_Error != 0) return false; else return true; }
void _glfwPlatformSetMouseCursorPos( int x, int y ) { struct IEPointerPixel ppxl; struct InputEvent event; // Adjust coordinates to window client area upper left corner x += _glfwWin.Window->LeftEdge; y += _glfwWin.Window->TopEdge; /* Set up IEPointerPixel fields */ ppxl.iepp_Screen = _glfwWin.Screen; ppxl.iepp_Position.X = x; ppxl.iepp_Position.Y = y; /* Set up InputEvent fields */ event.ie_EventAddress = (APTR)&ppxl; /* IEPointerPixel */ event.ie_NextEvent = NULL; event.ie_Class = IECLASS_NEWPOINTERPOS; /* new mouse pos */ event.ie_SubClass = IESUBCLASS_PIXEL; /* on pixel */ event.ie_Code = IECODE_NOBUTTON; event.ie_Qualifier = 0; /* absolute pos */ /* Set up I/O request */ _glfwWin.InputIO->io_Data = (APTR)&event; _glfwWin.InputIO->io_Length = sizeof(struct InputEvent); _glfwWin.InputIO->io_Command = IND_WRITEEVENT; /* Perform I/O (move mouse cursor) */ DoIO( (struct IORequest *)_glfwWin.InputIO ); }
static void write_sid(unsigned char reg, unsigned char data, int chipno) { unsigned char tData[2]; if (gSIDs == 0) { return; } if (gSwapSIDs) { chipno = 1 - chipno; } if (gCatweaselReq[chipno] == NULL) { return; } tData[0] = reg; tData[1] = data; gCatweaselReq[chipno]->iotd_Req.io_Length = 2; gCatweaselReq[chipno]->iotd_Req.io_Command = CMD_WRITE; gCatweaselReq[chipno]->iotd_Req.io_Data = tData; gCatweaselReq[chipno]->iotd_Req.io_Offset = 0; DoIO((struct IORequest *)gCatweaselReq[chipno]); }
static unsigned char read_sid(unsigned char reg, int chipno) { unsigned char tData[2]; if (gSIDs == 0) { return 0; } if (gSwapSIDs) { chipno = 1 - chipno; } if (gCatweaselReq[chipno] == NULL) { return 0; } tData[0] = reg; gCatweaselReq[chipno]->iotd_Req.io_Length = 2; gCatweaselReq[chipno]->iotd_Req.io_Command = CMD_READ; gCatweaselReq[chipno]->iotd_Req.io_Data = tData; gCatweaselReq[chipno]->iotd_Req.io_Offset = 0; DoIO((struct IORequest *)gCatweaselReq[chipno]); return ((unsigned char*)(gCatweaselReq[chipno]->iotd_Req.io_Data))[1]; }
void eka(char tecken) { conwritereq->io_Command=CMD_WRITE; conwritereq->io_Data=(APTR)&tecken; conwritereq->io_Length=1; DoIO((struct IORequest *)conwritereq); if(tecken == '\n') incantrader(); }
LONG getGeometry (struct AFSBase *afsbase, struct IOHandle *ioh, struct DriveGeometry *dg) { ioh->ioreq->iotd_Req.io_Command = TD_GETGEOMETRY; ioh->ioreq->iotd_Req.io_Data = dg; ioh->ioreq->iotd_Req.io_Length = sizeof(struct DriveGeometry); return DoIO((struct IORequest *)&ioh->ioreq->iotd_Req); }
/******************************************* Name : flush Descr.: flush buffers and update disk (sync) Input : volume - volume to flush Output: DOSTRUE ********************************************/ BOOL flush(struct AFSBase *afsbase, struct Volume *volume) { flushCache(afsbase, volume); volume->ioh.ioreq->iotd_Req.io_Command = CMD_UPDATE; DoIO((struct IORequest *)&volume->ioh.ioreq->iotd_Req); clearCache(afsbase, volume->blockcache); return DOSTRUE; }
static BOOL WritePAR(APTR buf, ULONG size) { ParIO->io_Command = CMD_WRITE; ParIO->io_Data = buf; ParIO->io_Length = size; return (DoIO((struct IORequest *)ParIO) == 0) ? TRUE : FALSE; }
void check64BitSupport(struct AFSBase *afsbase, struct Volume *volume) { struct NSDeviceQueryResult nsdq; UWORD *cmdcheck; if ( ( (volume->startblock+(volume->countblocks))* /* last block */ (volume->SizeBlock*4/512) /* 1 portion (block) equals 512 (bytes) */ )>8388608) { nsdq.SizeAvailable = 0; nsdq.DevQueryFormat = 0; volume->ioh.ioreq->iotd_Req.io_Command = NSCMD_DEVICEQUERY; volume->ioh.ioreq->iotd_Req.io_Data = &nsdq; volume->ioh.ioreq->iotd_Req.io_Length = sizeof(struct NSDeviceQueryResult); if (DoIO((struct IORequest *)volume->ioh.ioreq) == IOERR_NOCMD) { D(bug("[afs] initVolume-NSD: device doesn't understand NSD-Query\n")); } else { if ( (volume->ioh.ioreq->iotd_Req.io_Actual > sizeof(struct NSDeviceQueryResult)) || (volume->ioh.ioreq->iotd_Req.io_Actual == 0) || (volume->ioh.ioreq->iotd_Req.io_Actual != nsdq.SizeAvailable) ) { D(bug("[afs] initVolume-NSD: WARNING wrong io_Actual using NSD\n")); } else { D(bug("[afs] initVolume-NSD: using NSD commands\n")); if (nsdq.DeviceType != NSDEVTYPE_TRACKDISK) D(bug("[afs] initVolume-NSD: WARNING no trackdisk type\n")); for (cmdcheck=nsdq.SupportedCommands; *cmdcheck; cmdcheck++) { if (*cmdcheck == NSCMD_TD_READ64) volume->ioh.cmdread = NSCMD_TD_READ64; if (*cmdcheck == NSCMD_TD_WRITE64) volume->ioh.cmdwrite = NSCMD_TD_WRITE64; if (*cmdcheck == NSCMD_TD_SEEK64) volume->ioh.cmdseek = NSCMD_TD_SEEK64; if (*cmdcheck == NSCMD_TD_FORMAT64) volume->ioh.cmdformat = NSCMD_TD_FORMAT64; } if ( (volume->ioh.cmdread != NSCMD_TD_READ64) || (volume->ioh.cmdwrite != NSCMD_TD_WRITE64) ) D(bug("[afs] initVolume-NSD: WARNING no READ64/WRITE64\n")); } } } else { D(bug("[afs] initVolume-NSD: no need for NSD\n")); } }
long __saveds __regargs nik_swrite(char *databuffer,long size) { serwritereq->IOSer.io_Command=CMD_WRITE; serwritereq->IOSer.io_Length=size; serwritereq->IOSer.io_Data=(APTR)databuffer; if(DoIO((struct IORequest *)serwritereq) || carrierdropped()) { return(-1L); } return(0L); }
void DoSyncAction(void (*func)(struct IntuiActionMsg *, struct IntuitionBase *), struct IntuiActionMsg *msg, struct IntuitionBase *IntuitionBase) { struct IIHData *iihd = (struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data; struct Task *me = FindTask(NULL); if (me == iihd->InputDeviceTask) { func(msg, IntuitionBase); } else { #ifdef __MORPHOS__ struct IOStdReq req; struct MsgPort port; struct InputEvent ie; #endif msg->handler = func; msg->task = me; msg->done = FALSE; ObtainSemaphore(&GetPrivIBase(IntuitionBase)->IntuiActionLock); AddTail((struct List *)GetPrivIBase(IntuitionBase)->IntuiActionQueue, (struct Node *)msg); ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->IntuiActionLock); #ifdef __MORPHOS__ port.mp_Flags = PA_SIGNAL; port.mp_SigTask = me; port.mp_SigBit = SIGB_INTUITION; NEWLIST(&port.mp_MsgList); req.io_Message.mn_ReplyPort = &port; req.io_Device = GetPrivIBase(IntuitionBase)->InputIO->io_Device; req.io_Unit = GetPrivIBase(IntuitionBase)->InputIO->io_Unit; req.io_Command = IND_WRITEEVENT; req.io_Length = sizeof(ie); req.io_Data = &ie; ie.ie_Class = IECLASS_NULL; #endif if (!msg->done) { #ifdef __MORPHOS__ DoIO((APTR)&req); #else AddNullEvent(); #endif while (!msg->done) { Wait(SIGF_INTUITION); } } } }
static void myDoIO(struct IOStdReq *ioreq, LONG CMD, LONG FLAGS, LONG OFFSET, LONG LENGTH, LONG DATA) { if(CMD>=0) ioreq->io_Command = CMD; if(FLAGS>=0) ioreq->io_Flags = FLAGS; if(OFFSET>=0) ioreq->io_Offset = OFFSET; if(LENGTH>=0) ioreq->io_Length = LENGTH; if(DATA>=0) ioreq->io_Data = (void*)DATA; DoIO((struct IORequest*)ioreq); }
void wait_for_timer(struct timerequest *tr, struct timeval *tv ) { tr->tr_node.io_Command = TR_ADDREQUEST; /* add a new timer request */ /* structure assignment */ tr->tr_time = *tv; /* post request to the timer -- will go to sleep till done */ DoIO((struct IORequest *) tr ); }
void remChangeInt(struct AFSBase *afsbase, struct IOHandle *ioh) { if ( (ioh->iochangeint != NULL) && (ioh->iochangeint->iotd_Req.io_Error == 0) ) { ioh->iochangeint->iotd_Req.io_Command = TD_REMCHANGEINT; DoIO((struct IORequest *)&ioh->iochangeint->iotd_Req); } }
long __saveds __regargs nik_sread(char *databuffer,long size,long timeout) { ULONG signals,sersig=1L << serreadport->mp_SigBit, timersig=1L << timerport->mp_SigBit; if(timeout) { serreadreq->IOSer.io_Command=CMD_READ; serreadreq->IOSer.io_Length=size; serreadreq->IOSer.io_Data=(APTR)databuffer; SendIO((struct IORequest *)serreadreq); timerreq->tr_node.io_Command=TR_ADDREQUEST; timerreq->tr_time.tv_secs=timeout/1000000; timerreq->tr_time.tv_micro=timeout%1000000; timerreq->tr_node.io_Message.mn_ReplyPort=timerport; SendIO((struct IORequest *)timerreq); for(;;) { signals=Wait(sersig | timersig); if((signals & sersig) && CheckIO((struct IORequest *)serreadreq)) { WaitIO((struct IORequest *)serreadreq); AbortIO((struct IORequest *)timerreq); WaitIO((struct IORequest *)timerreq); if(serreadreq->IOSer.io_Error || carrierdropped()) return(-1L); return((long)serreadreq->IOSer.io_Actual); } if((signals & timersig) && CheckIO((struct IORequest *)timerreq)) { WaitIO((struct IORequest *)timerreq); AbortIO((struct IORequest *)serreadreq); WaitIO((struct IORequest *)serreadreq); /* printf("Timeout! Size=%d Timeout=%d Actual=%d",size,timeout,serreadreq->IOSer.io_Actual); */ return((long)serreadreq->IOSer.io_Actual); } } } else { serreadreq->IOSer.io_Command=SDCMD_QUERY; DoIO((struct IORequest *)serreadreq); serreadreq->IOSer.io_Command=CMD_READ; if(serreadreq->IOSer.io_Actual > size) serreadreq->IOSer.io_Length=size; else serreadreq->IOSer.io_Length=serreadreq->IOSer.io_Actual; serreadreq->IOSer.io_Data=(APTR)databuffer; DoIO((struct IORequest *)serreadreq); return((long)serreadreq->IOSer.io_Actual); } }
BYTE OpenTimer(struct timerequest *treq) { BYTE error; error=OpenDevice(TIMERNAME,UNIT_VBLANK,(struct IORequest *)treq,0); if(!error) { treq->tr_node.io_Command=TR_ADDREQUEST; treq->tr_node.io_Message.mn_ReplyPort=timerport; treq->tr_time.tv_secs=0; treq->tr_time.tv_micro=10; if(DoIO((struct IORequest *)timerreq)) printf("Fel DoIO i OpenTimer()\n"); } return(error); }
int main(void) { struct IOStdReq *ior; struct MsgPort *mp; char buff[10]; Printf("main\n"); if (mp = (struct MsgPort *)CreatePort(0,0)) { Printf("got port\n"); if (ior = (struct IOStdReq *) CreateExtIO(mp, sizeof(struct IOStdReq))) { Printf("got extio\n"); if (OpenDevice("example.device",0,(struct IORequest*)ior,0) == 0) { Printf("opened device\n"); ior->io_Data = buff; ior->io_Command = CMD_READ; ior->io_Length = 1; DoIO((struct IORequest *)ior); Printf("done read\n"); ior->io_Data = buff; ior->io_Command = CMD_WRITE; ior->io_Length = 1; DoIO((struct IORequest *)ior); Printf("done write\n"); CloseDevice((struct IORequest *)ior); } DeleteExtIO((struct IORequest *)ior); } DeletePort(mp); } Printf("done\n"); return 0; }
BOOL UsePrefs(void) { ULONG secs; secs = Date2Amiga(&clockdata); TimerIO->tr_node.io_Command = TR_SETSYSTIME; TimerIO->tr_time.tv_secs = secs; TimerIO->tr_time.tv_micro = 0; DoIO(&TimerIO->tr_node); return TRUE; }
void timer_usleep(void *t, int us) { struct timer_s *timer = t; if (timer != NULL) { /* setup */ timer->TimerIO.tr_node.io_Command = TR_ADDREQUEST; timer->TimerIO.tr_time.tv_secs = us / 1000000; timer->TimerIO.tr_time.tv_micro = us % 1000000; /* send & wait request */ DoIO((struct IORequest *)&timer->TimerIO); } }
bx_bool cdrom_interface::read_block(Bit8u* buf, int lba, int blocksize) { CDIO->iotd_Req.io_Data = buf; CDIO->iotd_Req.io_Command = CMD_READ; CDIO->iotd_Req.io_Length = BX_CD_FRAMESIZE; CDIO->iotd_Req.io_Offset = lba * BX_CD_FRAMESIZE; DoIO((struct IORequest *)CDIO); if (CDIO->iotd_Req.io_Error != 0) { BX_PANIC(("Error %d reading CD data sector: %ld", CDIO->iotd_Req.io_Error, lba)); return 0; } return 1; }
LONG set_new_time(LONG secs) { struct timerequest *tr; tr = create_timer( UNIT_MICROHZ ); /* non zero return says error */ if (tr == 0 ) return( -1 ); tr->tr_time.tv_secs = secs; tr->tr_time.tv_micro = 0; tr->tr_node.io_Command = TR_SETSYSTIME; DoIO((struct IORequest *) tr ); delete_timer(tr); return(0); }
void putchar(int c) { struct Console *mc = ConsoleBase; char buf = c; mc->cnior->length = 1; mc->cnior->buf = &buf; mc->cnior->cmd = Cmd_Wr; #ifdef SERCONSOLE if (use_serconsole) RawPutChar((int32_t)c); #endif (void)DoIO(mc->cnior); }