@ -10,7 +10,7 @@
# include <ide.h>
# include <common.h>
struct bloc k_dev _desc {
struct blk_desc {
int if_type ; /* type of the interface */
int dev ; /* device number */
unsigned char part_type ; /* partition type */
@ -28,23 +28,23 @@ struct block_dev_desc {
char vendor [ 40 + 1 ] ; /* IDE model, SCSI Vendor */
char product [ 20 + 1 ] ; /* IDE Serial no, SCSI product */
char revision [ 8 + 1 ] ; /* firmware revision */
unsigned long ( * block_read ) ( bloc k_dev_de sc_t * block_dev ,
unsigned long ( * block_read ) ( struct blk_desc * block_dev ,
lbaint_t start ,
lbaint_t blkcnt ,
void * buffer ) ;
unsigned long ( * block_write ) ( bloc k_dev_de sc_t * block_dev ,
unsigned long ( * block_write ) ( struct blk_desc * block_dev ,
lbaint_t start ,
lbaint_t blkcnt ,
const void * buffer ) ;
unsigned long ( * block_erase ) ( bloc k_dev_de sc_t * block_dev ,
unsigned long ( * block_erase ) ( struct blk_desc * block_dev ,
lbaint_t start ,
lbaint_t blkcnt ) ;
void * priv ; /* driver private struct pointer */
} ;
# define BLOCK_CNT(size, bloc k_dev _desc) (PAD_COUNT(size, bloc k_dev _desc->blksz))
# define PAD_TO_BLOCKSIZE(size, bloc k_dev _desc) \
( PAD_SIZE ( size , bloc k_dev _desc - > blksz ) )
# define BLOCK_CNT(size, blk_desc) (PAD_COUNT(size, blk_desc->blksz))
# define PAD_TO_BLOCKSIZE(size, blk_desc) \
( PAD_SIZE ( size , blk_desc - > blksz ) )
# define LOG2(x) (((x & 0xaaaaaaaa) ? 1 : 0) + ((x & 0xcccccccc) ? 2 : 0) + \
( ( x & 0xf0f0f0f0 ) ? 4 : 0 ) + ( ( x & 0xff00ff00 ) ? 8 : 0 ) + \
( ( x & 0xffff0000 ) ? 16 : 0 ) )
@ -101,52 +101,53 @@ typedef struct disk_partition {
/* Misc _get_dev functions */
# ifdef CONFIG_PARTITIONS
bloc k_dev_de sc_t * get_dev ( const char * ifname , int dev ) ;
bloc k_dev_de sc_t * ide_get_dev ( int dev ) ;
bloc k_dev_de sc_t * sata_get_dev ( int dev ) ;
bloc k_dev_de sc_t * scsi_get_dev ( int dev ) ;
bloc k_dev_de sc_t * usb_stor_get_dev ( int dev ) ;
bloc k_dev_de sc_t * mmc_get_dev ( int dev ) ;
struct blk_desc * get_dev ( const char * ifname , int dev ) ;
struct blk_desc * ide_get_dev ( int dev ) ;
struct blk_desc * sata_get_dev ( int dev ) ;
struct blk_desc * scsi_get_dev ( int dev ) ;
struct blk_desc * usb_stor_get_dev ( int dev ) ;
struct blk_desc * mmc_get_dev ( int dev ) ;
int mmc_select_hwpart ( int dev_num , int hwpart ) ;
bloc k_dev_de sc_t * systemace_get_dev ( int dev ) ;
bloc k_dev_de sc_t * mg_disk_get_dev ( int dev ) ;
bloc k_dev_de sc_t * host_get_dev ( int dev ) ;
int host_get_dev_err ( int dev , bloc k_dev_de sc_t * * blk_devp ) ;
struct blk_desc * systemace_get_dev ( int dev ) ;
struct blk_desc * mg_disk_get_dev ( int dev ) ;
struct blk_desc * host_get_dev ( int dev ) ;
int host_get_dev_err ( int dev , struct blk_desc * * blk_devp ) ;
/* 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 ) ;
int get_partition_info ( struct blk_desc * dev_desc , int part ,
disk_partition_t * info ) ;
void print_part ( struct blk_desc * dev_desc ) ;
void init_part ( struct blk_desc * dev_desc ) ;
void dev_print ( struct blk_desc * dev_desc ) ;
int get_device ( const char * ifname , const char * dev_str ,
bloc k_dev_de sc_t * * dev_desc ) ;
struct blk_desc * * dev_desc ) ;
int get_device_and_partition ( const char * ifname , const char * dev_part_str ,
bloc k_dev_de sc_t * * dev_desc ,
struct blk_desc * * dev_desc ,
disk_partition_t * info , int allow_whole_dev ) ;
# else
static inline bloc k_dev_de sc_t * get_dev ( const char * ifname , int dev )
static inline struct blk_desc * get_dev ( const char * ifname , int dev )
{ return NULL ; }
static inline bloc k_dev_de sc_t * ide_get_dev ( int dev ) { return NULL ; }
static inline bloc k_dev_de sc_t * sata_get_dev ( int dev ) { return NULL ; }
static inline bloc k_dev_de sc_t * scsi_get_dev ( int dev ) { return NULL ; }
static inline bloc k_dev_de sc_t * usb_stor_get_dev ( int dev ) { return NULL ; }
static inline bloc k_dev_de sc_t * mmc_get_dev ( int dev ) { return NULL ; }
static inline struct blk_desc * ide_get_dev ( int dev ) { return NULL ; }
static inline struct blk_desc * sata_get_dev ( int dev ) { return NULL ; }
static inline struct blk_desc * scsi_get_dev ( int dev ) { return NULL ; }
static inline struct blk_desc * usb_stor_get_dev ( int dev ) { return NULL ; }
static inline struct blk_desc * mmc_get_dev ( int dev ) { return NULL ; }
static inline int mmc_select_hwpart ( int dev_num , int hwpart ) { return - 1 ; }
static inline bloc k_dev_de sc_t * systemace_get_dev ( int dev ) { return NULL ; }
static inline bloc k_dev_de sc_t * mg_disk_get_dev ( int dev ) { return NULL ; }
static inline bloc k_dev_de sc_t * host_get_dev ( int dev ) { return NULL ; }
static inline struct blk_desc * systemace_get_dev ( int dev ) { return NULL ; }
static inline struct blk_desc * mg_disk_get_dev ( int dev ) { return NULL ; }
static inline struct blk_desc * host_get_dev ( int dev ) { return NULL ; }
static inline int get_partition_info ( bloc k_dev_de sc_t * dev_desc , int part ,
disk_partition_t * info ) { return - 1 ; }
static inline void print_part ( bloc k_dev_de sc_t * dev_desc ) { }
static inline void init_part ( bloc k_dev_de sc_t * dev_desc ) { }
static inline void dev_print ( bloc k_dev_de sc_t * dev_desc ) { }
static inline int get_partition_info ( struct blk_desc * dev_desc , int part ,
disk_partition_t * info ) { return - 1 ; }
static inline void print_part ( struct blk_desc * dev_desc ) { }
static inline void init_part ( struct blk_desc * dev_desc ) { }
static inline void dev_print ( struct blk_desc * dev_desc ) { }
static inline int get_device ( const char * ifname , const char * dev_str ,
bloc k_dev_de sc_t * * dev_desc )
struct blk_desc * * dev_desc )
{ return - 1 ; }
static inline int get_device_and_partition ( const char * ifname ,
const char * dev_part_str ,
bloc k_dev_de sc_t * * dev_desc ,
struct blk_desc * * dev_desc ,
disk_partition_t * info ,
int allow_whole_dev )
{ * dev_desc = NULL ; return - 1 ; }
@ -154,36 +155,41 @@ static inline int get_device_and_partition(const char *ifname,
# 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 ) ;
int get_partition_info_mac ( struct blk_desc * dev_desc , int part ,
disk_partition_t * info ) ;
void print_part_mac ( struct blk_desc * dev_desc ) ;
int test_part_mac ( struct blk_desc * 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 ) ;
int get_partition_info_dos ( struct blk_desc * dev_desc , int part ,
disk_partition_t * info ) ;
void print_part_dos ( struct blk_desc * dev_desc ) ;
int test_part_dos ( struct blk_desc * 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 ) ;
int get_partition_info_iso ( struct blk_desc * dev_desc , int part ,
disk_partition_t * info ) ;
void print_part_iso ( struct blk_desc * dev_desc ) ;
int test_part_iso ( struct blk_desc * dev_desc ) ;
# endif
# 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 ) ;
int get_partition_info_amiga ( struct blk_desc * dev_desc , int part ,
disk_partition_t * info ) ;
void print_part_amiga ( struct blk_desc * dev_desc ) ;
int test_part_amiga ( struct blk_desc * dev_desc ) ;
# endif
# ifdef CONFIG_EFI_PARTITION
# include <part_efi.h>
/* disk/part_efi.c */
int get_partition_info_efi ( block_dev_desc_t * dev_desc , int part , disk_partition_t * info ) ;
int get_partition_info_efi ( struct blk_desc * dev_desc , int part ,
disk_partition_t * info ) ;
/**
* get_partition_info_efi_by_name ( ) - Find the specified GPT partition table entry
*
@ -193,10 +199,10 @@ int get_partition_info_efi (block_dev_desc_t * dev_desc, int part, disk_partitio
*
* @ return - ' 0 ' on match , ' - 1 ' on no match , otherwise error
*/
int get_partition_info_efi_by_name ( bloc k_dev_de sc_t * dev_desc ,
int get_partition_info_efi_by_name ( struct blk_desc * dev_desc ,
const char * name , disk_partition_t * info ) ;
void print_part_efi ( bloc k_dev_de sc_t * dev_desc ) ;
int test_part_efi ( bloc k_dev_de sc_t * dev_desc ) ;
void print_part_efi ( struct blk_desc * dev_desc ) ;
int test_part_efi ( struct blk_desc * dev_desc ) ;
/**
* write_gpt_table ( ) - Write the GUID Partition Table to disk
@ -207,7 +213,7 @@ int test_part_efi (block_dev_desc_t *dev_desc);
*
* @ return - zero on success , otherwise error
*/
int write_gpt_table ( bloc k_dev_de sc_t * dev_desc ,
int write_gpt_table ( struct blk_desc * dev_desc ,
gpt_header * gpt_h , gpt_entry * gpt_e ) ;
/**
@ -233,7 +239,7 @@ int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
*
* @ return - error on str_guid conversion error
*/
int gpt_fill_header ( bloc k_dev_de sc_t * dev_desc , gpt_header * gpt_h ,
int gpt_fill_header ( struct blk_desc * dev_desc , gpt_header * gpt_h ,
char * str_guid , int parts_count ) ;
/**
@ -246,7 +252,7 @@ int gpt_fill_header(block_dev_desc_t *dev_desc, gpt_header *gpt_h,
*
* @ return zero on success
*/
int gpt_restore ( bloc k_dev_de sc_t * dev_desc , char * str_disk_guid ,
int gpt_restore ( struct blk_desc * dev_desc , char * str_disk_guid ,
disk_partition_t * partitions , const int parts_count ) ;
/**
@ -257,7 +263,7 @@ int gpt_restore(block_dev_desc_t *dev_desc, char *str_disk_guid,
*
* @ return - ' 0 ' on success , otherwise error
*/
int is_valid_gpt_buf ( bloc k_dev_de sc_t * dev_desc , void * buf ) ;
int is_valid_gpt_buf ( struct blk_desc * dev_desc , void * buf ) ;
/**
* write_mbr_and_gpt_partitions ( ) - write MBR , Primary GPT and Backup GPT
@ -267,7 +273,7 @@ int is_valid_gpt_buf(block_dev_desc_t *dev_desc, void *buf);
*
* @ return - ' 0 ' on success , otherwise error
*/
int write_mbr_and_gpt_partitions ( bloc k_dev_de sc_t * dev_desc , void * buf ) ;
int write_mbr_and_gpt_partitions ( struct blk_desc * dev_desc , void * buf ) ;
/**
* gpt_verify_headers ( ) - Function to read and CRC32 check of the GPT ' s header
@ -281,7 +287,7 @@ int write_mbr_and_gpt_partitions(block_dev_desc_t *dev_desc, void *buf);
*
* @ return - ' 0 ' on success , otherwise error
*/
int gpt_verify_headers ( bloc k_dev_de sc_t * dev_desc , gpt_header * gpt_head ,
int gpt_verify_headers ( struct blk_desc * dev_desc , gpt_header * gpt_head ,
gpt_entry * * gpt_pte ) ;
/**
@ -300,7 +306,7 @@ int gpt_verify_headers(block_dev_desc_t *dev_desc, gpt_header *gpt_head,
*
* @ return - ' 0 ' on success , otherwise error
*/
int gpt_verify_partitions ( bloc k_dev_de sc_t * dev_desc ,
int gpt_verify_partitions ( struct blk_desc * dev_desc ,
disk_partition_t * partitions , int parts ,
gpt_header * gpt_head , gpt_entry * * gpt_pte ) ;
# endif