drivers/macintosh/via-macii.c

Source file repositories/reference/linux-study-clean/drivers/macintosh/via-macii.c

File Facts

System
Linux kernel
Corpus path
drivers/macintosh/via-macii.c
Extension
.c
Size
14316 bytes
Lines
560
Domain
Driver Families
Bucket
drivers/macintosh
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (!(status & CTLR_IRQ)) {
			/* /CTLR_IRQ asserted in idle state means we must
			 * read an autopoll reply from the transceiver buffer.
			 */
			macii_state = reading;
			*reply_ptr = x;
			reply_len = 1;
		} else {
			/* bus timeout */
			reply_len = 0;
			break;
		}

		/* set ADB state = even for first data byte */
		via[B] = (via[B] & ~ST_MASK) | ST_EVEN;
		break;

	case sending:
		req = current_req;

		if (status == (ST_CMD | CTLR_IRQ)) {
			/* /CTLR_IRQ de-asserted after the command byte means
			 * the host can continue with the transaction.
			 */

			/* Store command byte */
			last_cmd = req->data[1];
			if ((last_cmd & OP_MASK) == TALK) {
				last_talk_cmd = last_cmd;
				if ((last_cmd & CMD_MASK) == ADB_READREG(0, 0))
					last_poll_cmd = last_cmd;
			}
		}

		if (status == ST_CMD) {
			/* /CTLR_IRQ asserted after the command byte means we
			 * must read an autopoll reply. The first byte was
			 * lost because the shift register was an output.
			 */
			macii_state = reading;

			reading_reply = false;
			reply_ptr = reply_buf;
			*reply_ptr = last_talk_cmd;
			reply_len = 1;

			/* reset to shift in */
			via[ACR] &= ~SR_OUT;
			x = via[SR];
		} else if (data_index >= req->nbytes) {
			req->sent = 1;

			if (req->reply_expected) {
				macii_state = reading;

				reading_reply = true;
				reply_ptr = req->reply;
				*reply_ptr = req->data[1];
				reply_len = 1;

				via[ACR] &= ~SR_OUT;
				x = via[SR];
			} else if ((req->data[1] & OP_MASK) == TALK) {
				macii_state = reading;

				reading_reply = false;
				reply_ptr = reply_buf;
				*reply_ptr = req->data[1];
				reply_len = 1;

				via[ACR] &= ~SR_OUT;
				x = via[SR];

				req->complete = 1;
				current_req = req->next;
				if (req->done)
					(*req->done)(req);
			} else {
				macii_state = idle;

				req->complete = 1;
				current_req = req->next;
				if (req->done)
					(*req->done)(req);
				break;
			}
		} else {
			via[SR] = req->data[data_index++];
		}

Annotation

Implementation Notes