/* * This is the thread which processes floppy I/O requests. */ static void Floppy_Request_Thread(ulong_t arg) { int rc; Debug("FRQ: Floppy request thread starting...\n"); for (;;) { struct Block_Request *request; /* Wait for an I/O request to arrive */ Debug("FRQ: Request thread waiting for a request\n"); request = Dequeue_Request(&s_floppyRequestQueue, &s_floppyWaitQueue); Debug("FRQ: Got a floppy request [@%x]\n", request); KASSERT(request->type == BLOCK_READ || request->type == BLOCK_WRITE); /* Perform the I/O. */ if (request->type == BLOCK_READ) rc = Floppy_Read(request->dev->unit, request->blockNum, request->buf); else rc = Floppy_Write(request->dev->unit, request->blockNum, request->buf); /* Notify the requesting thread of the outcome of the I/O. */ Debug("FRQ: Notifying requesting thread...\n"); Notify_Request_Completion(request, rc == 0 ? COMPLETED : ERROR, rc); Debug("FRQ: Completed floppy request\n"); } }
static void IDE_Request_Thread(ulong_t arg __attribute__ ((unused))) { for (;;) { struct Block_Request *request; int rc; /* Wait for a request to arrive */ request = Dequeue_Request(&s_ideRequestQueue, &s_ideWaitQueue); /* Do the I/O */ if (request->type == BLOCK_READ) rc = IDE_Read(request->dev->unit, request->blockNum, request->buf); else rc = IDE_Write(request->dev->unit, request->blockNum, request->buf); /* Notify requesting thread of final status */ Notify_Request_Completion(request, rc == 0 ? COMPLETED : ERROR, rc); } }