Skip to content

parport-pci: NetMos MCS9900 PCI parallel port with IEEE 1284 reverse#232

Open
SolAstrius wants to merge 3 commits into
LekKit:stagingfrom
pufit:feat/parport-pci
Open

parport-pci: NetMos MCS9900 PCI parallel port with IEEE 1284 reverse#232
SolAstrius wants to merge 3 commits into
LekKit:stagingfrom
pufit:feat/parport-pci

Conversation

@SolAstrius

@SolAstrius SolAstrius commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Adds a NetMos / MosChip MCS9900 PCI parallel port — a single SPP port plus the IEEE 1284 nibble-mode reverse channel — and wires up CLI flags to drive it. Builds on the I/O-port BAR + per-function subsystem-ID support merged in #225.

Device

PCI identity matches the MCS9900 datasheet (ASIX Rev 2.00, §6.2, the 2S+1P parallel function): vendor 0x9710, device 0x9900, class 0701h, subsystem 0xA000:0x2000. BAR 0 is an I/O-port BAR (PCI Local Bus Spec 3.0 §6.2.5.1) holding the 8-byte SPP register window (Data / Status / Control + EPP/ECP stubs). The subsystem IDs (PCI §6.2.4) are what a host driver strict-matches on to bind.

  • Forward path — standard Centronics (IEEE 1284 §7.3): the guest writes Data, then pulses the strobe; we forward the byte to a backend callback on the strobe edge.
  • Reverse path — IEEE 1284 §7.4 negotiation + §6.3 nibble mode: a small state machine tracks the negotiation events, presents peripheral bytes a nibble at a time on the status lines, and raises an edge INTx on nAck when IRQ is enabled. A lock-protected ring buffers host→guest bytes; nFault signals end-of-data when it drains.

CLI

A single -parport <spec> flag (structured value, like -portfwd/-res):

  • -parport null — attach with no backend.
  • -parport <path> — bare path shorthand; guest output is sinked to that file.
  • -parport out=<path>,in=<path>out= sinks guest (forward/Centronics) output to a file/pipe; in= sources the IEEE 1284 reverse channel from a file/fifo (a reader thread feeds bytes into the ring). Either field may be omitted.

Notes

  • We expose prog_if 0x00 (SPP); the silicon reports 0x03 (IEEE 1284 controller). SPP is sufficient for a host driver to bind and use the nibble reverse channel.
  • parport_pci_remove clears the instance from the lookup map before freeing, so a reused pci_dev_t address can't resolve to a freed device.

Test plan

Verified on an Alpine RISC-V guest (kernel with parallel-port + ppdev support):

  • enumerates with the expected IDs and I/O BAR; parport / lp / ppdev nodes appear
  • echo to the printer node lands in the host sink file
  • nibble-mode reverse reads (-parport_in → guest cat) deliver bytes intact

Signed-off-by: Sol Astrius <sol@astrius.ink>
@SolAstrius SolAstrius marked this pull request as draft June 18, 2026 15:48
Signed-off-by: Sol Astrius <sol@astrius.ink>
@SolAstrius SolAstrius marked this pull request as ready for review June 18, 2026 16:06
Comment thread src/main.c Fixed
Signed-off-by: Sol Astrius Phoenix <me@danielsol.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants