Driver docs

This commit is contained in:
Bottersnike 2022-04-25 01:47:34 +01:00
parent b30e4e8ac5
commit 5811482b4a
2 changed files with 600 additions and 9 deletions

47
docs.py
View File

@ -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

View File

@ -3,4 +3,566 @@
{% block body %}
<h1>Drivers</h1>
{{ generate_toc()|safe }}
<p>Ring* systems makes use of a number of (mostly) bespoke drivers, listed below:</p>
<ul>
<li><code>columba.sys</code></li>
<li><code>mxcmos.sys</code></li>
<li><code>mxhwreset.sys</code></li>
<li><code>mxjvs.sys</code></li>
<li><code>mxparallel.sys</code></li>
<li><code>mxsmbus.sys</code></li>
<li><code>mxsram.sys</code></li>
<li><code>mxsram_pci_isa_bridge.sys</code></li>
<li><code>mxsram_pcmcia.sys</code></li>
<li><code>mxsuperio.sys</code></li>
<li><code>mxusbdevice.sys</code></li>
</ul>
<!-- Notes for table generation:
Device Name: `IoCreateDevice` third argument
Symlink Name: `IoCreateSymbolicLink` first argument
Username Name:
Device GUID: `IoRegisterDeviceInterface` second argument
Major functions:
00: Create
01: Create named pipe
02: Close
03: Read
04: Write
05: Query info
06: Set info
07: Query EA
08: Set EA
09: Flush buffers
0a: Query vol info
0b: Set vol info
0c: Dir ctrl
0d: FS ctrl
0e: Device ctrl
0f: Internal device ctrl
10: Shutdown
11: Lock ctrl
12: Cleanup
13: Create mailslot
14: Query security
15: Set security
16: Power
17: System ctrl
18: Device change
19: Query quota
1a: Set quota
1b: PNP
Ports used:
*_PORT_*
-->
<h2 id="columba">columna</h2>
<p>Columba is a driver used to fetch DMI information about the current system.</p>
<h3>Devices overview</h3>
<table>
<tr>
<td>Device Name</td>
<td><code>\Device\columba</code></td>
</tr>
<tr>
<td>Symlink Name</td>
<td><code>\DosDevices\columba</code></td>
</tr>
<tr>
<td>Userspace Name</td>
<td><code>\\.\columba</code></td>
</tr>
<tr>
<td>Device GUID</td>
<td></td>
</tr>
</table>
<h3>IO control codes</h3>
<table>
<thead>
<tr>
<td>IOCTL Code</td>
<td>#define</td>
<td>Bytes in</td>
<td>Bytes out</td>
<td>Meaning</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>0x9c406104</code></td>
<td><code>{{ ioctl("0x9c406104") }}</code></td>
<td></td>
<td></td>
<td>Read the DMI at a given offset</td>
</tr>
</tbody>
</table>
<h2 id="mxcmos">mxcmos</h2>
<p>mxcmos is unknown currently</p>
<h2 id="mxhwreset">mxhwreset</h2>
<p>mxhwreset is </p>
<h3>Devices overview</h3>
<table>
<tr>
<td>Device Name</td>
<td><code>\Device\mxhwreset</code></td>
</tr>
<tr>
<td>Symlink Name</td>
<td><code>\DosDevices\mxhwreset</code></td>
</tr>
<tr>
<td>Userspace Name</td>
<td><code>\\.\mxhwreset</code></td>
</tr>
<tr>
<td>Device GUID</td>
<td></td>
</tr>
</table>
<h3>IO control codes</h3>
<table>
<thead>
<tr>
<td>IOCTL Code</td>
<td>#define</td>
<td>Bytes in</td>
<td>Bytes out</td>
<td>Meaning</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>0x9c402000</code></td>
<td><code>{{ ioctl("0x9c402000") }}</code></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<h3>Ports used</h3>
<ul>
<li><code>0xcf9</code></li>
</ul>
<h2 id="mxjvs">mxjvs</h2>
<p>mxjvs is the driver used to communicate with the JVS IO board connected to the Ring* PC via the JVS USB port.</p>
<h3>Devices overview</h3>
<table>
<tr>
<td>Device Name</td>
<td><code>\Device\mxjvs</code></td>
</tr>
<tr>
<td>Symlink Name</td>
<td><code>\DosDevices\mxjvs</code></td>
</tr>
<tr>
<td>Userspace Name</td>
<td><code>\\.\mxjvs</code></td>
</tr>
<tr>
<td>Device GUID</td>
<td></td>
</tr>
</table>
<h3>IO control codes</h3>
<table>
<thead>
<tr>
<td>IOCTL Code</td>
<td>#define</td>
<td>Bytes in</td>
<td>Bytes out</td>
<td>Meaning</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>0x9c402000</code></td>
<td><code>{{ ioctl("0x9c402000") }}</code></td>
<td><em>variable</em></td>
<td><em>variable</em></td>
<td>Exchange JVS packets with the JVS IO board</td>
</tr>
</tbody>
</table>
<h3>Extra values used, currently unknown</h3>
<ul>
<li><code>\Device\Serial3</code></li>
<li><code>86e0d1e0-8089-11d0-9ce4-08003e301f73</code></li>
</ul>
<h2 id="mxparallel">mxparallel</h2>
<p>mxparallel is a wrapper driver for the parallel port used to communicate with the keychip</p>
<h3>Devices overview</h3>
<table>
<tr>
<td>Device Name</td>
<td><code>\Device\mxparallel</code></td>
</tr>
<tr>
<td>Symlink Name</td>
<td><code>\DosDevices\mxparallel</code></td>
</tr>
<tr>
<td>Userspace Name</td>
<td><code>\\.\mxparallel</code></td>
</tr>
<tr>
<td>Device GUID</td>
<td></td>
</tr>
</table>
<h3>IO control codes</h3>
<table>
<thead>
<tr>
<td>IOCTL Code</td>
<td>#define</td>
<td>Bytes in</td>
<td>Bytes out</td>
<td>Meaning</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>0x9c40a000</code></td>
<td><code>{{ ioctl("0x9c40a000") }}</code></td>
<td></td>
<td></td>
<td>Write data</td>
</tr>
<tr>
<td><code>0x9c406004</code></td>
<td><code>{{ ioctl("0x9c406004") }}</code></td>
<td></td>
<td></td>
<td>Read data</td>
</tr>
<tr>
<td><code>0x9c40a008</code></td>
<td><code>{{ ioctl("0x9c40a008") }}</code></td>
<td></td>
<td></td>
<td>Write status</td>
</tr>
<tr>
<td><code>0x9c40600c</code></td>
<td><code>{{ ioctl("0x9c40600c") }}</code></td>
<td></td>
<td></td>
<td>Read status</td>
</tr>
<tr>
<td><code>0x9c40a010</code></td>
<td><code>{{ ioctl("0x9c40a010") }}</code></td>
<td></td>
<td></td>
<td>Write control</td>
</tr>
<tr>
<td><code>0x9c406014</code></td>
<td><code>{{ ioctl("0x9c406014") }}</code></td>
<td></td>
<td></td>
<td>Read control</td>
</tr>
<tr>
<td><code>0x9c40a018</code></td>
<td><code>{{ ioctl("0x9c40a018") }}</code></td>
<td></td>
<td></td>
<td>Write flags</td>
</tr>
<tr>
<td><code>0x9c40601c</code></td>
<td><code>{{ ioctl("0x9c40601c") }}</code></td>
<td></td>
<td></td>
<td>Read flags</td>
</tr>
</tbody>
</table>
<h3>Ports used</h3>
<ul>
<li><code>\Device\ParallelPort0</code></li>
</ul>
<h2 id="mxsmbus">mxsmbus</h2>
<p>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:</p>
<table>
<tr>
<td>RingWide</td>
<td>Intel(R) 82801G(ICH7 Family)SMBus Controller</td>
</tr>
<tr>
<td>RingEdge</td>
<td>Intel(R) ICH9 SMBus Controller</td>
</tr>
<tr>
<td>RingEdge 2</td>
<td>Intel(R) 5 Series/3400 Series Chipset Family SMBus Controller</td>
</tr>
</table>
<p>Devices currently confirmed to be located on the system message bus:</p>
<table>
<thead>
<tr>
<td>Address</td>
<td>Device</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>0x20</code></td>
<td>PCA9535; used for DIP switches</td>
</tr>
<tr>
<td><code>0x30</code></td>
<td></td>
</tr>
<tr>
<td><code>0x55</code></td>
<td></td>
</tr>
<tr>
<td><code>0x57</code></td>
<td>EEPROM</td>
</tr>
</tbody>
</table>
<h3>Devices overview</h3>
<table>
<tr>
<td>Device Name</td>
<td><code>\Device\mxsmbus</code></td>
</tr>
<tr>
<td>Symlink Name</td>
<td><code>\DosDevices\mxsmbus</code></td>
</tr>
<tr>
<td>Userspace Name</td>
<td><code>\\.\mxsmbus</code></td>
</tr>
<tr>
<td>Device GUID</td>
<td><code>5c49e1fe-3fec-4b8d-a4b5-76be7025d842</code></td>
</tr>
</table>
<h3>IO control codes</h3>
<table>
<thead>
<tr>
<td>IOCTL Code</td>
<td>#define</td>
<td>Bytes in</td>
<td>Bytes out</td>
<td>Meaning</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>0x9c406000</code></td>
<td><code>{{ ioctl("0x9c406000") }}</code></td>
<td>0</td>
<td>4</td>
<td>Not totally understood, but appears to retrieve the port number</td>
</tr>
<tr>
<td><code>0x9c402004</code></td>
<td><code>{{ ioctl("0x9c402004") }}</code></td>
<td>25<sub>h</sub></td>
<td>25<sub>h</sub></td>
<td>Exchange data over the smbus</td>
</tr>
<tr>
<td><code>0x9c406008</code></td>
<td><code>{{ ioctl("0x9c406008") }}</code></td>
<td>0</td>
<td>4</td>
<td>Retrieve the driver version</td>
</tr>
<tr>
<td><code>0x9c40200c</code></td>
<td><code>{{ ioctl("0x9c40200c") }}</code></td>
<td>27<sub>h</sub></td>
<td>27<sub>h</sub></td>
<td>Exchange data with an I2C device over the smbus</td>
</tr>
</tbody>
</table>
<h3>Ports used</h3>
<p>Unsure</p>
<h2 id="mxsram">mxsram</h2>
<p>The on-board SRAM. This device driver also supports reading and writing like a file.</p>
<h3>Devices overview</h3>
<table>
<tr>
<td>Device Name</td>
<td><code>\Device\mxsram</code></td>
</tr>
<tr>
<td>Symlink Name</td>
<td><code>\DosDevices\mxsram</code></td>
</tr>
<tr>
<td>Userspace Name</td>
<td><code>\\.\mxsram</code></td>
</tr>
<tr>
<td>Device GUID</td>
<td></td>
</tr>
</table>
<h3>IO control codes</h3>
<table>
<thead>
<tr>
<td>IOCTL Code</td>
<td>#define</td>
<td>Bytes in</td>
<td>Bytes out</td>
<td>Meaning</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>0x70000</code></td>
<td><code>IOCTL_DISK_GET_DRIVE_GEOMETRY</code></td>
<td>0</td>
<td>18<sub>h</sub></td>
<td></td>
</tr>
<tr>
<td><code>0x7405c</code></td>
<td><code>IOCTL_DISK_GET_LENGTH_INFO</code></td>
<td>0</td>
<td>8</td>
<td></td>
</tr>
<tr>
<td><code>0x9c406000</code></td>
<td><code>{{ ioctl("0x9c406000") }}</code></td>
<td></td>
<td></td>
<td>Ping</td>
</tr>
<tr>
<td><code>0x9c406004</code></td>
<td><code>{{ ioctl("0x9c406004") }}</code></td>
<td></td>
<td></td>
<td>Get sector size</td>
</tr>
<tr>
<td><code>0x9c406008</code></td>
<td><code>{{ ioctl("0x9c406008") }}</code></td>
<td></td>
<td></td>
<td>Get version</td>
</tr>
</tbody>
</table>
<h3>Ports used</h3>
<ul>
<li><code>\Device\memcard0</code></li>
</ul>
<h2 id="mxsram_pci_isa_bridge">mxsram_pci_isa_bridge</h2>
<p>mxsram_pci_isa_bridge is unknown currently</p>
<h2 id="mxsram_pcmcia">mxsram_pcmcia</h2>
<p>mxsram_pcmcia is unknown currently</p>
<h2 id="mxsuperio">mxsuperio</h2>
<p>This driver communicates with some additional on-board devices. Notably EEPROM and the W83791D hardware monitor.</p>
<h3>Devices overview</h3>
<table>
<tr>
<td>Device Name</td>
<td><code>\Device\mxsuperio</code></td>
</tr>
<tr>
<td>Symlink Name</td>
<td><code>\DosDevices\mxsuperio</code></td>
</tr>
<tr>
<td>Userspace Name</td>
<td><code>\\.\mxsuperio</code></td>
</tr>
<tr>
<td>Device GUID</td>
<td></td>
</tr>
</table>
<h3>IO control codes</h3>
<table>
<thead>
<tr>
<td>IOCTL Code</td>
<td>#define</td>
<td>Bytes in</td>
<td>Bytes out</td>
<td>Meaning</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>0x9c406000</code></td>
<td><code>{{ ioctl("0x9c406000") }}</code></td>
<td></td>
<td></td>
<td>Ping</td>
</tr>
<tr>
<td><code>0x9c402004</code></td>
<td><code>{{ ioctl("0x9c402004") }}</code></td>
<td></td>
<td></td>
<td>Read</td>
</tr>
<tr>
<td><code>0x9c40a008</code></td>
<td><code>{{ ioctl("0x9c40a008") }}</code></td>
<td></td>
<td></td>
<td>Write</td>
</tr>
<tr>
<td><code>0x9c40200c</code></td>
<td><code>{{ ioctl("0x9c40200c") }}</code></td>
<td></td>
<td></td>
<td>Hardware monitor Read</td>
</tr>
<tr>
<td><code>0x9c40a010</code></td>
<td><code>{{ ioctl("0x9c40a010") }}</code></td>
<td></td>
<td></td>
<td>Hardware monitor write</td>
</tr>
</tbody>
</table>
<h3>Ports used</h3>
<ul>
<li><code></code></li>
</ul>
<h2 id="mxusbdevice">mxusbdevice</h2>
<p>mxsram_pcmcia is unknown currently</p>
{% endblock %}