<< Back

cesky: , English:

SYSDISK

Logical (system) disks

System disks in the Litos8 system support FAT12 and FAT16 file systems with disk size up to 2 GB. Basic or extended partitions are supported on the hard disk. There can be up to 16 system disks, labeled A: to P:. Disks A: and B: are reserved for floppy disks, disk P: is reserved for RAM disk (i.e. memory disk, using remaining free memory up to 640 KB).


SDiskGetNum - get number of valid system disks

OUTPUT:
AL = number of system disks (0..16)


SDiskGetDesc - get system disk descriptor

INPUT:
AL = disk number (0...)

OUTPUT:
BX = pointer to
SDD descriptor (or NULL on CY error)
CY = error, invalid disk number (returns BX = NULL)


SDiskGetInfo - get system disk info TEXT

INPUT:
AL = system disk number (0...)

OUTPUT:
BX = pointer to
TEXT structure (NULL on memory error)
CY = disk or memory error (BX = NULL)

NOTES: Returned text should be destroyed using TextFree.


SDiskGetAllInfo - get system all disks info TEXT

OUTPUT:
BX = pointer to
TEXT structure (NULL on memory error)
CY = memory error (BX = NULL)

NOTES: Returned text should be destroyed using TextFree.


SDiskReadSect - read cached sector

INPUT:
DX:AX = absolute sector (0..)
BX = pointer to
SDD descriptor

OUTPUT:
SI = sector buffer SectBuf
CY = operation error

NOTES: Write cached sector using BDiskWriteSect.


SDDCheck - check system disk device

INPUT:
BL = system disk (0..)

OUTPUT:
CY = invalid system disk


SDDSize - get system disk size

INPUT:
BL = system disk (0..)

OUTPUT:
DX:AX = media size (0 on error)
CY = invalid system disk (DX:AX = 0)


SDDRead - read from system disk device

INPUT:
DX:AX = current sector offset
BL = system disk (0..1)
CX = number of sectors
DI = destination buffer

OUTPUT:
CY = error (CX > 0)
CX = remaining sectors (or CX = 0 if no error NC)


SDDWrite - write to system disk device

INPUT:
DX:AX = current sector offset
BL = system disk (0..1)
CX = number of sectors
DI = source buffer

OUTPUT:
CY = error (CX > 0)
CX = remaining sectors (or CX = 0 if no error NC)


SDiskCheckSize - check system disk size

INPUT:
DX:AX = total number of disk sectors (5..400000h)

OUTPUT:
CY = error, invalid disk size ( < 2.5 KB or > 2 GB)


SDiskReload - reload system disk

INPUT:
BX = pointer to
SDD descriptor

OUTPUT:
CY = error

NOTES: Loads SDD of removable disk if needed.


SDiskMediaDesc - get system disk default media descriptor

INPUT:
BX = pointer to
SDD descriptor

OUTPUT:
AL = default media descriptor


DefFATType - get default FAT type

INPUT:
DX:AX = total number of disk sectors (5..400000h)

OUTPUT:
CH = default
FAT type (SDDF_FAT12, SDDF_FAT16)


DefRootSize - get default root directory size

INPUT:
DX:AX = total number of disk sectors (5..400000h)

OUTPUT:
DI = number of root directory entries (16,32,112,224,448,512)


DefClustSize - get default cluster size

INPUT:
DX:AX = total number of disk sectors (FAT12: 5..40000h, FAT16: 5..400000h)
CH =
FAT type (SDDF_FAT12, SDDF_FAT16)
DI = number of root directory entries (1..0ffffh)

OUTPUT:
CL = sectors per cluster (1,2,4,8,16,32,64)


SDiskDefPar - get default parameters of system disk

INPUT:
DX:AX = total number of disk sectors (FAT12: 5..40000h, FAT16: 5..400000h)
CL = sectors per cluster (1,2,4,8,16,32,64; 0=auto)
CH =
FAT type (SDDF_FAT12, SDDF_FAT16; 0=auto)
DI = number of root directory entries (1..0ffffh, 0=auto)

OUTPUT:
Default parameters


GetClustNum - calculate number of clusters

INPUT:
DX:AX = data sectors (without boot, root and FATs)
CL = sectors per cluster (1,2,4,8,16,32,64)

OUTPUT:
AX = number of clusters (0..0ffffh)
CY = overflow (number of clusters > 64K)


BuildBoot - build BOOT sector parameter table

INPUT:
DX:AX = total number of disk sectors (FAT12: 5..40000h, FAT16: 5..400000h)
CL = sectors per cluster (1,2,4,8,16,32,64; 0=auto)
CH =
FAT type (SDDF_FAT12, SDDF_FAT16; 0=auto)
DI = number of root directory entries (1..0ffffh, 0=auto)
SI = pointer to BOOT sector (
BOOTHEAD structure)

OUTPUT:
Default parameters

NOTES: Fills up these entries: BOOT_OEM_Ident, BOOT_SectSize, BOOT_ClustSize, BOOT_Reserved, BOOT_RootSize, BOOT_SectNumW, BOOT_FATSize, BOOT_SectNum, BOOT_Signature, BOOT_Serial, BOOT_FatName


