How are the addresses of CHS begin and CHS end in the entries for sections in the MBR? I mean, let's say, the first byte is the number of the cylinder, the second is the heads, the third is the sectors, or is it somehow different? Somewhere I saw that some bits were "borrowed" from neighboring bytes, but I was no longer able to find that site, and then I didn’t understand anything.
1 answer
The MBR partition descriptor looks like this:
uint8 IsBootable; // 00 or 80h uint8 BeginHead; uint16 BeginSecCyl; // CX for int 13h uint8 FileSystem; uint8 EndHead; uint16 EndSecCyl; uint32 BeginAbsSect; uint32 TotalSectors; BeginSecCyl is designed to be suitable for use in int 13h .
les BX, buf mov AX, 0201h ; 02 = read, 01 = 1 sector mov CX, [BeginSecCyl] ; значение из соответствующего поля mov DH, [BeginHead] mov DL, 80h ; 80h для HDD + номер диска int 13h It considers you the boot sector of the selected partition in buf .
In BeginSecCyl lower 6 bits indicate the sector number, the upper 8 bits indicate the lower 8 bits of the cylinder number, and the remaining 2 bits (6–7) indicate the upper two bits of the cylinder number.
Addressing CHS is outdated, it allows you to gain access to only 8 gigabytes of disk. Modern drives use LBA addressing. The LBA address of the first sector is in the BeginAbsSect .
You cannot read large disks via int 31h , but the operating system allows you to open the entire disk as a file (Windows through CreateFile / ReadFile from "\\.\PhysicalDrive0" , Unix via /dev ), and read sectors at the desired offset. Newer operating systems ignore CHS values from the MBR, and use LBA addresses.
Since the BeginAbsSect field is 32 bits in size, this imposes another addressing limit: 2 terabytes. (An LBA address can take up to 48 bits.) This limit cannot be overcome while remaining in the MBR format. For larger discs, GPT is used.
- Thank! <AntiFilterDown> - velikiyv4
- @ velikiyv4: Please! - VladD
- @ velikiyv4: Updated the answer. - VladD