Apple II SP over SLIP - FujiNetWIFI/fujinet-firmware GitHub Wiki
SmartPort over Serial Line Internet Protocol (SP-over-SLIP) is related to Apple II Protocol Converter Bus (CBus). From a high-level perspective it transports almost the same data as CBus, but the actual coding of the data is pretty different. The primary difference in the transported data results from the fact that SP-over-SLIP runs on a point-to-point connection while CBus runs - nomen est omen - on a bus.
SP-over-SLIP can be used on any medium providing a transparent, duplex, lossless byte stream. Examples are a TCP connection or a USB CDC-ACM connection.
SP-over-SLIP strictly consists of request/response packets. Every packet is encapsulated in a SLIP frame for two reasons:
- SLIP frames allow to detect packet boundaries without parsing the (variable sized) packets.
- SLIP frames allow to detect incomplete packets caused by an Apple II Reset during packet transmission.
Every request/response packet starts with a Request Sequence Number for this reason: An Apple II Reset after sending a request but before receiving the response makes the response stay in some TCP or USB related buffer. Now the next send request / receive response sequence receives that wrong, old response. The Request Sequence Number allows to detect (and discard) that response.
A SLIP message consists of a message enclosed by $C0
- if the contents of the message contains a $C0, transmit $DB $DC instead
- if the contents of the message contains a $DB, transmit $DB $DD instead
See SLIP at Wikipedia for more details.
Note: The request/response packet descriptions below are meant to supplement the information in:
- Apple IIc Technical Reference Manual, Chapter 6: Block Device I/O
- Apple IIgs Firmware Reference, Chapter 7: SmartPort Firmware
Status Request ($00)
Size |
Content |
1 |
Request Sequence Number |
1 |
Command Number |
1 |
SmartPort Unit Number |
1 |
Status Code |
Status Response
Size |
Content |
1 |
Request Sequence Number |
1 |
Status |
[n] |
Status List (if Status == $00) |
Note: For Status Code $02 (return newline status), the Status List consists of two bytes. The first byte contains $00 if there is no NEWLINE character, and $80 if there is one. The second byte in the list contains the current NEWLINE character, if it exists.
ReadBlock Request ($01)
Size |
Content |
1 |
Request Sequence Number |
1 |
Command Number |
1 |
SmartPort Unit Number |
3 |
Block Number |
ReadBlock Response
Size |
Content |
1 |
Request Sequence Number |
1 |
Status |
[n] |
Block Data (if Status == 0x00) |
WriteBlock Request ($02)
Size |
Content |
1 |
Request Sequence Number |
1 |
Command Number |
1 |
SmartPort Unit Number |
3 |
Block Number |
n |
Block Data |
WriteBlock Response
Size |
Content |
1 |
Request Sequence Number |
1 |
Status |
Format Request ($03)
Size |
Content |
1 |
Request Sequence Number |
1 |
Command Number |
1 |
SmartPort Unit Number |
Format Response
Size |
Content |
1 |
Request Sequence Number |
1 |
Status |
Control Request ($04)
Size |
Content |
1 |
Request Sequence Number |
1 |
Command Number |
1 |
SmartPort Unit Number |
1 |
Control Code |
n |
Control List |
Note: For Control Code $02 (set newline status), the Control List consists of two bytes. The first byte contains $00 if there is no NEWLINE character, and $80 if there is one. The second byte in the list contains the current NEWLINE character, if it exists.
Note: The Apple II side of SP-over-SLIP is - in contrast to CBus - supposed to be implemented using some processor beside the 6502 main processor. This allows the Apple II to inform the connected devices about a 6502 reset. Doing so can i.e. have a modem drop an active connection or a printer eject a partially printed page. This can be done by sending a Control requestion with Control Code $00 to the connected devices.
Control Response
Size |
Content |
1 |
Request Sequence Number |
1 |
Status |
Init Request ($05)
Size |
Content |
1 |
Request Sequence Number |
1 |
Command Number |
1 |
SmartPort Unit Number |
Init Response
Size |
Content |
1 |
Request Sequence Number |
1 |
Status |
Open Request ($06)
Size |
Content |
1 |
Request Sequence Number |
1 |
Command Number |
1 |
SmartPort Unit Number |
Open Response
Size |
Content |
1 |
Request Sequence Number |
1 |
Status |
Close Request ($07)
Size |
Content |
1 |
Request Sequence Number |
1 |
Command Number |
1 |
SmartPort Unit Number |
Close Response
Size |
Content |
1 |
Request Sequence Number |
1 |
Status |
Read Request ($08)
Size |
Content |
1 |
Request Sequence Number |
1 |
Command Number |
1 |
SmartPort Unit Number |
2 |
Byte Count |
3 |
Address |
Read Response
Size |
Content |
1 |
Request Sequence Number |
1 |
Status |
[n] |
Read Data (if Status == $00) |
Write Request ($09)
Size |
Content |
1 |
Request Sequence Number |
1 |
Command Number |
1 |
SmartPort Unit Number |
2 |
Byte Count |
3 |
Address |
n |
Write Data |
Write Response
Size |
Content |
1 |
Request Sequence Number |
1 |
Status |