annotate docs/articles/os9software.article @ 3169:1ff3d7673e36

mc09 l2: bring sys/makefile in line with latest organisation for other platforms Revise bootfiles/makefile to remove sysgo from bootfile - it can be found on the root of the disk.
author Neal Crook <foofoobedoo@gmail.com>
date Mon, 17 Apr 2017 22:59:28 +0100
parents 1e04ad1dfdce
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
642
1fa5fc8256cd XMLify. Added makefile
roug
parents: 469
diff changeset
1 <!--
1fa5fc8256cd XMLify. Added makefile
roug
parents: 469
diff changeset
2 The author has not been contacted about adding this article to the
1fa5fc8256cd XMLify. Added makefile
roug
parents: 469
diff changeset
3 documentation set.
1fa5fc8256cd XMLify. Added makefile
roug
parents: 469
diff changeset
4 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
5 -->
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
6 <article>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
7 <articleinfo>
642
1fa5fc8256cd XMLify. Added makefile
roug
parents: 469
diff changeset
8 <author><firstname>Jon</firstname><surname>Bird</surname></author>
469
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
9 <title>Software for OS9</title>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
10 </articleinfo>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
11 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
12 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
13 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
14 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
15 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
16 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
17 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
18 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
19 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
20 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
21 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
22 column screen and hard disk.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
23 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
24 <section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
25 <title>DragonDOS vs OS9</title>
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 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
28 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
29 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
30 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
31 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
32 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
33 such like.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
34 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
35 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
36 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
37 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
38 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
39 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
40 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
41 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
42 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
43 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
44 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
45 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
46 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
47 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
48 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
49 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
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62 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
63 therefore look something like:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
64 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
65 Your OS9 Program says:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
66 'read 100 bytes from path number n'
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
67
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
68 Which is passed to IOMAN as:
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 which determines that RBFMan is responsible for path n:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
71
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
72 Which is passed to RBFMan as:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
73 'read 100 bytes from path number n'
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
74 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
75 100 bytes from:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
76
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
77 Which is then passed to DDISk as:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
78 'read sector m'
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
79 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
80 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
81 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
82 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
83 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
84 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
85 than procedures and subroutines for using your machine.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
86 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
87 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
88 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
89 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
90 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
91 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
92 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
93 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
94 example, under Dragon BASIC the line:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
95 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
96 PRINT "HELLO WORLD"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
97 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
98 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
99 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
100 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
101 Likewise with the OS9 Shell:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
102 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
103 chd /d0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
104 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
105 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
106 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
107 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
108 internal code required to perform this operation.
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 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
111 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
112 it explicitly, as in:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
113 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
114 RUN "MYPROG"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
115 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
116 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
117 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
118 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
119 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
120 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
121 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
122 it externally. For example:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
123 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
124 dir /d1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
125 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
126 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
127 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
128 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
129 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
130 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
131 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
132 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
133 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
134 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
135 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
136 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
137 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
138 Module Directory at 10:47:24
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
139 ADDR SIZE TY RV AT UC NAME
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
140 ---- ---- -- -- -- -- ---------
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
141 F05E 7E7 C1 1 r OS9
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
142 F853 4FC C1 1 r 1 OS9p2
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
143 FD4F 2E C0 1 r 1 Init
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
144 FD7D 182 C1 1 r 1 BooT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
145 BF00 122 C1 4 r 1 SYSGO
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
146 C022 101 C1 1 r 1 Clock
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
147 C123 6E7 C1 1 r 1 IOMan
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
148 C80A CF5 D1 1 r 1 Rbf
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
149 D4FF 40E D1 1 r 2 Scf
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
150 D90D 1FF D1 1 r PipeMan
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
151 DB0C 5E2 E1 7 r Ddisk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
152 E0EE 3AF E1 6 r 2 Kbvdio
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
153 E49D 8D E1 1 r Printer
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
154 E52A 28 E1 1 r Piper
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
155 E552 2E F1 1 r D0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
156 E580 2E F1 2 r D1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
157 E5AE 3C F1 1 r 2 Term
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
158 E5EA 3A F1 1 r P
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
159 E624 26 F1 1 r Pipe
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
160 E64A 4FA 11 1 r 2 Shell
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
161 EB44 121 E1 3 r 1 Rdisk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
162 EC65 2E F1 1 r 1 R0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
163 EC93 160 E1 1 r PC_Disk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
164 EDF3 30 F1 1 r H0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
165 5A00 1A6 11 1 r 1 Mdir
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
166 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
167 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
168 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176 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
177 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
178 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
179 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
180 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
181 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
182 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
183 more painful to work with than DragonDOS.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
184 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
185 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
186 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
187 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
188 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
189 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
190 10 EXEC &amp;H6C00
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
191 20 ALL
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
192 30 @MSG FCC 0,"HELLO WORLD",0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
193 40 @START LDX #@MSG
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
194 50 JSR $90E5
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
195 60 RTS
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
196 70 END @START
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
197 80 EXEC
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
198 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
199 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
200 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
201 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
202 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
203 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
204 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
205 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
206 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
207 80.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
208 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
209 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
210 Onto the OS9 version then:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
211 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
212 nam WORLD
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
213 ttl Hello World program
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
214
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
215 ifp1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
216 use /d0/defs/os9defs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
217 endc
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
218
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
219 *Data area
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
220 org 0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
221 stack rmb 200
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
222 datsiz equ .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
223
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
224 *Module header
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
225 type equ PRGRM+OBJCT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
226 revs equ REENT+1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
227 mod length,name,type,revs,start,datsiz
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
228 name fcs /WORLD/
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
229 msg fcc /Hello World/
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
230 fcb 13
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
231
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
232 *main code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
233 start leax msg,pcr
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
234 ldy #12
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
235 lda #1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
236 os9 i$writln
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
237 bcs error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
238 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
239 error os9 f$exit
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
240
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
241 emod
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
242
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
243 length equ *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
244 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
245 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
246 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
247 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
248 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
249 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
250 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
251 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
252 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
253 asm world #20k
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
254 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
255 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
256 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
257 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
258 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
259 /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
260 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
261 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
262 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
263 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
264 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
265 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
266 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
267 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
268 screen.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
269 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
270 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
271 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
272 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
273 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
274 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
275 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
276 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
277 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
278 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
279 definitions from os9defs.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
280 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
281 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
282 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
283 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
284 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
285 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
286 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
287 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
288 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
289 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
290 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
291 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
292 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
293 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
294 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
295 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
296 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
297 data size.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
298 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
299 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
300 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
301 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
302 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
303 main code for the program occurs.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
304 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
305 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
306 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
307 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
308 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
309 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
310 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
311 '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
312 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
313 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
314 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
315 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
316 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
317 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
318 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
319 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
320 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
321 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
322 routine not an RTS instruction.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
323 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
324 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
325 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
326 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
327 is calculated.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
328 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
329 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
330 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
331 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
332 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
333 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
334 DDOS: LDX #@MSG - absolute address of MSG
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
335 OS9: leax msg,pcr - relative address of MSG
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 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
338 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
339 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
340 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
341 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
342 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
343 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
344 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
345 format or it will not work.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
346 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
347 </section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
348 <section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
349 <title>OS9 Advantages</title>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
350 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
351 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
352 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
353 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
354 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
355 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
356 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
357 are a few other advantages of the OS9 variant.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
358 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
359 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
360 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
361 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
362 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
363 Dragon BASIC: POKE 111,254:EXEC
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
364 OS9: world >/p
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 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
367 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
368 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
369 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
370 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
371 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
372 DOS variants can use the OPEN# format:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
373 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
374 OPEN #1,"O","TEST.DAT"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
375 POKE 111,1:EXEC
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
376 CLOSE #1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
377 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
378 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
379 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
380 Once again the OS9 variant is pretty much straightforward:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
381 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
382 world >test.dat
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
383 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
384 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
385 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
386 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
387 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
388 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
389 automatically be used with your new device:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
390 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
391 world >/p1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
392 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
393 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
394 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
395 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
396 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
397 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
398 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
399 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
400 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
401 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
402 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
403 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
404 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
405 set of data.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
406 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
407 </section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
408 <section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
409 <title>OS9 Data Storage</title>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
410 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
411 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
412 rmb directives starting at 0 eg.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
413 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
414 *Data area
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
415 org 0 specify starting at 0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
416 length rmb 2 data items for
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
417 name rmb 20 the program
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
418 next rmb 2
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
419 stack rmb 200
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
420 datsiz equ .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
421 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
422 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
423 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
424 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
425 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
426 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
427 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
428 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
429 mod length,name,type,revs,start,datsiz
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
430 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
431 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
432 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
433 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
434 information about your data area-
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
435 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
436 | |
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
437 | Parameter Area |
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
438 ------------------- -- X, S
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 | |
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
441 | Data Area |
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 | Direct Page |
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
445 ------------------- -- U, DP (LS address)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
446 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
447 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
448 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
449 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
450 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
451 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
452 your program:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
453 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
454 sty length,u stores Y into 'length'
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
455 ldx next,u loads X from 'next'
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 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
458 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
459 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
460 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
461 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
462 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
463 label:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
464 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
465 sty length use DP addressing to
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
466 ldx next access data items
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 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
469 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
470 Using the data declarations used earlier:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
471 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
472 length lies at offset 0 ($00).
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
473 next lies at offset 22 ($16).
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 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
476 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
477 The assembler translates this into:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
478 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
479 STY $00
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
480 LDX $16
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 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
483 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
484 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
485 the address. Therefore, if DP=$20 this would become:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
486 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
487 STY $2000
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
488 LDX $2016
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 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
491 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
492 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
493 quicker to execute.
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 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
496 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
497 since you cannot use the DP register for this:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
498 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
499 leax name,u X=start of name item
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
500 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
501 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
502 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
503 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
504 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
505 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
506 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
507 ldx next -> LDX $16
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
508 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
509 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
510 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
511 However, DragonDOS assemblers will automatically use extended addressing so
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
512 assuming @NEXT lies at address $5020.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
513 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
514 LDX #@NEXT -> LDX $5020
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
515 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
516 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
517 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
518 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
519 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
520 ldx >$16 -> LDX $0016
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
521 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
522 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
523 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
524 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
525 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
526 ldx >$F0 -> LDX $F0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
527 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
528 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
529 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
530 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
531 quickly access memory locations 0-255.
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 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
534 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
535 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
536 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
537 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
538 recall:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
539 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
540 *Module header
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
541 type equ PRGRM+OBJCT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
542 revs equ REENT+1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
543 mod length,name,type,revs,start,datsiz
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
544 name fcs /WORLD/
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
545 msg fcc /Hello World/
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
546 fcb 13
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
547 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
548 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
549 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
550 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
551 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
552 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
553 carriage return ie.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
554 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
555 OS9:world this is a parameter
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
556 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
557 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
558 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
559 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
560 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
561 this is a parameter[CR]
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
562 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
563 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
564 </section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
565 <section>
1066
1e04ad1dfdce Build a book out of the articles. To be uploaded to sourceforge later.
roug
parents: 642
diff changeset
566 <title>Other Programming Tips</title>
469
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
567 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
568 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
569 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
570 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
571 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
572 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
573 standard IO paths.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
574 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
575 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
576 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
577 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
578 ldy #12
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
579 lda #1 standard output
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
580 os9 i$writln
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
581 bcs error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
582 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
583 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
584 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
585 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
586 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
587 0 = Standard Input (keyboard)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
588 1 = Standard Output (screen)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
589 2 = Standard Error (screen)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
590 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
591 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
592 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
593 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
594 shell or other program has re-directed them ie.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
595 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
596 world >/p
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
597 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
598 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
599 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
600 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
601 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
602 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
603 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
604 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
605 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
606 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
607 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
608 loop
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
609 leax buffer,u point to buffer
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
610 ldy #1 1 char to read
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
611 clra from stdin
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
612 os9 i$read read byte
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
613 bcs error handle error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
614 inca set to stdout
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
615 os9 i$write write byte
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
616 bcs error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
617 ldb ,x was it a CR
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
618 cmpb #13
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
619 bne loop no, loop for next
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
620 ldb #10 write an LF
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
621 stb ,x to stdout
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
622 os9 i$write
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
623 bcs error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
624 bra loop
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
625
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
626 error cmpb #E$EOF check for EOF
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
627 bne term if not, exit with error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
628 clrb else quit ok
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
629 term os9 f$exit
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
630 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
631 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
632 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
633 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
634 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
635 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
636 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
637 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
638 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
639 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
640 mail merge utility (mm):
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
641 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
642 mm my_doc ! addlf >/d1/my_doc.out
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
643 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
644 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
645 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
646 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
647 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
648 (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
649 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
650 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
651 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
652 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
653 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
654 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
655 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
656 in a separate loop.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
657 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
658 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
659 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
660 remain unchanged from when the call was made eg.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
661 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
662 i$read: Entry: X = Addr of data
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
663 Y = Bytes to read
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
664 A = Path number
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
665 Exit: Y = Bytes actually read
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
666 ALL OTHER REGISTERS UNCHANGED
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
667 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
668 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
669 </section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
670 <section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
671 <title>Device Drivers</title>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
672 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
673 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
674 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
675 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
676 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
677 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
678 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
679 '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
680 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
681 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
682 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
683 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
684 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
685 - 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
686 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
687 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
688 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
689 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
690 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
691 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
692 required.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
693 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
694 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
695 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
696 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
697 of a device driver which is called DEVx:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
698 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
699 nam DEVx
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
700 ttl DEVx device driver
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
701
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
702 ifp1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
703 use /h0/defs/os9defs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
704 use /h0/defs/iodefs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
705 use /h0/defs/scfdefs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
706 endc
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
707
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
708 *data
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
709 org V.SCF
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
710 PST equ .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
711
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
712 type equ DRIVR+OBJCT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
713 revs equ REENT+1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
714 mod PEND,PNAM,type,revs,PENT,PST
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
715
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
716 PNAM fcs /DEVx/
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
717
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
718 PENT lbra INIT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
719 lbra READ
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
720 lbra WRITE
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
721 lbra GETSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
722 lbra PUTSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
723 lbra TERM
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
724
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
725 INIT .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
726 READ .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
727 WRITE .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
728 GETSTA .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
729 PUTSTA .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
730 TERM .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
731
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
732 emod
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
733 PEND equ *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
734 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
735 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
736 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
737 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
738 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
739 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
740 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
741 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
742 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
743 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
744 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
745 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
746 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
747 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
748 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
749 these routines which are as follows:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
750 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
751 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
752 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
753 to set your device up.
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 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
756 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
757 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
758 sector (RBF devices).
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
759 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
760 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
761 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
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 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
765 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
766 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
767 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
768 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
769 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
770 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
771 on the device.
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 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
774 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
775 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
776 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
777 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
778 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
779 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
780 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
781 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
782 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
783 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
784 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
785 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
786 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
787 org V.SCF
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
788 flag rmb 1
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 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
791 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
792 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
793 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
794 lda flag,u
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
795 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
796 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
797 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
798 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
799 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
800 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
801 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
802 (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
803 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
804 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
805 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
806 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
807 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
808 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
809 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
810 accessed:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
811 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
812 lda #$FF A=255
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
813 ldx V.Port,u port address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
814 sta 1,x port address+1=255
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
815 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
816 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
817 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
818 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
819 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
820 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
821 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
822 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
823 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
824 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
825 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
826 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
827 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
828 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
829 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
830 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
831 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
832 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
833 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
834 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
835 follows:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
836 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
837 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
838 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
839 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
840 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
841 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
842 an SCF device, the other an RBF device.
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 </section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
845 <section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
846 <title>SCF Device Driver</title>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
847 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
848 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
849 </para>
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 The first section is the common module header format:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
852 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
853 *******************************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
854 * PIA21
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
855 * Device Driver for MC6821 PIAs
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 * By J.Bird (c) 1992
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
858 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
859 * Uses Side B of MC6821 PIA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
860 * CA2 &amp; CB2 Control Strobe lines
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
861 * Non-interrupt driven
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
862 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
863
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
864 nam PIA21
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
865 ttl MC6821 PIA Device Driver
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 ifp1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
868 use /h0/defs/os9defs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
869 use /h0/defs/iodefs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
870 use /h0/defs/scfdefs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
871 endc
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
872
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
873 ***********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
874 * Edition History
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 * # date Comments
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
877 * - -------- -------------------------------
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
878 * 1 05.05.92 Driver first written. JRB
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
879 * 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
880
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
881 Revision equ 2
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
882
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
883 PBCREG equ %00101101
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
884 PBOUTP equ %11111111
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
885 PBINP equ %00000000
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
886
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
887 org V.SCF
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
888 PST equ .
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 mod PEND,PNAM,Drivr+Objct,Reent+Revision,PENT,PST
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
891 fcb READ.+WRITE.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
892 PNAM fcs /PIA21/
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
893
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
894 PENT lbra INIT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
895 lbra READ
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
896 lbra WRITE
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
897 lbra GETSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
898 lbra PUTSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
899 lbra TERM
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
900 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
901 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
902 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
903 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
904 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
905 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
906 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
907 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
908 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
909 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
910 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
911 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
912 static storage to find the IO port's address.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
913 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
914 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
915 * SETOUT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
916 * Set port dir for o/p
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 ldx V.PORT,u load port address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
919 clr 1,x clear control reg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
920 lda #PBOUTP set port for o/p
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
921 sta ,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
922 lda #PBCREG reload ctrl reg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
923 sta 1,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
924 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
925 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
926
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
927 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
928 * SETIN ldx V.PORT,u
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
929 * Set port dir for i/p
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 clr 1,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
933 lda #PBINP
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
934 sta ,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
935 lda #PBCREG
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
936 sta 1,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
937 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
938 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
939 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
940 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
941 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
942 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
943 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
944 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
945 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
946 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
947 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
948 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
949 * INIT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
950 * Entry: U = Static storage
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
951 * Setup the PIA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
952 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
953 INIT bsr setin
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
954 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
955 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
956 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
957 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
958 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
959 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
960 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
961 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
962 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
963 * READ
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
964 * Entry: U = Static Storage
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
965 * Y = Path Descriptor
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
966 * Exit: A = Character read
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
967 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
968 * Read a byte from Port B
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
969 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
970 READ ldx V.PORT,u load port address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
971 readlp tst 1,x test for data ready
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
972 bmi readbyte
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
973 pshs x sleep for a bit if not
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
974 ldx #10
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
975 os9 f$sleep
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
976 puls x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
977 bra readlp
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
978 readbyte lda ,x read byte
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
979 sta ,x issue strobe
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
980 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
981 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
982 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
983 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
984 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
985 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
986 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
987 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
988 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
989 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
990 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
991 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
992 between checks you ensure this cannot happen.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
993 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
994 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
995 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
996 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
997 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
998 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
999 * WRITE
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1000 * Entry: U = Static storage
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1001 * Y = Path Descriptor
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1002 * A = Char to write
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1003 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1004 * Write a byte to Port B
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1005 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1006 WRITE ldx V.PORT,U load port address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1007 sta ,x write byte
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1008 writlp tst 1,x wait for ack
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1009 bmi wrt
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1010 pshs x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1011 ldx #1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1012 os9 f$sleep
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1013 puls x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1014 bra writlp
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1015 wrt lda ,x clear control reg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1016 ok clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1017 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1018 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1019 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1020 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1021 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
1022 SetStat calls and also the path descriptor.
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 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1025 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
1026 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
1027 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
1028 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
1029 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
1030 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1031 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1032 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
1033 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
1034 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
1035 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
1036 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1037 chklp clra pathnum of stdin
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1038 ldb #SS.Ready getstat code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1039 os9 i$getstt issue call
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1040 bcc okay if c bit clear data is rdy
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1041 cmpb #E$NRDY otherwise check the code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1042 bne error returned was not ready
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1043 bra chklp
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1044 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1045 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1046 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1047 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
1048 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
1049 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
1050 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
1051 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
1052 easy.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1053 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1054 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1055 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
1056 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
1057 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
1058 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
1059 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
1060 - 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
1061 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
1062 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
1063 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
1064 procedure defined earlier. All other codes return an error.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1065 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1066 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1067 * GETSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1068 * U = Static Storage
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1069 * Y = Path Descriptor
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1070 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1071 GETSTA ldx PD.Rgs,y X=pointer to registers
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1072 lda R$B,x A=contents of B reg.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1073 cmpa #SS.Ready check for ready code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1074 bne gsta1 if not, check next
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1075 ldx V.Port,u use the PIA to determine
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1076 tst 1,x if data is available
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1077 bmi ok
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1078 ldb #E$NotRdy
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1079 coma sets the carry flag
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1080 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1081 gsta1 cmpa #SS.EOF check for eof code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1082 beq ok which always returns ok
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1083 cmpa #SS.VSupv check for a special code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1084 beq setin which changes port dir
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1085 comb otherwise return
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1086 ldb #E$UnkSVC unknown code error
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1087 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1088 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1089 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1090 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1091 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
1092 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
1093 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
1094 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
1095 'setout' procedure:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1096 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1097 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1098 * PUTSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1099 * Supv request sets port to o/p
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 ldx PD.Rgs,y X=register stack
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1102 ldb R$B,x B=contents of reg B
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1103 cmpb #SS.VSupv check for recognized code
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1104 beq setout and process it
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1105 comb otherwise return error.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1106 ldb #E$UnkSVC
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1107 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1108 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1109 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1110 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1111 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
1112 or anything it can just return okay:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1113 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1114 **********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1115 * TERM
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1116 * Terminate Driver
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 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1119 rts
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 emod
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1122 PEND equ *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1123 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1124 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1125 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1126 Thats just about it.
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 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
1130 complete the new SCF device - a device descriptor.
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 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1133 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
1134 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
1135 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
1136 it you just refer to this device ie.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1137 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1138 list startup >/p1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1139 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1140 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1141 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1142 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
1143 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
1144 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
1145 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
1146 referring to the capabilities of the device.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1147 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1148 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1149 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
1150 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1151 ****************************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1152 * PIA Descriptor module
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1153 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1154 * Source by J.Bird (C) 1992
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1155 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1156 ifp1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1157 use /h0/defs/os9defs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1158 endc
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1159
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1160 nam P1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1161 ttl PIA Device Descriptor
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 mod PEND,PNAM,DEVIC+OBJCT,REENT+1,PMGR,PDRV
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1164
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1165 fcb READ.+WRITE.+SHARE.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1166 fcb $FF IOBlock (unused)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1167 fdb $FF32 hardware address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1168 fcb PNAM-*-1 option byte count
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1169 fcb $0 SCF device
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1170 fcb $0 Case (upper &amp; lower)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1171 fcb $1 Erase on backspace
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1172 fcb $0 delete (BSE over line)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1173 fcb $0 echo off
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1174 fcb $1 lf on
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1175 fcb $0 eol null count
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1176 fcb $0 no pause
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1177 fcb 24 lines per page
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1178 fcb $8 backspace
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1179 fcb $18 delete line char
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1180 fcb $0D end of record
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1181 fcb $1b eof
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1182 fcb $04 reprint line char
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1183 fcb $01 duplicate last line char
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1184 fcb $17 pause char
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1185 fcb $03 interrupt char
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1186 fcb $05 quit char
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1187 fcb $08 backspace echo char
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1188 fcb $07 bell
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1189 fcb $00 n/a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1190 fcb $00 n/a
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1191 fdb pnam offset to name
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1192 fdb $0000 offset to status routine
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1193 pnam fcs "P1"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1194 pmgr fcs "SCF"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1195 pdrv fcs "PIA21"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1196 emod
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1197 pend equ *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1198 end
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1199 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1200 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1201 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1202 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
1203 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
1204 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
1205 create. Some key features to note however are:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1206 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1207 fcb READ.+WRITE.+SHARE.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1208 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1209 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1210 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1211 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
1212 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
1213 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
1214 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1215 fdb $FF32 hardware address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1216 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1217 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1218 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1219 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
1220 memory - copied to V.Port in the device driver.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1221 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1222 fcb $0 echo off
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1223 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1224 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1225 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1226 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
1227 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
1228 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
1229 not a good idea.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1230 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1231 pnam fcs "P1"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1232 pmgr fcs "SCF"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1233 pdrv fcs "PIA21"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1234 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1235 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1236 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1237 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
1238 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
1239 working this out.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1240 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1241 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1242 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
1243 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
1244 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
1245 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
1246 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
1247 'open'.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1248 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1249 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1250 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
1251 then any OS9 program can use them:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1252 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1253 load pia21
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1254 load p1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1255 list startup >/p
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1256 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1257 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1258 </section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1259 <section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1260 <title>RBF Device Driver</title>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1261 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1262 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
1263 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
1264 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
1265 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
1266 using here is based around the
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1267 <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
1268 I wrote a couple of years ago in Up2Date.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1269 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1270 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1271 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
1272 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
1273 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
1274 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1275 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1276 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
1277 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
1278 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
1279 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
1280 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
1281 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
1282 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1283 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1284 The PIA design allowed for the following operations:
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 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
1288 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
1289 bits).
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1290 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1291 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1292 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
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 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
1296 to a buffer.
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 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1299 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
1300 drive hardware.
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 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1303 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
1304 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
1305 conversion.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1306 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1307 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1308 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
1309 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
1310 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
1311 example.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1312 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1313 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1314 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
1315 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
1316 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1317 *********************************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1318 * Rdisk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1319 * A driver for a Ram disk!
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1320 * By G.Twist (c) 1986
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1321 * modified by Bernd H. Neuner 1987
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1322 * Version for a totally different Ram disk!
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1323 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1324 * By J.B. &amp; O.B. (C) 1991,1992
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1325 *
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 nam Rdisk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1328 ttl A Device Driver for a RAM Disk
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 ifp1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1331 use /d0/defs/os9defs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1332 use /d0/defs/iodefs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1333 use /d0/defs/rbfdefs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1334 endc
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1335
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1336 ***********************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1337 * Edition History
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 * # date Comments
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1340 * -- -------- ----------------------------------------------
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1341 * 1 86/12/17 Driver first developed GDT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1342 * 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
1343 * 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
1344 * 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
1345 * 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
1346 * 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
1347
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1348 Revision equ 6
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1349 NumDrvs set 1 Number of drives
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 * pia control comands
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1352 pia.ddr equ %00111000
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1353 pia.off equ %00111100
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1354 pia.act equ %00101100
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1355 ext.msr equ %00000001
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1356 ext.lsr equ %00001000
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1357 ext.read equ %00000010
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1358 ext.writ equ %00000110
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1359 output equ %11111111
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1360 outb equ %00001111
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1361 pia.iora equ 0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1362 pia.cnra equ 1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1363 pia.iorb equ 2
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1364 pia.cnrb equ 3
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1365
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1366
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1367 org Drvbeg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1368 rmb NumDrvs*DrvMem
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1369 LSNZERO rmb 1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1370 RAMSTA equ .
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1371
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1372 mod RAMEND,RAMNAM,Drivr+Objct,Reent+Revision,RAMENT,RAMSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1373 RAMNAM fcs /Rdisk/
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 RAMENT lbra INIT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1376 lbra READ
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1377 lbra WRITE
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1378 lbra GETSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1379 lbra PUTSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1380 lbra TERM
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1381 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1382 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1383 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1384 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
1385 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
1386 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
1387 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
1388 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
1389 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
1390 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
1391 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
1392 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
1393 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
1394 the LSNZERO byte.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1395 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1396 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1397 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
1398 all RBF drivers:
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 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1401 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
1402 drives the driver will deal with.
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 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1405 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
1406 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
1407 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1408 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1409 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
1410 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
1411 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
1412 initialises our own data item.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1413 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1414 *****************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1415 * INIT
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1416 * Set up the ramdisk
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 lda #NumDrvs Set no drives to 1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1419 sta V.NDRV,U
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1420 clr LSNZERO,U Initialise our data
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1421 lda #$FF non-zero value
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1422 leax DrvBeg,U X=Start of drive table
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1423 initdrv
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1424 sta DD.Tot,X write in non-zero values
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1425 sta V.Trak,X
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1426 leax DrvMem,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1427 deca loop through drives
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1428 bne initdrv
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1429 * set up pia
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1430 ldx V.PORT,U
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1431 lda #pia.off
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1432 sta pia.cnra,x select a side off
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1433 lda #pia.ddr
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1434 sta pia.cnrb,x select b side ddr
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1435 lda #outb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1436 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
1437 lda #pia.off
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1438 sta pia.cnrb,x select b side io reg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1439 clr pia.iorb,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1440 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1441 INITXIT rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1442 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1443 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1444 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1445 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
1446 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
1447 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1448 bits#
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1449 23 ... 15 ... 7 ... 0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1450 | B | X |
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1451 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1452 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1453 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1454 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
1455 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
1456 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
1457 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1458 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1459 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
1460 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
1461 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
1462 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
1463 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1464 *****************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1465 * READ
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1466 * read a sector from disk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1467 * Entry: U = Static Storage
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1468 * Y = Path Descriptor
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1469 * B = MSB of LSN
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1470 * X = LSB's of LSN
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1471 * Exit: 256 byte sector in PD.BUF buffer
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1472 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1473 READ clr LSNZERO,U init LSNZERO flag
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1474 bsr VALID validate the LSN supplied
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1475 bcs READ99 raise error if invalid
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1476 pshs Y preserve pointer to PD
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1477 ldy PD.BUF,Y Y=start of sector buffer
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1478 ldx V.PORT,U X=PIA port address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1479 lda #pia.ddr program PIA for transfer
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1480 sta pia.cnra,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1481 clr pia.iora,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1482 lda #pia.act
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 lda #ext.read
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1485 sta pia.iorb,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1486 leax pia.iora,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1487 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1488 READS10 lda ,x transfer sector from PIA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1489 sta ,y+
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1490 decb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1491 bne READS10
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1492 leax V.Port,u reset PIA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1493 clr pia.iorb,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1494 lda #pia.off
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1495 sta pia.cnra,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1496 puls Y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1497 *mandatory RBF code - copy LSN 0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1498 tst LSNZERO,U VALID routine will set this
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1499 beq READ90 if LSN 0 specified
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1500 lda PD.DRV,Y extract drive num
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1501 ldb #DRVMEM size of drive table
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1502 mul
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1503 leax DRVBEG,U start of drive tables
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1504 leax D,X add on drive offset
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1505 ldy PD.BUF,Y copy DD.Siz bytes
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1506 ldb #DD.SIZ-1 into drive table
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1507 COPLSN0 lda B,Y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1508 sta B,X
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1509 decb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1510 bpl COPLSN0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1511 READ90 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1512 READ99 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1513 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1514 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1515 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1516 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
1517 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
1518 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
1519 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1520 *****************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1521 * WRITE
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1522 * Write a sector to disk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1523 * Entry: U = Static Storage
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1524 * Y = Path Descriptor
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1525 * B = MSB of LSN
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1526 * X = LSB's of LSN
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1527 * PD.Buf = Sector to write
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1528 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1529 WRITE bsr VALID validate sector
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1530 bcs WRIT99
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1531 WRITS pshs Y save PD
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1532 ldy PD.BUF,Y Y=sector buffer
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1533 ldx V.PORT,U X=port address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1534 lda #pia.ddr program PIA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1535 sta pia.cnra,x for write txfr
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1536 lda #output
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1537 sta pia.iora,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1538 lda #pia.act
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1539 sta pia.cnra,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1540 lda #ext.writ
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1541 sta pia.iorb,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1542 leax pia.iora,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1543 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1544 WRITS10 lda ,y+ transfer sector
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1545 sta ,x to PIA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1546 lda ,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1547 decb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1548 bne WRITS10
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1549 ldx V.PORT,U restore PIA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1550 clr pia.iorb,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1551 lda #pia.off
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1552 sta pia.cnra,x
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1553 puls Y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1554 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1555 WRIT99 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1556 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1557 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1558 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1559 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
1560 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
1561 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
1562 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1563 *****************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1564 * VALID
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1565 * validate a sector
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1566 * and set up external registers
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1567 * to reqired page in ram
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1568 *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1569 VALID
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1570 cmpx #$0000 check for LSN 0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1571 bne NOTLSN0 set flag appropriatly
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1572 inc LSNZERO,U
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1573 NOTLSN0 pshs y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1574 ldy V.PORT,U
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1575 lda #pia.ddr select direction reg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1576 sta pia.cnra,y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1577 lda #output set bits to output
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1578 sta pia.iora,y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1579 lda #pia.act enable ca2 strobe
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1580 sta pia.cnra,y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1581 lda #ext.msr select ms sector reg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1582 sta pia.iorb,y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1583 tfr x,d
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1584 sta pia.iora,y write ms value
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1585 lda pia.iora,y do the read (strobe)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1586 lda #ext.lsr select ls sector reg
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1587 sta pia.iorb,y
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1588 stb pia.iora,y write ls value
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1589 ldb pia.iora,y do the read (strobe)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1590 clr pia.iorb,y select nothing
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1591 puls y note a side still set for output
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1592 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1593 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1594 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1595 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1596 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1597 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
1598 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
1599 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
1600 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
1601 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
1602 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
1603 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1604 **************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1605 * GETSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1606 * get device status
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 Unknown comb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1610 ldb #E$UnkSVC
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1611 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1612
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1613 **************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1614 * PUTSTA
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1615 * Set device Status
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 cmpb #SS.Reset
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1618 beq PUTSTA90
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1619 cmpb #SS.WTrk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1620 bne Unknown
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1621
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1622 PUTSTA90 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1623 rts
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1624 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1625 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1626 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1627 Finally, the TERM routine simply exits cleanly:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1628 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1629 *****************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1630 * TERM
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1631 * terminate Driver
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 clrb
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1634 rts
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 emod
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1637 RAMEND equ *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1638 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1639 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1640 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1641 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
1642 lot simpler than the SCF one:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1643 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1644 ******************************************
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1645 * RamDisk Discriptor module
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1646 *
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 ifp1
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1649 use /d0/defs/os9defs
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1650 endc
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1651
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1652 nam R0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1653 ttl Drive Discriptor module
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 mod DEnd,DNam,DEVIC+OBJCT,REENT+1,DMgr,DDrv
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1656
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1657 fcb DIR.+SHARE.+PREAD.+PWRIT.+UPDAT.+EXEC.+PEXEC.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1658 fcb $FF IOBlock (unused)
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1659 fdb $FF34 hardware address
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1660 fcb DNam-*-1 option byte count
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1661 fcb $1 Rbf device
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1662 fcb 0 Drive number
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1663 fcb 03 6ms Step rate
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1664 fcb $80 Standard OS9 Winchester drive
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1665 fcb 0 Single density
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1666 fdb 4 number of tracks
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1667 fcb 1 number of sides
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1668 fcb 1 dont verify any writes
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1669 fdb 256 sectors per track
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1670 fdb 256 sectors on track 0, side 0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1671 fcb 1 sector interleave factor
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1672 fcb 1 sector allocation size
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1673 DNam fcs "R0"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1674 DMgr fcs "RBF"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1675 DDrv fcs "RDisk"
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1676 emod
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1677 DEnd equ *
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1678 end
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1679 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1680 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1681 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1682 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
1683 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
1684 (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
1685 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
1686 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
1687 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
1688 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
1689 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
1690 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1691 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1692 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
1693 disk on your system:
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1694 <screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1695 load rdisk
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1696 load r0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1697 chd /r0
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1698 copy /d0/startup /r0/startup #32k
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1699
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1700 etc.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1701 </screen>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1702 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1703 <para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1704 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
1705 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
1706 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
1707 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
1708 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
1709 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
1710 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
1711 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
1712 driver logic.
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1713 </para>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1714 </section>
6b15b51ee3ba An article by Jon Bird about writing OS9 device drivers.
roug
parents:
diff changeset
1715 </article>