[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] pickles: Add mbr.pk for MBR partition table
From: |
Mohammad-Reza Nabipoor |
Subject: |
Re: [PATCH] pickles: Add mbr.pk for MBR partition table |
Date: |
Tue, 26 Jan 2021 12:13:39 +0330 |
On Tue, Jan 26, 2021 at 07:23:34AM +0100, Jose E. Marchesi wrote:
>
> > This gives constraint violation!
> > I even tried the following alternatives:
> > - `uint16 magic : magic == 0xaa55UH;`
> > - `byte[2] magic = [0x55UB, 0xaaUB];` and
> > - `byte[2] magic : magic == [0x55UB, 0xaaUB];`
>
> Using uint16 won't work in big-endian.
>
> byte[2] magic = [0x55UB, 0xaaUB] should work well...
>
MBR format requires little-endian.
It uses 16-bit and 32-bit little-endian numbers.
> > +type MBR_CHS =
> > + struct
> > + {
> > + byte[3] chs;
> > +
> > + method get_head = uint<8>:
> > + {
> > + return chs[0];
> > + }
> > + method get_sector = uint<6>:
> > + {
> > + return chs[1] & 0x3f;
> > + }
> > + method get_cylinder = uint<10>:
> > + {
> > + return (chs[1] & 0xc0) <<. 2 | chs[2];
> > + }
> > + method _print = void:
> > + {
> > + printf ("#<head=%u8d, sector=%u6d, cylinder=%u10d>",
> > + get_head, get_sector, get_cylinder);
> > + }
> > + };
>
> Where is the CHS address format described? Coulnd't find it in the
> MBR_(x86) article you link.
The second table in https://wiki.osdev.org/Partition_Table.
But it's not very clear.
A better document is https://formats.kaitai.io/mbr_partition_table/index.html.
Or there's a table here:
https://en.wikipedia.org/wiki/Master_boot_record#Partition_table_entries