hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/arch/m68k/mac/iop.c
....@@ -293,7 +293,6 @@
293293
294294 /*
295295 * Register the interrupt handler for the IOPs.
296
- * TODO: might be wrong for non-OSS machines. Anyone?
297296 */
298297
299298 void __init iop_register_interrupts(void)
....@@ -348,8 +347,8 @@
348347 int chan = msg->channel;
349348 int i,offset;
350349
351
- iop_pr_debug("msg %p iop_num %d channel %d\n", msg, msg->iop_num,
352
- msg->channel);
350
+ iop_pr_debug("iop_num %d chan %d reply %*ph\n",
351
+ msg->iop_num, msg->channel, IOP_MSG_LEN, msg->reply);
353352
354353 offset = IOP_ADDR_RECV_MSG + (msg->channel * IOP_MSG_LEN);
355354
....@@ -373,6 +372,9 @@
373372 volatile struct mac_iop *iop = iop_base[msg->iop_num];
374373 int i,offset;
375374
375
+ iop_pr_debug("iop_num %d chan %d message %*ph\n",
376
+ msg->iop_num, msg->channel, IOP_MSG_LEN, msg->message);
377
+
376378 offset = IOP_ADDR_SEND_MSG + (msg->channel * IOP_MSG_LEN);
377379
378380 for (i = 0 ; i < IOP_MSG_LEN ; i++, offset++) {
....@@ -395,8 +397,6 @@
395397 struct iop_msg *msg;
396398 int i,offset;
397399
398
- iop_pr_debug("iop_num %d chan %d\n", iop_num, chan);
399
-
400400 iop_writeb(iop, IOP_ADDR_SEND_STATE + chan, IOP_MSG_IDLE);
401401
402402 if (!(msg = iop_send_queue[iop_num][chan])) return;
....@@ -406,6 +406,9 @@
406406 for (i = 0 ; i < IOP_MSG_LEN ; i++, offset++) {
407407 msg->reply[i] = iop_readb(iop, offset);
408408 }
409
+ iop_pr_debug("iop_num %d chan %d reply %*ph\n",
410
+ iop_num, chan, IOP_MSG_LEN, msg->reply);
411
+
409412 if (msg->handler) (*msg->handler)(msg);
410413 msg->status = IOP_MSGSTATUS_UNUSED;
411414 msg = msg->next;
....@@ -425,8 +428,6 @@
425428 int i,offset;
426429 struct iop_msg *msg;
427430
428
- iop_pr_debug("iop_num %d chan %d\n", iop_num, chan);
429
-
430431 msg = iop_get_unused_msg();
431432 msg->iop_num = iop_num;
432433 msg->channel = chan;
....@@ -438,6 +439,8 @@
438439 for (i = 0 ; i < IOP_MSG_LEN ; i++, offset++) {
439440 msg->message[i] = iop_readb(iop, offset);
440441 }
442
+ iop_pr_debug("iop_num %d chan %d message %*ph\n",
443
+ iop_num, chan, IOP_MSG_LEN, msg->message);
441444
442445 iop_writeb(iop, IOP_ADDR_RECV_STATE + chan, IOP_MSG_RCVD);
443446
....@@ -447,9 +450,7 @@
447450 if (msg->handler) {
448451 (*msg->handler)(msg);
449452 } else {
450
- iop_pr_debug("unclaimed message on iop_num %d chan %d\n",
451
- iop_num, chan);
452
- iop_pr_debug("%*ph\n", IOP_MSG_LEN, msg->message);
453
+ memset(msg->reply, 0, IOP_MSG_LEN);
453454 iop_complete_message(msg);
454455 }
455456 }
....@@ -557,36 +558,41 @@
557558 uint iop_num = (uint) dev_id;
558559 volatile struct mac_iop *iop = iop_base[iop_num];
559560 int i,state;
561
+ u8 events = iop->status_ctrl & (IOP_INT0 | IOP_INT1);
560562
561
- iop_pr_debug("status %02X\n", iop->status_ctrl);
563
+ do {
564
+ iop_pr_debug("iop_num %d status %02X\n", iop_num,
565
+ iop->status_ctrl);
562566
563
- /* INT0 indicates a state change on an outgoing message channel */
564
-
565
- if (iop->status_ctrl & IOP_INT0) {
566
- iop->status_ctrl = IOP_INT0 | IOP_RUN | IOP_AUTOINC;
567
- iop_pr_debug("new status %02X, send states", iop->status_ctrl);
568
- for (i = 0 ; i < NUM_IOP_CHAN ; i++) {
569
- state = iop_readb(iop, IOP_ADDR_SEND_STATE + i);
570
- iop_pr_cont(" %02X", state);
571
- if (state == IOP_MSG_COMPLETE) {
572
- iop_handle_send(iop_num, i);
567
+ /* INT0 indicates state change on an outgoing message channel */
568
+ if (events & IOP_INT0) {
569
+ iop->status_ctrl = IOP_INT0 | IOP_RUN | IOP_AUTOINC;
570
+ for (i = 0; i < NUM_IOP_CHAN; i++) {
571
+ state = iop_readb(iop, IOP_ADDR_SEND_STATE + i);
572
+ if (state == IOP_MSG_COMPLETE)
573
+ iop_handle_send(iop_num, i);
574
+ else if (state != IOP_MSG_IDLE)
575
+ iop_pr_debug("chan %d send state %02X\n",
576
+ i, state);
573577 }
574578 }
575
- iop_pr_cont("\n");
576
- }
577579
578
- if (iop->status_ctrl & IOP_INT1) { /* INT1 for incoming msgs */
579
- iop->status_ctrl = IOP_INT1 | IOP_RUN | IOP_AUTOINC;
580
- iop_pr_debug("new status %02X, recv states", iop->status_ctrl);
581
- for (i = 0 ; i < NUM_IOP_CHAN ; i++) {
582
- state = iop_readb(iop, IOP_ADDR_RECV_STATE + i);
583
- iop_pr_cont(" %02X", state);
584
- if (state == IOP_MSG_NEW) {
585
- iop_handle_recv(iop_num, i);
580
+ /* INT1 for incoming messages */
581
+ if (events & IOP_INT1) {
582
+ iop->status_ctrl = IOP_INT1 | IOP_RUN | IOP_AUTOINC;
583
+ for (i = 0; i < NUM_IOP_CHAN; i++) {
584
+ state = iop_readb(iop, IOP_ADDR_RECV_STATE + i);
585
+ if (state == IOP_MSG_NEW)
586
+ iop_handle_recv(iop_num, i);
587
+ else if (state != IOP_MSG_IDLE)
588
+ iop_pr_debug("chan %d recv state %02X\n",
589
+ i, state);
586590 }
587591 }
588
- iop_pr_cont("\n");
589
- }
592
+
593
+ events = iop->status_ctrl & (IOP_INT0 | IOP_INT1);
594
+ } while (events);
595
+
590596 return IRQ_HANDLED;
591597 }
592598