home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 1
/
FishNMoreVol1.bin
/
more
/
system
/
idev
/
idev.doc
< prev
next >
Wrap
Text File
|
1988-01-02
|
8KB
|
245 lines
IDEV: An Interactive Device Explorer
--------------------------
Ed Puckett August 26, 1987
INTRODUCTION
IDEV will let you muck around with Amiga Exec devices,
interactively sending and receiving data through IORequests.
A data buffer and an extended IORequest are maintained
internally for your use. You may read or write the data
contained in these two structures to or from disk files;
with the aid of a file zap utility or an invertible dump
program, you will be able to send almost anything you please
to a device, and also see what returns.
I wrote IDEV to help me discover how to use the sasi.device
which came with my Tecmar T-card. It was my means of
"hypothesis testing" between rounds of disassembly!
[ Amiga is a trademark of Commodore-Amiga Inc. ]
[ Tecmar and T-card are trademarks of Tecmar, Incorporated. ]
BACKGROUND AND CONVENTIONS
This document assumes some familiarity with Exec devices
and libraries.
Numbers will be represented in this document as follows:
* If a string begins with `0x', the remaining portion
is the hexadecimal representation of the intended number.
* If it begins with `0', but not `0x', then it is octal.
* Strings beginning with the digits `1' through `9' are
decimal representations.
(Unfortunately, IDEV itself only understands numbers input
in decimal representation, even if they begin with `0'.
IDEV's output follows the above conventions.)
USING IDEV
IDEV is invoked with three parameters: the name of the device,
the unit number, and the flags to be passed to OpenDevice().
For example,
IDEV sasi.device 1 10
tells IDEV to open unit 1 of the device "sasi.device" with
flags 0x0A. (Note that you are forced to give the decimal
representation of numbers.)
Unless there is a problem opening the device (in which case
you will be informed and the program will exit), idev will
print the following:
| Device: "sasi.device"
| Unit: 1
| Flags: 0x0000000A
|
| Buffer Address = 0x00123456 I/O Request Address = 0x00654321
| Buffer Size = 0x00000400 I/O Request Size = 0x00002000
|
| Commands:
| ? or h help
| ri filename read I/O request from file
| wi filename size write I/O request to file
| rb filename read buffer from file
| wb filename size write buffer to file
| & patch buffer address to ioreq->io_Data
| ! send I/O request to device via DoIO
| ^ n send I/O request in reg A1 via vector #n
| q quit
|
| Notes: I/O request memory is read/written starting from io_Command.
| Vectors are numbered starting from 1.
| ESC ('\\033') will abort a partially entered command.
Note: the addresses given above are for illustration only.
They are the addresses of the internal buffers, wherever they
landed. The sizes reflect hard-coded constants: the data buffer
is given 1024 bytes and the I/O request is given 8192 bytes.
The "Device", "Unit" and "Flags" come from the command line.
The above help screen is produced by typing either `?'
or `h'. (All commands are parsed ignoring case, so `H'
will also produce the help screen.)
Reading Data Into the Internal Structures
To modify either the data buffer or the I/O Request
structure, you may read them in from a file. For example,
r i T:iobytes
reads the file "T:iobytes" into the I/O Request. It stops
when EOF is reached, or when the end of the buffer is reached,
whichever comes first. (If the file is indeed larger than
the buffer, you will be informed.)
(Note: there is no way to specify file names which contain
embedded spaces. Quotes will be parsed as parts of their
adjoining strings.)
The space between the `r' and the `i' above is optional.
Commands may be spread across more than one line or,
opppositely, many commands may be issued on a single line.
However, the prompt "IDEV-->" will be issued as each
command is parsed.
If an error is encountered while parsing a command, the
remaining characters on the line will be discarded and
the next command will be parsed beginning on the next line.
When the I/O Request is read from or written to a file, its
first 0x1C bytes are unaffected (i.e., the io_Message,
io_Device and io_Unit fields are untouched). The total
number of bytes transferred does not include these bytes.
Writing Internal Data to a File
Now, let's say you have sent an I/O Request (through
mechanisms described later), and want to examine the data
buffer which the device filled for you. You might type:
w b T:returned_buf 512
This will write a binary image of the first 512 bytes of the
internal data buffer to the file "T:returned_buf". Unless
the buffer contained text, it will probably not be editable.
Instead, process files written in this manner with a file
zap program, or use a dump program (preferably an invertible
one, so you can convert the edited files back to binary).
Notice that if we had written the I/O Request like:
w i T:returned_ioreq 512
we get bytes 0x001C through 0x021B of the I/O request dumped
to the file because the first 0x1C bytes are protected.
The `&' command patches the buffer address into the
I/O Request's io_Data field. A typical setup for a call
to a device is:
ri T:intended_ioreq rb T:intended_buf &
All three commands are entered on one line here. This reads
the I/O request and data buffer from their respective files,
and then links them using the `&' command.
Don't forget to link in the data buffer before sending
the I/O Request, especially if you want the device to
write to the buffer. Leaving garbage there (say 0x000004)
can evoke Amiga trances!
Sending Data to the Device
Two mechanisms are provided by which you may call the
device with data you have prepared for it.
`!' sends the current I/O Request to the device via DoIO(),
and prints the returned error code when (if?) it returns
(or "no error" if 0 is returned).
`^', in conjunction with a number, calls one of the
device's library vectors. For example,
^ 1
calls the device's Open() vector, and
^ 3
calls the device's Expunge() vector. The device is passed
the pointer to the I/O request in register A1, and the
value returned is printed in the same fashion as with `!'.
The device's vector table is scanned in an attempt to
prevent nonexistent vectors from being called. If a NULL
or -1 longword is found prior to your requested vector,
an error will be issued.
If this calling mechanism does not fit the device with which
you are working, you must modify the program. Notably, the
register by which the I/O request is sent cannot be changed
by any IDEV command.
Additional Notes
Command parsing is case-insensitive.
CTRL-C will abort most operations over which IDEV has control.
It probably will not break out of a stuck DoIO() call, however.
CTRL-C stops the cleans up the structures and exits the program.
The <ESC> character will abort partially entered commands,
like the following:
w b T:junk <ESC>
In addition, the rest of the line on which the <ESC> appears
is discarded.
Warnings are prefixed by three astersisks followed by the word
"Warning: " ("*** Warning: ").
Error messages are prefixed by three asterisks ("***") not
followed by the word "Warning".
COMPILATION
IDEV is written in C, with one support routine in 68000
assembly language. It compiles using Lattice 3.03.
Compile main.c and idev.c to produce main.o and idev.o,
and assemble vect_intfc.asm to vect_intfc.o. Then use
Alink (or BLink) to link the modules together:
Alink FROM LStartup.obj,main.o,idev.o,vect_intfc.o \
TO idev \
LIBRARY amiga.lib lc.lib
AUTHOR
+-------------------------------------------\
| Ed Puckett \
| \
| EMAIL: ...!ihnp4!mit-eddie!mit-oz!qix } (26-Aug-87)
| US MAIL: MIT Branch PO, Box 61 /
| Cambridge, MA 02139 /
+-------------------------------------------/