annotate docs/articles/os9software.article @ 710:4b8f2de93c51

Added DS40 target
author boisy
date Sat, 04 Jan 2003 02:23:45 +0000
parents 1fa5fc8256cd
children 1e04ad1dfdce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
642
1fa5fc8256cd XMLify. Added makefile
roug
parents: 469
diff changeset
1 <?xml version="1.0" ?>
1fa5fc8256cd XMLify. Added makefile
roug
parents: 469
diff changeset
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
1fa5fc8256cd XMLify. Added makefile
roug
parents: 469
diff changeset
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
1fa5fc8256cd XMLify. Added makefile
roug
parents: 469
diff changeset
4 <!--
1fa5fc8256cd XMLify. Added makefile
roug
parents: 469
diff changeset
5 The author has not been contacted about adding this article to the
1fa5fc8256cd XMLify. Added makefile
roug
parents: 469
diff changeset
6 documentation set.
1fa5fc8256cd XMLify. Added makefile
roug
parents: 469
diff changeset
7 Original URL: http://www.onastick.clara.net/os9sw.htm
469
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
8 -->
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
9 <article>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
10 <articleinfo>
642
1fa5fc8256cd XMLify. Added makefile
roug
parents: 469
diff changeset
11 <author><firstname>Jon</firstname><surname>Bird</surname></author>
469
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
12 <title>Software for OS9</title>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
13 </articleinfo>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
14 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
15 There has been a fair deal of material written on using OS9, applications and
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
16 filters but very little that I have seen (in the Dragon world anyway) about
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
17 actually writing software for OS9. I think most people only tend to use it for
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
18 Stylograph and such like, because it is a completly different environent to
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
19 the Dragon in it's native mode and can to be honest pretty horrendous to get
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
20 to grips with on a normal 64K Dragon. Originally I intended to cover this as
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
21 part of the stuff I've been writing on connecting PC's/Dragons but it's such a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
22 big subject I thought breaking it out separatly would be better. Therefore,
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
23 I'll also cover device drivers and stuff like that in support of the PC thing,
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
24 because OS9 gets a lot better and easier to use by the addition of say an 80
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
25 column screen and hard disk.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
26 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
27 <section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
28 <title>DragonDOS vs OS9</title>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
29 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
30 Trying to explain the difference between a Dragon running normal BASIC/DOS and
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
31 one running OS9 is difficult if you have not used one or the other. However,
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
32 for the programmer the Dragon is ideal, because you get the best of both
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
33 worlds, in 'native' mode where you can program and do exactly what you want
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
34 with the machine and under OS9 where things are a lot more tightly managed by
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
35 the operating system which is a lot more how it is becoming with Windows and
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
36 such like.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
37 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
38 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
39 Essentially, OS9 is composed of a set of 'building blocks' and can easily be
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
40 expanded by adding or changing another building block or module. A completly
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
41 minmimal setup would therefore consist of the OS9 kernel (called OS9p1 &amp; OS9p2
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
42 on a Dragon) which is just a block of core procedures required to manage the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
43 system. It has no idea of keyboards, disks or screens or any input/output come
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
44 to that and does not even come with any sort of command interpretor (the shell
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
45 utility performs this which is a seperate entity in its own right). In fact on
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
46 its own it is pretty much useless on an ordinary home computer. However, OS9
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
47 has found its home (as many of the books on it will tell you) in lots of real
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
48 time applications, where there is no need for direct human interaction.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
49 However, for most of use some sort of interaction is reqired so you will find
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
50 a dedicated module for handling all I/O (called the IO Manager (or IOMAN for
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
51 short)) and further modules for dealing with specific types of IO. As an
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
52 example, standard OS9 is shipped with two file managers, the Sequential File
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
53 Manager (SCFMan) which manages all sequential types of devices, such as the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
54 keyboard, screen and knows all about sequential type peripherals, such as
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
55 delete keys, carriage return and other line editing functions. The other file
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
56 manager is the Random Block File Manager (RBFMan) which looks after random
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
57 block type devices, such as disks. This knows all about what an OS9 disks
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
58 looks like, what makes up a file and how to find it. Finally, there are the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
59 drivers, which actually talk to the hardware, and on the Dragon are
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
60 specifically designed for the Dragon's hardware. For example, DDISK the Dragon
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
61 device driver, knows how to talk to the disk controller chip to read a bit of
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
62 the disk. On the other hand, it does not know what a file is. Right at the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
63 bottom of the change are the device descriptors, which are basicly blocks of
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
64 memory to tell the system, this is disk drive 0, it uses DDISK to talk to the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
65 disk controller, and RBFMan is it's file manager. A common data flow would
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
66 therefore look something like:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
67 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
68 Your OS9 Program says:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
69 'read 100 bytes from path number n'
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
70
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
71 Which is passed to IOMAN as:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
72 'read 100 bytes from path number n'
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
73 which determines that RBFMan is responsible for path n:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
74
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
75 Which is passed to RBFMan as:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
76 'read 100 bytes from path number n'
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
77 who knows all about what path n is, and where to get those
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
78 100 bytes from:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
79
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
80 Which is then passed to DDISk as:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
81 'read sector m'
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
82 which actually gets the disk controller to read the data
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
83 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
84 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
85 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
86 This collection of modules forms, in equivalent Dragon terms the BASIC &amp; DOS
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
87 ROM starting at 32768 ($8000) onwards. On its own, they provide little more
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
88 than procedures and subroutines for using your machine.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
89 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
90 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
91 In order to utilise these routines, and actually get your machine doing some
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
92 useful work, some sort of user friendly interface is needed to talk to the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
93 user, under OS9 a program called Shell is provided to do this, and the BASIC
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
94 interpretor provides this facility under normal DragonDOS mode. They both work
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
95 in a similar manner: each has a set of internal commands which it understands
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
96 and can execute, and each has the ability to run external programs. For
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
97 example, under Dragon BASIC the line:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
98 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
99 PRINT "HELLO WORLD"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
100 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
101 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
102 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
103 is effectivly running at internal program within the interpretor called PRINT.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
104 Likewise with the OS9 Shell:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
105 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
106 chd /d0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
107 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
108 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
109 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
110 is understood by the Shell to mean 'change directory to drive D0' and runs the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
111 internal code required to perform this operation.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
112 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
113 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
114 In order to run a program external to the BASIC interpretor, you need to tell
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
115 it explicitly, as in:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
116 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
117 RUN "MYPROG"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
118 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
119 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
120 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
121 Tells it that MYPROG.BAS is not part of the on board ROM, and that it has to
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
122 go away and fetch it from somewhere else (in this case the disk). The Shell
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
123 works slightly differently, in that any command you type which is not
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
124 recognized by the Shell itself means that is will go away and attempt to find
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
125 it externally. For example:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
126 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
127 dir /d1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
128 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
129 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
130 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
131 The DIR command is not recognized by the Shell, therefore it automatically
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
132 attempts to load and run it from elsewhere. The Shell itself contains
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
133 relativly few in-built commands (unlike the BASIC interpretor) and so for the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
134 majority of things will be forcing the execution of an external program.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
135 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
136 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
137 One of the utility programs shipped with Dragon OS9 is MDIR which simply
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
138 provides a list of things in memory, or a very simplified OS9 memory map. When
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
139 I run it on my system I get something like the following:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
140 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
141 Module Directory at 10:47:24
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
142 ADDR SIZE TY RV AT UC NAME
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
143 ---- ---- -- -- -- -- ---------
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
144 F05E 7E7 C1 1 r OS9
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
145 F853 4FC C1 1 r 1 OS9p2
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
146 FD4F 2E C0 1 r 1 Init
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
147 FD7D 182 C1 1 r 1 BooT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
148 BF00 122 C1 4 r 1 SYSGO
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
149 C022 101 C1 1 r 1 Clock
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
150 C123 6E7 C1 1 r 1 IOMan
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
151 C80A CF5 D1 1 r 1 Rbf
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
152 D4FF 40E D1 1 r 2 Scf
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
153 D90D 1FF D1 1 r PipeMan
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
154 DB0C 5E2 E1 7 r Ddisk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
155 E0EE 3AF E1 6 r 2 Kbvdio
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
156 E49D 8D E1 1 r Printer
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
157 E52A 28 E1 1 r Piper
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
158 E552 2E F1 1 r D0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
159 E580 2E F1 2 r D1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
160 E5AE 3C F1 1 r 2 Term
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
161 E5EA 3A F1 1 r P
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
162 E624 26 F1 1 r Pipe
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
163 E64A 4FA 11 1 r 2 Shell
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
164 EB44 121 E1 3 r 1 Rdisk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
165 EC65 2E F1 1 r 1 R0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
166 EC93 160 E1 1 r PC_Disk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
167 EDF3 30 F1 1 r H0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
168 5A00 1A6 11 1 r 1 Mdir
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
169 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
170 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
171 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
172 The majority of these modules are the drivers, managers and general routines
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
173 that make up the 'core' of the OS9 system. In fact, the only programs as such
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
174 are the Shell, and the MDIR program itself. One of the things to note, is that
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
175 if you run MDIR on your OS9 system, it would almost certainly look different:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
176 not only would you probably have different drivers, they would almost
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
177 certainly appear in different areas of memory. This is one of the key
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
178 differences between OS9 and normal Dragon BASIC mode, that any program written
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
179 for OS9 does not know where it will be in memory and therefore has to be
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
180 written to be run from any location in memory. One of the side effects of this
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
181 is that code modules in OS9 will probably tend to execute slower that a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
182 DragonDOS counterpart. Part of this is also due to the fact that within the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
183 Dragon BASIC/DOS ROM routines always lie at fixed addresses, and can be called
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
184 quickly. OS9 programs have to perform more complex indexing operations to find
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
185 routines. Therefore, OS9 always seems considerably more slower and therefore
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
186 more painful to work with than DragonDOS.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
187 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
188 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
189 To see this, and some of the pros and cons of writing programs for each
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
190 system, here is a couple of 'hello world' routines for each system. Firstly,
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
191 the Dragon assembler version - this assumes DASM to be the assembler:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
192 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
193 10 EXEC &amp;H6C00
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
194 20 ALL
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
195 30 @MSG FCC 0,"HELLO WORLD",0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
196 40 @START LDX #@MSG
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
197 50 JSR $90E5
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
198 60 RTS
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
199 70 END @START
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
200 80 EXEC
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
201 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
202 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
203 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
204 It is a fairly simple piece of code, and also fairly easy to write, assemble
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
205 and get running. Firstly, DASM is loaded from disk, you write the code much
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
206 like a BASIC program using all the normal BASIC editor functions then just run
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
207 it. The program itself makes use of a standard ROM routine, which prints a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
208 string pointed to by the X register. The 'END' statement at line 70 puts the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
209 starting address into the default EXEC location, which is then called by line
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
210 80.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
211 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
212 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
213 Onto the OS9 version then:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
214 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
215 nam WORLD
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
216 ttl Hello World program
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
217
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
218 ifp1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
219 use /d0/defs/os9defs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
220 endc
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
221
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
222 *Data area
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
223 org 0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
224 stack rmb 200
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
225 datsiz equ .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
226
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
227 *Module header
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
228 type equ PRGRM+OBJCT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
229 revs equ REENT+1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
230 mod length,name,type,revs,start,datsiz
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
231 name fcs /WORLD/
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
232 msg fcc /Hello World/
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
233 fcb 13
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
234
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
235 *main code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
236 start leax msg,pcr
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
237 ldy #12
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
238 lda #1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
239 os9 i$writln
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
240 bcs error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
241 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
242 error os9 f$exit
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
243
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
244 emod
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
245
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
246 length equ *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
247 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
248 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
249 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
250 One of the first problems is actually getting an environment to write this in.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
251 Dragon OS9 comes with an edit command, which in all honestly is complete
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
252 rubbish and I'd suggest you use Stylo or another editor. I use a program
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
253 called 'ed' which is based on the Unix 'vi' editor. Once you've written it,
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
254 saved it to disk, you can assemble it using the OS9 assembler:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
255 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
256 asm world #20k
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
257 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
258 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
259 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
260 Assumes you've saved the file as world. Assuming all goes well, you will end
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
261 up with a file called 'world' in your default execution directory (typically
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
262 /d0/cmds). However, it is the norm for OS9 (I have found anyway) that things
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
263 are not often that straightforward. Firstly, you may find you don't actually
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
264 have a copy of the 'asm' program, and even if you do the program you have just
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
265 written requires an additional file (called up by the 'use /d0/defs/os9defs'
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
266 statement) which may or may not be on your disk. Either way, you will probably
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
267 end up searching through a variety of disks in order to get the files required
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
268 to the right place. Once you have, and a great deal of disk chugging later
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
269 with any luck, simply typing 'world' at the OS9 shell prompt, should once
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
270 again after a bit of disk chugging display the message 'hello world' on your
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
271 screen.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
272 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
273 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
274 So how does it all work, and is it all worth it. Firstly, the NAM and TTL
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
275 directives just tell the assembler the name and title of your program and are
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
276 not strictly required. Next, there is an assembler directive to include the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
277 file /d0/defs/os9defs but only on pass one (the IFP1 condition) of the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
278 assembly. This file contains a list of definitions about OS9 and is almost
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
279 always required for any OS9 module. Whilst you can get away without it, for
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
280 general neatness and code readability it's a good idea to use it. For example,
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
281 in our simple program, the words PRGRM, OBJCT, i$write and f$exit are all
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
282 definitions from os9defs.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
283 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
284 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
285 Next the program's data area is defined, which as a minimum should define at
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
286 least 200 bytes for the stack (I'll cover data areas later). Following this,
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
287 information for the programs module header is defined. In OS9, each program
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
288 unit or module must conform to a specific format in order for OS9 to recognize
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
289 it and successfully execute it. In particular, it contains information about
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
290 the execution address, how much data size is required and also a checksum of
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
291 the whole module. All this minimizes the risk of trying to run corrupted or
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
292 invalid code. The 'mod' assembler directive tells the assembler to form this
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
293 header using the information provided. This requires the overall length of the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
294 module then a pointer to the name of the module. Next are two equates defined
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
295 as TYPE and REVS. The TYPE equate is a single byte defining the module type
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
296 and language and is preset to a normal program module (PRGRM) and 6809-object
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
297 code (OBJCT). The REVS equate is a single byte defining the module attributes
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
298 and revision level. It has an attribute of sharable (REENT) and a revision
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
299 level of 1. The final two parameters are the start address and overall module
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
300 data size.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
301 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
302 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
303 Following the module header is the module name. The FCS directive is much like
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
304 the FCC directive except the top bit of the last character is the string is
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
305 set. This is often used by OS9 to indicate the end of a string. Finally, the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
306 main code for the program occurs.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
307 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
308 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
309 The code make use of the OS9 system call i$writln. In order to make a system
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
310 call, the assembler directive 'os9' is used followed by the call name. All the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
311 valid OS9 call names are defined in the os9defs file. OS9 system calls are
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
312 made through one of the software interrupts, in this case SWI2 followed by a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
313 unique code identifying the call number. Therefore, the assembler directive
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
314 'os9 i$writln' translates into 'SWI2 $8C' where $8C is the i$writln code.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
315 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
316 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
317 This call is much like the ROM call at $90E5, where the X register points to
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
318 the string to display. In addition, however the Y register should also contain
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
319 the maximum number of characters to display and the A register should contain
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
320 the path number. A path number of 1 refers to the standard output - the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
321 display. The call will then display the required number of characters, or up
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
322 to the first carriage return - whichever occurs sooner. On completion of the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
323 call, the carry bit is set if an error has occured with the error number in
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
324 the B register. Finally, the routine is terminated with a call to the F$EXIT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
325 routine not an RTS instruction.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
326 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
327 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
328 Once the code is complete, the EMOD statement indicates that this is the end
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
329 of the module, and generates the module's checksum and then the length label
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
330 is calculated.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
331 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
332 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
333 This program also gives an example writing position independent code ie. code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
334 that can be executed anywhere in memory. Note how the X register in the os9
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
335 example is set to point to the string compared to the DragonDOS one:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
336 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
337 DDOS: LDX #@MSG - absolute address of MSG
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
338 OS9: leax msg,pcr - relative address of MSG
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
339 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
340 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
341 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
342 The OS9 variant sets X to point to the MSG label relative to the current
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
343 program counter ie. whereever you are in memory. The DragonDOS one specifies
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
344 the absolute address in memory. This means that with the DragonDOS code you
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
345 are forced to have your program at this location in order for it to work. Of
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
346 course, you could replace your DragonDOS one with the same instruction as the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
347 OS9 one and make it position independent, but with OS9 you must use this
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
348 format or it will not work.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
349 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
350 </section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
351 <section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
352 <title>OS9 Advantages</title>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
353 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
354 From the last couple of articles, we have created two comparable programs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
355 under Dragon BASIC and OS9 - the now famous 'Hello World' program. However,
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
356 the steps to create the OS9 one are significantly more complex than the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
357 DragonDOS counterpart. We have already seen one of the OS9 program's
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
358 advantages - that of position independent code, though with a bit of
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
359 forethought the Dragon BASIC one can also be made position independent. Here
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
360 are a few other advantages of the OS9 variant.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
361 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
362 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
363 Suppose you wanted to print the words 'Hello World' on the printer. This can
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
364 be accomplished fairly simply under both OS9 and Dragon BASIC:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
365 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
366 Dragon BASIC: POKE 111,254:EXEC
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
367 OS9: world >/p
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
368 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
369 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
370 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
371 The Dragon BASIC variant simply sets the default IO location to 254 (-2) the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
372 printer. The OS9 one utilises the shell re-direction operator (>) to send the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
373 output to the printer. So far so good. What if you wanted to send this message
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
374 to a file for example. With standard DragonDOS, there is no easy way - later
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
375 DOS variants can use the OPEN# format:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
376 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
377 OPEN #1,"O","TEST.DAT"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
378 POKE 111,1:EXEC
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
379 CLOSE #1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
380 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
381 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
382 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
383 Once again the OS9 variant is pretty much straightforward:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
384 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
385 world >test.dat
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
386 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
387 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
388 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
389 Suppose then you have added a custom device to your system, an extra parallel
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
390 port for example for a second printer. Under OS9 all you need to do is create
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
391 a new device driver/descriptor and call it say P1. The world program can
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
392 automatically be used with your new device:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
393 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
394 world >/p1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
395 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
396 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
397 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
398 The OS9 world program can then theorhetically be run on any OS9 system and
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
399 make use of any device which is implemented on that machine.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
400 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
401 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
402 The other 'selling point' of OS9 is it's multi-tasking ability - ie. run more
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
403 than one program at once. This is all handled by the OS9 kernel routines, and
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
404 you do not need to worry about it when writing code, except to ensure your
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
405 programs are position independent, and re-entrant. A re-entrant program is all
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
406 to do with how any data your program utilises is managed and means that one
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
407 copy of a program in memory can be running a number of times with a different
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
408 set of data.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
409 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
410 </section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
411 <section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
412 <title>OS9 Data Storage</title>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
413 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
414 When you write your OS9 program, you should allocate all your data areas using
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
415 rmb directives starting at 0 eg.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
416 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
417 *Data area
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
418 org 0 specify starting at 0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
419 length rmb 2 data items for
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
420 name rmb 20 the program
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
421 next rmb 2
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
422 stack rmb 200
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
423 datsiz equ .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
424 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
425 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
426 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
427 Your program's stack is also part of this data area, so you should allocate a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
428 sufficient area for this - 200 bytes is a recommended minimum. The datsiz
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
429 label gives the total data size required for the program, and is used as part
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
430 of the module header created by the MOD assembler directive:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
431 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
432 mod length,name,type,revs,start,datsiz
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
433 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
434 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
435 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
436 When OS9 starts your program, it sets up some of the CPU registers to provide
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
437 information about your data area-
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
438 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
439 | |
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
440 | Parameter Area |
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
441 ------------------- -- X, S
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
442 | |
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
443 | |
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
444 | Data Area |
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
445 | |
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
446 -------------------
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
447 | Direct Page |
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
448 ------------------- -- U, DP (LS address)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
449 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
450 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
451 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
452 Firstly, the U and DP registers point to the start of your data area, with the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
453 stack pointer set to the top of your data area. Essentially then, you just
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
454 need to reference the U register when accessing your data variables within
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
455 your program:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
456 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
457 sty length,u stores Y into 'length'
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
458 ldx next,u loads X from 'next'
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
459 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
460 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
461 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
462 However, any data items stored within the first 256 bytes of your data area
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
463 can be accessed more quickly and efficiently by making use of the DP register.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
464 This is an 8 bit register which contains the upper 8 bits of an address. In
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
465 order to specify DP addressing with the OS9 assembler simply supply the data
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
466 label:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
467 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
468 sty length use DP addressing to
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
469 ldx next access data items
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
470 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
471 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
472 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
473 Using the data declarations used earlier:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
474 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
475 length lies at offset 0 ($00).
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
476 next lies at offset 22 ($16).
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
477 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
478 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
479 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
480 The assembler translates this into:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
481 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
482 STY $00
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
483 LDX $16
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
484 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
485 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
486 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
487 instructing the processor to use the DP register to provide the upper part of
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
488 the address. Therefore, if DP=$20 this would become:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
489 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
490 STY $2000
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
491 LDX $2016
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
492 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
493 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
494 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
495 Not only does this form of addressing take up less storage space, it is also
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
496 quicker to execute.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
497 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
498 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
499 You will still need to use the U register to set up pointers to data buffers
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
500 since you cannot use the DP register for this:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
501 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
502 leax name,u X=start of name item
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
503 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
504 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
505 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
506 There is an important difference between the way the OS9 assembler and
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
507 DragonDOS assemblers (DASM &amp; DREAM) use the DP register. By default, the OS9
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
508 assembler will use the DP register if you just enter something like:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
509 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
510 ldx next -> LDX $16
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
511 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
512 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
513 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
514 However, DragonDOS assemblers will automatically use extended addressing so
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
515 assuming @NEXT lies at address $5020.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
516 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
517 LDX #@NEXT -> LDX $5020
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
518 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
519 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
520 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
521 The assembler directive '>' is used to set extended addressing under OS9 ie.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
522 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
523 ldx >$16 -> LDX $0016
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
524 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
525 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
526 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
527 and co-incidently is used to force DP addressing under DragonDOS ie.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
528 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
529 ldx >$F0 -> LDX $F0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
530 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
531 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
532 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
533 The DP register is nearly always set to 0 under DragonDOS so you can use it to
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
534 quickly access memory locations 0-255.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
535 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
536 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
537 So, just by the kernel setting the U and DP registers to different positions
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
538 in memory the same piece of code need only be resident in memory once but can
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
539 be running in different tasks with different data areas. The REENT bit set in
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
540 the module header is used to tell OS9 that our program supports this - if you
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
541 recall:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
542 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
543 *Module header
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
544 type equ PRGRM+OBJCT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
545 revs equ REENT+1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
546 mod length,name,type,revs,start,datsiz
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
547 name fcs /WORLD/
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
548 msg fcc /Hello World/
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
549 fcb 13
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
550 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
551 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
552 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
553 The parameter area (pointed to by the X register on program entry) is utilised
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
554 to pass data to a program. If it has been started from the shell (command
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
555 line) any text following the program name will be stored here terminated by a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
556 carriage return ie.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
557 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
558 OS9:world this is a parameter
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
559 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
560 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
561 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
562 then X would point to a block of memory containing the ASCII string:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
563 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
564 this is a parameter[CR]
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
565 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
566 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
567 </section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
568 <section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
569 <title>Other Progamming Tips</title>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
570 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
571 Generally, thats about all there is to writing OS9 programs. Remember, that an
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
572 OS9 process should exit by calling os9 f$exit (with the B register containing
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
573 any error code you wish to return, or 0 for none) instead of rts. The OS9
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
574 System Programmers Manual which you should have with your copy of OS9 contains
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
575 all the system calls available. However, its worth mentioning a bit about
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
576 standard IO paths.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
577 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
578 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
579 We have already seen standard output used with the Hello World program:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
580 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
581 ldy #12
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
582 lda #1 standard output
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
583 os9 i$writln
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
584 bcs error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
585 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
586 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
587 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
588 On entry to any OS9 program 3 file paths are open:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
589 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
590 0 = Standard Input (keyboard)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
591 1 = Standard Output (screen)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
592 2 = Standard Error (screen)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
593 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
594 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
595 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
596 These may or may not correspond to screen or keyboard depending on whether the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
597 shell or other program has re-directed them ie.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
598 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
599 world >/p
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
600 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
601 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
602 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
603 forces standard output to be the printer. This means that for the duration of
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
604 your program, path number 1 is still valid but points to the printer instead.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
605 This is the premise of a lot of OS9 utilities called filters which typically
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
606 perform some kind of modification to incoming data and write the modified data
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
607 out. An example might be a program to add line feeds to a file in preparation
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
608 to porting it to another environment which requires CR/LF terminated strings
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
609 as opposed to CR which OS9 uses. The basis of the filter might be:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
610 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
611 loop
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
612 leax buffer,u point to buffer
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
613 ldy #1 1 char to read
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
614 clra from stdin
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
615 os9 i$read read byte
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
616 bcs error handle error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
617 inca set to stdout
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
618 os9 i$write write byte
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
619 bcs error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
620 ldb ,x was it a CR
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
621 cmpb #13
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
622 bne loop no, loop for next
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
623 ldb #10 write an LF
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
624 stb ,x to stdout
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
625 os9 i$write
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
626 bcs error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
627 bra loop
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
628
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
629 error cmpb #E$EOF check for EOF
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
630 bne term if not, exit with error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
631 clrb else quit ok
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
632 term os9 f$exit
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
633 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
634 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
635 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
636 Here we make use of the i$read, i$write calls which read and write 'raw' data.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
637 A byte is read from stdin and then written out again to stdout. If it was a CR
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
638 then an LF is also written to stdout. The program will terminate when an error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
639 condition occurs. If all the data is exhausted, this error will be EOF on the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
640 read which is therefore not treated as an error and causes the program to exit
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
641 without error. This is the case for all filters. Assuming the program is
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
642 assembled to the file 'addlf' an example usage could be with the stylograph
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
643 mail merge utility (mm):
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
644 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
645 mm my_doc ! addlf >/d1/my_doc.out
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
646 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
647 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
648 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
649 Here the Stylograph file 'my_doc' is output by mailmerge and piped into our
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
650 addlf utility, so stdin is redirected here from the pipe. The resulting output
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
651 (stdout) is then sent to the file 'my_doc.out'.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
652 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
653 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
654 This filter isn't very efficient, because it carries the overhead of calling
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
655 i$read/i$write for every byte. If you recall, an OS9 system call translates
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
656 into an SWI2 (software interrupt) call. This results in a lot of processing,
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
657 and also the stacking/de-stacking of all the registers required for an SWI
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
658 call. It would be far better to read the data in larger chunks and process it
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
659 in a separate loop.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
660 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
661 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
662 Note that any registers not updated explicity for output of a system call will
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
663 remain unchanged from when the call was made eg.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
664 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
665 i$read: Entry: X = Addr of data
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
666 Y = Bytes to read
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
667 A = Path number
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
668 Exit: Y = Bytes actually read
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
669 ALL OTHER REGISTERS UNCHANGED
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
670 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
671 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
672 </section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
673 <section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
674 <title>Device Drivers</title>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
675 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
676 One of the things which became apparant after the infamous 'world' routine was
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
677 that this simple program could make use of any OS9 system peripherals provided
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
678 the drivers were there for it to use. This is also true of most OS9 software -
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
679 if you have the drivers any software can use it. For example, if you added a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
680 hard drive to your system and called it H0, you could quite easily store
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
681 Stylograph on it, save your data on it, run the C compiler not to mention our
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
682 'Hello World' program. Unfortunatly, this isn't the case with DragonDOS which
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
683 is more or less tied to the pre-set Dragon hardware. So if you are planning to
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
684 add ram discs, hard discs etc. then OS9 is by far the easiest platform to
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
685 write software for. You will also probably find that writing software becomes
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
686 that much easier for OS9 once you have access to faster disk drives and maybe
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
687 an 80 column screen. It's by no means impossible to write stuff for DragonDOS
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
688 - just a lot harder thats all and I'll touch on this a bit later.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
689 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
690 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
691 The key to this flexibility really comes down to device drivers and
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
692 descriptors on an OS9 system. Generally, any device you add will fall under
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
693 the category of disk - in which case an RBF device driver is required or
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
694 sequential (serial port, printer etc.) in which case an SCF device driver is
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
695 required.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
696 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
697 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
698 Device drivers are just like any other OS9 program, they have a module header,
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
699 data area and code to perform to necessary operations. Here is a rough outline
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
700 of a device driver which is called DEVx:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
701 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
702 nam DEVx
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
703 ttl DEVx device driver
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
704
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
705 ifp1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
706 use /h0/defs/os9defs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
707 use /h0/defs/iodefs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
708 use /h0/defs/scfdefs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
709 endc
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
710
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
711 *data
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
712 org V.SCF
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
713 PST equ .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
714
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
715 type equ DRIVR+OBJCT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
716 revs equ REENT+1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
717 mod PEND,PNAM,type,revs,PENT,PST
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
718
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
719 PNAM fcs /DEVx/
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
720
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
721 PENT lbra INIT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
722 lbra READ
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
723 lbra WRITE
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
724 lbra GETSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
725 lbra PUTSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
726 lbra TERM
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
727
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
728 INIT .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
729 READ .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
730 WRITE .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
731 GETSTA .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
732 PUTSTA .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
733 TERM .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
734
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
735 emod
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
736 PEND equ *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
737 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
738 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
739 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
740 It follows the standard module structure, first the name and title of the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
741 module NAM and TTL. Then the 'use' files are given. As well as os9defs we
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
742 include iodefs which contains i/o specific definitions, and because this just
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
743 happens to be an SCF device, scfdefs are included also. Next comes the data
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
744 area, however because the file managers (RBF or SCF) also require some data,
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
745 you should not start your data area off at 0 but the V.SCF equate (or DRVBEG
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
746 for RBF devices). No stack space is required here as the stack used will be
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
747 the one from the calling program. The PST label marks the datasize of the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
748 module, and then the module header is given. Notice that the PRGRM equate is
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
749 replaced by the DRIVR equate indicating this is a device driver.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
750 The PENT label marks the start of the driver. All OS9 drivers have 5 entry
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
751 points at the module start and LBRA instructions should always be used to call
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
752 these routines which are as follows:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
753 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
754 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
755 INIT - called once on module start. Include any initialisation code required
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
756 to set your device up.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
757 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
758 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
759 READ - called to read an 'item' of data from the device. Depending on the file
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
760 manager an 'item' can be anything from 1 character (SCF devices) to a disk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
761 sector (RBF devices).
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
762 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
763 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
764 WRITE - called to write an 'item' of data to the device.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
765 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
766 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
767 GETSTA - called to perform miscellaneous IO status routines. Since all IO
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
768 devices have different capabilities this provides a method to perform
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
769 operations which generally return some sort of status back to the caller - for
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
770 example the End Of File function (EOF) is implemented via a GetStat call.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
771 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
772 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
773 SETSTA - similar to GetSta, but generally used to set some status information
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
774 on the device.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
775 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
776 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
777 TERM - called once when the module is about to be removed from memory. Include
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
778 any de-allocation of memory/clean up routines etc. here.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
779 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
780 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
781 Prior to showing a couple of example drivers, there are a few data structures
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
782 you need to be aware of when dealing with device drivers. Firstly, there is
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
783 your static storage, which can be thought of in similar terms to the data area
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
784 of a normal module. The static storage area for your device driver starts at
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
785 the V.SCF (or DRVBEG) position given in the previous header file, and
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
786 similarly to a normal OS9 program, the U register always points to this area.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
787 Note, that unlike a module's data area, you should not use DP addressing on
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
788 data items. So, if you declare a variable as such:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
789 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
790 org V.SCF
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
791 flag rmb 1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
792 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
793 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
794 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
795 it can be accessed in any of the 5 procedures as:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
796 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
797 lda flag,u
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
798 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
799 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
800 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
801 In addition to your own data held here, the system also stores some of it's
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
802 own static data just prior to the V.SCF (or DRVBEG) label which you can also
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
803 access. This consists of a 'common' area followed by a file manager specific
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
804 area. The exact format of these are listed in the System Programmers Guide
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
805 (and also in the iodefs,scf/rbfdefs files) but one of these items held in the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
806 common area which the example drivers will make use of is named V.Port and
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
807 holds the address of the physical device in memory. How this gets set up, I
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
808 will cover later but suffice to say it enables the driver to access a physical
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
809 device in memory without having to know where it is exactly. As an example, if
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
810 you had an SCF device driver to talk to MC6821 PIAs and you had 4 of these
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
811 PIAs in your system you would only need 1 copy of the driver loaded - the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
812 system would ensure V.Port is setup correctly depending on which PIA is being
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
813 accessed:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
814 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
815 lda #$FF A=255
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
816 ldx V.Port,u port address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
817 sta 1,x port address+1=255
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
818 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
819 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
820 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
821 The other data block you may need to be aware of is called the path
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
822 descriptor. This is a unique set of data for each open file or device in the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
823 system. You cannot allocate your own data items here, but you can read &amp; write
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
824 to data items here. Generally, the path descriptor holds information relevent
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
825 to the current open file or device (such as path numbers, file lengths etc.)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
826 rather than constant device characteristics (port address etc.). Again, there
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
827 is a common part of the path descriptor, and then a file manager specific
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
828 area. The format of path descriptors is also listed in the System Programmers
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
829 Guide and can also be found in the iodefs,scf/rbfdefs files. Initially, you
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
830 will not probably need to utilise anything in the path descriptor, but if you
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
831 start writing more complex drivers you almost certainly will - generally the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
832 file manager will provide most of the path descriptor management.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
833 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
834 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
835 The path descriptor is pointed to by the Y register given in the READ, WRITE,
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
836 GETSTA &amp; SETSTA procedures (remember, it only exists for an open file so will
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
837 not be accessable by the INIT &amp; TERM routines) and as such can be accessed as
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
838 follows:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
839 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
840 lda PD.PD,y A=path number from path descriptor
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
841 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
842 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
843 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
844 Last time I covered general device drivers. Next, are 2 example drivers, one
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
845 an SCF device, the other an RBF device.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
846 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
847 </section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
848 <section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
849 <title>SCF Device Driver</title>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
850 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
851 This device driver utilises an MC6821 PIA to perform character driven IO.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
852 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
853 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
854 The first section is the common module header format:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
855 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
856 *******************************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
857 * PIA21
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
858 * Device Driver for MC6821 PIAs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
859 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
860 * By J.Bird (c) 1992
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
861 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
862 * Uses Side B of MC6821 PIA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
863 * CA2 &amp; CB2 Control Strobe lines
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
864 * Non-interrupt driven
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
865 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
866
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
867 nam PIA21
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
868 ttl MC6821 PIA Device Driver
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
869
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
870 ifp1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
871 use /h0/defs/os9defs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
872 use /h0/defs/iodefs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
873 use /h0/defs/scfdefs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
874 endc
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
875
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
876 ***********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
877 * Edition History
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
878 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
879 * # date Comments
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
880 * - -------- -------------------------------
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
881 * 1 05.05.92 Driver first written. JRB
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
882 * 2 25.03.95 Update for Parallel Dragon link. JRB.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
883
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
884 Revision equ 2
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
885
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
886 PBCREG equ %00101101
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
887 PBOUTP equ %11111111
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
888 PBINP equ %00000000
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
889
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
890 org V.SCF
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
891 PST equ .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
892
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
893 mod PEND,PNAM,Drivr+Objct,Reent+Revision,PENT,PST
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
894 fcb READ.+WRITE.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
895 PNAM fcs /PIA21/
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
896
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
897 PENT lbra INIT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
898 lbra READ
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
899 lbra WRITE
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
900 lbra GETSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
901 lbra PUTSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
902 lbra TERM
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
903 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
904 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
905 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
906 This defines an SCF man device called PIA21. On a sideline note, you may have
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
907 noticed the revision number as 2, and this is built into the module header.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
908 This will ensure that if this module is loaded into memory and revision 1 is
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
909 also in memory (as part of the OS9 boot load for example) that revision 2 will
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
910 be used. Subsequently, a revision 3 would take precedence over 2 etc. etc.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
911 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
912 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
913 The following two routines will be used throughout the code to configure the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
914 port for either input or output. Note the use of the V.Port address from the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
915 static storage to find the IO port's address.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
916 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
917 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
918 * SETOUT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
919 * Set port dir for o/p
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
920 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
921 SETOUT ldx V.PORT,u load port address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
922 clr 1,x clear control reg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
923 lda #PBOUTP set port for o/p
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
924 sta ,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
925 lda #PBCREG reload ctrl reg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
926 sta 1,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
927 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
928 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
929
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
930 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
931 * SETIN ldx V.PORT,u
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
932 * Set port dir for i/p
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
933 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
934 SETIN ldx V.PORT,u
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
935 clr 1,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
936 lda #PBINP
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
937 sta ,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
938 lda #PBCREG
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
939 sta 1,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
940 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
941 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
942 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
943 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
944 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
945 The first of the device driver procedures INIT, just configures the port as
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
946 input and returns. All routines should return with B=0 and the carry bit clear
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
947 unless you wish to report an error, in which case the B register should
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
948 contain the OS9 error code. Note, that rts is used to return from a device
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
949 driver routine, not os9 f$exit as per normal OS9 programs.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
950 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
951 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
952 * INIT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
953 * Entry: U = Static storage
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
954 * Setup the PIA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
955 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
956 INIT bsr setin
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
957 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
958 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
959 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
960 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
961 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
962 The READ routine is required to fetch a data item from the IO port. For SCF
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
963 type devices, this is 1 character and should be returned in the A register.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
964 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
965 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
966 * READ
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
967 * Entry: U = Static Storage
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
968 * Y = Path Descriptor
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
969 * Exit: A = Character read
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
970 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
971 * Read a byte from Port B
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
972 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
973 READ ldx V.PORT,u load port address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
974 readlp tst 1,x test for data ready
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
975 bmi readbyte
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
976 pshs x sleep for a bit if not
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
977 ldx #10
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
978 os9 f$sleep
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
979 puls x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
980 bra readlp
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
981 readbyte lda ,x read byte
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
982 sta ,x issue strobe
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
983 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
984 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
985 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
986 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
987 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
988 The READ routine makes use of another OS9 system call - sleep. On entry, X
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
989 should contain the number of clock cycles to sleep for (clock cycle = 1/50
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
990 second on the Dragon). This is not strictly required, however when an IO
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
991 request is performed OS9 prevents any other process from running until it
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
992 completes or executes a sleep request. For example, if you had a process
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
993 running as a background task using this device and the device stalled (ie. it
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
994 never became ready) your machine would lockup. By sleeping for a short while
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
995 between checks you ensure this cannot happen.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
996 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
997 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
998 The WRITE routine acts in a similar way to READ, except the character passed
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
999 in the A register should be written to the port:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1000 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1001 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1002 * WRITE
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1003 * Entry: U = Static storage
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1004 * Y = Path Descriptor
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1005 * A = Char to write
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1006 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1007 * Write a byte to Port B
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1008 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1009 WRITE ldx V.PORT,U load port address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1010 sta ,x write byte
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1011 writlp tst 1,x wait for ack
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1012 bmi wrt
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1013 pshs x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1014 ldx #1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1015 os9 f$sleep
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1016 puls x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1017 bra writlp
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1018 wrt lda ,x clear control reg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1019 ok clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1020 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1021 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1022 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1023 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1024 The next two routines demonstrate device driver usage of the GetStat and
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1025 SetStat calls and also the path descriptor.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1026 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1027 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1028 There are a few predefined GetStat calls under OS9 which nearly all SCF device
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1029 drivers will have to deal with. These are Test for Data Ready and Test for End
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1030 Of File. The predefined GetStat codes are defined in the OS9Defs file but be
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1031 warned: a lot are device dependent and will not be implemented. Generally,
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1032 only the ones listed above are available on all SCF devices.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1033 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1034 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1035 GetStat calls are made by the caller by issuing an OS9 i$getstt call with the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1036 A register containing the path number and the B register containing the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1037 GetStat code - the other register contents depend on the GetStat call being
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1038 made. This example program loops until data is available from the keyboard:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1039 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1040 chklp clra pathnum of stdin
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1041 ldb #SS.Ready getstat code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1042 os9 i$getstt issue call
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1043 bcc okay if c bit clear data is rdy
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1044 cmpb #E$NRDY otherwise check the code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1045 bne error returned was not ready
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1046 bra chklp
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1047 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1048 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1049 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1050 In order to write a routine to process a GetStat call, you need to access the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1051 contents of the registers when the call was made - in this case the B register
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1052 to obtain the getstat code. Within the common part of the path descriptor is a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1053 pointer to a data area which contains all the register contents when the call
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1054 was made. Labels set up in the os9defs file make accessing this information
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1055 easy.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1056 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1057 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1058 The following GetStat routine processes 3 codes. It first retrieves the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1059 register pointer from the path descriptor then loads what was in the B
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1060 register into the A register using the R$B label to find the location. The 3
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1061 getstat codes are SS.Ready - test for data ready which is performed by using
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1062 the PIA to determine if a data byte is waiting to be processed or not, SS.EOF
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1063 - end of file which for this device has no meaning and therefore always
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1064 returns with no error ie. not end of file. The final code is a user defined
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1065 one I created specific for this device named SS.VSupv. When called with this
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1066 code it forces the port to change direction to input using the 'setin'
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1067 procedure defined earlier. All other codes return an error.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1068 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1069 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1070 * GETSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1071 * U = Static Storage
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1072 * Y = Path Descriptor
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1073 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1074 GETSTA ldx PD.Rgs,y X=pointer to registers
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1075 lda R$B,x A=contents of B reg.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1076 cmpa #SS.Ready check for ready code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1077 bne gsta1 if not, check next
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1078 ldx V.Port,u use the PIA to determine
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1079 tst 1,x if data is available
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1080 bmi ok
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1081 ldb #E$NotRdy
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1082 coma sets the carry flag
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1083 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1084 gsta1 cmpa #SS.EOF check for eof code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1085 beq ok which always returns ok
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1086 cmpa #SS.VSupv check for a special code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1087 beq setin which changes port dir
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1088 comb otherwise return
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1089 ldb #E$UnkSVC unknown code error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1090 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1091 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1092 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1093 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1094 The SetSta call works in an identical way to GetStat, and generally SCF
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1095 devices do not use SetStat calls so you can just return the E$UnkSVC error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1096 immediatly. For our example driver, SetStat supports the new SS.VSupv code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1097 which when received will force the port direction to be output using the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1098 'setout' procedure:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1099 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1100 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1101 * PUTSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1102 * Supv request sets port to o/p
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1103 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1104 PUTSTA ldx PD.Rgs,y X=register stack
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1105 ldb R$B,x B=contents of reg B
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1106 cmpb #SS.VSupv check for recognized code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1107 beq setout and process it
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1108 comb otherwise return error.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1109 ldb #E$UnkSVC
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1110 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1111 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1112 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1113 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1114 Finally, the TERM routine. Since the driver has not allocated any extra memory
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1115 or anything it can just return okay:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1116 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1117 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1118 * TERM
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1119 * Terminate Driver
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1120 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1121 TERM clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1122 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1123
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1124 emod
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1125 PEND equ *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1126 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1127 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1128 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1129 Thats just about it.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1130 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1131 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1132 Before proceeding to an RBF device driver there is one more thing required to
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1133 complete the new SCF device - a device descriptor.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1134 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1135 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1136 The device descriptor is just composed of a set of data items which define the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1137 device you are creating. In particular, it is the name you refer to when you
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1138 want to access the device - so our example is called P1 so in order to access
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1139 it you just refer to this device ie.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1140 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1141 list startup >/p1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1142 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1143 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1144 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1145 copies the startup file to device /p1. The descriptor also contains information
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1146 to identify it's device driver, file manager and other unique information. It
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1147 also contains the port address (which is copied to V.Port so your driver can
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1148 refer to it) and in the case of SCF devices contains a whole list of attributes
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1149 referring to the capabilities of the device.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1150 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1151 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1152 Here is the PIA device descriptor to go with the PIA21 device driver:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1153 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1154 ****************************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1155 * PIA Descriptor module
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1156 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1157 * Source by J.Bird (C) 1992
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1158 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1159 ifp1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1160 use /h0/defs/os9defs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1161 endc
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1162
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1163 nam P1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1164 ttl PIA Device Descriptor
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1165
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1166 mod PEND,PNAM,DEVIC+OBJCT,REENT+1,PMGR,PDRV
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1167
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1168 fcb READ.+WRITE.+SHARE.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1169 fcb $FF IOBlock (unused)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1170 fdb $FF32 hardware address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1171 fcb PNAM-*-1 option byte count
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1172 fcb $0 SCF device
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1173 fcb $0 Case (upper &amp; lower)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1174 fcb $1 Erase on backspace
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1175 fcb $0 delete (BSE over line)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1176 fcb $0 echo off
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1177 fcb $1 lf on
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1178 fcb $0 eol null count
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1179 fcb $0 no pause
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1180 fcb 24 lines per page
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1181 fcb $8 backspace
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1182 fcb $18 delete line char
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1183 fcb $0D end of record
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1184 fcb $1b eof
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1185 fcb $04 reprint line char
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1186 fcb $01 duplicate last line char
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1187 fcb $17 pause char
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1188 fcb $03 interrupt char
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1189 fcb $05 quit char
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1190 fcb $08 backspace echo char
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1191 fcb $07 bell
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1192 fcb $00 n/a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1193 fcb $00 n/a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1194 fdb pnam offset to name
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1195 fdb $0000 offset to status routine
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1196 pnam fcs "P1"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1197 pmgr fcs "SCF"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1198 pdrv fcs "PIA21"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1199 emod
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1200 pend equ *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1201 end
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1202 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1203 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1204 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1205 Once again it's format is similiar to any OS9 module, with a program type of
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1206 DEVIC indicating device descriptor. The module just consists of fcb data
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1207 stataments. Generally, this may well suffice for any SCF module you care to
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1208 create. Some key features to note however are:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1209 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1210 fcb READ.+WRITE.+SHARE.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1211 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1212 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1213 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1214 indicates the device can be read, written and also multiple processes can
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1215 access it at any one time. Failing to specify some of these will cause the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1216 system to return 'device not capable of operation' type errors.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1217 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1218 fdb $FF32 hardware address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1219 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1220 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1221 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1222 The physical hardware port address. This indicates our PIA sits at $FF32 in
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1223 memory - copied to V.Port in the device driver.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1224 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1225 fcb $0 echo off
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1226 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1227 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1228 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1229 This is an important one. If set to non-zero when the SCF file manager reads a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1230 byte it will automatically send it back out using the write routine. In the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1231 case of our 6821 driver which only operates in one direction at a time this is
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1232 not a good idea.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1233 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1234 pnam fcs "P1"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1235 pmgr fcs "SCF"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1236 pdrv fcs "PIA21"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1237 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1238 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1239 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1240 Finally, these give the device descriptor name (pnam), its associated file
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1241 manager (pmgr) and device driver (pdrv) and is the only way the system has of
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1242 working this out.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1243 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1244 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1245 As an additional note, the device driver INIT also sets the Y register to point
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1246 to the device descriptor data should you need to access it. Most of the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1247 parameters are also copied into the path descriptor option section where you
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1248 can access them if required. Remember, any modifications you make to the path
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1249 descriptor locations will only be valid for the duration the device or file is
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1250 'open'.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1251 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1252 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1253 Once you have your new driver and descriptor you just load them into memory and
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1254 then any OS9 program can use them:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1255 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1256 load pia21
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1257 load p1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1258 list startup >/p
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1259 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1260 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1261 </section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1262 <section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1263 <title>RBF Device Driver</title>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1264 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1265 RBF drivers tend to be a little more complex than SCF ones but not drastically
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1266 so. In addition, practically everything covered in the SCF device also applies
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1267 to RBF device covered here. They also tend to open up your system a lot more -
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1268 essentially you are getting another disk drive out of it. The example I am
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1269 using here is based around the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1270 <ulink url="http://www.onastick.clara.net/rdisk.htm">RAM disc design</ulink>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1271 I wrote a couple of years ago in Up2Date.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1272 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1273 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1274 The RAM disc design used once again an MC6821 PIA, which utilised one side to
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1275 select a RAM function to be performed and the other side as the data bus. The
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1276 design was specifically built to make it easy to interface into an OS9 system.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1277 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1278 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1279 For RBF devices, the read and write functions are required to transfer a 256
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1280 byte sector from a given 24 bit logical sector number (LSN). LSNs give a means
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1281 of addressing disks without having to worry about tracks/sectors per track.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1282 They are numbered from 0 upwards starting (on a 'real' disk anyway) as LSN
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1283 0=track 0, sector 1 etc. On a standard Dragon disk (40T/SS) LSN 0=Track 0,
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1284 sector 1, LSN 1=Track 0, sector 2, LSN 18=Track 1, sector 1 etc.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1285 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1286 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1287 The PIA design allowed for the following operations:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1288 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1289 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1290 1. Write MSB of LSN. Write the top 16 bits of the LSN to the RAM drive (the top
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1291 8 bits are discarded as you would need a phenominal amount of RAM to need these
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1292 bits).
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1293 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1294 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1295 2. Write LSN of LSN. Write the botton 8 bits of the LSN to the RAM drive.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1296 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1297 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1298 3. Read a sector. Transfer the sector byte by byte from the RAM drive hardware
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1299 to a buffer.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1300 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1301 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1302 4. Write a sector. Transfer a sector byte by byte from a buffer to the RAM
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1303 drive hardware.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1304 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1305 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1306 So, there is really minimal processing involved to utilise the RAM drives. Most
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1307 floppy, or hard disk drivers would normally require some LSN to track/sector
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1308 conversion.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1309 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1310 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1311 All RBF device drivers differ subtly from SCF drivers in that there are
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1312 certain mandatory things you must perform within them in order for them to
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1313 function correctly. I will attempt to explain these throughout the driver
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1314 example.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1315 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1316 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1317 An RBF driver starts off like all OS9 modules, with the standard header
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1318 format. Here you see I am up to revision 6 of the PIA RAM disk driver:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1319 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1320 *********************************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1321 * Rdisk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1322 * A driver for a Ram disk!
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1323 * By G.Twist (c) 1986
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1324 * modified by Bernd H. Neuner 1987
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1325 * Version for a totally different Ram disk!
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1326 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1327 * By J.B. &amp; O.B. (C) 1991,1992
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1328 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1329
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1330 nam Rdisk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1331 ttl A Device Driver for a RAM Disk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1332
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1333 ifp1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1334 use /d0/defs/os9defs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1335 use /d0/defs/iodefs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1336 use /d0/defs/rbfdefs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1337 endc
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1338
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1339 ***********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1340 * Edition History
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1341
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1342 * # date Comments
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1343 * -- -------- ----------------------------------------------
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1344 * 1 86/12/17 Driver first developed GDT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1345 * 2 86/12/18 work to fix minor access bugs GDT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1346 * 3 30.11.87 bug in COPY routine fixed. BHN (no more error 214 now.)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1347 * 4 31.12.91 Test version for main RAM JB/OB
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1348 * 5 08.01.92 Driver for 128K PIA RAM JB/OB
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1349 * 6 18.09.92 Up-issue to support up to 512K JB
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1350
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1351 Revision equ 6
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1352 NumDrvs set 1 Number of drives
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1353
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1354 * pia control comands
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1355 pia.ddr equ %00111000
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1356 pia.off equ %00111100
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1357 pia.act equ %00101100
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1358 ext.msr equ %00000001
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1359 ext.lsr equ %00001000
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1360 ext.read equ %00000010
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1361 ext.writ equ %00000110
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1362 output equ %11111111
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1363 outb equ %00001111
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1364 pia.iora equ 0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1365 pia.cnra equ 1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1366 pia.iorb equ 2
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1367 pia.cnrb equ 3
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1368
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1369
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1370 org Drvbeg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1371 rmb NumDrvs*DrvMem
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1372 LSNZERO rmb 1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1373 RAMSTA equ .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1374
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1375 mod RAMEND,RAMNAM,Drivr+Objct,Reent+Revision,RAMENT,RAMSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1376 RAMNAM fcs /Rdisk/
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1377
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1378 RAMENT lbra INIT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1379 lbra READ
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1380 lbra WRITE
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1381 lbra GETSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1382 lbra PUTSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1383 lbra TERM
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1384 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1385 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1386 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1387 Along with the equates needed for the driver, the RBF driver static storage is
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1388 being utilised (note the V.SCF equate replaced with DRVBEG). The first
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1389 mandatory thing about an RBF driver is that you must allocate a drive table
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1390 for EACH drive you plan the driver to deal with. The drive table will hold
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1391 information particular to the drive (such as number of sectors/track etc.) and
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1392 must be the first block of data in your static storage. You should reserve
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1393 DRVMEM bytes (DRVMEM is defined in the rbfdefs file) multiplied by the number
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1394 of drives your driver can handle (in this case NumDrvs is defined as 1). So
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1395 the DDISK OS9 driver reserves 4 times this amount to handle the 4 possible
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1396 floppy disks on a Dragon system. The only data item declared for our use is
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1397 the LSNZERO byte.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1398 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1399 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1400 The INIT routine of the driver also requires some mandatory code required by
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1401 all RBF drivers:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1402 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1403 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1404 1. Initialise the V.NDRV variable of the RBF static storage to the number of
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1405 drives the driver will deal with.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1406 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1407 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1408 2. Initialise the DD.TOT and V.Trak variables held within the drive tables of
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1409 the static storage of EACH drive to a non-zero value.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1410 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1411 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1412 In this driver, although it is only targetted for 1 drive, there is a loop
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1413 construct present for dealing with multiple drives should this ever be a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1414 requirement. In addition, our INIT routine also sets up the PIA and
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1415 initialises our own data item.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1416 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1417 *****************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1418 * INIT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1419 * Set up the ramdisk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1420
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1421 INIT lda #NumDrvs Set no drives to 1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1422 sta V.NDRV,U
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1423 clr LSNZERO,U Initialise our data
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1424 lda #$FF non-zero value
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1425 leax DrvBeg,U X=Start of drive table
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1426 initdrv
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1427 sta DD.Tot,X write in non-zero values
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1428 sta V.Trak,X
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1429 leax DrvMem,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1430 deca loop through drives
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1431 bne initdrv
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1432 * set up pia
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1433 ldx V.PORT,U
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1434 lda #pia.off
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1435 sta pia.cnra,x select a side off
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1436 lda #pia.ddr
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1437 sta pia.cnrb,x select b side ddr
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1438 lda #outb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1439 sta pia.iorb,x set ls 4 bits to outputs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1440 lda #pia.off
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1441 sta pia.cnrb,x select b side io reg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1442 clr pia.iorb,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1443 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1444 INITXIT rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1445 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1446 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1447 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1448 The READ routine is required to transfer an entire disk sector to a buffer.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1449 The 24 bit LSN number to read is held in the B and X registers as follows:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1450 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1451 bits#
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1452 23 ... 15 ... 7 ... 0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1453 | B | X |
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1454 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1455 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1456 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1457 The VALID procedure actually performs the sector validation and loading of
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1458 this data into the PIAs. The sector is then transfered into the sector buffer
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1459 pointed to by the PD.BUF location in the path descriptor.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1460 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1461 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1462 The READ routine (surprisingly enough) also has to perform some mandatory
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1463 operations - in particular when LSN 0 is read. This contains disk ID
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1464 information and whenever a request is made to read this sector, the driver is
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1465 required to copy DD.SIZ bytes into the drive table for the required drive:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1466 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1467 *****************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1468 * READ
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1469 * read a sector from disk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1470 * Entry: U = Static Storage
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1471 * Y = Path Descriptor
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1472 * B = MSB of LSN
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1473 * X = LSB's of LSN
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1474 * Exit: 256 byte sector in PD.BUF buffer
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1475 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1476 READ clr LSNZERO,U init LSNZERO flag
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1477 bsr VALID validate the LSN supplied
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1478 bcs READ99 raise error if invalid
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1479 pshs Y preserve pointer to PD
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1480 ldy PD.BUF,Y Y=start of sector buffer
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1481 ldx V.PORT,U X=PIA port address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1482 lda #pia.ddr program PIA for transfer
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1483 sta pia.cnra,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1484 clr pia.iora,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1485 lda #pia.act
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1486 sta pia.cnra,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1487 lda #ext.read
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1488 sta pia.iorb,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1489 leax pia.iora,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1490 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1491 READS10 lda ,x transfer sector from PIA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1492 sta ,y+
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1493 decb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1494 bne READS10
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1495 leax V.Port,u reset PIA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1496 clr pia.iorb,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1497 lda #pia.off
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1498 sta pia.cnra,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1499 puls Y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1500 *mandatory RBF code - copy LSN 0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1501 tst LSNZERO,U VALID routine will set this
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1502 beq READ90 if LSN 0 specified
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1503 lda PD.DRV,Y extract drive num
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1504 ldb #DRVMEM size of drive table
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1505 mul
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1506 leax DRVBEG,U start of drive tables
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1507 leax D,X add on drive offset
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1508 ldy PD.BUF,Y copy DD.Siz bytes
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1509 ldb #DD.SIZ-1 into drive table
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1510 COPLSN0 lda B,Y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1511 sta B,X
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1512 decb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1513 bpl COPLSN0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1514 READ90 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1515 READ99 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1516 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1517 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1518 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1519 The sector write routine works in a similar manner: the LSN is supplied in the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1520 same format, and this time the sector held in PD.BUF must be transferred to
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1521 the RAM disk PIAs. No special processing is required for LSN 0.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1522 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1523 *****************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1524 * WRITE
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1525 * Write a sector to disk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1526 * Entry: U = Static Storage
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1527 * Y = Path Descriptor
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1528 * B = MSB of LSN
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1529 * X = LSB's of LSN
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1530 * PD.Buf = Sector to write
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1531 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1532 WRITE bsr VALID validate sector
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1533 bcs WRIT99
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1534 WRITS pshs Y save PD
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1535 ldy PD.BUF,Y Y=sector buffer
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1536 ldx V.PORT,U X=port address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1537 lda #pia.ddr program PIA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1538 sta pia.cnra,x for write txfr
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1539 lda #output
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1540 sta pia.iora,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1541 lda #pia.act
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1542 sta pia.cnra,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1543 lda #ext.writ
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1544 sta pia.iorb,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1545 leax pia.iora,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1546 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1547 WRITS10 lda ,y+ transfer sector
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1548 sta ,x to PIA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1549 lda ,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1550 decb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1551 bne WRITS10
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1552 ldx V.PORT,U restore PIA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1553 clr pia.iorb,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1554 lda #pia.off
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1555 sta pia.cnra,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1556 puls Y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1557 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1558 WRIT99 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1559 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1560 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1561 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1562 The VALID subroutine is shown below. This serves to program the PIA with the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1563 LSN supplied - note the top part of the LSN held in the B register is
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1564 discarded for this driver, only the X part is used.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1565 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1566 *****************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1567 * VALID
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1568 * validate a sector
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1569 * and set up external registers
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1570 * to reqired page in ram
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1571 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1572 VALID
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1573 cmpx #$0000 check for LSN 0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1574 bne NOTLSN0 set flag appropriatly
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1575 inc LSNZERO,U
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1576 NOTLSN0 pshs y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1577 ldy V.PORT,U
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1578 lda #pia.ddr select direction reg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1579 sta pia.cnra,y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1580 lda #output set bits to output
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1581 sta pia.iora,y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1582 lda #pia.act enable ca2 strobe
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1583 sta pia.cnra,y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1584 lda #ext.msr select ms sector reg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1585 sta pia.iorb,y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1586 tfr x,d
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1587 sta pia.iora,y write ms value
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1588 lda pia.iora,y do the read (strobe)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1589 lda #ext.lsr select ls sector reg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1590 sta pia.iorb,y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1591 stb pia.iora,y write ls value
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1592 ldb pia.iora,y do the read (strobe)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1593 clr pia.iorb,y select nothing
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1594 puls y note a side still set for output
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1595 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1596 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1597 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1598 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1599 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1600 On the GETSTA and SETSTA side of things, there are no 'mandatory' getsta codes
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1601 you need to deal with and two SETSTA codes: SS.RST (restore head to track 0)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1602 and SS.WRT (write track). Restore head to track 0 serves no useful purpose on
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1603 a RAM disc and can just return okay. The SS.WRT call is used during format
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1604 operations to actually format the track - again for a RAM drive this will not
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1605 be required and can just return okay. All others return with an error:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1606 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1607 **************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1608 * GETSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1609 * get device status
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1610 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1611 GETSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1612 Unknown comb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1613 ldb #E$UnkSVC
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1614 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1615
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1616 **************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1617 * PUTSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1618 * Set device Status
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1619 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1620 PUTSTA cmpb #SS.Reset
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1621 beq PUTSTA90
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1622 cmpb #SS.WTrk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1623 bne Unknown
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1624
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1625 PUTSTA90 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1626 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1627 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1628 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1629 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1630 Finally, the TERM routine simply exits cleanly:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1631 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1632 *****************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1633 * TERM
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1634 * terminate Driver
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1635 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1636 TERM clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1637 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1638
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1639 emod
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1640 RAMEND equ *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1641 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1642 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1643 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1644 All that remains to cover is the RBF device descriptor, which is actually a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1645 lot simpler than the SCF one:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1646 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1647 ******************************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1648 * RamDisk Discriptor module
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1649 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1650 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1651 ifp1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1652 use /d0/defs/os9defs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1653 endc
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1654
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1655 nam R0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1656 ttl Drive Discriptor module
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1657
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1658 mod DEnd,DNam,DEVIC+OBJCT,REENT+1,DMgr,DDrv
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1659
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1660 fcb DIR.+SHARE.+PREAD.+PWRIT.+UPDAT.+EXEC.+PEXEC.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1661 fcb $FF IOBlock (unused)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1662 fdb $FF34 hardware address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1663 fcb DNam-*-1 option byte count
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1664 fcb $1 Rbf device
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1665 fcb 0 Drive number
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1666 fcb 03 6ms Step rate
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1667 fcb $80 Standard OS9 Winchester drive
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1668 fcb 0 Single density
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1669 fdb 4 number of tracks
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1670 fcb 1 number of sides
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1671 fcb 1 dont verify any writes
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1672 fdb 256 sectors per track
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1673 fdb 256 sectors on track 0, side 0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1674 fcb 1 sector interleave factor
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1675 fcb 1 sector allocation size
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1676 DNam fcs "R0"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1677 DMgr fcs "RBF"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1678 DDrv fcs "RDisk"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1679 emod
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1680 DEnd equ *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1681 end
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1682 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1683 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1684 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1685 This is the device descriptor named R0 for our RAM drive. It shares similar
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1686 properties to the SCF one, firstly the attributes byte indicating full access
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1687 (READ.+WRITE. etc. ) including directory access. There is also the familiar
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1688 hardware address and at the end the device descriptor name, file manager name
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1689 and driver name. Most of the descriptor is composed of the drive attributes:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1690 drive number, total tracks, sectors per track etc. Since this is a RAM drive
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1691 all I have done is ensured the total sectors on the media is equal to the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1692 amount of RAM I have available - in this case 256K.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1693 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1694 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1695 Once assembled, you can simply load and access the RAM drive like any other
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1696 disk on your system:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1697 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1698 load rdisk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1699 load r0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1700 chd /r0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1701 copy /d0/startup /r0/startup #32k
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1702
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1703 etc.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1704 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1705 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1706 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1707 That just about wraps it up. A couple of other points worth noting: it's
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1708 normally worth either checking out or basing your driver on someone else's as
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1709 a good starting point, there is also a fair deal of information around
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1710 particularly from the CoCo side of things. And something I'd always recommend:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1711 as you have seen is nearly always easier to debug stuff under normal DragonDOS
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1712 so I'd suggest at least prototyping your code under this environment to see if
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1713 at least the logic works how you think it should. That way, when you port it
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1714 to OS9 all you have to worry about is the quirks of OS9 rather than your own
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1715 driver logic.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1716 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1717 </section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1718 </article>