<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.ndwiki.org/index.php?action=history&amp;feed=atom&amp;title=README-CODING-IO</id>
	<title>README-CODING-IO - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.ndwiki.org/index.php?action=history&amp;feed=atom&amp;title=README-CODING-IO"/>
	<link rel="alternate" type="text/html" href="https://www.ndwiki.org/index.php?title=README-CODING-IO&amp;action=history"/>
	<updated>2026-05-09T10:19:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://www.ndwiki.org/index.php?title=README-CODING-IO&amp;diff=2821&amp;oldid=prev</id>
		<title>Tingo: added Category</title>
		<link rel="alternate" type="text/html" href="https://www.ndwiki.org/index.php?title=README-CODING-IO&amp;diff=2821&amp;oldid=prev"/>
		<updated>2016-06-07T22:05:47Z</updated>

		<summary type="html">&lt;p&gt;added Category&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:05, 7 June 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l64&quot;&gt;Line 64:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 64:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Since the function called for IOX is passed the IOX number as its&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Since the function called for IOX is passed the IOX number as its&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;only parameter, every device can thus find it&amp;#039;s own datastructure.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;only parameter, every device can thus find it&amp;#039;s own datastructure.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:ND100 emulator project]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Tingo</name></author>
	</entry>
	<entry>
		<id>https://www.ndwiki.org/index.php?title=README-CODING-IO&amp;diff=1639&amp;oldid=prev</id>
		<title>Roger: Created page with &quot;==Coding for the IO/devices part of nd100em== To code for nd100em this document gives some information on how to add functionality easily to the emulator.  IO functionality is ba...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.ndwiki.org/index.php?title=README-CODING-IO&amp;diff=1639&amp;oldid=prev"/>
		<updated>2011-07-15T06:15:29Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Coding for the IO/devices part of nd100em== To code for nd100em this document gives some information on how to add functionality easily to the emulator.  IO functionality is ba...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Coding for the IO/devices part of nd100em==&lt;br /&gt;
To code for nd100em this document gives some information on&lt;br /&gt;
how to add functionality easily to the emulator.&lt;br /&gt;
&lt;br /&gt;
IO functionality is basically done in two steps. The main&lt;br /&gt;
cpu threads executes IOX calls and thus for a device you&lt;br /&gt;
need a function for these IOX calls that return suitable&lt;br /&gt;
values or sets variables for the device. The actual device&lt;br /&gt;
then runs as a separate thread and does the real work.&lt;br /&gt;
To avoid race conditions we use a semaphore whenever we&lt;br /&gt;
access information in the common device structure created for&lt;br /&gt;
that device.&lt;br /&gt;
&lt;br /&gt;
To add a new thread there is basically 2 functions we need&lt;br /&gt;
to consider:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pthread_t add_thread(void *funcpointer, bool is_jointype);&lt;br /&gt;
void start_threads(void);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The first one is the one actually initializing and starting the&lt;br /&gt;
thread, and the second is the main point where the emulator starts&lt;br /&gt;
all needed threads. This is where we would add a new device thread.&lt;br /&gt;
add_thread is called with two parameters:&lt;br /&gt;
* a pointer to our function, which from now on will run as a separate thread.&lt;br /&gt;
* and a boolean variable that if true tells the emulator the thread be waited for to join when it quits. If zero it is instead killed.&lt;br /&gt;
&lt;br /&gt;
For example, the main cpu routine thread addition looks like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
thread_id = add_thread(&amp;amp;cpu_thread,1);&lt;br /&gt;
if (debug) fprintf(debugfile,&amp;quot;Added thread id: %d as cpu_thread\n&amp;quot;,thread_id);&lt;br /&gt;
if (debug) fflush(debugfile);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The main functionality for the cpu thread is done in another way.&lt;br /&gt;
Basically we have one array of 64k containing functionpointers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void (*ioarr[65536])(ushort);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
They are default initialised to a default function that fails&lt;br /&gt;
the IOX call after ~ 10uSec, as per real ND100 behaviour:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void Default_IO(ushort ioadd);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The routine that adds new IOX &amp;quot;device&amp;quot; functions is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void Setup_IO_Handlers ();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We can take an example from currently added devices, the&lt;br /&gt;
onboard rtc on the cpu clock. It resides at IOX 10-13 octal,&lt;br /&gt;
and to add that one we have in the above routine:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
IO_Handler_Add(8,11,&amp;amp;RTC_IO,NULL);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The parameters are start IO address, end IO adress (decimal),&lt;br /&gt;
pointer to function that handles device, and pointer to device&lt;br /&gt;
data structure. Last one is however not implemented, but thats&lt;br /&gt;
the way we will go.&lt;br /&gt;
&lt;br /&gt;
We also have then the structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void (*iodata[65536]);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This if for the future IO device handling, as it allows reusing&lt;br /&gt;
the same function for multiple identical devices.&lt;br /&gt;
Since the function called for IOX is passed the IOX number as its&lt;br /&gt;
only parameter, every device can thus find it&amp;#039;s own datastructure.&lt;/div&gt;</summary>
		<author><name>Roger</name></author>
	</entry>
</feed>