[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] pickles: Add mbr.pk for MBR partition table
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH] pickles: Add mbr.pk for MBR partition table |
Date: |
Tue, 26 Jan 2021 07:23:34 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> A new pickle!
> Everything is OK (from my PoV) except a weird constraint violation.
>
> There's a problem in constraint of `magic` field of `MBR` struct.
>
> struct {
> /* ... */
> uint16 magic = 0xaa55UH;
> };
>
> 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...
> +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.