[Home]
[Search]
[CTG]
[RTL]
[IDDE]
Last update Mar 27, 2002
The following command values are available:
| cmd | Meaning |
|---|---|
| 0 | Resets disk system by a hard reset; all other parameters are ignored. |
| 1 | Returns the status of the last disk operation; all other parameters are ignored. |
| 2 | Reads the specified disk sectors. The head, track, and sector arguments specify the starting sector. The nsects argument specifies the number of sectors to read. The read data is stored in buffer. |
| 3 | Writes disk sectors from memory. The head, track, and sector arguments specify the starting sector. The nsects argument specifies the number of sectors to write. The data is read from buffer. |
| 4 | Verifies sectors. The head, track, and sector arguments specify the starting sector. The nsects argument specifies the number of sectors to verify. |
| 5 | Formats a track. The head and track arguments specify the track to format. Buffer stores the sector headers. |
| 6 | Formats a track and sets bad sector flags. |
| 7 | Formats the drive beginning at a specific track. |
| 8 | Gets the current drive parameters and stores them in buffer. |
| 9 | Initializes drive-pair characteristics. |
| 10 | Does a long read. |
| 11 | Does a long write. |
| 12 | Does a disk seek. |
| 13 | Alternates disk reset. |
| 14 | Reads sector buffer. |
| 15 | Writes sector buffer. |
| 16 | Tests the specified drive to see if it is ready. |
| 17 | Recalibrates the drive. |
| 18 | Performs diagnostics on controller RAM. |
| 19 | Performs drive diagnostics. |
| 20 | Performs controller internal diagnostics. |
| 0x00 | Successful completion |
| 0x01 | Bad command |
| 0x02 | Address mark not found |
| 0x03 | Attempt to write to write-protected disk |
| 0x04 | Sector not found |
| 0x05 | Reset failed (hard disk) |
| 0x06 | Disk changed since last operation |
| 0x07 | Drive parameter activity failed |
| 0x08 | Direct memory access (DMA) overrun |
| 0x09 | Attempt to perform DMA across 64K |
| 0x0A | Bad sector detected |
| 0x0B | Bad track detected |
| 0x0C | Usupported track |
| 0x11 | CRC/ECC corrected data error |
| 0x20 | Controller failure |
| 0x40 | Seek operation failed |
| 0x80 | Attachment failed to respond |
| 0xAA | Drive not ready (hard disk) |
| 0xBB | Undefined errror occurred (hard disk) |
| 0xCC | Write fault occurred |
| 0xE0 | Status error |
| 0xFF | Sense operation failed |
/* Example for biosdisk */
#include <stdio.h>
#include <stdlib.h>
#include <bios.h>
void main()
{
int result;
char buffer[512];
printf("Attempting to read from drive A:\n");
result = biosdisk(_DISK_READ, 0, 0, 1, 1, 1, buffer);
}
| Name | Value | Meaning |
|---|---|---|
| _KEYBRD_READ | 0x00 | Read the next key value from the keyboard input buffer. Wait for one if none are available. |
| _KEYBRD_READY | 0x01 | Determine if any keys are in the keyboard input buffer. |
| _KEYBRD_SHIFTSTATUS | 0x02 | Read the status of the shift keys. |
| _NKEYBRD_READ | 0x10 | Enhanced read |
| _NKEYBRD_READY | 0x11 | Enhanced ready |
| _NKEYBRD_SHIFTSTATUS | 0x12 | Enhanced shift status |
If flag is 1, 0 is returned if there are no keys in the input buffer, otherwise the next key value is returned. The key value is not removed from the input buffer, and is still available to be read.
If flag is 2, the value returned is the state of the shift keys
encoded into the bits as follows:
| 0x01 | Right shift key is down |
| 0x02 | Left shift key is down |
| 0x04 | Ctrl key is down |
| 0x08 | Alt key is down |
| 0x10 | Scroll Lock is toggled |
| 0x20 | Num Lock is toggled |
| 0x40 | Caps Lock is toggled |
| 0x80 | Ins is toggled |
/* Example for _bios_keybrd */
#include <bios.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
int key, shift;
int lastshift;
while (1)
{
shift = _bios_keybrd(2);
/* if shift status changes */
if (shift != lastshift)
printf("Shift = 0x% 02x \n", shift);
/* if a key is available */
if (_bios_keybrd(1))
{
/* read the key */
key = _bios_keybrd(0);
if ((key & 0xFF) == 'q') break;
printf("Key = 0x% 04x \n", key);
}
lastshift = shift;
}
}
/* Example for biosprint */
#include <stdio.h>
#include <bios.h>
void main ()
{
int status, bit_number;
char *description[] =
{
"Printer timed out",
"Unknown status",
"Unknown status",
"I/ O error",
"Printer selected",
"Out of paper",
"Acknowledge",
"Printer not busy"
};
status = biosprint (_PRINTER_STATUS, 0, 1);
for (bit_number = 0; bit_number < 8;
bit_number += 1)
if (status & (1 << bit_number))
printf("% s\n",
description[bit_number]);
}
/* Example for biostime */
#include <stdio.h>
#include <bios.h>
void main ()
{
long ticks;
ticks = biostime (0, 0L);
printf("Ticks since midnight is %d\n",
ticks);
}
Six services are available on a basic IBM PC. They are selected by service:
| service | Value | Operation |
|---|---|---|
| _DISK_RESET | 0 | Causes a hard reset of the floppy disk controller and is useful after an error occurs. Ignores the info parameter. |
| _DISK_STATUS | 1 | Obtains the status of the last disk operation. Ignores the info parameter. |
| _DISK_READ | 2 | Reads one or more disk sectors into the memory buffer pointed to by buffer in the diskinfo_t structure. Requires all fields in the diskinfo_t structure, pointed to by info, be correctly set up. |
| _DISK_WRITE | 3 | Writes one or more disk sectors with data from the memory buffer pointed to by buffer in the diskinfo_t structure. Requires all fields in structure diskinfo_t, pointed to by info, be correctly set up. |
| _DISK_VERIFY | 4 | Verifies that disk sectors exist and are readable. Performs a CRC (cyclic redundancy check). Requires all fields in structure diskinfo_t, pointed to by info, be correctly set up. |
| _DISK_FORMAT | 5 | Formats the track specified in the head and track fields of the diskinfo_t structure pointed to by info. Only one track can be formatted in each call. The buffer field contains a set of sector markers, the format of which depends on the type of disk drive. See an IBM reference manual for marker formats. |
struct diskinfo_t {
unsigned drive; /* drive number*/
unsigned head; /* head number*/
unsigned track; /* track number*/
unsigned sector; /* start sector no.*/
unsigned nsectors; /* sectors to process */
void __far *buffer; /* Memory buffer to use */
};
| 0x01 | Invalid request / bad command |
| 0x02 | Address mark not found |
| 0x04 | Sector not found |
| 0x05 | Reset failure |
| 0x07 | Drive parameter activity failure |
| 0x09 | DMA overrun |
| 0x0a | Bad sector flag detected |
| 0x10 | Data read (ECC) error |
| 0x11 | Corrected data read (ECC) error |
| 0x20 | Controller failure |
| 0x40 | Seek error |
| 0x80 | Disk timed out / not responding |
| 0xaa | Drive not ready |
| 0xbb | Undefined error |
| 0xcc | Write fault |
| 0xe0 | Status error |
| 0XFF | Sense operation failed |
/* Example for _bios_disk */
#include <bios.h>
#include <stdio.h>
#include <stdlib. h>
int lowbytes (int tomask)
{
return (tomask & 0x00FF);
}
int highbytes (int toshift)
{
return (toshift >> 8);
}
void main()
{
int status;
struct diskinfo_t disk;
status = _bios_disk (1, &disk);
status = highbytes (status);
if (status != 0)
printf("Last disk operation had error
%x\n", status);
else
printf("Last disk operation completed
OK.\n");
}
/* Example for _bios_equiplist */
#include <bios.h>
#include <stdio.h>
#include <stdlib. h>
#define GAME_ADAPTOR 0x0c
void main()
{
unsigned equipment;
equipment = _bios_equiplist();
if (equipment & GAME_ADAPTOR)
printf("Game adaptor installed.\n");
else
printf("No game adaptor installed.\n");
}
/* Example for _bios_keybrd */
#include <bios.h>
#include <stdio.h>
#include <stdlib. h>
void main()
{
int key, shift;
int lastshift;
while (1)
{
shift = _bios_keybrd (2);
/* if shift status changes */
if (shift != lastshift)
printf("Shift = 0x% 02x \n", shift);
/* if a key is available */
if (_bios_keybrd(1))
{
/* read the key */
key = _bios_keybrd(0);
if ((key & 0xFF) == 'q') break;
printf("Key = 0x% 04x \n", key);
}
lastshift = shift;
}
}
/* Example for _bios_memsize */
#include <bios.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
printf("The memory size of this system is
%dK\n",_bios_memsize());
}
/* Example for _bios_printer
*/
#include <bios.h>
#include <stdio.h>
#include <stdlib. h>
void main()
{
unsigned i, data = 36;
unsigned status;
printf("Place printer offline and
press \n");
getchar ();
status = _bios_printer(2,0, data);
printf("Status with printer offline: %x\n",
status);
printf("Press to initialize printer\n");
getchar();
status = _bios_printer(1,0, data);
printf("Status after printer initialized:
%x\n", status);
printf("Press to print\n");
getchar();
for (i= 0; i> 10; i++)
_bios_printer (0,0, data);
status = _bios_printer (0,0, '\n');
printf("Status after printing %d %c's:% x\n",
i, data, status);
}
/* Example for _bios_serialcom */
#include <bios.h>
#include <stdio.h>
#include <stdlib. h>
void main()
{
unsigned com1_status;
com1_status = _bios_serialcom (3,0,0);
printf("Com1 status : %x\n", com1_status);
}
| mode | Value | Meaning |
|---|---|---|
| _TIME_GETCLOCK | 0 | Retrieve time |
| _TIME_SETCLOCK | 1 | Set time |
/* Example for _bios_timeofday */
#include <bios.h>
#include <stdio.h>
#include <stdlib. h>
void main()
{
unsigned hours, minutes;
long btime;
_bios_timeofday (0,& btime);
btime = (btime* 10)/ 182;
minutes = (unsigned) btime / 60;
hours = minutes / 60;
minutes %= 60;
printf("The time is %2d:% 2d\n",
hours, minutes);
}
/* Example for _int86 */
#include <dos.h>
#include <stdio.h>
void main ()
{
union _REGS inregs, outregs;
unsigned char last_flags, new_flags;
int n;
char *description[] =
{
"right shift",
"left shift",
"control",
"alt",
"scroll lock",
"num lock",
"caps lock",
"insert"
};
printf("Press keyboard toggles and shift
keys\n");
printf("Press ctrl-break to quit\n");
for (;;)
{
inregs. h. ah = 2; /* get keyboard flags */
_int86 (0x16, &inregs, &outregs);
new_flags = outregs. h. al ^ last_flags;
if (new_flags)
for (n = 0; n < 8; n += 1)
if (new_flags & (1 << n))
printf("% s %s\n", description[n],
outregs. h. al & (1 << n)? "on":
"off");
last_flags = outregs. h. al;
}
}
See _int86