From 5811482b4a03b8fe99cf3b25186c504a7c65e334 Mon Sep 17 00:00:00 2001 From: Bottersnike Date: Mon, 25 Apr 2022 01:47:34 +0100 Subject: [PATCH] Driver docs --- docs.py | 47 +- .../pages/sega/software/drivers/index.html | 562 ++++++++++++++++++ 2 files changed, 600 insertions(+), 9 deletions(-) diff --git a/docs.py b/docs.py index e97d687..afee6a3 100644 --- a/docs.py +++ b/docs.py @@ -44,15 +44,18 @@ SEGA_CONTENTS = { "hardware": ("Hardware", ()), "software": ("Software", { "jvs.html": "JVS", - "drivers": ("Device drivers", { - "columba.html": "columba", - "mxsram.html": "mxsram", - "mxhwreset.html": "mxhwreset", - "mxsuperio.html": "mxsuperio", - "mxjvs.html": "mxjvs", - "mxparallel.html": "mxparallel", - "mxsmbus.html": "mxsmbus", - }), + "drivers": ("Device drivers", + #{ + # "columba.html": "columba", + # "mxsram.html": "mxsram", + # "mxhwreset.html": "mxhwreset", + # "mxsuperio.html": "mxsuperio", + # "mxjvs.html": "mxjvs", + # "mxparallel.html": "mxparallel", + # "mxsmbus.html": "mxsmbus", + #} + None + ), "security": ("Security", { "game.html": "Game encryption", "dongle.html": "Dongles", @@ -159,6 +162,8 @@ def generate_toc(base, name, route, start=1): if url == "": filename += "index.html" + if "." not in filename: + filename += "/index.html" with open(filename) as page: headers = HTAG.findall(page.read()) @@ -242,6 +247,29 @@ def generate_footer(base, name, route): return footer +def ioctl(original): + original = eval(original) # Unsafe as hell + + def CTL_CODE(DeviceType, Function, Method, Access): + return ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) + + deviceType = original >> 16 + access = (original >> 14) & 0x3 + function = (original >> 2) & 0xfff + method = original & 0x3 + + assert hex(CTL_CODE(deviceType, function, method, access)) == hex(original) + + deviceType = hex(deviceType) + if deviceType == "0x9c40": + deviceType = "FILE_DEVICE_SEGA" + function = hex(function) + method = "METHOD_" + ["BUFFERED", "IN_DIRECT", "OUT_DIRECT", "NEITHER"][method] + access = ["FILE_ANY_ACCESS", "FILE_READ_ACCESS", "FILE_WRITE_ACCESS"][access] + + return (f"CTL_CODE({deviceType}, {function}, {method}, {access})") + + @app.route("/styles.css") def styles(): return send_from_directory(".", "styles.css") @@ -291,6 +319,7 @@ for base, _, files in os.walk(TEMPLATES + "/" + PAGES_BASE): generate_toc=lambda start=1: generate_toc(base, name, route, start), generate_footer=lambda: generate_footer(base, name, route), part=part, + ioctl=ioctl, ) return handler diff --git a/templates/pages/sega/software/drivers/index.html b/templates/pages/sega/software/drivers/index.html index b6d74bf..6549eef 100644 --- a/templates/pages/sega/software/drivers/index.html +++ b/templates/pages/sega/software/drivers/index.html @@ -3,4 +3,566 @@ {% block body %}

Drivers

{{ generate_toc()|safe }} + +

Ring* systems makes use of a number of (mostly) bespoke drivers, listed below:

+ + + + +

columna

+

Columba is a driver used to fetch DMI information about the current system.

+

Devices overview

+ + + + + + + + + + + + + + + + + +
Device Name\Device\columba
Symlink Name\DosDevices\columba
Userspace Name\\.\columba
Device GUID
+

IO control codes

+ + + + + + + + + + + + + + + + + + + +
IOCTL Code#defineBytes inBytes outMeaning
0x9c406104{{ ioctl("0x9c406104") }}Read the DMI at a given offset
+ +

mxcmos

+

mxcmos is unknown currently

+ +

mxhwreset

+

mxhwreset is

+

Devices overview

+ + + + + + + + + + + + + + + + + +
Device Name\Device\mxhwreset
Symlink Name\DosDevices\mxhwreset
Userspace Name\\.\mxhwreset
Device GUID
+

IO control codes

+ + + + + + + + + + + + + + + + + + + +
IOCTL Code#defineBytes inBytes outMeaning
0x9c402000{{ ioctl("0x9c402000") }}
+

Ports used

+ + + +

mxjvs

+

mxjvs is the driver used to communicate with the JVS IO board connected to the Ring* PC via the JVS USB port.

+

Devices overview

+ + + + + + + + + + + + + + + + + +
Device Name\Device\mxjvs
Symlink Name\DosDevices\mxjvs
Userspace Name\\.\mxjvs
Device GUID
+

IO control codes

+ + + + + + + + + + + + + + + + + + + +
IOCTL Code#defineBytes inBytes outMeaning
0x9c402000{{ ioctl("0x9c402000") }}variablevariableExchange JVS packets with the JVS IO board
+

Extra values used, currently unknown

+ + +

mxparallel

+

mxparallel is a wrapper driver for the parallel port used to communicate with the keychip

+

Devices overview

+ + + + + + + + + + + + + + + + + +
Device Name\Device\mxparallel
Symlink Name\DosDevices\mxparallel
Userspace Name\\.\mxparallel
Device GUID
+

IO control codes

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IOCTL Code#defineBytes inBytes outMeaning
0x9c40a000{{ ioctl("0x9c40a000") }}Write data
0x9c406004{{ ioctl("0x9c406004") }}Read data
0x9c40a008{{ ioctl("0x9c40a008") }}Write status
0x9c40600c{{ ioctl("0x9c40600c") }}Read status
0x9c40a010{{ ioctl("0x9c40a010") }}Write control
0x9c406014{{ ioctl("0x9c406014") }}Read control
0x9c40a018{{ ioctl("0x9c40a018") }}Write flags
0x9c40601c{{ ioctl("0x9c40601c") }}Read flags
+

Ports used

+ + +

mxsmbus

+

This driver communicates with the system message bus chip on the motherboard. This driver appears to be a slightly + modified reference driver from Intel. The exact chipset used varies depending on the system:

+ + + + + + + + + + + + + +
RingWideIntel(R) 82801G(ICH7 Family)SMBus Controller
RingEdgeIntel(R) ICH9 SMBus Controller
RingEdge 2Intel(R) 5 Series/3400 Series Chipset Family SMBus Controller
+

Devices currently confirmed to be located on the system message bus:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
AddressDevice
0x20PCA9535; used for DIP switches
0x30
0x55
0x57EEPROM
+

Devices overview

+ + + + + + + + + + + + + + + + + +
Device Name\Device\mxsmbus
Symlink Name\DosDevices\mxsmbus
Userspace Name\\.\mxsmbus
Device GUID5c49e1fe-3fec-4b8d-a4b5-76be7025d842
+

IO control codes

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IOCTL Code#defineBytes inBytes outMeaning
0x9c406000{{ ioctl("0x9c406000") }}04Not totally understood, but appears to retrieve the port number
0x9c402004{{ ioctl("0x9c402004") }}25h25hExchange data over the smbus
0x9c406008{{ ioctl("0x9c406008") }}04Retrieve the driver version
0x9c40200c{{ ioctl("0x9c40200c") }}27h27hExchange data with an I2C device over the smbus
+

Ports used

+

Unsure

+ +

mxsram

+

The on-board SRAM. This device driver also supports reading and writing like a file.

+

Devices overview

+ + + + + + + + + + + + + + + + + +
Device Name\Device\mxsram
Symlink Name\DosDevices\mxsram
Userspace Name\\.\mxsram
Device GUID
+

IO control codes

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IOCTL Code#defineBytes inBytes outMeaning
0x70000IOCTL_DISK_GET_DRIVE_GEOMETRY018h
0x7405cIOCTL_DISK_GET_LENGTH_INFO08
0x9c406000{{ ioctl("0x9c406000") }}Ping
0x9c406004{{ ioctl("0x9c406004") }}Get sector size
0x9c406008{{ ioctl("0x9c406008") }}Get version
+

Ports used

+ + +

mxsram_pci_isa_bridge

+

mxsram_pci_isa_bridge is unknown currently

+ +

mxsram_pcmcia

+

mxsram_pcmcia is unknown currently

+ +

mxsuperio

+

This driver communicates with some additional on-board devices. Notably EEPROM and the W83791D hardware monitor.

+

Devices overview

+ + + + + + + + + + + + + + + + + +
Device Name\Device\mxsuperio
Symlink Name\DosDevices\mxsuperio
Userspace Name\\.\mxsuperio
Device GUID
+

IO control codes

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IOCTL Code#defineBytes inBytes outMeaning
0x9c406000{{ ioctl("0x9c406000") }}Ping
0x9c402004{{ ioctl("0x9c402004") }}Read
0x9c40a008{{ ioctl("0x9c40a008") }}Write
0x9c40200c{{ ioctl("0x9c40200c") }}Hardware monitor Read
0x9c40a010{{ ioctl("0x9c40a010") }}Hardware monitor write
+

Ports used

+ + +

mxusbdevice

+

mxsram_pcmcia is unknown currently

+ {% endblock %} \ No newline at end of file