anchor.diff:     dup f = swap          ( true|false true|false id )
      85 =                  ( true|false true|false true|false )
      or or                 ( true|false )
  -;
  -
  -: partition>part-entry ( partition -- part-entry )
  -   1- /partition-entry * block mbr>partition-table +
  -;
  -
  -: partition>start-sector ( partition -- sector-offset )
  -   partition>part-entry part-entry>sector-offset l@-le
   ;
   
   : count-dos-logical-partitions ( -- #logical-partitions )
  
positive.code: 
  CONSTANT /partition-entry
  
  
  \ Defined by IEEE 1275-1994 (3.8.1)
  
  
negative.code:    drop 0
  ;
  
  \ Check for GPT PReP partition GUID
  9E1A2D38     CONSTANT GPT-PREP-PARTITION-1
  C612         CONSTANT GPT-PREP-PARTITION-2
  4316         CONSTANT GPT-PREP-PARTITION-3
  AA26         CONSTANT GPT-PREP-PARTITION-4
  8B49521E5A8B CONSTANT GPT-PREP-PARTITION-5
  
  : gpt-prep-partition? ( -- true|false )
     block gpt-part-entry>part-type-guid l@-le GPT-PREP-PARTITION-1 = IF
        block gpt-part-entry>part-type-guid 4 + w@-le
        GPT-PREP-PARTITION-2 = IF
           block gpt-part-entry>part-type-guid 6 + w@-le
           GPT-PREP-PARTITION-3 = IF
              block gpt-part-entry>part-type-guid 8 + w@
              GPT-PREP-PARTITION-4 = IF
                 block gpt-part-entry>part-type-guid a + w@
                 block gpt-part-entry>part-type-guid c + l@ swap lxjoin
                 GPT-PREP-PARTITION-5 = IF
                     TRUE EXIT
                 THEN
              THEN
           THEN
        THEN
     THEN
     FALSE
  ;
  
  : load-from-gpt-prep-partition ( addr -- size )
     no-gpt? IF FALSE EXIT THEN
     debug-disk-label? IF
        cr ." GPT partition found " cr
     THEN
  
     1 read-sector block gpt>part-entry-lba l@-le
     block-size * to seek-pos
     block gpt>part-entry-size l@-le to gpt-part-size
     block gpt>num-part-entry l@-le dup 0= IF FALSE EXIT THEN
     1+ 1 ?DO
        seek-pos 0 seek drop
        block gpt-part-size read drop gpt-prep-partition? IF
           debug-disk-label? IF
              ." GPT PReP partition found " cr
           THEN
           block gpt-part-entry>first-lba x@ xbflip
           block gpt-part-entry>last-lba x@ xbflip
           over - 1+                 ( addr offset len )
           swap                      ( addr len offset )
           block-size * to part-offset
           0 0 seek drop             ( addr len )
           block-size * read         ( size )
           UNLOOP EXIT
        THEN
        seek-pos gpt-part-size i * + to seek-pos
     LOOP
     FALSE
  ;
  
  \ load from a bootable partition
  
  : load-from-boot-partition ( addr -- size )
     load-from-dos-boot-partition dup 0= IF
       drop load-from-gpt-prep-partition
     THEN
     \ More boot partition formats ...
  ;
  
  