Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/mbr/libmbr.h

    rdc76f4a r9bdfde73  
    3838
    3939#include <sys/types.h>
    40 #include "mbr.h"
    4140
    4241#define LIBMBR_NAME     "libmbr"
     42
     43#ifdef DEBUG_CONFIG
     44#include <stdio.h>
     45#include <str_error.h>
     46#define DEBUG_PRINT_0(str) \
     47        printf("%s:%d: " str, __FILE__, __LINE__)
     48#define DEBUG_PRINT_1(str, arg1) \
     49        printf("%s:%d: " str, __FILE__, __LINE__, arg1)
     50#define DEBUG_PRINT_2(str, arg1, arg2) \
     51        printf("%s:%d: " str, __FILE__, __LINE__, arg1, arg2)
     52#define DEBUG_PRINT_3(str, arg1, arg2, arg3) \
     53        printf("%s:%d: " str, __FILE__, __LINE__, arg1, arg2, arg3)
     54#else
     55#define DEBUG_PRINT_0(str)
     56#define DEBUG_PRINT_1(str, arg1)
     57#define DEBUG_PRINT_2(str, arg1, arg2)
     58#define DEBUG_PRINT_3(str, arg1, arg2, arg3)
     59#endif
     60
     61/** Number of primary partition records */
     62#define N_PRIMARY               4
     63
     64/** Boot record signature */
     65#define BR_SIGNATURE    0xAA55
     66
     67enum {
     68        /** Non-bootable */
     69        B_INACTIVE = 0x00,
     70        /** Bootable */
     71        B_ACTIVE = 0x80,
     72        /** Anything else means invalid */
     73};
    4374
    4475typedef enum {
     
    4980        ST_LOGIC = 8
    5081} MBR_FLAGS;
     82
     83enum {
     84        /** Unused partition entry */
     85        PT_UNUSED       = 0x00,
     86        /** Extended partition */
     87        PT_EXTENDED     = 0x05,
     88        /** Extended partition with LBA */
     89        PT_EXTENDED_LBA = 0x0F,
     90        /** GPT Protective partition */
     91        PT_GPT  = 0xEE,
     92};
    5193
    5294typedef enum {
     
    71113} mbr_err_val;
    72114
     115
     116/** Structure of a partition table entry */
     117typedef struct {
     118        uint8_t status;
     119        /** CHS of fist block in partition */
     120        uint8_t first_chs[3];
     121        /** Partition type */
     122        uint8_t ptype;
     123        /** CHS of last block in partition */
     124        uint8_t last_chs[3];
     125        /** LBA of first block in partition */
     126        uint32_t first_lba;
     127        /** Number of blocks in partition */
     128        uint32_t length;
     129} __attribute__((packed)) pt_entry_t;
     130
     131/** Structure of a boot-record block */
     132typedef struct {
     133        /** Area for boot code */
     134        uint8_t code_area[440];
     135        /** Optional media ID */
     136        uint32_t media_id;
     137        /** Padding */
     138        uint16_t pad0;
     139        /** Partition table entries */
     140        pt_entry_t pte[N_PRIMARY];
     141        /** Boot record block signature (@c BR_SIGNATURE) */
     142        uint16_t signature;
     143} __attribute__((packed)) br_block_t;
     144
    73145/** MBR header */
    74146typedef struct {
Note: See TracChangeset for help on using the changeset viewer.