wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2001 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <command.h> |
| 26 | #include <ide.h> |
Grant Likely | ffc2dd7 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 27 | #include <part.h> |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 28 | |
| 29 | #undef PART_DEBUG |
| 30 | |
| 31 | #ifdef PART_DEBUG |
| 32 | #define PRINTF(fmt,args...) printf (fmt ,##args) |
| 33 | #else |
| 34 | #define PRINTF(fmt,args...) |
| 35 | #endif |
| 36 | |
Jon Loeliger | f7f54a8 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 37 | #if (defined(CONFIG_CMD_IDE) || \ |
unsik Kim | f0b1bdd | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 38 | defined(CONFIG_CMD_MG_DISK) || \ |
Dave Liu | 76596ba | 2008-03-26 22:49:44 +0800 | [diff] [blame] | 39 | defined(CONFIG_CMD_SATA) || \ |
Jon Loeliger | f7f54a8 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 40 | defined(CONFIG_CMD_SCSI) || \ |
| 41 | defined(CONFIG_CMD_USB) || \ |
wdenk | acd0536 | 2005-02-24 23:23:29 +0000 | [diff] [blame] | 42 | defined(CONFIG_MMC) || \ |
| 43 | defined(CONFIG_SYSTEMACE) ) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 44 | |
Grant Likely | ffc2dd7 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 45 | struct block_drvr { |
| 46 | char *name; |
| 47 | block_dev_desc_t* (*get_dev)(int dev); |
| 48 | }; |
| 49 | |
| 50 | static const struct block_drvr block_drvr[] = { |
Jon Loeliger | f7f54a8 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 51 | #if defined(CONFIG_CMD_IDE) |
Grant Likely | ffc2dd7 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 52 | { .name = "ide", .get_dev = ide_get_dev, }, |
| 53 | #endif |
Dave Liu | 76596ba | 2008-03-26 22:49:44 +0800 | [diff] [blame] | 54 | #if defined(CONFIG_CMD_SATA) |
| 55 | {.name = "sata", .get_dev = sata_get_dev, }, |
| 56 | #endif |
Jon Loeliger | f7f54a8 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 57 | #if defined(CONFIG_CMD_SCSI) |
Grant Likely | ffc2dd7 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 58 | { .name = "scsi", .get_dev = scsi_get_dev, }, |
| 59 | #endif |
Jon Loeliger | f7f54a8 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 60 | #if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE) |
Grant Likely | ffc2dd7 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 61 | { .name = "usb", .get_dev = usb_stor_get_dev, }, |
| 62 | #endif |
| 63 | #if defined(CONFIG_MMC) |
| 64 | { .name = "mmc", .get_dev = mmc_get_dev, }, |
| 65 | #endif |
| 66 | #if defined(CONFIG_SYSTEMACE) |
| 67 | { .name = "ace", .get_dev = systemace_get_dev, }, |
| 68 | #endif |
unsik Kim | f0b1bdd | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 69 | #if defined(CONFIG_CMD_MG_DISK) |
| 70 | { .name = "mgd", .get_dev = mg_disk_get_dev, }, |
| 71 | #endif |
Grant Likely | ffc2dd7 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 72 | { }, |
| 73 | }; |
| 74 | |
Stefan Roese | 61ddee4 | 2007-02-20 13:21:57 +0100 | [diff] [blame] | 75 | DECLARE_GLOBAL_DATA_PTR; |
Stefan Roese | 61ddee4 | 2007-02-20 13:21:57 +0100 | [diff] [blame] | 76 | |
Grant Likely | ffc2dd7 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 77 | block_dev_desc_t *get_dev(char* ifname, int dev) |
| 78 | { |
| 79 | const struct block_drvr *drvr = block_drvr; |
Stefan Roese | 5b084e1 | 2007-02-22 07:43:34 +0100 | [diff] [blame] | 80 | block_dev_desc_t* (*reloc_get_dev)(int dev); |
Heiko Schocher | 9b98723 | 2010-09-17 13:10:36 +0200 | [diff] [blame] | 81 | char *name; |
Grant Likely | ffc2dd7 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 82 | |
Tim Kientzle | 47e444c | 2012-03-27 11:43:25 +0200 | [diff] [blame] | 83 | if (!ifname) |
| 84 | return NULL; |
| 85 | |
Heiko Schocher | 9b98723 | 2010-09-17 13:10:36 +0200 | [diff] [blame] | 86 | name = drvr->name; |
Wolfgang Denk | d0813e5 | 2010-10-28 20:00:11 +0200 | [diff] [blame] | 87 | #ifdef CONFIG_NEEDS_MANUAL_RELOC |
Heiko Schocher | 9b98723 | 2010-09-17 13:10:36 +0200 | [diff] [blame] | 88 | name += gd->reloc_off; |
| 89 | #endif |
Lei Wen | 2a01067 | 2011-02-15 16:56:40 +0800 | [diff] [blame] | 90 | while (drvr->name) { |
Heiko Schocher | 9b98723 | 2010-09-17 13:10:36 +0200 | [diff] [blame] | 91 | name = drvr->name; |
Peter Tyser | 9057cbf | 2009-09-21 11:20:36 -0500 | [diff] [blame] | 92 | reloc_get_dev = drvr->get_dev; |
Wolfgang Denk | d0813e5 | 2010-10-28 20:00:11 +0200 | [diff] [blame] | 93 | #ifdef CONFIG_NEEDS_MANUAL_RELOC |
Heiko Schocher | 9b98723 | 2010-09-17 13:10:36 +0200 | [diff] [blame] | 94 | name += gd->reloc_off; |
Peter Tyser | 9057cbf | 2009-09-21 11:20:36 -0500 | [diff] [blame] | 95 | reloc_get_dev += gd->reloc_off; |
| 96 | #endif |
Heiko Schocher | 9b98723 | 2010-09-17 13:10:36 +0200 | [diff] [blame] | 97 | if (strncmp(ifname, name, strlen(name)) == 0) |
Stefan Roese | 61ddee4 | 2007-02-20 13:21:57 +0100 | [diff] [blame] | 98 | return reloc_get_dev(dev); |
Grant Likely | ffc2dd7 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 99 | drvr++; |
| 100 | } |
| 101 | return NULL; |
| 102 | } |
| 103 | #else |
| 104 | block_dev_desc_t *get_dev(char* ifname, int dev) |
| 105 | { |
| 106 | return NULL; |
| 107 | } |
| 108 | #endif |
| 109 | |
Jon Loeliger | f7f54a8 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 110 | #if (defined(CONFIG_CMD_IDE) || \ |
unsik Kim | f0b1bdd | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 111 | defined(CONFIG_CMD_MG_DISK) || \ |
Dave Liu | 76596ba | 2008-03-26 22:49:44 +0800 | [diff] [blame] | 112 | defined(CONFIG_CMD_SATA) || \ |
Jon Loeliger | f7f54a8 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 113 | defined(CONFIG_CMD_SCSI) || \ |
| 114 | defined(CONFIG_CMD_USB) || \ |
Grant Likely | ffc2dd7 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 115 | defined(CONFIG_MMC) || \ |
| 116 | defined(CONFIG_SYSTEMACE) ) |
| 117 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 118 | /* ------------------------------------------------------------------------- */ |
| 119 | /* |
| 120 | * reports device info to the user |
| 121 | */ |
Sergei Trofimovich | 89d935b | 2010-08-08 15:05:39 +0300 | [diff] [blame] | 122 | |
wdenk | c35ba4e | 2004-03-14 22:25:36 +0000 | [diff] [blame] | 123 | #ifdef CONFIG_LBA48 |
Sergei Trofimovich | 89d935b | 2010-08-08 15:05:39 +0300 | [diff] [blame] | 124 | typedef uint64_t lba512_t; |
wdenk | f602aa0 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 125 | #else |
Sergei Trofimovich | 89d935b | 2010-08-08 15:05:39 +0300 | [diff] [blame] | 126 | typedef lbaint_t lba512_t; |
wdenk | f602aa0 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 127 | #endif |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 128 | |
Sergei Trofimovich | 89d935b | 2010-08-08 15:05:39 +0300 | [diff] [blame] | 129 | /* |
| 130 | * Overflowless variant of (block_count * mul_by / div_by) |
| 131 | * when div_by > mul_by |
| 132 | */ |
| 133 | static lba512_t lba512_muldiv (lba512_t block_count, lba512_t mul_by, lba512_t div_by) |
| 134 | { |
| 135 | lba512_t bc_quot, bc_rem; |
| 136 | |
| 137 | /* x * m / d == x / d * m + (x % d) * m / d */ |
| 138 | bc_quot = block_count / div_by; |
| 139 | bc_rem = block_count - div_by * bc_quot; |
| 140 | return bc_quot * mul_by + (bc_rem * mul_by) / div_by; |
| 141 | } |
| 142 | |
| 143 | void dev_print (block_dev_desc_t *dev_desc) |
| 144 | { |
| 145 | lba512_t lba512; /* number of blocks if 512bytes block size */ |
| 146 | |
Wolfgang Denk | 8561e71 | 2009-05-15 09:27:58 +0200 | [diff] [blame] | 147 | if (dev_desc->type == DEV_TYPE_UNKNOWN) { |
| 148 | puts ("not available\n"); |
| 149 | return; |
| 150 | } |
| 151 | |
Tor Krill | 03ff330 | 2008-05-29 11:10:30 +0200 | [diff] [blame] | 152 | switch (dev_desc->if_type) { |
Detlev Zundel | bec6b32 | 2008-05-05 16:11:21 +0200 | [diff] [blame] | 153 | case IF_TYPE_SCSI: |
| 154 | printf ("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n", |
| 155 | dev_desc->target,dev_desc->lun, |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 156 | dev_desc->vendor, |
Detlev Zundel | bec6b32 | 2008-05-05 16:11:21 +0200 | [diff] [blame] | 157 | dev_desc->product, |
| 158 | dev_desc->revision); |
| 159 | break; |
Remy Bohmer | f9f718b | 2008-09-19 13:30:06 +0200 | [diff] [blame] | 160 | case IF_TYPE_ATAPI: |
Detlev Zundel | bec6b32 | 2008-05-05 16:11:21 +0200 | [diff] [blame] | 161 | case IF_TYPE_IDE: |
| 162 | case IF_TYPE_SATA: |
Dave Liu | 76596ba | 2008-03-26 22:49:44 +0800 | [diff] [blame] | 163 | printf ("Model: %s Firm: %s Ser#: %s\n", |
| 164 | dev_desc->vendor, |
| 165 | dev_desc->revision, |
| 166 | dev_desc->product); |
Detlev Zundel | bec6b32 | 2008-05-05 16:11:21 +0200 | [diff] [blame] | 167 | break; |
Remy Bohmer | f9f718b | 2008-09-19 13:30:06 +0200 | [diff] [blame] | 168 | case IF_TYPE_SD: |
| 169 | case IF_TYPE_MMC: |
NÃcolas Carneiro Lebedenco | ef3edd4 | 2008-09-04 15:35:46 -0300 | [diff] [blame] | 170 | case IF_TYPE_USB: |
| 171 | printf ("Vendor: %s Rev: %s Prod: %s\n", |
| 172 | dev_desc->vendor, |
| 173 | dev_desc->revision, |
| 174 | dev_desc->product); |
| 175 | break; |
Remy Bohmer | f9f718b | 2008-09-19 13:30:06 +0200 | [diff] [blame] | 176 | case IF_TYPE_DOC: |
| 177 | puts("device type DOC\n"); |
| 178 | return; |
Tor Krill | 03ff330 | 2008-05-29 11:10:30 +0200 | [diff] [blame] | 179 | case IF_TYPE_UNKNOWN: |
Remy Bohmer | f9f718b | 2008-09-19 13:30:06 +0200 | [diff] [blame] | 180 | puts("device type unknown\n"); |
| 181 | return; |
Detlev Zundel | bec6b32 | 2008-05-05 16:11:21 +0200 | [diff] [blame] | 182 | default: |
Remy Bohmer | f9f718b | 2008-09-19 13:30:06 +0200 | [diff] [blame] | 183 | printf("Unhandled device type: %i\n", dev_desc->if_type); |
Detlev Zundel | bec6b32 | 2008-05-05 16:11:21 +0200 | [diff] [blame] | 184 | return; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 185 | } |
| 186 | puts (" Type: "); |
| 187 | if (dev_desc->removable) |
| 188 | puts ("Removable "); |
| 189 | switch (dev_desc->type & 0x1F) { |
Detlev Zundel | 0e11cc6 | 2008-05-05 16:11:22 +0200 | [diff] [blame] | 190 | case DEV_TYPE_HARDDISK: |
| 191 | puts ("Hard Disk"); |
| 192 | break; |
| 193 | case DEV_TYPE_CDROM: |
| 194 | puts ("CD ROM"); |
| 195 | break; |
| 196 | case DEV_TYPE_OPDISK: |
| 197 | puts ("Optical Device"); |
| 198 | break; |
| 199 | case DEV_TYPE_TAPE: |
| 200 | puts ("Tape"); |
| 201 | break; |
| 202 | default: |
| 203 | printf ("# %02X #", dev_desc->type & 0x1F); |
| 204 | break; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 205 | } |
| 206 | puts ("\n"); |
| 207 | if ((dev_desc->lba * dev_desc->blksz)>0L) { |
| 208 | ulong mb, mb_quot, mb_rem, gb, gb_quot, gb_rem; |
wdenk | f602aa0 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 209 | lbaint_t lba; |
wdenk | 0593920 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 210 | |
| 211 | lba = dev_desc->lba; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 212 | |
wdenk | f602aa0 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 213 | lba512 = (lba * (dev_desc->blksz/512)); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 214 | /* round to 1 digit */ |
Sergei Trofimovich | 89d935b | 2010-08-08 15:05:39 +0300 | [diff] [blame] | 215 | mb = lba512_muldiv(lba512, 10, 2048); /* 2048 = (1024 * 1024) / 512 MB */ |
| 216 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 217 | mb_quot = mb / 10; |
| 218 | mb_rem = mb - (10 * mb_quot); |
| 219 | |
| 220 | gb = mb / 1024; |
| 221 | gb_quot = gb / 10; |
| 222 | gb_rem = gb - (10 * gb_quot); |
wdenk | c35ba4e | 2004-03-14 22:25:36 +0000 | [diff] [blame] | 223 | #ifdef CONFIG_LBA48 |
wdenk | 0593920 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 224 | if (dev_desc->lba48) |
wdenk | f602aa0 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 225 | printf (" Supports 48-bit addressing\n"); |
| 226 | #endif |
Heiko Schocher | 0f602e1 | 2009-12-03 11:21:21 +0100 | [diff] [blame] | 227 | #if defined(CONFIG_SYS_64BIT_LBA) |
Mike Frysinger | 2b745dc | 2009-02-16 23:21:36 -0500 | [diff] [blame] | 228 | printf (" Capacity: %ld.%ld MB = %ld.%ld GB (%Ld x %ld)\n", |
wdenk | f602aa0 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 229 | mb_quot, mb_rem, |
| 230 | gb_quot, gb_rem, |
| 231 | lba, |
| 232 | dev_desc->blksz); |
| 233 | #else |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 234 | printf (" Capacity: %ld.%ld MB = %ld.%ld GB (%ld x %ld)\n", |
| 235 | mb_quot, mb_rem, |
| 236 | gb_quot, gb_rem, |
wdenk | f602aa0 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 237 | (ulong)lba, |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 238 | dev_desc->blksz); |
wdenk | f602aa0 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 239 | #endif |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 240 | } else { |
| 241 | puts (" Capacity: not available\n"); |
| 242 | } |
| 243 | } |
Jon Loeliger | 1670a5b | 2007-07-10 11:19:50 -0500 | [diff] [blame] | 244 | #endif |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 245 | |
Jon Loeliger | f7f54a8 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 246 | #if (defined(CONFIG_CMD_IDE) || \ |
unsik Kim | f0b1bdd | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 247 | defined(CONFIG_CMD_MG_DISK) || \ |
Dave Liu | 76596ba | 2008-03-26 22:49:44 +0800 | [diff] [blame] | 248 | defined(CONFIG_CMD_SATA) || \ |
Jon Loeliger | f7f54a8 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 249 | defined(CONFIG_CMD_SCSI) || \ |
| 250 | defined(CONFIG_CMD_USB) || \ |
Haavard Skinnemoen | 01d354e | 2006-12-17 18:53:56 +0100 | [diff] [blame] | 251 | defined(CONFIG_MMC) || \ |
unsik Kim | f0b1bdd | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 252 | defined(CONFIG_SYSTEMACE) ) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 253 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 254 | #if defined(CONFIG_MAC_PARTITION) || \ |
| 255 | defined(CONFIG_DOS_PARTITION) || \ |
wdenk | 452cfd6 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 256 | defined(CONFIG_ISO_PARTITION) || \ |
richardretanubun | e674559 | 2008-09-26 11:13:22 -0400 | [diff] [blame] | 257 | defined(CONFIG_AMIGA_PARTITION) || \ |
| 258 | defined(CONFIG_EFI_PARTITION) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 259 | |
| 260 | void init_part (block_dev_desc_t * dev_desc) |
| 261 | { |
| 262 | #ifdef CONFIG_ISO_PARTITION |
| 263 | if (test_part_iso(dev_desc) == 0) { |
| 264 | dev_desc->part_type = PART_TYPE_ISO; |
| 265 | return; |
| 266 | } |
| 267 | #endif |
| 268 | |
| 269 | #ifdef CONFIG_MAC_PARTITION |
| 270 | if (test_part_mac(dev_desc) == 0) { |
| 271 | dev_desc->part_type = PART_TYPE_MAC; |
| 272 | return; |
| 273 | } |
| 274 | #endif |
| 275 | |
richardretanubun | e674559 | 2008-09-26 11:13:22 -0400 | [diff] [blame] | 276 | /* must be placed before DOS partition detection */ |
| 277 | #ifdef CONFIG_EFI_PARTITION |
| 278 | if (test_part_efi(dev_desc) == 0) { |
| 279 | dev_desc->part_type = PART_TYPE_EFI; |
| 280 | return; |
| 281 | } |
| 282 | #endif |
| 283 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 284 | #ifdef CONFIG_DOS_PARTITION |
| 285 | if (test_part_dos(dev_desc) == 0) { |
| 286 | dev_desc->part_type = PART_TYPE_DOS; |
| 287 | return; |
| 288 | } |
| 289 | #endif |
wdenk | 452cfd6 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 290 | |
| 291 | #ifdef CONFIG_AMIGA_PARTITION |
| 292 | if (test_part_amiga(dev_desc) == 0) { |
| 293 | dev_desc->part_type = PART_TYPE_AMIGA; |
| 294 | return; |
| 295 | } |
| 296 | #endif |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | |
Peter Pearse | fb312c8 | 2007-05-18 16:47:03 +0100 | [diff] [blame] | 300 | int get_partition_info (block_dev_desc_t *dev_desc, int part |
| 301 | , disk_partition_t *info) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 302 | { |
Heiko Schocher | 633e03a | 2007-06-22 19:11:54 +0200 | [diff] [blame] | 303 | switch (dev_desc->part_type) { |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 304 | #ifdef CONFIG_MAC_PARTITION |
| 305 | case PART_TYPE_MAC: |
| 306 | if (get_partition_info_mac(dev_desc,part,info) == 0) { |
| 307 | PRINTF ("## Valid MAC partition found ##\n"); |
| 308 | return (0); |
| 309 | } |
| 310 | break; |
| 311 | #endif |
| 312 | |
| 313 | #ifdef CONFIG_DOS_PARTITION |
| 314 | case PART_TYPE_DOS: |
| 315 | if (get_partition_info_dos(dev_desc,part,info) == 0) { |
| 316 | PRINTF ("## Valid DOS partition found ##\n"); |
| 317 | return (0); |
| 318 | } |
| 319 | break; |
| 320 | #endif |
| 321 | |
| 322 | #ifdef CONFIG_ISO_PARTITION |
| 323 | case PART_TYPE_ISO: |
| 324 | if (get_partition_info_iso(dev_desc,part,info) == 0) { |
| 325 | PRINTF ("## Valid ISO boot partition found ##\n"); |
| 326 | return (0); |
| 327 | } |
| 328 | break; |
| 329 | #endif |
wdenk | 452cfd6 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 330 | |
| 331 | #ifdef CONFIG_AMIGA_PARTITION |
| 332 | case PART_TYPE_AMIGA: |
| 333 | if (get_partition_info_amiga(dev_desc, part, info) == 0) |
| 334 | { |
| 335 | PRINTF ("## Valid Amiga partition found ##\n"); |
| 336 | return (0); |
| 337 | } |
| 338 | break; |
| 339 | #endif |
richardretanubun | e674559 | 2008-09-26 11:13:22 -0400 | [diff] [blame] | 340 | |
| 341 | #ifdef CONFIG_EFI_PARTITION |
| 342 | case PART_TYPE_EFI: |
| 343 | if (get_partition_info_efi(dev_desc,part,info) == 0) { |
| 344 | PRINTF ("## Valid EFI partition found ##\n"); |
| 345 | return (0); |
| 346 | } |
| 347 | break; |
| 348 | #endif |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 349 | default: |
| 350 | break; |
| 351 | } |
| 352 | return (-1); |
| 353 | } |
| 354 | |
| 355 | static void print_part_header (const char *type, block_dev_desc_t * dev_desc) |
| 356 | { |
| 357 | puts ("\nPartition Map for "); |
| 358 | switch (dev_desc->if_type) { |
Detlev Zundel | 0e11cc6 | 2008-05-05 16:11:22 +0200 | [diff] [blame] | 359 | case IF_TYPE_IDE: |
| 360 | puts ("IDE"); |
| 361 | break; |
| 362 | case IF_TYPE_SATA: |
| 363 | puts ("SATA"); |
| 364 | break; |
| 365 | case IF_TYPE_SCSI: |
| 366 | puts ("SCSI"); |
| 367 | break; |
| 368 | case IF_TYPE_ATAPI: |
| 369 | puts ("ATAPI"); |
| 370 | break; |
| 371 | case IF_TYPE_USB: |
| 372 | puts ("USB"); |
| 373 | break; |
| 374 | case IF_TYPE_DOC: |
| 375 | puts ("DOC"); |
| 376 | break; |
Lei Wen | 61dba93 | 2010-09-13 22:07:28 +0800 | [diff] [blame] | 377 | case IF_TYPE_MMC: |
| 378 | puts ("MMC"); |
| 379 | break; |
Detlev Zundel | 0e11cc6 | 2008-05-05 16:11:22 +0200 | [diff] [blame] | 380 | default: |
| 381 | puts ("UNKNOWN"); |
| 382 | break; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 383 | } |
| 384 | printf (" device %d -- Partition Type: %s\n\n", |
| 385 | dev_desc->dev, type); |
| 386 | } |
| 387 | |
| 388 | void print_part (block_dev_desc_t * dev_desc) |
| 389 | { |
| 390 | |
| 391 | switch (dev_desc->part_type) { |
| 392 | #ifdef CONFIG_MAC_PARTITION |
| 393 | case PART_TYPE_MAC: |
| 394 | PRINTF ("## Testing for valid MAC partition ##\n"); |
| 395 | print_part_header ("MAC", dev_desc); |
| 396 | print_part_mac (dev_desc); |
| 397 | return; |
| 398 | #endif |
| 399 | #ifdef CONFIG_DOS_PARTITION |
| 400 | case PART_TYPE_DOS: |
| 401 | PRINTF ("## Testing for valid DOS partition ##\n"); |
| 402 | print_part_header ("DOS", dev_desc); |
| 403 | print_part_dos (dev_desc); |
| 404 | return; |
| 405 | #endif |
| 406 | |
| 407 | #ifdef CONFIG_ISO_PARTITION |
| 408 | case PART_TYPE_ISO: |
| 409 | PRINTF ("## Testing for valid ISO Boot partition ##\n"); |
| 410 | print_part_header ("ISO", dev_desc); |
| 411 | print_part_iso (dev_desc); |
| 412 | return; |
| 413 | #endif |
wdenk | 452cfd6 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 414 | |
| 415 | #ifdef CONFIG_AMIGA_PARTITION |
| 416 | case PART_TYPE_AMIGA: |
| 417 | PRINTF ("## Testing for a valid Amiga partition ##\n"); |
| 418 | print_part_header ("AMIGA", dev_desc); |
| 419 | print_part_amiga (dev_desc); |
| 420 | return; |
| 421 | #endif |
richardretanubun | e674559 | 2008-09-26 11:13:22 -0400 | [diff] [blame] | 422 | |
| 423 | #ifdef CONFIG_EFI_PARTITION |
| 424 | case PART_TYPE_EFI: |
| 425 | PRINTF ("## Testing for valid EFI partition ##\n"); |
| 426 | print_part_header ("EFI", dev_desc); |
| 427 | print_part_efi (dev_desc); |
| 428 | return; |
| 429 | #endif |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 430 | } |
| 431 | puts ("## Unknown partition table\n"); |
| 432 | } |
| 433 | |
| 434 | |
richardretanubun | e674559 | 2008-09-26 11:13:22 -0400 | [diff] [blame] | 435 | #else /* neither MAC nor DOS nor ISO nor AMIGA nor EFI partition configured */ |
Wolfgang Denk | a9d7acb | 2007-06-06 16:26:56 +0200 | [diff] [blame] | 436 | # error neither CONFIG_MAC_PARTITION nor CONFIG_DOS_PARTITION |
richardretanubun | e674559 | 2008-09-26 11:13:22 -0400 | [diff] [blame] | 437 | # error nor CONFIG_ISO_PARTITION nor CONFIG_AMIGA_PARTITION |
| 438 | # error nor CONFIG_EFI_PARTITION configured! |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 439 | #endif |
| 440 | |
Jon Loeliger | f7f54a8 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 441 | #endif |