source: mainline/uspace/lib/mbr/mbr.h@ 68b5dd11

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 68b5dd11 was 6453e306, checked in by Martin Decky <martin@…>, 12 years ago

basic code review and coding style cleanup

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 * Copyright (c) 2009 Jiri Svoboda
3 * Copyright (c) 2011-2013 Dominik Taborsky
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 /** @addtogroup libmbr
31 * @{
32 */
33/** @file
34 */
35
36#ifndef LIBMBR_MBR_H_
37#define LIBMBR_MBR_H_
38
39#include <sys/types.h>
40
41enum {
42 /** Number of primary partition records */
43 N_PRIMARY = 4,
44
45 /** Boot record signature */
46 BR_SIGNATURE = 0xAA55
47};
48
49enum {
50 /** Non-bootable */
51 B_INACTIVE = 0x00,
52 /** Bootable */
53 B_ACTIVE = 0x80,
54 /** Anything else means invalid */
55};
56
57enum {
58 /** Unused partition entry */
59 PT_UNUSED = 0x00,
60 /** Extended partition */
61 PT_EXTENDED = 0x05,
62 /** Extended partition with LBA */
63 PT_EXTENDED_LBA = 0x0F,
64 /** GPT Protective partition */
65 PT_GPT = 0xEE,
66};
67
68/** Structure of a partition table entry */
69typedef struct {
70 uint8_t status;
71 /** CHS of fist block in partition */
72 uint8_t first_chs[3];
73 /** Partition type */
74 uint8_t ptype;
75 /** CHS of last block in partition */
76 uint8_t last_chs[3];
77 /** LBA of first block in partition */
78 uint32_t first_lba;
79 /** Number of blocks in partition */
80 uint32_t length;
81} __attribute__((packed)) pt_entry_t;
82
83/** Structure of a boot-record block */
84typedef struct {
85 /** Area for boot code */
86 uint8_t code_area[440];
87 /** Optional media ID */
88 uint32_t media_id;
89 /** Padding */
90 uint16_t pad0;
91 /** Partition table entries */
92 pt_entry_t pte[N_PRIMARY];
93 /** Boot record block signature (@c BR_SIGNATURE) */
94 uint16_t signature;
95} __attribute__((packed)) br_block_t;
96
97#endif
98
Note: See TracBrowser for help on using the repository browser.