source: grub-pc/trunk/fuentes/debian/grub-extras/ntldr-img/utils.h @ 22

Last change on this file since 22 was 22, checked in by mabarracus, 4 years ago

updated version and apply net.ifnames=0 into debian/rules

File size: 2.4 KB
Line 
1/*
2 *  GRUB Utilities --  Utilities for GRUB Legacy, GRUB2 and GRUB for DOS
3 *  Copyright (C) 2007 Bean (bean123@126.com)
4 *
5 *  This program is free software; you can redistribute it and/or modify
6 *  it under the terms of the GNU General Public License as published by
7 *  the Free Software Foundation; either version 2 of the License, or
8 *  (at your option) any later version.
9 *
10 *  This program is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *  GNU General Public License for more details.
14 *
15 *  You should have received a copy of the GNU General Public License
16 *  along with this program; if not, write to the Free Software
17 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20#ifndef __UTILS_H
21#define __UTILS_H
22
23#if defined(__cplusplus) || defined(c_plusplus)
24extern "C" {
25#endif
26
27#define MAX_DISKS               10
28#define MAX_PARTS               30
29
30#define FST_OTHER               0
31#define FST_MBR                 1
32#define FST_FAT16               2
33#define FST_FAT32               3
34#define FST_NTFS                4
35#define FST_EXT2                5
36
37typedef struct {
38  unsigned char cur;            // Current partition number
39  unsigned char nxt;            // Next partition number
40  unsigned char dfs;            // File system flag
41  unsigned char pad;            // Padding
42  unsigned long bse;            // Partition start address
43  unsigned long len;            // Partition length
44  unsigned long ebs;            // Base address for the extended partition
45} __attribute__ ((packed)) xde_t;
46
47static inline unsigned short
48get16 (const void *buf_, unsigned offset)
49{
50  unsigned char *buf = (unsigned char *) buf_ + offset;
51  return buf[0] | (buf[1] << 8);
52}
53static inline unsigned int
54get32 (const void *buf_, unsigned offset)
55{
56  unsigned char *buf = (unsigned char *) buf_ + offset;
57  return buf[0] | (buf[1] << 8) | (buf[1] << 16) | (buf[1] << 24);
58}
59
60static inline void
61set16 (void *buf_, unsigned offset, unsigned short val)
62{
63  unsigned char *buf = (unsigned char *) buf_ + offset;
64  buf[0] = val;
65  buf[1] = val >> 8;
66}
67
68static inline void
69set32 (void *buf_, unsigned offset, unsigned int val)
70{
71  unsigned char *buf = (unsigned char *) buf_ + offset;
72  buf[0] = val;
73  buf[1] = val >> 8;
74  buf[2] = val >> 16;
75  buf[3] = val >> 24;
76}
77
78extern int mbr_nhd, mbr_spt;
79int go_sect(int,unsigned long);
80int xd_enum(int,xde_t*);
81int get_fstype(unsigned char*);
82const char* fst2str(int);
83const char* dfs2str(int);
84
85#if defined(__cplusplus) || defined(c_plusplus)
86}
87#endif
88#endif /* __UTILS_H */
Note: See TracBrowser for help on using the repository browser.