// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: disk_ui.cc
// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
// The above named program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License version 2 as published by the Free Software Foundation.
// The above named program is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public
// License along with this work; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
// ========== Copyright Header End ============================================
void Disk::display_label(){
fprintf(debug_file
,"%s:%s Disk Label, Type _SUNOS_VTOC_8\n",disk_name
,fake_vtoc
?"Fake":"Real");
fprintf(debug_file
," dkl_asciilabel %s\n",disk_label
.dkl_ascii_label
);
fprintf(debug_file
," dkl_vtoc\n");
fprintf(debug_file
," v_version 0x%lx\n",disk_label
.dkl_vtoc
.v_version
);
fprintf(debug_file
," v_volume %s\n",disk_label
.dkl_vtoc
.v_volume
);
fprintf(debug_file
," v_nparts 0x%x\n",disk_label
.dkl_vtoc
.v_nparts
);
fprintf(debug_file
," v_part\n");
for(int i
= 0; i
< VTOC8_NDKMAP
; i
++){
if(disk_label
.dkl_vtoc
.v_part
[i
].p_tag
!= 0){
fprintf(debug_file
," [%d] p_tag 0x%x\n",i
,disk_label
.dkl_vtoc
.v_part
[i
].p_tag
);
fprintf(debug_file
," [%d] p_flag 0x%x\n",i
,disk_label
.dkl_vtoc
.v_part
[i
].p_flag
);
fprintf(debug_file
," v_bootinfo (%lx %lx %lx)\n",\
disk_label
.dkl_vtoc
.v_bootinfo
[0],\
disk_label
.dkl_vtoc
.v_bootinfo
[1],\
disk_label
.dkl_vtoc
.v_bootinfo
[2]);
fprintf(debug_file
," v_sanity 0x%lx\n",disk_label
.dkl_vtoc
.v_sanity
);
fprintf(debug_file
," v_timestamp\n");
for(int i
= 0; i
< VTOC8_NDKMAP
; i
++)
if(disk_label
.dkl_vtoc
.v_timestamp
[i
] != 0)
fprintf(debug_file
," [%d] 0x%lx\n",disk_label
.dkl_vtoc
.v_timestamp
[i
]);
fprintf(debug_file
," dkl_write_reinstruct 0x%x\n",disk_label
.dkl_write_reinstruct
);
fprintf(debug_file
," dkl_read_reinstruct 0x%x\n",disk_label
.dkl_read_reinstruct
);
fprintf(debug_file
," dkl_rpm %d\n",disk_label
.dkl_rpm
);
fprintf(debug_file
," dkl_pcyl %d\n",disk_label
.dkl_pcyl
);
fprintf(debug_file
," dkl_apc %d\n",disk_label
.dkl_apc
);
fprintf(debug_file
," dkl_intrlv %d\n",disk_label
.dkl_intrlv
);
fprintf(debug_file
," dkl_ncyl %d\n",disk_label
.dkl_ncyl
);
fprintf(debug_file
," dkl_acyl %d\n",disk_label
.dkl_acyl
);
fprintf(debug_file
," dkl_nhead %d\n",disk_label
.dkl_nhead
);
fprintf(debug_file
," dkl_nsect %d\n",disk_label
.dkl_nsect
);
fprintf(debug_file
," dkl_map\n");
for(int i
= 0; i
< VTOC8_NDKMAP
; i
++)
if(disk_label
.dkl_map
[i
].dkl_nblk
!= 0){
fprintf(debug_file
," [%d] dkl_cylno %ld\n",i
,disk_label
.dkl_map
[i
].dkl_cylno
);
fprintf(debug_file
," [%d] dkl_nblk %ld\n",i
,disk_label
.dkl_map
[i
].dkl_nblk
);
fprintf(debug_file
," dkl_magic 0x%x\n",disk_label
.dkl_magic
);
fprintf(debug_file
," dkl_cksum 0x%x\n",disk_label
.dkl_cksum
);
void Disk::display_geometry(){
fprintf(debug_file
,"%s\n",disk_name
);
fprintf(debug_file
,"bytes/sector %d\n",bytes_per_sector
);
fprintf(debug_file
,"sectors/track %d\n",sectors_per_track
);
fprintf(debug_file
,"tracks/cylinder %d\n",tracks_per_cylinder
);
fprintf(debug_file
,"cylinders %ld\n",num_cylinder
);
fprintf(debug_file
,"total blocks(SAM) %lld\n",num_blks
);
fprintf(debug_file
,"\n\n");
fprintf(debug_file
,"SAM's Disk Geometry\n");
fprintf(debug_file
," First Sector Last\n");
fprintf(debug_file
,"Partition Sector Count Sector\n");
for(int i
= 0; i
< MAX_PARTITIONS
; i
++){
fprintf(debug_file
,"%4d%12lld%12lld%12lld\n",i
,partitions
[i
]->start_lblk
,partitions
[i
]->nblks
,partitions
[i
]->end_lblk
);
fprintf(debug_file
,"\n\n");
fprintf(debug_file
,"VTOC Disk Geometry\n");
fprintf(debug_file
," First Sector Last\n");
fprintf(debug_file
,"Partition Sector Count Sector\n");
for(int i
= 0; i
< VTOC8_NDKMAP
; i
++)
if(disk_label
.dkl_map
[i
].dkl_nblk
!= 0){
uint64_t first_sector
= 1ULL*disk_label
.dkl_map
[i
].dkl_cylno
* disk_label
.dkl_nsect
* disk_label
.dkl_nhead
;
uint32_t num_sectors
= disk_label
.dkl_map
[i
].dkl_nblk
;
fprintf(debug_file
,"%4d%12lld%12ld%12lld\n",i
,\
first_sector
,num_sectors
,first_sector
+num_sectors
-1);
void Disk::display_stats(){
fprintf(debug_file
,"%s:\n",disk_name
);
for(int i
= 0; i
< MAX_PARTITIONS
; i
++)
fprintf(debug_file
," %s[%d]\n",partitions
[i
]->part_name
,i
);
fprintf(debug_file
," total reads - %lld\n",partitions
[i
]->lblk_reads
);
fprintf(debug_file
," total writes - %lld\n",partitions
[i
]->lblk_writes
);
fprintf(debug_file
," backup reads - %lld\n",partitions
[i
]->lblk_reads_primary
);
fprintf(debug_file
," backup writes - %lld\n",partitions
[i
]->lblk_writes_primary
);
fprintf(debug_file
," overlay reads - %lld\n",partitions
[i
]->lblk_reads_overlay
);
fprintf(debug_file
," overlay writes - %lld\n",partitions
[i
]->lblk_writes_overlay
);
fprintf(debug_file
," ckpt reads - %lld\n",partitions
[i
]->lblk_reads_ckpt
);
void Disk::display_partitions(int part_num
){
fprintf(debug_file
,"Disk %s, target id:%d, debug_file <%s>\n",disk_name
,target_id
,debug_file_name
);
for(int i
= 0; i
< MAX_PARTITIONS
; i
++)
if(!partitions
[part_num
]){
fprintf(debug_file
," No partition %d present\n",part_num
);
partitions
[part_num
]->info();
void Disk::display_disk_delay(){
fprintf(debug_file
,"%s: disk delay %u/%u micro seconds\n",disk_name
,get_read_delay(),get_write_delay());
void Disk::display_help(){
fprintf(stderr
,"gdisk \n");
fprintf(stderr
," - display configured disks \n");
fprintf(stderr
,"gdisk help\n");
fprintf(stderr
," - display this message\n");
fprintf(stderr
,"gdisk <disk_name | all> <command_name> [args]\n");
fprintf(stderr
," commands are\n");
fprintf(stderr
," label\n");
fprintf(stderr
," - display disk label\n");
fprintf(stderr
," geometry\n");
fprintf(stderr
," - display disk geometry\n");
fprintf(stderr
," stat\n");
fprintf(stderr
," - display any supported stats\n");
fprintf(stderr
," partitions [number]\n");
fprintf(stderr
," - display partition[number] info\n");
fprintf(stderr
," - display all partitions by default\n");
fprintf(stderr
," vpd\n");
fprintf(stderr
," - display supported disk VPD data\n");
fprintf(stderr
," op [file]\n");
fprintf(stderr
," - redirect all o/p to <file>\n");
fprintf(stderr
," - by default print current op file\n");
fprintf(stderr
," dd [read latency/write latency]\n");
fprintf(stderr
," - display disk latency\n");
fprintf(stderr
," debug [level]\n");
fprintf(stderr
," - set debug vebosity to <level>\n");
fprintf(stderr
," - displays current level by default\n");
void Disk::set_debug_level(int l
){
for(int i
= 0; i
< MAX_PARTITIONS
; i
++)
partitions
[i
]->set_debug_level(l
);
void Disk::set_debug_file(const char * file
){
if(!strcmp(file
,"stderr")){
strcpy(debug_file_name
,"stderr");
}else if(!strcmp(file
,"stdout")){
strcpy(debug_file_name
,"stdout");
debug_file
= fopen(file
,"w+");
fprintf(stderr
,"%s Unable to open %s\n",disk_name
,file
);
strcpy(debug_file_name
,"stderr");
strcpy(debug_file_name
,file
);
for(int i
= 0; i
< MAX_PARTITIONS
; i
++)
partitions
[i
]->set_debug_file(debug_file
);
fprintf(debug_file
," %s\n",part_name
);
fprintf(debug_file
," Contains Disk label\n");
fprintf(debug_file
," partition# %d\n",index
);
fprintf(debug_file
," backup_file %s\n",part_filename
,rw
?"Read/Write":"Read Only");
fprintf(debug_file
," %s\n",rw
?"Read/Write":"Read Only");
fprintf(debug_file
," %s\n",has_vtoc
?"Contains Disk Label":"No Disk Label");
fprintf(debug_file
," overlay_file %s\n",overlay_filename
);
fprintf(debug_file
," ckpt_file %s\n",ckpt_filename
);
fprintf(debug_file
," size (bytes) %lld\n",size
);
fprintf(debug_file
," nblks %lld\n",nblks
);
fprintf(debug_file
," padding %lld\n",nblks
*BYTES_PER_SECTOR
- size
);
fprintf(debug_file
," start_lblk %lld\n",start_lblk
);
fprintf(debug_file
," end_lblk %lld\n",end_lblk
);
fprintf(debug_file
," debug_level %d\n",debug_level
);
void SCSIDisk::display_vpd(){
fprintf(debug_file
,"%s\n",disk_name
);
fprintf(debug_file
," vendorid - ");
fwrite(vendorid
,sizeof_vendorid
,1,debug_file
);
fprintf(debug_file
,"\n");
fprintf(debug_file
," productid - ");
fwrite(productid
,sizeof_productid
,1,debug_file
);
fprintf(debug_file
,"\n");
fprintf(debug_file
," revisionid - ");
fwrite(revisionid
,sizeof_revisionid
,1,debug_file
);
fprintf(debug_file
,"\n");
fprintf(debug_file
," serialno - ");
fwrite(serialno
,sizeof_serialno
,1,debug_file
);
fprintf(debug_file
,"\n");
fprintf(debug_file
," prodserialno - ");
fwrite(prodserialno
,sizeof_prodserialno
,1,debug_file
);
fprintf(debug_file
,"\n");
fprintf(debug_file
," brdserialno - ");
fwrite(brdserialno
,sizeof_brdserialno
,1,debug_file
);
fprintf(debug_file
,"\n");
fprintf(debug_file
," portwwn - ");
fwrite(portwwn
,sizeof_portwwn
,1,debug_file
);
fprintf(debug_file
,"\n");
fprintf(debug_file
," nodewwn - ");
fwrite(nodewwn
,sizeof_nodewwn
,1,debug_file
);
fprintf(debug_file
,"\n");