FAT12 entry (max. 128 MB, usually max. 10 MB):

FAT12_FREE: (=0) FAT12 free cluster
FAT12_MIN: (=2) FAT12 minimal cluster index
FAT12_MAX: (=0fefh) FAT12 maximal cluster index (4079)
FAT12_RESMIN: (=0ff0h) FAT12 minimal reserved cluster (4080)
FAT12_RESMAX: (=0ff6h) FAT12 maximal reserved cluster (4086)
FAT12_BAD: (=0ff7h) FAT12 bad cluster (4087)
FAT12_ENDMIN: (=0ff8h) FAT12 minimal end mark (4088)
FAT12_ENDMAX: (=0fffh) FAT12 maximal end mark (4095)
FAT12_END: (=0fffh) FAT12 default end mark (4095)
FAT12_NUM: (=FAT12_MAX+1-FAT12_MIN) FAT12 max. clusters (4078)
FAT12_FATSECT: (=((FAT12_NUM+(FAT12_NUM+1)/2)+SECTSIZE-1)/SECTSIZE) FAT12 table max. sectors (=12)

FAT16 entry (max. 2 GB):

FAT16_FREE: (=0) FAT16 free cluster
FAT16_MIN: (=2) FAT16 minimal cluster index
FAT16_MAX: (=0ffefh) FAT16 maximal cluster index (65519)
FAT16_RESMIN: (=0fff0h) FAT12 minimal reserved cluster (65520)
FAT16_RESMAX: (=0fff6h) FAT12 maximal reserved cluster (65526)
FAT16_BAD: (=0fff7h) FAT16 bad cluster (65527)
FAT16_ENDMIN: (=0fff8h) FAT16 minimal end mark (65528)
FAT16_ENDMAX: (=0ffffh) FAT16 maximal end mark (65535)
FAT16_END: (=0ffffh) FAT16 default end mark (65535)
FAT16_NUM: (=FAT16_MAX+1-FAT16_MIN) FAT16 max. clusters (65518)
FAT16_FATSECT: (=(FAT16_NUM*2+SECTSIZE-1)/SECTSIZE) FAT16 table max. sectors (=256)


System disk descriptor (logical disk) SDD:

SDD_FlagsDisk: (byte) flags and disk (see below)
SDD_MediaDesc: (byte) media descriptor
SDD_SectClust: (byte) number of sectors per cluster (1,2,4,8,16,32,64)
SDD_FatNum: (byte) number of FAT tables
SDD_LastTime: (word) last access time LOW (in seconds)
SDD_BDD: (word) pointer to
BDD descriptor (0=skip this disk, invalid)
SDD_ResSect: (word) number of reserved sectors (Boot)
SDD_RootEntries: (word) number of Root entries
SDD_FatSect: (word) number of sectors per one FAT
SDD_ClustNum: (word) number of clusters
SDD_RootSect: (word) number of sectors per Root
SDD_ClustSize: (word) cluster size (max. 32KB)
SDD_HiddenSect: (dword) relative hidden sectors
SDD_StartSect: (dword) absolute start sector
SDD_SectNum: (dword) total number of sectors
SDD_Serial: (dword) disk serial number
SDD_RootStart: (dword) start sector with root
SDD_ClustStart: (dword) start sector with clusters

SYSTEM disk flags:

SDDF_DiskMask: (=0fh) system disk (0..15)
SDDF_FAT12: (=B4) FAT 12 format
SDDF_FAT16: (=B5) FAT 16 format
SDDF_FormMask: (=SDDF_FAT12+SDDF_FAT16) mask of file format
SDDF_Valid: (=B6) disk format is valid (loaded)
SDDF_Removable: (=B7) disk is removable


head of FAT12/FAT16 file system BOOTHEAD:

BOOT_Jump: (3 bytes) jump to ReadSect function
BOOT_OEM_Ident: (8 bytes) OEM identifier "LITOS8 1"
BOOT_SectSize: (word) number of bytes per sector
BOOT_ClustSize: (byte) sectors per cluster (1..64)
BOOT_Reserved: (word) reserved sectors (boot)
BOOT_FATNum: (byte) number of FAT tables
BOOT_RootSize: (word) number of root entries
BOOT_SectNumW: (word) number of sectors (if > 65535 this entry is zero)
BOOT_MediaDesc: (byte) media descriptor (FF=320K, FE=160K, FD=360K, FC=180K, F9=1.2M and 720K, F8=HD, FA=RAM, F0=1.44M and 2.88M)
BOOT_FATSize: (word) sectors per one FAT table
BOOT_SectTrk: (word) sectors per track
BOOT_Heads: (word) number of heads
BOOT_Hidden: (dword) number of hidden sectors
BOOT_SectNum: (dword) number of sectors (if > 65535)
BOOT_Disk: (byte) BIOS disk (0=A: or 80h=C:)
BOOT_Head: (byte) head (not used, reserved)
BOOT_Signature: (byte) extension signature 29h
BOOT_Serial: (dword) disk serial number
BOOT_Label: (11 bytes) volume label (11 characters)
BOOT_FatName: (8 bytes) file system (8 chars)

BOOTSIGN EQU 29h ; boot extension signature


Source code SYSDISK.ASM

<< Back