-
Notifications
You must be signed in to change notification settings - Fork 78
Apple II SP over SLIP
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
Example dummy message
message: 01 DB 49 C0 15
message sent: C0 01 DB DD 49 DB DC 15 C0
Note that on the Apple II implementation, all block sizes are 512 bytes, but the interface is generic, so the size must be specified in the request.
The Status command returns information about a specific device on the SCSI bus. The information returned by this command is determined by status code.
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Command Number ($00) |
| 1 | SmartPort Unit Number |
| 1 | Status Code |
| Status Code | Meaning |
|---|---|
| $00 | Return device status |
| $01 | Not supported |
| $02 | Not supported |
| $03 | Return Device Information Block (DIB) |
| $04 | Return Device Information Block (DIB), extra |
| $05 | Return last error status |
| $06 | Return bytes/block parameter for device |
Example SLIP Status Request Message
Sequence Number
| Status Command
| | SmartPort
| | | Status Code
| | | |
AppleWin -> FujiNet : c0 12 00 01 03 c0
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status |
| [n] | Status List (if Status == $00) |
General Status Byte
| Bit | Meaning |
|---|---|
| 7 | 0=Character Device 1=Block Device |
| 6 | Read Allowed |
| 5 | Write Allowed |
| 4 | Device Ready |
| 3 | 0=Format Allowed |
| 2 | 0=Write Protected (Block devices only) |
| 1 | Device currently interrupting |
| 0 | Device currently open (Character devices only |
| Type | Subtype | Device |
|---|---|---|
| $00 | $00 | Apple II memory expansion card |
| $01 | $00 | Apple 3.5 drive |
| $01 | $40 | UniDisk 3.5 |
| $02 | ProFile™ hard disk | |
| 3-9 | Reserved | |
| $0A | 5.25-inch disk | |
| B-F | Reserved |
Example Status Response Message
FujiNet -> AppleWin : c0 12 00 fc 18 01 00 0e 46 55 4a 49 4e 45 54 5f 44 49 53 4b 5f 30 20 20 01 40 01 0f c0
| | | | | | |---16 bytes always---------------------------| | | | |
| | | | | | |F U J I N E T _ D I S K _ 0 | | | Firmware
| | | | | String Length | | Version
| | | | / | Subtype
| | | Blocks on device (3 bytes) Device Type
| | General Status Byte
| Status Command
Sequence Number
The Read Block command reads one 512-byte block from the target device specified in the unit number parameter.
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Command Number ($01) |
| 1 | SmartPort Unit Number |
| 2 | Block Size* |
| 3 | Block Number |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status |
| [N] | Block Data (if Status == $00) |
The Write Block command writes one 512-byte block to the target device specified in the unit number parameter.
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Command Number ($02) |
| 1 | SmartPort Unit Number |
| 2 | Block Size* |
| 3 | Block Number |
| N | Block Data |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status |
The Format command prepares all the blocks on the device specified in the unit number parameter for read/write use. This command is for use on block-type devices only. The Format command checks the target device for existing partitions prior to beginning execution. If valid partitions are found, the command terminates and control is turned over in the normal fashion. If no partitions are found, a full SCSI FORMAT ($04) command is executed on the target device, and the routine lays down a DDM and DPM for the drive, treating the entire storage volume as a single partition.
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Command Number ($03) |
| 1 | SmartPort Unit Number |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status |
The Control command provides two basic functions. The first is to execute device control routines designed by Apple. The second is to execute SCSI commands. The command interpreter handles all of the functions required to execute the routine or command, including the routines necessary to read your routine or command out of RAM and pass it to the device, and receive any data returned by the command and write it into the RAM address you have specified (where appropriate). If you need to use a SCSI command not supported by a SmartPort control code, you must write some special code in order to pass your command to the interpreter.
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Command Number ($04) |
| 1 | SmartPort Unit Number |
| n | Control List |
| Command | Byte | Content |
|---|---|---|
| 'O' | 0 | Open |
| 0-1 | payload size | |
| 2 | mode read, write or both | |
| 3 | translation | |
| 4... | url | |
| 'C' | 0 | Close |
| 0-1 | payload size of zero | |
| 'R' | 0 | Read |
| 0-1 | payload size | |
| 2... | data | |
| 'W' | 0 | Write |
| 0-1 | payload size | |
| 2... | data | |
| 'A' | 0 | Accept |
| 0-1 | payload size $00 | |
| 'D' | 0 | udp destination |
| 0-1 | payload size | |
| 2... | url |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status |
The Init command forces the firmware to reinitialize the SCSI bus. All the devices on the SCSI bus are hard reset, the partition offsets for each of the devices online are reinitialized, and new unit numbers are assigned, where necessary.
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Command Number ($05) |
| 1 | SmartPort Unit Number |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status |
The Open command opens a logical me on the target device for data I/0. This command is used for character devices only.
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Command Number ($06) |
| 1 | SmartPort Unit Number |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status |
The Close command closes a logical file on the target device after a data VO sequence is completed. This command is used for character devices only.
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Command Number ($07) |
| 1 | SmartPort Unit Number |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status |
The Read command reads a specified number of bytes from the target device specified in the unit number parameter.
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Command Number ($08) |
| 1 | SmartPort Unit Number |
| 2 | Byte Count |
| 3 | Address |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status |
| [n] | Read Data (if Status == $00) |
The Write command writes a specified number of bytes to the target device specified in the unit number p4rameter.
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Command Number ($09) |
| 1 | SmartPort Unit Number |
| 2 | Byte Count |
| 3 | Address |
| n | Write Data |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status |
The Apple II side of SP-over-SLIP is supposed to be implemented using some processor beside the 6502 main processor. This allows the Apple II - in contrast to CBus - to inform the connected devices about a 6502 reset. This can i.e. have a modem drop an active connection or a printer eject a partially printed page.
NOTE: This is NOT the smartport command SetFormatOptions
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Command Number ($0A) |
| 1 | SmartPort Unit Number |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status |
Copyright 2024 Contributors to the FujiNetWIFI project.
Join us on Discord: https://discord.gg/7MfFTvD
- Home
- What is FujiNet?
- The Definition of Done
- Board bring up for FujiNet Platform.IO code
- The Complete Linux CLI Guide
- The Complete macOS CLI Guide
- Development Env for Apps
- FujiNet-Development-Guidelines
- System Quickstarts
- FujiNet Flasher
- Setting up a TNFS Server
- FujiNet Configuration File: fnconfig.ini
- AppKey Registry - SIO Command $DC Open App Key
- CP-M Support
- BBS
- Official Hardware Versions
- Prototype Board Revisions
- FujiNet Development Guidelines
- Atari Programming
- Apple Programming
- C64 Programming
- ADAM Programming
- Testing Plan
- Hacker List
- FujiNet VirtualMachine