2002-03-08 21:31:05 +00:00
|
|
|
/*
|
2004-03-14 22:25:36 +00:00
|
|
|
* (C) Copyright 2000-2004
|
2002-03-08 21:31:05 +00:00
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2004-03-14 22:25:36 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2002-03-08 21:31:05 +00:00
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
#ifndef _PART_H
|
|
|
|
#define _PART_H
|
2007-02-20 08:04:34 +00:00
|
|
|
|
2004-04-18 17:39:38 +00:00
|
|
|
#include <ide.h>
|
2002-03-08 21:31:05 +00:00
|
|
|
|
|
|
|
typedef struct block_dev_desc {
|
2004-03-14 22:25:36 +00:00
|
|
|
int if_type; /* type of the interface */
|
2008-03-26 23:03:57 +00:00
|
|
|
int dev; /* device number */
|
|
|
|
unsigned char part_type; /* partition type */
|
2004-03-14 22:25:36 +00:00
|
|
|
unsigned char target; /* target SCSI ID */
|
|
|
|
unsigned char lun; /* target LUN */
|
|
|
|
unsigned char type; /* device type */
|
|
|
|
unsigned char removable; /* removable device */
|
|
|
|
#ifdef CONFIG_LBA48
|
|
|
|
unsigned char lba48; /* device can use 48bit addr (ATA/ATAPI v7) */
|
|
|
|
#endif
|
2012-05-19 07:25:27 +00:00
|
|
|
lbaint_t lba; /* number of blocks */
|
2004-03-14 22:25:36 +00:00
|
|
|
unsigned long blksz; /* block size */
|
2008-03-26 23:03:57 +00:00
|
|
|
char vendor [40+1]; /* IDE model, SCSI Vendor */
|
2007-10-18 22:25:33 +00:00
|
|
|
char product[20+1]; /* IDE Serial no, SCSI product */
|
|
|
|
char revision[8+1]; /* firmware revision */
|
2004-03-14 22:25:36 +00:00
|
|
|
unsigned long (*block_read)(int dev,
|
|
|
|
unsigned long start,
|
2004-04-18 17:39:38 +00:00
|
|
|
lbaint_t blkcnt,
|
2007-02-20 08:05:45 +00:00
|
|
|
void *buffer);
|
2007-02-20 08:05:38 +00:00
|
|
|
unsigned long (*block_write)(int dev,
|
|
|
|
unsigned long start,
|
|
|
|
lbaint_t blkcnt,
|
|
|
|
const void *buffer);
|
2011-06-22 17:03:31 +00:00
|
|
|
unsigned long (*block_erase)(int dev,
|
|
|
|
unsigned long start,
|
|
|
|
lbaint_t blkcnt);
|
2008-03-26 14:49:44 +00:00
|
|
|
void *priv; /* driver private struct pointer */
|
2002-03-08 21:31:05 +00:00
|
|
|
}block_dev_desc_t;
|
2003-06-29 21:03:46 +00:00
|
|
|
|
2002-03-08 21:31:05 +00:00
|
|
|
/* Interface types: */
|
2003-06-29 21:03:46 +00:00
|
|
|
#define IF_TYPE_UNKNOWN 0
|
|
|
|
#define IF_TYPE_IDE 1
|
2002-03-08 21:31:05 +00:00
|
|
|
#define IF_TYPE_SCSI 2
|
|
|
|
#define IF_TYPE_ATAPI 3
|
2003-06-29 21:03:46 +00:00
|
|
|
#define IF_TYPE_USB 4
|
|
|
|
#define IF_TYPE_DOC 5
|
2003-09-10 22:30:53 +00:00
|
|
|
#define IF_TYPE_MMC 6
|
2007-11-20 09:40:24 +00:00
|
|
|
#define IF_TYPE_SD 7
|
2008-03-26 14:49:44 +00:00
|
|
|
#define IF_TYPE_SATA 8
|
2003-06-29 21:03:46 +00:00
|
|
|
|
2002-03-08 21:31:05 +00:00
|
|
|
/* Part types */
|
2004-03-14 22:25:36 +00:00
|
|
|
#define PART_TYPE_UNKNOWN 0x00
|
2002-03-08 21:31:05 +00:00
|
|
|
#define PART_TYPE_MAC 0x01
|
|
|
|
#define PART_TYPE_DOS 0x02
|
|
|
|
#define PART_TYPE_ISO 0x03
|
2004-03-14 22:25:36 +00:00
|
|
|
#define PART_TYPE_AMIGA 0x04
|
2008-09-26 15:13:22 +00:00
|
|
|
#define PART_TYPE_EFI 0x05
|
2002-11-19 11:04:11 +00:00
|
|
|
|
2003-06-29 21:03:46 +00:00
|
|
|
/*
|
|
|
|
* Type string for U-Boot bootable partitions
|
|
|
|
*/
|
|
|
|
#define BOOT_PART_TYPE "U-Boot" /* primary boot partition type */
|
|
|
|
#define BOOT_PART_COMP "PPCBoot" /* PPCBoot compatibility type */
|
|
|
|
|
2002-03-08 21:31:05 +00:00
|
|
|
/* device types */
|
2003-06-29 21:03:46 +00:00
|
|
|
#define DEV_TYPE_UNKNOWN 0xff /* not connected */
|
|
|
|
#define DEV_TYPE_HARDDISK 0x00 /* harddisk */
|
2004-03-14 22:25:36 +00:00
|
|
|
#define DEV_TYPE_TAPE 0x01 /* Tape */
|
|
|
|
#define DEV_TYPE_CDROM 0x05 /* CD-ROM */
|
|
|
|
#define DEV_TYPE_OPDISK 0x07 /* optical disk */
|
2002-03-08 21:31:05 +00:00
|
|
|
|
2004-03-14 22:25:36 +00:00
|
|
|
typedef struct disk_partition {
|
2002-03-08 21:31:05 +00:00
|
|
|
ulong start; /* # of first block in partition */
|
|
|
|
ulong size; /* number of blocks in partition */
|
|
|
|
ulong blksz; /* block size in bytes */
|
|
|
|
uchar name[32]; /* partition name */
|
|
|
|
uchar type[32]; /* string type description */
|
2012-08-23 11:31:43 +00:00
|
|
|
int bootable; /* Active/Bootable flag is set */
|
2012-09-21 09:50:59 +00:00
|
|
|
#ifdef CONFIG_PARTITION_UUIDS
|
|
|
|
char uuid[37]; /* filesystem UUID as string, if exists */
|
|
|
|
#endif
|
2002-03-08 21:31:05 +00:00
|
|
|
} disk_partition_t;
|
|
|
|
|
2007-02-20 08:04:34 +00:00
|
|
|
/* Misc _get_dev functions */
|
2011-05-24 05:31:19 +00:00
|
|
|
#ifdef CONFIG_PARTITIONS
|
2012-09-21 04:08:17 +00:00
|
|
|
block_dev_desc_t *get_dev(const char *ifname, int dev);
|
2007-02-20 08:04:34 +00:00
|
|
|
block_dev_desc_t* ide_get_dev(int dev);
|
2008-03-26 14:49:44 +00:00
|
|
|
block_dev_desc_t* sata_get_dev(int dev);
|
2007-02-20 08:04:34 +00:00
|
|
|
block_dev_desc_t* scsi_get_dev(int dev);
|
|
|
|
block_dev_desc_t* usb_stor_get_dev(int dev);
|
|
|
|
block_dev_desc_t* mmc_get_dev(int dev);
|
|
|
|
block_dev_desc_t* systemace_get_dev(int dev);
|
2009-02-25 02:31:24 +00:00
|
|
|
block_dev_desc_t* mg_disk_get_dev(int dev);
|
2007-02-20 08:04:34 +00:00
|
|
|
|
2002-03-08 21:31:05 +00:00
|
|
|
/* disk/part.c */
|
|
|
|
int get_partition_info (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
|
|
|
|
void print_part (block_dev_desc_t *dev_desc);
|
|
|
|
void init_part (block_dev_desc_t *dev_desc);
|
|
|
|
void dev_print(block_dev_desc_t *dev_desc);
|
2012-09-21 09:50:56 +00:00
|
|
|
int get_device(const char *ifname, const char *dev_str,
|
|
|
|
block_dev_desc_t **dev_desc);
|
disk: get_device_and_partition() "auto" partition and cleanup
Rework get_device_and_partition() to:
a) Implement a new partition ID of "auto", which requests that U-Boot
search for the first "bootable" partition, and fall back to the first
valid partition if none is found. This way, users don't need to
specify an explicit partition in their commands.
b) Make use of get_device().
c) Add parameter to indicate whether returning a whole device is
acceptable, or whether a partition is mandatory.
d) Make error-checking of the user's device-/partition-specification
more complete. In particular, if strtoul() doesn't convert all
characters, it's an error rather than just ignored.
The resultant device/partition returned by the function will be as
follows, based on whether the disk has a partition table (ptable) or not,
and whether the calling command allows the whole device to be returned
or not.
(D and P are integers, P >= 1)
D
D:
No ptable:
!allow_whole_dev: error
allow_whole_dev: device D
ptable:
device D partition 1
D:0
!allow_whole_dev: error
allow_whole_dev: device D
D:P
No ptable: error
ptable: device D partition P
D:auto
No ptable:
!allow_whole_dev: error
allow_whole_dev: device D
ptable:
first partition in device D with bootable flag set.
If none, first valid paratition in device D.
Note: In order to review this patch, it's probably easiest to simply
look at the file contents post-application, rather than reading the
patch itself.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
[swarren: Rob implemented scanning for bootable partitions. I fixed a
couple of issues there, switched the syntax to ":auto", added the
error-checking rework, and ":0" syntax for the whole device]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2012-09-21 09:50:57 +00:00
|
|
|
int get_device_and_partition(const char *ifname, const char *dev_part_str,
|
2012-09-21 04:08:17 +00:00
|
|
|
block_dev_desc_t **dev_desc,
|
disk: get_device_and_partition() "auto" partition and cleanup
Rework get_device_and_partition() to:
a) Implement a new partition ID of "auto", which requests that U-Boot
search for the first "bootable" partition, and fall back to the first
valid partition if none is found. This way, users don't need to
specify an explicit partition in their commands.
b) Make use of get_device().
c) Add parameter to indicate whether returning a whole device is
acceptable, or whether a partition is mandatory.
d) Make error-checking of the user's device-/partition-specification
more complete. In particular, if strtoul() doesn't convert all
characters, it's an error rather than just ignored.
The resultant device/partition returned by the function will be as
follows, based on whether the disk has a partition table (ptable) or not,
and whether the calling command allows the whole device to be returned
or not.
(D and P are integers, P >= 1)
D
D:
No ptable:
!allow_whole_dev: error
allow_whole_dev: device D
ptable:
device D partition 1
D:0
!allow_whole_dev: error
allow_whole_dev: device D
D:P
No ptable: error
ptable: device D partition P
D:auto
No ptable:
!allow_whole_dev: error
allow_whole_dev: device D
ptable:
first partition in device D with bootable flag set.
If none, first valid paratition in device D.
Note: In order to review this patch, it's probably easiest to simply
look at the file contents post-application, rather than reading the
patch itself.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
[swarren: Rob implemented scanning for bootable partitions. I fixed a
couple of issues there, switched the syntax to ":auto", added the
error-checking rework, and ":0" syntax for the whole device]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2012-09-21 09:50:57 +00:00
|
|
|
disk_partition_t *info, int allow_whole_dev);
|
2011-05-24 05:31:19 +00:00
|
|
|
#else
|
2012-09-21 04:08:17 +00:00
|
|
|
static inline block_dev_desc_t *get_dev(const char *ifname, int dev)
|
|
|
|
{ return NULL; }
|
2011-05-24 05:31:19 +00:00
|
|
|
static inline block_dev_desc_t* ide_get_dev(int dev) { return NULL; }
|
|
|
|
static inline block_dev_desc_t* sata_get_dev(int dev) { return NULL; }
|
|
|
|
static inline block_dev_desc_t* scsi_get_dev(int dev) { return NULL; }
|
|
|
|
static inline block_dev_desc_t* usb_stor_get_dev(int dev) { return NULL; }
|
|
|
|
static inline block_dev_desc_t* mmc_get_dev(int dev) { return NULL; }
|
|
|
|
static inline block_dev_desc_t* systemace_get_dev(int dev) { return NULL; }
|
|
|
|
static inline block_dev_desc_t* mg_disk_get_dev(int dev) { return NULL; }
|
2002-03-08 21:31:05 +00:00
|
|
|
|
2011-05-24 05:31:19 +00:00
|
|
|
static inline int get_partition_info (block_dev_desc_t * dev_desc, int part,
|
|
|
|
disk_partition_t *info) { return -1; }
|
|
|
|
static inline void print_part (block_dev_desc_t *dev_desc) {}
|
|
|
|
static inline void init_part (block_dev_desc_t *dev_desc) {}
|
|
|
|
static inline void dev_print(block_dev_desc_t *dev_desc) {}
|
2012-09-21 09:50:56 +00:00
|
|
|
static inline int get_device(const char *ifname, const char *dev_str,
|
|
|
|
block_dev_desc_t **dev_desc)
|
|
|
|
{ return -1; }
|
2012-09-21 04:08:17 +00:00
|
|
|
static inline int get_device_and_partition(const char *ifname,
|
disk: get_device_and_partition() "auto" partition and cleanup
Rework get_device_and_partition() to:
a) Implement a new partition ID of "auto", which requests that U-Boot
search for the first "bootable" partition, and fall back to the first
valid partition if none is found. This way, users don't need to
specify an explicit partition in their commands.
b) Make use of get_device().
c) Add parameter to indicate whether returning a whole device is
acceptable, or whether a partition is mandatory.
d) Make error-checking of the user's device-/partition-specification
more complete. In particular, if strtoul() doesn't convert all
characters, it's an error rather than just ignored.
The resultant device/partition returned by the function will be as
follows, based on whether the disk has a partition table (ptable) or not,
and whether the calling command allows the whole device to be returned
or not.
(D and P are integers, P >= 1)
D
D:
No ptable:
!allow_whole_dev: error
allow_whole_dev: device D
ptable:
device D partition 1
D:0
!allow_whole_dev: error
allow_whole_dev: device D
D:P
No ptable: error
ptable: device D partition P
D:auto
No ptable:
!allow_whole_dev: error
allow_whole_dev: device D
ptable:
first partition in device D with bootable flag set.
If none, first valid paratition in device D.
Note: In order to review this patch, it's probably easiest to simply
look at the file contents post-application, rather than reading the
patch itself.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
[swarren: Rob implemented scanning for bootable partitions. I fixed a
couple of issues there, switched the syntax to ":auto", added the
error-checking rework, and ":0" syntax for the whole device]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2012-09-21 09:50:57 +00:00
|
|
|
const char *dev_part_str,
|
2012-09-21 04:08:17 +00:00
|
|
|
block_dev_desc_t **dev_desc,
|
disk: get_device_and_partition() "auto" partition and cleanup
Rework get_device_and_partition() to:
a) Implement a new partition ID of "auto", which requests that U-Boot
search for the first "bootable" partition, and fall back to the first
valid partition if none is found. This way, users don't need to
specify an explicit partition in their commands.
b) Make use of get_device().
c) Add parameter to indicate whether returning a whole device is
acceptable, or whether a partition is mandatory.
d) Make error-checking of the user's device-/partition-specification
more complete. In particular, if strtoul() doesn't convert all
characters, it's an error rather than just ignored.
The resultant device/partition returned by the function will be as
follows, based on whether the disk has a partition table (ptable) or not,
and whether the calling command allows the whole device to be returned
or not.
(D and P are integers, P >= 1)
D
D:
No ptable:
!allow_whole_dev: error
allow_whole_dev: device D
ptable:
device D partition 1
D:0
!allow_whole_dev: error
allow_whole_dev: device D
D:P
No ptable: error
ptable: device D partition P
D:auto
No ptable:
!allow_whole_dev: error
allow_whole_dev: device D
ptable:
first partition in device D with bootable flag set.
If none, first valid paratition in device D.
Note: In order to review this patch, it's probably easiest to simply
look at the file contents post-application, rather than reading the
patch itself.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
[swarren: Rob implemented scanning for bootable partitions. I fixed a
couple of issues there, switched the syntax to ":auto", added the
error-checking rework, and ":0" syntax for the whole device]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2012-09-21 09:50:57 +00:00
|
|
|
disk_partition_t *info,
|
|
|
|
int allow_whole_dev)
|
2012-09-21 04:08:17 +00:00
|
|
|
{ *dev_desc = NULL; return -1; }
|
2011-05-24 05:31:19 +00:00
|
|
|
#endif
|
2002-03-08 21:31:05 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_MAC_PARTITION
|
|
|
|
/* disk/part_mac.c */
|
|
|
|
int get_partition_info_mac (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
|
|
|
|
void print_part_mac (block_dev_desc_t *dev_desc);
|
|
|
|
int test_part_mac (block_dev_desc_t *dev_desc);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_DOS_PARTITION
|
|
|
|
/* disk/part_dos.c */
|
|
|
|
int get_partition_info_dos (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
|
|
|
|
void print_part_dos (block_dev_desc_t *dev_desc);
|
|
|
|
int test_part_dos (block_dev_desc_t *dev_desc);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_ISO_PARTITION
|
|
|
|
/* disk/part_iso.c */
|
|
|
|
int get_partition_info_iso (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
|
|
|
|
void print_part_iso (block_dev_desc_t *dev_desc);
|
|
|
|
int test_part_iso (block_dev_desc_t *dev_desc);
|
|
|
|
#endif
|
|
|
|
|
2002-11-19 11:04:11 +00:00
|
|
|
#ifdef CONFIG_AMIGA_PARTITION
|
|
|
|
/* disk/part_amiga.c */
|
|
|
|
int get_partition_info_amiga (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
|
|
|
|
void print_part_amiga (block_dev_desc_t *dev_desc);
|
|
|
|
int test_part_amiga (block_dev_desc_t *dev_desc);
|
|
|
|
#endif
|
|
|
|
|
2008-09-26 15:13:22 +00:00
|
|
|
#ifdef CONFIG_EFI_PARTITION
|
|
|
|
/* disk/part_efi.c */
|
|
|
|
int get_partition_info_efi (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
|
|
|
|
void print_part_efi (block_dev_desc_t *dev_desc);
|
|
|
|
int test_part_efi (block_dev_desc_t *dev_desc);
|
|
|
|
#endif
|
|
|
|
|
2002-03-08 21:31:05 +00:00
|
|
|
#endif /* _PART_H */
|