ALL ABOUT THE BIOS by Cronos
Originally published in ST NEWS Volume 1 Issue 3, launched on
August 16th, 1986.
As most of you will know, the word BIOS is short for Basic
Input/Output System. One could call it the interface between
GEMDOS and the hardware. Before I start talking about all the BIOS
functions, you should know a few things:
Data should be given to the stack before you call a BIOS function
Sometimes, return values are put into D0
Except for registers D0-D2 and A0-A2 will all register stay
intact
For the BIOS functions, TRAP number 13 was reserved
Most information used in this article is used from "The
Hitchhiker's Guide to the BIOS", ©1985 by Atari, Inc.
You can now read a systematic list of BIOS calls: their numbers,
names and functions.....
(0) getmpb
VOID getmpb(p_mpb)
LONG p_mpb;
Upon entry, 'p_mpb' points to a 'sizeof(MPB)' block to be filled
in with the system initial Memory Parameter Block. Upon return,
the MPB is filled in.
(1) bconstat
WORD bconstat(dev)
WORD dev;
Returns character-device input status, D0.L will be $0000 if no
characters are available, or $FFFF if (at least one) character is
available. 'dev' can be one of these:
0 PRT: printer, the parallel port
1 AUX: aux device, the RS232 port
2 CON: console, the screen
3 MIDI: the midi interface
4 KBD: keyboard
Legal operations on character devices are:
(0) (1) (2) (3) (4)
Operation PRT AUX CON MIDI KBD
----------------------------------------------------------------
bconstat() no yes yes yes no
bconin() yes yes yes yes no
bconout() yes yes yes yes yes
bcostat() yes yes yes yes yes
(2)bconin
WORD bconin(dev)
WORD dev;
'dev' is the character device number described in function 1. This
does not return until a character has been input (busy-wait). It
returns the character value in D0.L, with the high word zero (in
case you don't know what a word is: it's 2 bytes = 16 bits, RED).
For the console (CON: device 2) it returns the IBM-PC compatible
scancode in the low byte of the upper word, and the Ascii
character in the low byte of the low word.
If bit 3 in the system variable 'conterm' is set, then the high
byte of the upper word will contain the value of the system
variable 'kbdshift' for that keystroke. Normally, bit 3 of
'conterm' is not set (0). If you want to know more about system
variables, please read the article about system variables in ST
NEWS Volume 1 Issue 2.
(3) bconout
VOID bconout (dev,c)
WORD dev, c;
'dev' is the character device number described in function 1.
Output character 'c' to the device. Does not return untill the
character has been written.
(4) rwabs
LONG rwabs(rwflag,buf,count,recno,dev)
WORD rwflag;
LONG buf;
WORD count, recno, dev;
Read or write logical sectors on a device. 'rwflag' is one of:
0 read
1 write
2 read, do not affect media change
3 write, do not affect media change
'buf' points to a buffer to read or write to (unaligned transfers
- on odd boundaries - are permitted, but they are slow). 'count'
is the number of sectors to transfer. 'recno' is the logical
sector number to start the transfer at. 'dev' is the device
number, which can be one of:
0 floppy drive A
1 floppy drive B (or 'logical' drive A on single-drive
systems)
2+ hard disks, networks, etc.
On return, OL indicates a succesful operation. Any negative number
indicates an error condition. (It is the responsibility of the
BIOS to detect media changes, and return the appropriate error
code)
Modes 2 and 3 force a physical disk operation that will NOT affect
the media change, nor result in one (this allows the GEMDOS disk
formatter, for instance, to read and write logical sectors after
formatting a disk, and still allow the BIOS to recognize a media
change on the volume just formatted).
(5) setexc
LONG setexc(vecnum,vec)
WORD vecnum
LONG vec;
'vecnum' is the number of the vector to get or set. 'vec' is the
address to setup in the vector slot; no set is done if 'vec' is -
1L. The vector's previous value is returned.
Vectors $00 through $FF are reserved for the 68000.
Logical vectors $100 through $1FF are reserved for GEMDOS. Vectors
currently implemented are:
$100 System Timer Interrupt
$101 Critical Error Handler
$102 Process terminate hook
$103-$107 Currently unused, reserved
Logical vectors $200 through $FFFF are reserved for OEM use. The
ST BIOS makes no provision for these.
(6) tickcal
LONG tickcal()
Returns a system-timer calibration value, to the nearest
millisecond.
This is a silly function, since the number of elapsed milliseconds
is passed on the stack duyring a system-timer trap.
(7) *getbpb
BPB *getbpb(dev)
WORD dev;
'dev' is a device number (0 for drive A, etc.). Returns a pointer
to the BIOS Parameter Block for the specified drive, or 0L if (for
some reason) the BPB cannot be determined.
(8) bcostat
LONG bcostat(dev)
'dev' is a character device number, as in function 1. Returns the
character output status:
-1 Device is ready to send (no waiting on next
device output call)
0 Device is not ready to send
(9) mediach
LONG mediach(dev)
WORD dev
'dev' is a drive number. Returns are on of these:
0 Media definately has not changed
1 Media might have changed
2 Media definately has changed
GEMDOS will respond with a return value of "1" with a read
operation. If the BIOS detects an absolute media change, it will
return a "media change error" at that time.
(10) drvmap
LONG drvmap()
Returns a bit-vector that contains a "1" in a bit position
(0...31) when a drive is available for that bit, or a 0 if there
is no drive available for that bit.
Installable disk drivers must correctly maintain the longword
'_drvbits' (see the chapter about system variables in ST NEWS
volume 1 issue 2).
(11) kbshift
LONG kbshift(mode)
WORD mode
If 'mode' is non-negative, sets the keyboard shift bits
accordingly and returns the old shift bits. If 'mode' is less than
zero, returns the IBM-PC compatible state of the shift keys on the
keyboard, as a bit-vector in the low byte of d0.
Bit assignments are:
0 Right shift key
1 Left shift key
2 Control key
3 ALT key
4 Caps-lock
5 Right mouse button (CLR/HOME)
6 Left mouse button (INSERT)
7 (reserved, currently zero)
That's all for this time; next time more about GEMDOS...
Disclaimer
The text of the articles is identical to the originals like they appeared
in old ST NEWS issues. Please take into consideration that the author(s)
was (were) a lot younger and less responsible back then. So bad jokes,
bad English, youthful arrogance, insults, bravura, over-crediting and
tastelessness should be taken with at least a grain of salt. Any contact
and/or payment information, as well as deadlines/release dates of any
kind should be regarded as outdated. Due to the fact that these pages are
not actually contained in an Atari executable here, references to scroll
texts, featured demo screens and hidden articles may also be irrelevant.