void video_banner(void) { block_dev_desc_t *ide; int i; char *s; int maxdev; if (video_inited == 0) return; #ifdef EASTEREGG if (video_easteregg_active) { prompt_string=""; video_clear(); printf("\n"); printf(" **** COMMODORE 64 BASIC X2 ****\n\n"); printf(" 64K RAM SYSTEM 38911 BASIC BYTES FREE\n\n"); printf("READY\n"); } else { #endif s = getenv("ide_maxbus"); if (s) maxdev = atoi(s) * 2; else maxdev = 4; s = getenv("stdout"); if (s && strcmp(s, "serial") == 0) return; video_clear(); printf("%s\n\nCPU: ", version_string); checkcpu(); printf("DRAM: %ld MB\n", gd->bd->bi_memsize/(1024*1024)); printf("FSB: %ld MHz\n", gd->bd->bi_busfreq/1000000); printf("\n---- Disk summary ----\n"); for (i = 0; i < maxdev; i++) { ide = ide_get_dev(i); printf("Device %d: ", i); dev_print(ide); } /* video_draw_box(SINGLE_BOX, 0x0F, "Test 1", 0, 0,18, 72, 4); video_draw_box(DOUBLE_BOX, 0x0F, "Test 2", 1, 4,10, 50, 6); video_draw_box(DOUBLE_BOX, 0x0F, "Test 3", 0, 40, 3, 20, 5); video_draw_text(1, 4, 0x2F, "Highlighted options"); video_draw_text(1, 5, 0x0F, "Non-selected option"); video_draw_text(1, 6, 0x07, "disabled option"); */ #ifdef EASTEREGG } #endif }
/********************************************************************************* * show info on storage devices; 'usb start/init' must be invoked earlier * as we only retrieve structures populated during devices initialization */ void usb_stor_info(void) { int i; if (usb_max_devs > 0) for (i = 0; i < usb_max_devs; i++) { printf (" Device %d: ", i); dev_print(&usb_dev_desc[i]); } else printf("No storage devices, perhaps not 'usb start'ed..?\n"); }
/********************************************************************************* * (re)-scan the usb and reports device info * to the user if mode = 1 * returns current device or -1 if no */ int usb_stor_scan(int mode) { unsigned char i; struct usb_device *dev; /* GJ */ memset(usb_stor_buf, 0, sizeof(usb_stor_buf)); if(mode==1) { printf(" scanning bus for storage devices...\n"); } usb_disable_asynch(1); /* asynch transfer not allowed */ for(i=0;i<USB_MAX_STOR_DEV;i++) { memset(&usb_dev_desc[i],0,sizeof(block_dev_desc_t)); usb_dev_desc[i].target=0xff; usb_dev_desc[i].if_type=IF_TYPE_USB; usb_dev_desc[i].dev=i; usb_dev_desc[i].part_type=PART_TYPE_UNKNOWN; usb_dev_desc[i].block_read=usb_stor_read; } usb_max_devs=0; for(i=0;i<USB_MAX_DEVICE;i++) { dev=usb_get_dev_index(i); /* get device */ USB_STOR_PRINTF("i=%d\n",i); if(dev==NULL) { break; /* no more devices avaiable */ } if(usb_storage_probe(dev,0,&usb_stor[usb_max_devs])) { /* ok, it is a storage devices */ /* get info and fill it in */ if(usb_stor_get_info(dev, &usb_stor[usb_max_devs], &usb_dev_desc[usb_max_devs])) { if(mode==1) { printf (" Device %d: ", usb_max_devs); dev_print(&usb_dev_desc[usb_max_devs]); } /* if mode */ usb_max_devs++; } /* if get info ok */ } /* if storage device */ if(usb_max_devs==USB_MAX_STOR_DEV) { printf("max USB Storage Device reached: %d stopping\n",usb_max_devs); break; } } /* for */ usb_disable_asynch(0); /* asynch transfer allowed */ if(usb_max_devs>0) return 0; else return-1; }
/********************************************************************************* * show info on storage devices; 'usb start/init' must be invoked earlier * as we only retrieve structures populated during devices initialization */ int usb_stor_info(void) { int i; if (usb_max_devs <= 0){ printf("No storage devices, perhaps not 'usb start'ed..?\n"); return 1; } for (i = 0; i < usb_max_devs; i++) { printf (" Device %d: ", i); dev_print(&usb_dev_desc[i]); } return 0; }
int blk_print_device_num(enum if_type if_type, int devnum) { struct blk_driver *drv = blk_driver_lookup_type(if_type); struct blk_desc *desc; int ret; if (!drv) return -ENOSYS; ret = get_desc(drv, devnum, &desc); if (ret) return ret; printf("\n%s device %d: ", drv->if_typename, devnum); dev_print(desc); return 0; }
void blk_list_devices(enum if_type if_type) { struct blk_driver *drv = blk_driver_lookup_type(if_type); struct blk_desc *desc; int i; if (!drv) return; for (i = 0; i < drv->max_devs; ++i) { if (get_desc(drv, i, &desc)) continue; if (desc->type == DEV_TYPE_UNKNOWN) continue; /* list only known devices */ printf("Device %d: ", i); dev_print(desc); } }
static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) { int ret; struct udevice *bdev; struct blk_desc bd; struct blk_desc *bdesc; char str[10]; /* * detect the scsi driver to get information about its geometry (block * size, number of blocks) and other parameters (ids, type, ...) */ scsi_init_dev_desc_priv(&bd); if (scsi_detect_dev(dev, id, lun, &bd)) return -ENODEV; /* * Create only one block device and do detection * to make sure that there won't be a lot of * block devices created */ snprintf(str, sizeof(str), "id%dlun%d", id, lun); ret = blk_create_devicef(dev, "scsi_blk", str, IF_TYPE_SCSI, -1, bd.blksz, bd.blksz * bd.lba, &bdev); if (ret) { debug("Can't create device\n"); return ret; } bdesc = dev_get_uclass_platdata(bdev); bdesc->target = id; bdesc->lun = lun; bdesc->removable = bd.removable; bdesc->type = bd.type; memcpy(&bdesc->vendor, &bd.vendor, sizeof(bd.vendor)); memcpy(&bdesc->product, &bd.product, sizeof(bd.product)); memcpy(&bdesc->revision, &bd.revision, sizeof(bd.revision)); part_init(bdesc); if (verbose) { printf(" Device %d: ", 0); dev_print(bdesc); } return 0; }
int blk_show_device(enum if_type if_type, int devnum) { struct blk_driver *drv = blk_driver_lookup_type(if_type); struct blk_desc *desc; int ret; if (!drv) return -ENOSYS; printf("\nDevice %d: ", devnum); if (devnum >= drv->max_devs) { puts("unknown device\n"); return -ENODEV; } ret = get_desc(drv, devnum, &desc); if (ret) return ret; dev_print(desc); if (desc->type == DEV_TYPE_UNKNOWN) return -ENOENT; return 0; }
static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { int rc = 0; if (argc == 2 && strcmp(argv[1], "init") == 0) return sata_initialize(); /* If the user has not yet run `sata init`, do it now */ if (sata_curr_device == -1) if (sata_initialize()) return 1; switch (argc) { case 0: case 1: return CMD_RET_USAGE; case 2: if (strncmp(argv[1],"inf", 3) == 0) { int i; putc('\n'); for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; ++i) { if (sata_dev_desc[i].type == DEV_TYPE_UNKNOWN) continue; printf ("SATA device %d: ", i); dev_print(&sata_dev_desc[i]); } return 0; } else if (strncmp(argv[1],"dev", 3) == 0) { if ((sata_curr_device < 0) || (sata_curr_device >= CONFIG_SYS_SATA_MAX_DEVICE)) { puts("\nno SATA devices available\n"); return 1; } printf("\nSATA device %d: ", sata_curr_device); dev_print(&sata_dev_desc[sata_curr_device]); return 0; } else if (strncmp(argv[1],"part",4) == 0) { int dev, ok; for (ok = 0, dev = 0; dev < CONFIG_SYS_SATA_MAX_DEVICE; ++dev) { if (sata_dev_desc[dev].part_type != PART_TYPE_UNKNOWN) { ++ok; if (dev) putc ('\n'); print_part(&sata_dev_desc[dev]); } } if (!ok) { puts("\nno SATA devices available\n"); rc ++; } return rc; } return CMD_RET_USAGE; case 3: if (strncmp(argv[1], "dev", 3) == 0) { int dev = (int)simple_strtoul(argv[2], NULL, 10); printf("\nSATA device %d: ", dev); if (dev >= CONFIG_SYS_SATA_MAX_DEVICE) { puts ("unknown device\n"); return 1; } dev_print(&sata_dev_desc[dev]); if (sata_dev_desc[dev].type == DEV_TYPE_UNKNOWN) return 1; sata_curr_device = dev; puts("... is now current device\n"); return 0; } else if (strncmp(argv[1], "part", 4) == 0) { int dev = (int)simple_strtoul(argv[2], NULL, 10); if (sata_dev_desc[dev].part_type != PART_TYPE_UNKNOWN) { print_part(&sata_dev_desc[dev]); } else { printf("\nSATA device %d not available\n", dev); rc = 1; } return rc; } return CMD_RET_USAGE; default: /* at least 4 args */ if (strcmp(argv[1], "read") == 0) { ulong addr = simple_strtoul(argv[2], NULL, 16); ulong cnt = simple_strtoul(argv[4], NULL, 16); ulong n; lbaint_t blk = simple_strtoul(argv[3], NULL, 16); printf("\nSATA read: device %d block # %ld, count %ld ... ", sata_curr_device, blk, cnt); n = sata_read(sata_curr_device, blk, cnt, (u32 *)addr); /* flush cache after read */ flush_cache(addr, cnt * sata_dev_desc[sata_curr_device].blksz); printf("%ld blocks read: %s\n", n, (n==cnt) ? "OK" : "ERROR"); return (n == cnt) ? 0 : 1; } else if (strcmp(argv[1], "write") == 0) { ulong addr = simple_strtoul(argv[2], NULL, 16); ulong cnt = simple_strtoul(argv[4], NULL, 16); ulong n; lbaint_t blk = simple_strtoul(argv[3], NULL, 16); printf("\nSATA write: device %d block # %ld, count %ld ... ", sata_curr_device, blk, cnt); n = sata_write(sata_curr_device, blk, cnt, (u32 *)addr); printf("%ld blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR"); return (n == cnt) ? 0 : 1; } else { return CMD_RET_USAGE; } return rc; } }
/********************************************************************************* * (re)-scan the scsi bus and reports scsi device info * to the user if mode = 1 */ void scsi_scan(int mode) { unsigned char i,perq,modi,lun; lbaint_t capacity; unsigned long blksz; ccb* pccb=(ccb *)&tempccb; if(mode==1) { printf("scanning bus for devices...\n"); } for(i=0;i<CONFIG_SYS_SCSI_MAX_DEVICE;i++) { scsi_dev_desc[i].target=0xff; scsi_dev_desc[i].lun=0xff; scsi_dev_desc[i].lba=0; scsi_dev_desc[i].blksz=0; scsi_dev_desc[i].type=DEV_TYPE_UNKNOWN; scsi_dev_desc[i].vendor[0]=0; scsi_dev_desc[i].product[0]=0; scsi_dev_desc[i].revision[0]=0; scsi_dev_desc[i].removable=FALSE; scsi_dev_desc[i].if_type=IF_TYPE_SCSI; scsi_dev_desc[i].dev=i; scsi_dev_desc[i].part_type=PART_TYPE_UNKNOWN; scsi_dev_desc[i].block_read=scsi_read; scsi_dev_desc[i].block_write = scsi_write; } scsi_max_devs=0; for(i=0;i<CONFIG_SYS_SCSI_MAX_SCSI_ID;i++) { pccb->target=i; for(lun=0;lun<CONFIG_SYS_SCSI_MAX_LUN;lun++) { pccb->lun=lun; pccb->pdata=(unsigned char *)&tempbuff; pccb->datalen=512; scsi_setup_inquiry(pccb); if(scsi_exec(pccb)!=TRUE) { if(pccb->contr_stat==SCSI_SEL_TIME_OUT) { debug ("Selection timeout ID %d\n",pccb->target); continue; /* selection timeout => assuming no device present */ } /* Device present at this target/lun * but may not be ready yet. */ scsi_print_error(pccb); continue; } perq=tempbuff[0]; modi=tempbuff[1]; if((perq & 0x1f)==0x1f) { continue; /* skip unknown devices */ } if((modi&0x80)==0x80) /* drive is removable */ scsi_dev_desc[scsi_max_devs].removable=TRUE; /* get info for this device */ scsi_ident_cpy((unsigned char *)&scsi_dev_desc[scsi_max_devs].vendor[0], &tempbuff[8], 8); scsi_ident_cpy((unsigned char *)&scsi_dev_desc[scsi_max_devs].product[0], &tempbuff[16], 16); scsi_ident_cpy((unsigned char *)&scsi_dev_desc[scsi_max_devs].revision[0], &tempbuff[32], 4); scsi_dev_desc[scsi_max_devs].target=pccb->target; scsi_dev_desc[scsi_max_devs].lun=pccb->lun; pccb->datalen=0; scsi_setup_test_unit_ready(pccb); if(scsi_exec(pccb)!=TRUE) { if(scsi_dev_desc[scsi_max_devs].removable==TRUE) { scsi_dev_desc[scsi_max_devs].type=perq; goto removable; } scsi_print_error(pccb); continue; } if (scsi_read_capacity(pccb, &capacity, &blksz)) { scsi_print_error(pccb); continue; } scsi_dev_desc[scsi_max_devs].lba=capacity; scsi_dev_desc[scsi_max_devs].blksz=blksz; scsi_dev_desc[scsi_max_devs].type=perq; init_part(&scsi_dev_desc[scsi_max_devs]); removable: if(mode==1) { printf (" Device %d: ", scsi_max_devs); dev_print(&scsi_dev_desc[scsi_max_devs]); } /* if mode */ scsi_max_devs++; } /* next LUN */ } if(scsi_max_devs>0) scsi_curr_dev=0; else scsi_curr_dev = -1; printf("Found %d device(s).\n", scsi_max_devs); }
/********************************************************************************* * scsi command intepreter */ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { switch (argc) { case 0: case 1: return CMD_RET_USAGE; case 2: if (strncmp(argv[1],"res",3) == 0) { printf("\nReset SCSI\n"); scsi_bus_reset(); scsi_scan(1); return 0; } if (strncmp(argv[1],"inf",3) == 0) { int i; for (i=0; i<CONFIG_SYS_SCSI_MAX_DEVICE; ++i) { if(scsi_dev_desc[i].type==DEV_TYPE_UNKNOWN) continue; /* list only known devices */ printf ("SCSI dev. %d: ", i); dev_print(&scsi_dev_desc[i]); } return 0; } if (strncmp(argv[1],"dev",3) == 0) { if ((scsi_curr_dev < 0) || (scsi_curr_dev >= CONFIG_SYS_SCSI_MAX_DEVICE)) { printf("\nno SCSI devices available\n"); return 1; } printf ("\n Device %d: ", scsi_curr_dev); dev_print(&scsi_dev_desc[scsi_curr_dev]); return 0; } if (strncmp(argv[1],"scan",4) == 0) { scsi_scan(1); return 0; } if (strncmp(argv[1],"part",4) == 0) { int dev, ok; for (ok=0, dev=0; dev<CONFIG_SYS_SCSI_MAX_DEVICE; ++dev) { if (scsi_dev_desc[dev].type!=DEV_TYPE_UNKNOWN) { ok++; if (dev) printf("\n"); debug ("print_part of %x\n",dev); print_part(&scsi_dev_desc[dev]); } } if (!ok) printf("\nno SCSI devices available\n"); return 1; } return CMD_RET_USAGE; case 3: if (strncmp(argv[1],"dev",3) == 0) { int dev = (int)simple_strtoul(argv[2], NULL, 10); printf ("\nSCSI device %d: ", dev); if (dev >= CONFIG_SYS_SCSI_MAX_DEVICE) { printf("unknown device\n"); return 1; } printf ("\n Device %d: ", dev); dev_print(&scsi_dev_desc[dev]); if(scsi_dev_desc[dev].type == DEV_TYPE_UNKNOWN) { return 1; } scsi_curr_dev = dev; printf("... is now current device\n"); return 0; } if (strncmp(argv[1],"part",4) == 0) { int dev = (int)simple_strtoul(argv[2], NULL, 10); if(scsi_dev_desc[dev].type != DEV_TYPE_UNKNOWN) { print_part(&scsi_dev_desc[dev]); } else { printf ("\nSCSI device %d not available\n", dev); } return 1; } return CMD_RET_USAGE; default: /* at least 4 args */ if (strcmp(argv[1],"read") == 0) { ulong addr = simple_strtoul(argv[2], NULL, 16); ulong blk = simple_strtoul(argv[3], NULL, 16); ulong cnt = simple_strtoul(argv[4], NULL, 16); ulong n; printf ("\nSCSI read: device %d block # %ld, count %ld ... ", scsi_curr_dev, blk, cnt); n = scsi_read(scsi_curr_dev, blk, cnt, (ulong *)addr); printf ("%ld blocks read: %s\n",n,(n==cnt) ? "OK" : "ERROR"); return 0; } else if (strcmp(argv[1], "write") == 0) { ulong addr = simple_strtoul(argv[2], NULL, 16); ulong blk = simple_strtoul(argv[3], NULL, 16); ulong cnt = simple_strtoul(argv[4], NULL, 16); ulong n; printf("\nSCSI write: device %d block # %ld, " "count %ld ... ", scsi_curr_dev, blk, cnt); n = scsi_write(scsi_curr_dev, blk, cnt, (ulong *)addr); printf("%ld blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR"); return 0; } } /* switch */ return CMD_RET_USAGE; }
/********************************************************************************* * (re)-scan the scsi bus and reports scsi device info * to the user if mode = 1 */ void scsi_scan(int mode) { unsigned char i,perq,modi,lun; lbaint_t capacity; unsigned long blksz; ccb* pccb=(ccb *)&tempccb; static int scsi_detected = 0; if (scsi_detected) { printf("** scsi detection can run only once - please"); printf(" reset board before running detection again **\n"); return; } scsi_detected = 1; if(mode==1) { printf("scanning bus for devices...\n"); } if (tempbuff == NULL) { tempbuff = memalign(ARCH_DMA_MINALIGN, 512); if (tempbuff == NULL) { if (mode == 1) printf("error: cannot allocate buffer\n"); return; } } for(i = 0; i < CONFIG_SYS_SCSI_MAX_DEVICE; i++) { scsi_dev_desc[i].target=0xff; scsi_dev_desc[i].lun=0xff; scsi_dev_desc[i].lba=0; scsi_dev_desc[i].blksz=0; scsi_dev_desc[i].log2blksz = LOG2_INVALID(typeof(scsi_dev_desc[i].log2blksz)); scsi_dev_desc[i].type=DEV_TYPE_UNKNOWN; scsi_dev_desc[i].vendor[0]=0; scsi_dev_desc[i].product[0]=0; scsi_dev_desc[i].revision[0]=0; scsi_dev_desc[i].removable=FALSE; scsi_dev_desc[i].if_type=IF_TYPE_SCSI; scsi_dev_desc[i].dev=i; scsi_dev_desc[i].part_type=PART_TYPE_UNKNOWN; scsi_dev_desc[i].block_read=scsi_read; scsi_dev_desc[i].block_write = scsi_write; } scsi_max_devs=0; for(i=0; i<CONFIG_SYS_SCSI_MAX_SCSI_ID; i++) { pccb->target=i; for(lun=0; lun<CONFIG_SYS_SCSI_MAX_LUN; lun++) { pccb->lun=lun; pccb->pdata = (unsigned char *)tempbuff; pccb->datalen=512; scsi_setup_inquiry(pccb); if(scsi_exec(pccb)!=TRUE) { if(pccb->contr_stat==SCSI_SEL_TIME_OUT) { debug ("Selection timeout ID %d\n",pccb->target); continue; /* selection timeout => assuming no device present */ } scsi_print_error(pccb); continue; } perq=tempbuff[0]; modi=tempbuff[1]; if((perq & 0x1f)==0x1f) { continue; /* skip unknown devices */ } if((modi&0x80)==0x80) /* drive is removable */ scsi_dev_desc[scsi_max_devs].removable=TRUE; /* get info for this device */ scsi_ident_cpy((unsigned char *)&scsi_dev_desc[scsi_max_devs].vendor[0], &tempbuff[8], 8); scsi_ident_cpy((unsigned char *)&scsi_dev_desc[scsi_max_devs].product[0], &tempbuff[16], 16); scsi_ident_cpy((unsigned char *)&scsi_dev_desc[scsi_max_devs].revision[0], &tempbuff[32], 4); scsi_dev_desc[scsi_max_devs].target=pccb->target; scsi_dev_desc[scsi_max_devs].lun=pccb->lun; pccb->datalen=0; scsi_setup_test_unit_ready(pccb); if(scsi_exec(pccb)!=TRUE) { if(scsi_dev_desc[scsi_max_devs].removable==TRUE) { scsi_dev_desc[scsi_max_devs].type=perq; goto removable; } scsi_print_error(pccb); continue; } if (scsi_read_capacity(pccb, &capacity, &blksz)) { scsi_print_error(pccb); continue; } scsi_dev_desc[scsi_max_devs].lba=capacity; scsi_dev_desc[scsi_max_devs].blksz=blksz; scsi_dev_desc[scsi_max_devs].log2blksz = LOG2(scsi_dev_desc[scsi_max_devs].blksz); scsi_dev_desc[scsi_max_devs].type=perq; init_part(&scsi_dev_desc[scsi_max_devs]); removable: if(mode==1) { printf (" Device %d: ", scsi_max_devs); dev_print(&scsi_dev_desc[scsi_max_devs]); } /* if mode */ scsi_max_devs++; } /* next LUN */ } if (scsi_max_devs > 0) scsi_curr_dev = 0; else scsi_curr_dev = -1; printf("Found %d device(s).\n", scsi_max_devs); setenv_ulong("scsidevs", scsi_max_devs); }
/** * clear to eol */ void dev_clreol() { dev_print("\033[K"); }