ST-DOS specific syscalls ST-DOS kernel mostly implements the standard DOS API, but some of the syscalls are special to ST-DOS. Those are listed here. The kernel supports nested syscalls, which means that the programs can also do syscalls from interrupt handlers. The device drivers can also do syscalls. Doing syscalls that may cause disk I/O and/or DMA I/O from device interrupt handlers and int 28h handler is not allowed and may crash the system. Nested syscalls may cause the kernel to not restore the FLAGS register correctly, but it shouldn't normally be a problem. (ah == 0x18): Get information about the first memory control block Returns: AX = segment of the first MCB DX = code segment of the kernel This is used by the MEM.COM program. (ah == 0x6a) Load a driver Arguments: DX:BX = pointer to a string containing the name of the device DS:DI = pointer to a table of driver functions CX = type of the driver (0 == device, 1 == filesystem driver, 2 == mount filesystem image file, 3 == unmount filesystem image, 4 == mount drive partition, 5 == unmount drive partition, 6 == get address to the kernel's DMA buffer, 7 == change filesystem size) Loads a device driver. After this syscall the device can be opened to a file handle. For example if the name of the device (DX:BX) is "NULL", all strings from NULL0 - NULL65535 become reserved filenames that all refer to devices handled by this driver. When mounting a filesystem image: DS:DI[0] = target drive (A = 0, B = 1 ...) DS:DI[1] = filesystem type (FAT12 = 1, FAT16 = 0, use filesystem driver = 0x80) DS:DI[2] = partition size in blocks (dword) DS:DI[6] = path to the image file (ASCIIZ) DX:BX = name of the filesystem driver if DS:DI[1] == 0x80 When unmounting a filesystem image: DX:BX[0] = target drive (A = 0, B = 1 ...) Returns: If no error, AX = 0 and carry flag clear If error, AX = -1 or an error code and carry flag set When mounting a drive partition: DS:DI[0] = target drive(A = 0, B = 1 ...) DS:DI[1] = filesystem type (FAT12 = 1, FAT16 = 0, use filesystem driver = 0x80) DS:DI[2] = sector size (word) DS:DI[4] = partition size in blocks (dword) DS:DI[8] = starting sector of the partition (dword) DX:BX = name of the filesystem driver if DS:DI[1] = 0x80 Returns the drive number to AX (0 = A, 1 = B...) When unmounting a drive partition: DX:BX[0] = target drive(A = 0, B = 1 ...) Returns 0 if the drive was successfully unmounted. Address to the kernel's DMA buffer: DS:DI must point to a 6 bytes long buffer. The kernel returns the following values to the buffer: Offset 0: 16-bit word, length of the DMA buffer Offset 2: 32-bit far pointer to the DMA buffer This function is useful for device drivers and filesystem drivers that may want to "borrow" the DMA buffer that the kernel uses for disk I/O. The program MUST call this function every time before using the buffer. When changing the size of a filesystem: DS:DI must point to a identical struct as in subfunction 4. Offset 0 contains the drive number, offset 2 contains the sector size in bytes and offset 4 contains the new size in blocks. (ah == 0x6b) Send a command to a driver Arguments: DX:BX = pointer to a string containing the name of the device DS:DI = pointer to the command Sends a command to a driver. Returns: If no error, AX = a value returned by the driver and carry flag clear If error, AX = error code and carry flag set Possible error codes from the kernel: 0x01 = the driver does not support this function 0x02 = incorrect name of a driver The driver can also set its own error code. (ah == 0x6c) Unload a driver Arguments: DX:BX = device name Unloads a driver. Returns: If no error, carry flag is not set If error, carry flag is set and AX contains an error code (ah == 0x6d) Set or get file buffer size Arguments: al == 0: set file buffer size == 1: get file buffer size == 2: allocate cache buffer BX == new file buffer size in bytes if al == 0 == count of allocated paragraphs if al == 2 DS:DI == pointer to a byte if al == 2 If al == 0 or 1: Set or get file buffer size. The default file buffer size is 65535. If al == 2: Allocates a cache buffer. The user program can use the allocated buffer to store temporary data. When the kernel needs that memory area for something else, it deallocates and overwrites it and writes 0xFF to the byte that was pointed in DS:DI. This function is useful for device and filesystem drivers for caching stuff. The program can temporarily lock the buffer by writing 0xFE to the byte in DS:DI, which prevents the kernel from freeing it. Returns: AX = file buffer size, or segment of allocated memory block