1 /* ----------------------------------------------------------------------- *
3 * Copyright 2003-2009 H. Peter Anvin - All Rights Reserved
4 * Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
5 * Copyright (C) 2010 Shao Miller
7 * Permission is hereby granted, free of charge, to any person
8 * obtaining a copy of this software and associated documentation
9 * files (the "Software"), to deal in the Software without
10 * restriction, including without limitation the rights to use,
11 * copy, modify, merge, publish, distribute, sublicense, and/or
12 * sell copies of the Software, and to permit persons to whom
13 * the Software is furnished to do so, subject to the following
16 * The above copyright notice and this permission notice shall
17 * be included in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 * OTHER DEALINGS IN THE SOFTWARE.
28 * ----------------------------------------------------------------------- */
31 * @file syslinux/disk.h
33 * Deal with disks and partitions
36 #ifndef _SYSLINUX_DISK_H
37 #define _SYSLINUX_DISK_H
42 #define SECTOR 512 /* bytes/sector */
46 int ebios; /* EBIOS supported on this disk */
47 int cbios; /* CHS geometry is valid */
52 struct disk_ebios_dapa {
61 * CHS (cylinder, head, sector) value extraction macros.
62 * Taken from WinVBlock. None expand to an lvalue.
64 #define chs_head(chs) chs[0]
65 #define chs_sector(chs) (chs[1] & 0x3F)
66 #define chs_cyl_high(chs) (((uint16_t)(chs[1] & 0xC0)) << 2)
67 #define chs_cyl_low(chs) ((uint16_t)chs[2])
68 #define chs_cylinder(chs) (chs_cyl_high(chs) | chs_cyl_low(chs))
69 typedef uint8_t disk_chs[3];
71 /* A DOS partition table entry */
72 struct disk_dos_part_entry {
73 uint8_t active_flag; /* 0x80 if "active" */
79 } __attribute__ ((packed));
86 struct disk_dos_part_entry table[4];
88 } __attribute__ ((packed));
89 #define disk_mbr_sig_magic 0xAA55
92 * A GPT disk/partition GUID
94 * Be careful with endianness, you must adjust it yourself
95 * iff you are directly using the fourth data chunk.
96 * There might be a better header for this...
103 } __attribute__ ((packed));
106 * This walk-map effectively reverses the little-endian
107 * portions of a GPT disk/partition GUID for a string representation.
108 * There might be a better header for this...
110 static const char guid_le_walk_map[] = {
118 /* A GPT partition */
119 struct disk_gpt_part_entry {
126 } __attribute__ ((packed));
128 extern int disk_int13_retry(const com32sys_t * inreg, com32sys_t * outreg);
129 extern int disk_get_params(int disk, struct disk_info *const diskinfo);
130 extern void *disk_read_sectors(const struct disk_info *const diskinfo,
131 uint64_t lba, uint8_t count);
132 extern int disk_write_sector(const struct disk_info *const diskinfo,
133 unsigned int lba, const void *data);
134 extern int disk_write_verify_sector(const struct disk_info *const diskinfo,
135 unsigned int lba, const void *buf);
136 extern void disk_dos_part_dump(const struct disk_dos_part_entry *const part);
138 #endif /* _SYSLINUX_DISK_H */