MEDIA open_scsi_as_media(long bus, long device) { SCSI_MEDIA a; UInt32 blockCount; UInt32 blockSize; if (scsi_inited == 0) { scsi_init(); } if (scsi_mgr.exists == 0) { return 0; } a = 0; if (DoTestUnitReady(device, bus) > 0) { if (DoReadCapacity(device, bus, &blockCount, &blockSize) != 0) { a = new_scsi_media(); if (a != 0) { a->m.kind = scsi_mgr.kind; a->m.grain = blockSize; a->m.size_in_bytes = ((long long)blockCount) * blockSize; a->m.do_read = read_scsi_media; a->m.do_write = write_scsi_media; a->m.do_close = close_scsi_media; a->m.do_os_reload = os_reload_scsi_media; a->bus = bus; a->id = device; } } } return (MEDIA) a; }
MEDIA_ITERATOR create_scsi_iterator(void) { SCSI_MEDIA_ITERATOR a; if (scsi_inited == 0) { scsi_init(); } if (scsi_mgr.exists == 0) { return 0; } a = new_scsi_iterator(); if (a != 0) { a->m.kind = scsi_mgr.kind; a->m.state = kInit; a->m.do_reset = reset_scsi_iterator; a->m.do_step = step_scsi_iterator; a->m.do_delete = delete_scsi_iterator; a->bus_index = 0; a->bus = 0; a->id = 0; } return (MEDIA_ITERATOR) a; }
/* * This has the same structure as lookup_scsi_device() except we are * matching on the value & type rather than the bus & id. */ long lookup_scsi_index(long index, int is_cdrom, long *bus, long *id) { struct cache_item *item; struct cache_item *next; long result = 0; int count = 0; if (scsi_inited == 0) { scsi_init(); } while (1) { count++; for (item = linux_order.first; item != NULL; item = item->next) { if (item->value == index && item->is_cdrom == is_cdrom && item->unsure == 0) { result = 1; *bus = item->bus; *id = item->id; break; } } if (count < 2 && result == 0 && !linux_cache_loaded()) { probe_all(); } else { break; } }; return result; }
static int initr_scsi(void) { puts("SCSI: "); scsi_init(); return 0; }
int scsi_init_r(void) { puts("SCSI: "); scsi_init(); return 0; }
int _start(int argc, char** argv) { M_PRINTF("IEEE1394 Driver v%d.%d\n", MAJOR_VER, MINOR_VER); // initialize the SCSI driver if (scsi_init() != 0) { M_PRINTF("ERROR: initializing SCSI driver!\n"); return MODULE_NO_RESIDENT_END; } // initialize the IEEE1394 driver init_ieee1394DiskDriver(); return MODULE_RESIDENT_END; }
/** * Function name: mass_storage_init * Description: Initializes the mass storage function driver. * Parameters: * @ctx: (IN) Core context * * Return value: 0 on success, otherwise an error code * Scope: Global **/ jresult_t mass_storage_init(void *ctx) { jresult_t rc; fd_storage_t *fd; fd = jmalloc(sizeof(fd_storage_t), M_ZERO); if (!fd) return JENOMEM; fd->core_ctx = ctx; fd->state = STATE_DISABLED; fd->fd_desc = copy_fd_desc(); if (!fd->fd_desc) { jfree(fd); return JENOMEM; } /* Allocate requests */ fd->ep0_request = core_request_alloc(1, NULL); if (!fd->ep0_request) { DBG_E(DSLAVE_MS_USB, ("mass_storage_init: Failed to allocate ep0 " "request\n")); return JENOMEM; } fd->cmd_request = core_request_alloc(SCSI_MAX_REQUEST_SIZE, NULL); if (!fd->cmd_request) { DBG_E(DSLAVE_MS_USB, ("mass_storage_init: Failed to allocate cmd " "request\n")); return JENOMEM; } /* The completion callback of ep0 is always the same */ fd->ep0_request->complete = ep0_callback; fd->ep0_request->context = (void *)fd; rc = scsi_init(fd, &fd->total_luns, &fd->scsi_device); if (rc) return rc; return core_register_fd(fd->core_ctx, &fd_ops, (context_t)fd); }
/* * The routine called by the adapter boards to get all their * devices configured in. */ void scsibusattach(struct device *parent, struct device *self, void *aux) { struct scsibus_softc *sb = (struct scsibus_softc *)self; struct scsibus_attach_args *saa = aux; struct scsi_link *sc_link_proto = saa->saa_sc_link; int nbytes, i; if (!cold) scsi_autoconf = 0; sc_link_proto->scsibus = sb->sc_dev.dv_unit; sb->adapter_link = sc_link_proto; if (sb->adapter_link->adapter_buswidth == 0) sb->adapter_link->adapter_buswidth = 8; sb->sc_buswidth = sb->adapter_link->adapter_buswidth; if (sb->adapter_link->luns == 0) sb->adapter_link->luns = 8; printf(": %d targets\n", sb->sc_buswidth); /* Initialize shared data. */ scsi_init(); nbytes = sb->sc_buswidth * sizeof(struct scsi_link **); sb->sc_link = malloc(nbytes, M_DEVBUF, M_NOWAIT); if (sb->sc_link == NULL) panic("scsibusattach: can't allocate target links"); nbytes = sb->adapter_link->luns * sizeof(struct scsi_link *); for (i = 0; i < sb->sc_buswidth; i++) { sb->sc_link[i] = malloc(nbytes, M_DEVBUF, M_NOWAIT); if (sb->sc_link[i] == NULL) panic("scsibusattach: can't allocate lun links"); bzero(sb->sc_link[i], nbytes); } #if NBIO > 0 if (bio_register(&sb->sc_dev, scsibus_bioctl) != 0) printf("%s: unable to register bio\n", sb->sc_dev.dv_xname); #endif scsi_probe_bus(sb); }
/* * The routine called by the adapter boards to get all their * devices configured in. */ void scsibusattach(struct device *parent, struct device *self, void *aux) { struct scsibus_softc *sb = (struct scsibus_softc *)self; struct scsibus_attach_args *saa = aux; struct scsi_link *sc_link_proto = saa->saa_sc_link; if (!cold) scsi_autoconf = 0; sc_link_proto->bus = sb; sc_link_proto->scsibus = sb->sc_dev.dv_unit; sb->adapter_link = sc_link_proto; if (sb->adapter_link->adapter_buswidth == 0) sb->adapter_link->adapter_buswidth = 8; sb->sc_buswidth = sb->adapter_link->adapter_buswidth; if (sb->adapter_link->luns == 0) sb->adapter_link->luns = 8; printf(": %d targets", sb->sc_buswidth); if (sb->adapter_link->adapter_target < sb->sc_buswidth) printf(", initiator %d", sb->adapter_link->adapter_target); if (sb->adapter_link->port_wwn != 0x0 && sb->adapter_link->node_wwn != 0x0) { printf(", WWPN %016llx, WWNN %016llx", sb->adapter_link->port_wwn, sb->adapter_link->node_wwn); } printf("\n"); /* Initialize shared data. */ scsi_init(); SLIST_INIT(&sb->sc_link); #if NBIO > 0 if (bio_register(&sb->sc_dev, scsibus_bioctl) != 0) printf("%s: unable to register bio\n", sb->sc_dev.dv_xname); #endif scsi_probe_bus(sb); }
long lookup_scsi_device(long bus, long id, int *is_cdrom, int *unsure) { /* walk down list looking for bus and id ? * * only probe out of iterate (so always add in order) * reset list if we reset the iterate */ struct cache_item *item; struct cache_item *next; long result = -1; int count = 0; if (scsi_inited == 0) { scsi_init(); } while (1) { count++; for (item = linux_order.first; item != NULL; item = item->next) { if (item->bus == bus && item->id == id) { result = item->value; *is_cdrom = item->is_cdrom; *unsure = item->unsure; break; } } if (count < 2 && result < 0) { probe_all(); } else { break; } }; return result; }
void board_init_r(gd_t *id, ulong dest_addr) { ulong malloc_start; #if !defined(CONFIG_SYS_NO_FLASH) ulong flash_size; #endif gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r"); monitor_flash_len = (ulong)&__rel_dyn_end - (ulong)_start; /* Enable caches */ enable_caches(); debug("monitor flash len: %08lX\n", monitor_flash_len); board_init(); /* Setup chipselects */ /* * TODO: printing of the clock inforamtion of the board is now * implemented as part of bdinfo command. Currently only support for * davinci SOC's is added. Remove this check once all the board * implement this. */ #ifdef CONFIG_CLOCKS set_cpu_clk_info(); /* Setup clock information */ #endif serial_initialize(); debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr); #ifdef CONFIG_LOGBUFFER logbuff_init_ptrs(); #endif #ifdef CONFIG_POST post_output_backlog(); #endif /* The Malloc area is immediately below the monitor copy in DRAM */ malloc_start = dest_addr - TOTAL_MALLOC_LEN; mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN); #ifdef CONFIG_ARCH_EARLY_INIT_R arch_early_init_r(); #endif power_init_board(); #if !defined(CONFIG_SYS_NO_FLASH) puts("Flash: "); flash_size = flash_init(); if (flash_size > 0) { # ifdef CONFIG_SYS_FLASH_CHECKSUM print_size(flash_size, ""); /* * Compute and print flash CRC if flashchecksum is set to 'y' * * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX */ if (getenv_yesno("flashchecksum") == 1) { printf(" CRC: %08X", crc32(0, (const unsigned char *) CONFIG_SYS_FLASH_BASE, flash_size)); } putc('\n'); # else /* !CONFIG_SYS_FLASH_CHECKSUM */ print_size(flash_size, "\n"); # endif /* CONFIG_SYS_FLASH_CHECKSUM */ } else { puts(failed); hang(); } #endif #if defined(CONFIG_CMD_NAND) puts("NAND: "); nand_init(); /* go init the NAND */ #endif #if defined(CONFIG_CMD_ONENAND) onenand_init(); #endif #ifdef CONFIG_GENERIC_MMC puts("MMC: "); mmc_initialize(gd->bd); #endif #ifdef CONFIG_CMD_SCSI puts("SCSI: "); scsi_init(); #endif #ifdef CONFIG_HAS_DATAFLASH AT91F_DataflashInit(); dataflash_print_info(); #endif /* initialize environment */ if (should_load_env()) env_relocate(); else set_default_env(NULL); #if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI) arm_pci_init(); #endif stdio_init(); /* get the devices list going. */ jumptable_init(); #if defined(CONFIG_API) /* Initialize API */ api_init(); #endif console_init_r(); /* fully init console as a device */ #ifdef CONFIG_DISPLAY_BOARDINFO_LATE # ifdef CONFIG_OF_CONTROL /* Put this here so it appears on the LCD, now it is ready */ display_fdt_model(gd->fdt_blob); # else checkboard(); # endif #endif #if defined(CONFIG_ARCH_MISC_INIT) /* miscellaneous arch dependent initialisations */ arch_misc_init(); #endif #if defined(CONFIG_MISC_INIT_R) /* miscellaneous platform dependent initialisations */ misc_init_r(); #endif /* set up exceptions */ interrupt_init(); /* enable exceptions */ enable_interrupts(); /* Initialize from environment */ load_addr = getenv_ulong("loadaddr", 16, load_addr); #ifdef CONFIG_BOARD_LATE_INIT board_late_init(); #endif #ifdef CONFIG_FASTBOOT fastboot_setup(); #endif #ifdef CONFIG_BITBANGMII bb_miiphy_init(); #endif #if defined(CONFIG_CMD_NET) puts("Net: "); eth_initialize(gd->bd); #if defined(CONFIG_RESET_PHY_R) debug("Reset Ethernet PHY\n"); reset_phy(); #endif #endif #ifdef CONFIG_POST post_run(NULL, POST_RAM | post_bootmode_get(0)); #endif #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) /* * Export available size of memory for Linux, * taking into account the protected RAM at top of memory */ { ulong pram = 0; uchar memsz[32]; #ifdef CONFIG_PRAM pram = getenv_ulong("pram", 10, CONFIG_PRAM); #endif #ifdef CONFIG_LOGBUFFER #ifndef CONFIG_ALT_LB_ADDR /* Also take the logbuffer into account (pram is in kB) */ pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024; #endif #endif sprintf((char *)memsz, "%ldk", (gd->ram_size / 1024) - pram); setenv("mem", (char *)memsz); } #endif #ifdef CONFIG_FASTBOOT check_fastboot(); #endif /* main_loop() can return to retry autoboot, if so just run it again. */ for (;;) { main_loop(); } /* NOTREACHED - no way out of command loop except booting */ }
/* * This is the next part if the initialization sequence: we are now * running from RAM and have a "normal" C environment, i. e. global * data can be written, BSS has been cleared, the stack size in not * that critical any more, etc. */ void board_init_r(gd_t *id, ulong dest_addr) { bd_t *bd; ulong malloc_start; #ifndef CONFIG_SYS_NO_FLASH ulong flash_size; #endif gd = id; /* initialize RAM version of global data */ bd = gd->bd; gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ /* The Malloc area is immediately below the monitor copy in DRAM */ malloc_start = dest_addr - TOTAL_MALLOC_LEN; #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) /* * The gd->arch.cpu pointer is set to an address in flash before * relocation. We need to update it to point to the same CPU entry * in RAM. */ gd->arch.cpu += dest_addr - CONFIG_SYS_MONITOR_BASE; /* * If we didn't know the cpu mask & # cores, we can save them of * now rather than 'computing' them constantly */ fixup_cpu(); #endif #ifdef CONFIG_SYS_EXTRA_ENV_RELOC /* * Some systems need to relocate the env_addr pointer early because the * location it points to will get invalidated before env_relocate is * called. One example is on systems that might use a L2 or L3 cache * in SRAM mode and initialize that cache from SRAM mode back to being * a cache in cpu_init_r. */ gd->env_addr += dest_addr - CONFIG_SYS_MONITOR_BASE; #endif serial_initialize(); debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr); WATCHDOG_RESET(); /* * Setup trap handlers */ trap_init(dest_addr); #ifdef CONFIG_ADDR_MAP init_addr_map(); #endif #if defined(CONFIG_BOARD_EARLY_INIT_R) board_early_init_r(); #endif monitor_flash_len = (ulong)&__init_end - dest_addr; WATCHDOG_RESET(); #ifdef CONFIG_LOGBUFFER logbuff_init_ptrs(); #endif #ifdef CONFIG_POST post_output_backlog(); #endif WATCHDOG_RESET(); #if defined(CONFIG_SYS_DELAYED_ICACHE) icache_enable(); /* it's time to enable the instruction cache */ #endif #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500) unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */ #endif #if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT) /* * Do early PCI configuration _before_ the flash gets initialised, * because PCU ressources are crucial for flash access on some boards. */ pci_init(); #endif #if defined(CONFIG_WINBOND_83C553) /* * Initialise the ISA bridge */ initialise_w83c553f(); #endif asm("sync ; isync"); mem_malloc_init(malloc_start, TOTAL_MALLOC_LEN); #if !defined(CONFIG_SYS_NO_FLASH) puts("Flash: "); if (board_flash_wp_on()) { printf("Uninitialized - Write Protect On\n"); /* Since WP is on, we can't find real size. Set to 0 */ flash_size = 0; } else if ((flash_size = flash_init()) > 0) { #ifdef CONFIG_SYS_FLASH_CHECKSUM print_size(flash_size, ""); /* * Compute and print flash CRC if flashchecksum is set to 'y' * * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX */ if (getenv_yesno("flashchecksum") == 1) { printf(" CRC: %08X", crc32(0, (const unsigned char *) CONFIG_SYS_FLASH_BASE, flash_size) ); } putc('\n'); #else /* !CONFIG_SYS_FLASH_CHECKSUM */ print_size(flash_size, "\n"); #endif /* CONFIG_SYS_FLASH_CHECKSUM */ } else { puts(failed); hang(); } /* update start of FLASH memory */ bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; /* size of FLASH memory (final value) */ bd->bi_flashsize = flash_size; #if defined(CONFIG_SYS_UPDATE_FLASH_SIZE) /* Make a update of the Memctrl. */ update_flash_size(flash_size); #endif #if defined(CONFIG_OXC) || defined(CONFIG_RMU) /* flash mapped at end of memory map */ bd->bi_flashoffset = CONFIG_SYS_TEXT_BASE + flash_size; #elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE bd->bi_flashoffset = monitor_flash_len; /* reserved area for monitor */ #endif #endif /* !CONFIG_SYS_NO_FLASH */ WATCHDOG_RESET(); /* initialize higher level parts of CPU like time base and timers */ cpu_init_r(); WATCHDOG_RESET(); #ifdef CONFIG_SPI #if !defined(CONFIG_ENV_IS_IN_EEPROM) spi_init_f(); #endif spi_init_r(); #endif #if defined(CONFIG_CMD_NAND) WATCHDOG_RESET(); puts("NAND: "); nand_init(); /* go init the NAND */ #endif #ifdef CONFIG_GENERIC_MMC /* * MMC initialization is called before relocating env. * Thus It is required that operations like pin multiplexer * be put in board_init. */ WATCHDOG_RESET(); puts("MMC: "); mmc_initialize(bd); #endif /* relocate environment function pointers etc. */ env_relocate(); /* * after non-volatile devices & environment is setup and cpu code have * another round to deal with any initialization that might require * full access to the environment or loading of some image (firmware) * from a non-volatile device */ cpu_secondary_init_r(); /* * Fill in missing fields of bd_info. * We do this here, where we have "normal" access to the * environment; we used to do this still running from ROM, * where had to use getenv_f(), which can be pretty slow when * the environment is in EEPROM. */ #if defined(CONFIG_SYS_EXTBDINFO) #if defined(CONFIG_405GP) || defined(CONFIG_405EP) #if defined(CONFIG_I2CFAST) /* * set bi_iic_fast for linux taking environment variable * "i2cfast" into account */ { if (getenv_yesno("i2cfast") == 1) { bd->bi_iic_fast[0] = 1; bd->bi_iic_fast[1] = 1; } } #endif /* CONFIG_I2CFAST */ #endif /* CONFIG_405GP, CONFIG_405EP */ #endif /* CONFIG_SYS_EXTBDINFO */ #if defined(CONFIG_SC3) sc3_read_eeprom(); #endif #if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET) mac_read_from_eeprom(); #endif #ifdef CONFIG_CMD_NET /* kept around for legacy kernels only ... ignore the next section */ eth_getenv_enetaddr("ethaddr", bd->bi_enetaddr); #ifdef CONFIG_HAS_ETH1 eth_getenv_enetaddr("eth1addr", bd->bi_enet1addr); #endif #ifdef CONFIG_HAS_ETH2 eth_getenv_enetaddr("eth2addr", bd->bi_enet2addr); #endif #ifdef CONFIG_HAS_ETH3 eth_getenv_enetaddr("eth3addr", bd->bi_enet3addr); #endif #ifdef CONFIG_HAS_ETH4 eth_getenv_enetaddr("eth4addr", bd->bi_enet4addr); #endif #ifdef CONFIG_HAS_ETH5 eth_getenv_enetaddr("eth5addr", bd->bi_enet5addr); #endif #endif /* CONFIG_CMD_NET */ WATCHDOG_RESET(); #if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT) /* * Do pci configuration */ pci_init(); #endif /** leave this here (after malloc(), environment and PCI are working) **/ /* Initialize stdio devices */ stdio_init(); /* Initialize the jump table for applications */ jumptable_init(); #if defined(CONFIG_API) /* Initialize API */ api_init(); #endif /* Initialize the console (after the relocation and devices init) */ console_init_r(); #if defined(CONFIG_MISC_INIT_R) /* miscellaneous platform dependent initialisations */ misc_init_r(); #endif #if defined(CONFIG_CMD_KGDB) WATCHDOG_RESET(); puts("KGDB: "); kgdb_init(); #endif debug("U-Boot relocated to %08lx\n", dest_addr); /* * Enable Interrupts */ interrupt_init(); #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT) status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING); #endif udelay(20); /* Initialize from environment */ load_addr = getenv_ulong("loadaddr", 16, load_addr); WATCHDOG_RESET(); #if defined(CONFIG_CMD_SCSI) WATCHDOG_RESET(); puts("SCSI: "); scsi_init(); #endif #if defined(CONFIG_CMD_DOC) WATCHDOG_RESET(); puts("DOC: "); doc_init(); #endif #ifdef CONFIG_BITBANGMII bb_miiphy_init(); #endif #if defined(CONFIG_CMD_NET) WATCHDOG_RESET(); puts("Net: "); eth_initialize(bd); #endif #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R) WATCHDOG_RESET(); debug("Reset Ethernet PHY\n"); reset_phy(); #endif #ifdef CONFIG_POST post_run(NULL, POST_RAM | post_bootmode_get(0)); #endif #if defined(CONFIG_CMD_PCMCIA) \ && !defined(CONFIG_CMD_IDE) WATCHDOG_RESET(); puts("PCMCIA:"); pcmcia_init(); #endif #if defined(CONFIG_CMD_IDE) WATCHDOG_RESET(); #ifdef CONFIG_IDE_8xx_PCCARD puts("PCMCIA:"); #else puts("IDE: "); #endif #if defined(CONFIG_START_IDE) if (board_start_ide()) ide_init(); #else ide_init(); #endif #endif #ifdef CONFIG_LAST_STAGE_INIT WATCHDOG_RESET(); /* * Some parts can be only initialized if all others (like * Interrupts) are up and running (i.e. the PC-style ISA * keyboard). */ last_stage_init(); #endif #if defined(CONFIG_CMD_BEDBUG) WATCHDOG_RESET(); bedbug_init(); #endif #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) /* * Export available size of memory for Linux, * taking into account the protected RAM at top of memory */ { ulong pram = 0; char memsz[32]; #ifdef CONFIG_PRAM pram = getenv_ulong("pram", 10, CONFIG_PRAM); #endif #ifdef CONFIG_LOGBUFFER #ifndef CONFIG_ALT_LB_ADDR /* Also take the logbuffer into account (pram is in kB) */ pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024; #endif #endif sprintf(memsz, "%ldk", (ulong) (bd->bi_memsize / 1024) - pram); setenv("mem", memsz); } #endif #ifdef CONFIG_PS2KBD puts("PS/2: "); kbd_init(); #endif /* Initialization complete - start the monitor */ /* main_loop() can return to retry autoboot, if so just run it again. */ for (;;) { WATCHDOG_RESET(); main_loop(); } /* NOTREACHED - no way out of command loop except booting */ }
/********************************************************************************* * scsi command intepreter */ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { if (argc == 2 && strcmp(argv[1], "init") == 0) { scsi_init(); return 0; } /* If the user has not yet run `sata init`, do it now */ if ((argc == 2) && (scsi_curr_dev == -1) && (strncmp(argv[1],"res",3) != 0)) printf("please run 'scsi init' first!!!\n"); //scsi_init(); switch (argc) { case 0: case 1: return CMD_RET_USAGE; case 2: if (strncmp(argv[1],"res",3) == 0) { printf("\nReset SCSI\n"); if(scsi_curr_dev == -1) scsi_init(); else { 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) { if (scsi_curr_dev < 0) return 1; else { 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; }
void atapiscsi_attach(struct device *parent, struct device *self, void *aux) { struct atapiscsi_softc *as = (struct atapiscsi_softc *)self; struct ata_atapi_attach *aa_link = aux; struct scsibus_attach_args saa; struct ata_drive_datas *drvp = aa_link->aa_drv_data; struct channel_softc *chp = drvp->chnl_softc; struct ataparams *id = &drvp->id; struct device *child; extern struct scsi_iopool wdc_xfer_iopool; printf("\n"); /* Initialize shared data. */ scsi_init(); #ifdef WDCDEBUG if (chp->wdc->sc_dev.dv_cfdata->cf_flags & WDC_OPTION_PROBE_VERBOSE) wdcdebug_atapi_mask |= DEBUG_PROBE; #endif as->chp = chp; as->drive = drvp->drive; as->sc_adapterlink.adapter_softc = as; as->sc_adapterlink.adapter_target = 7; as->sc_adapterlink.adapter_buswidth = 2; as->sc_adapterlink.adapter = &atapiscsi_switch; as->sc_adapterlink.luns = 1; as->sc_adapterlink.openings = 1; as->sc_adapterlink.flags = SDEV_ATAPI; as->sc_adapterlink.pool = &wdc_xfer_iopool; strlcpy(drvp->drive_name, as->sc_dev.dv_xname, sizeof(drvp->drive_name)); drvp->cf_flags = as->sc_dev.dv_cfdata->cf_flags; wdc_probe_caps(drvp, id); WDCDEBUG_PRINT( ("general config %04x capabilities %04x ", id->atap_config, id->atap_capabilities1), DEBUG_PROBE); #if (NERRS_MAX > 2) drvp->n_dmaerrs = NERRS_MAX - 2; #else drvp->n_dmaerrs = 0; #endif drvp->drive_flags |= DRIVE_DEVICE_RESET; /* Tape drives do funny DSC stuff */ if (ATAPI_CFG_TYPE(id->atap_config) == ATAPI_CFG_TYPE_SEQUENTIAL) drvp->atapi_cap |= ACAP_DSC; if ((id->atap_config & ATAPI_CFG_CMD_MASK) == ATAPI_CFG_CMD_16) drvp->atapi_cap |= ACAP_LEN; drvp->atapi_cap |= (id->atap_config & ATAPI_CFG_DRQ_MASK); WDCDEBUG_PRINT(("driver caps %04x\n", drvp->atapi_cap), DEBUG_PROBE); bzero(&saa, sizeof(saa)); saa.saa_sc_link = &as->sc_adapterlink; child = config_found((struct device *)as, &saa, scsiprint); if (child != NULL) { struct scsibus_softc *scsi = (struct scsibus_softc *)child; struct scsi_link *link = scsi_get_link(scsi, 0, 0); if (link) { strlcpy(drvp->drive_name, ((struct device *)(link->device_softc))->dv_xname, sizeof(drvp->drive_name)); wdc_print_caps(drvp); } } #ifdef WDCDEBUG if (chp->wdc->sc_dev.dv_cfdata->cf_flags & WDC_OPTION_PROBE_VERBOSE) wdcdebug_atapi_mask &= ~DEBUG_PROBE; #endif }
void main_init(int argc, char *argv[]) { char t[512], *p; int c; int tapenext = 0, discnext = 0; startblit(); log_open(); log_info("main: starting %s", VERSION_STR); vid_fskipmax = 1; al_init_main(argc, argv); append_filename(t, exedir, "roms/tube/ReCo6502ROM_816", 511); if (!file_exists(t,FA_ALL,NULL) && selecttube == 4) selecttube = -1; curtube = selecttube; model_check(); for (c = 1; c < argc; c++) { // log_debug("%i : %s",c,argv[c]); /* if (!strcasecmp(argv[c],"-1770")) { I8271=0; WD1770=1; } else*/ //#ifndef WIN32 if (!strcasecmp(argv[c], "--help")) { printf("%s command line options :\n\n", VERSION_STR); printf("-mx - start as model x (see readme.txt for models)\n"); printf("-tx - start with tube x (see readme.txt for tubes)\n"); printf("-disc disc.ssd - load disc.ssd into drives :0/:2\n"); printf("-disc1 disc.ssd - load disc.ssd into drives :1/:3\n"); printf("-autoboot - boot disc in drive :0\n"); printf("-tape tape.uef - load tape.uef\n"); printf("-fasttape - set tape speed to fast\n"); printf("-s - scanlines display mode\n"); printf("-i - interlace display mode\n"); printf("-debug - start debugger\n"); printf("-allegro - use Allegro for video rendering\n"); exit(-1); } else //#endif if (!strcasecmp(argv[c], "-tape")) { tapenext = 2; } else if (!strcasecmp(argv[c], "-disc") || !strcasecmp(argv[c], "-disk")) { discnext = 1; } else if (!strcasecmp(argv[c], "-disc1")) { discnext = 2; } else if (argv[c][0] == '-' && (argv[c][1] == 'm' || argv[c][1] == 'M')) { sscanf(&argv[c][2], "%i", &curmodel); } else if (argv[c][0] == '-' && (argv[c][1] == 't' || argv[c][1] == 'T')) { sscanf(&argv[c][2], "%i", &curtube); } else if (!strcasecmp(argv[c], "-fasttape")) { fasttape = 1; } else if (!strcasecmp(argv[c], "-autoboot")) { autoboot = 150; } else if (argv[c][0] == '-' && (argv[c][1] == 'f' || argv[c][1]=='F')) { sscanf(&argv[c][2], "%i", &vid_fskipmax); if (vid_fskipmax < 1) vid_fskipmax = 1; if (vid_fskipmax > 9) vid_fskipmax = 9; } else if (argv[c][0] == '-' && (argv[c][1] == 's' || argv[c][1] == 'S')) { vid_scanlines = 1; } else if (!strcasecmp(argv[c], "-debug")) { debug_core = 1; } else if (!strcasecmp(argv[c], "-debugtube")) { debug_tube = 1; } else if (argv[c][0] == '-' && (argv[c][1] == 'i' || argv[c][1] == 'I')) { vid_interlace = 1; vid_linedbl = vid_scanlines = 0; } else if (tapenext) strcpy(tape_fn, argv[c]); else if (discnext) { strcpy(discfns[discnext-1], argv[c]); discnext = 0; } else { if ((p = strrchr(argv[c], '.')) && (!strcasecmp(p, ".uef") || !strcasecmp(p, ".csw"))) { strncpy(tape_fn, argv[c], sizeof tape_fn); tapenext = 0; } else { strncpy(discfns[0], argv[c], sizeof discfns[0]); discnext = 0; autoboot = 150; } } if (tapenext) tapenext--; } video_init(); mode7_makechars(); #ifndef WIN32 install_keyboard(); #endif install_timer(); mem_init(); ddnoise_init(); tapenoise_init(); sound_init(); al_init(); sid_init(); sid_settype(sidmethod, cursid); music5000_init(); adc_init(); #ifdef WIN32 pal_init(); #endif disc_init(); fdi_init(); scsi_init(); ide_init(); vdfs_init(); model_init(); midi_init(); main_reset(); install_int_ex(secint, MSEC_TO_TIMER(1000)); install_int_ex(int50, MSEC_TO_TIMER(20)); set_display_switch_mode(SWITCH_BACKGROUND); #ifdef WIN32 timeBeginPeriod(1); #endif oldmodel = curmodel; if (curtube == 3 || mouse_amx) install_mouse(); disc_load(0, discfns[0]); disc_load(1, discfns[1]); tape_load(tape_fn); if (defaultwriteprot) writeprot[0] = writeprot[1] = 1; endblit(); debug_start(); }
/********************************************************************************* * scsi command intepreter */ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { switch (argc) { case 0: case 1: cmd_usage(cmdtp); return 1; case 2: if (strncmp(argv[1],"init",4) == 0) { printf("\nInit SCSI\n"); scsi_init(); return 0; } 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; } cmd_usage(cmdtp); return 1; 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; } cmd_usage(cmdtp); return 1; 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); printf("\naddr = 0x%08x\n", addr); n = scsi_read(scsi_curr_dev, blk, cnt, (ulong *)addr); printf ("%ld blocks read: %s\n",n,(n==cnt) ? "OK" : "ERROR"); return 0; } } /* switch */ cmd_usage(cmdtp); return 1; }
void board_init_r(gd_t *id, ulong dest_addr) { char *s; ulong size; static bd_t bd_data; static gd_t gd_data; init_fnc_t **init_fnc_ptr; show_boot_progress(0x21); /* Global data pointer is now writable */ gd = &gd_data; memcpy(gd, id, sizeof(gd_t)); /* compiler optimization barrier needed for GCC >= 3.4 */ __asm__ __volatile__("": : :"memory"); gd->bd = &bd_data; memset (gd->bd, 0, sizeof (bd_t)); show_boot_progress(0x22); gd->baudrate = CONFIG_BAUDRATE; mem_malloc_init((((ulong)dest_addr - CONFIG_SYS_MALLOC_LEN)+3)&~3, CONFIG_SYS_MALLOC_LEN); for (init_fnc_ptr = init_sequence_r; *init_fnc_ptr; ++init_fnc_ptr) { if ((*init_fnc_ptr)() != 0) hang (); } show_boot_progress(0x23); #ifdef CONFIG_SERIAL_MULTI serial_initialize(); #endif /* configure available FLASH banks */ size = flash_init(); display_flash_config(size); show_boot_progress(0x24); show_boot_progress(0x25); /* initialize environment */ env_relocate (); show_boot_progress(0x26); #ifdef CONFIG_CMD_NET /* IP Address */ bd_data.bi_ip_addr = getenv_IPaddr ("ipaddr"); #endif #if defined(CONFIG_PCI) /* * Do pci configuration */ pci_init(); #endif show_boot_progress(0x27); stdio_init (); jumptable_init (); /* Initialize the console (after the relocation and devices init) */ console_init_r(); #ifdef CONFIG_MISC_INIT_R /* miscellaneous platform dependent initialisations */ misc_init_r(); #endif #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE) WATCHDOG_RESET(); puts ("PCMCIA:"); pcmcia_init(); #endif #if defined(CONFIG_CMD_KGDB) WATCHDOG_RESET(); puts("KGDB: "); kgdb_init(); #endif /* enable exceptions */ enable_interrupts(); show_boot_progress(0x28); #ifdef CONFIG_STATUS_LED status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING); #endif udelay(20); /* Initialize from environment */ load_addr = getenv_ulong("loadaddr", 16, load_addr); #if defined(CONFIG_CMD_NET) if ((s = getenv ("bootfile")) != NULL) { copy_filename (BootFile, s, sizeof (BootFile)); } #endif WATCHDOG_RESET(); #if defined(CONFIG_CMD_IDE) WATCHDOG_RESET(); puts("IDE: "); ide_init(); #endif #if defined(CONFIG_CMD_SCSI) WATCHDOG_RESET(); puts("SCSI: "); scsi_init(); #endif #if defined(CONFIG_CMD_DOC) WATCHDOG_RESET(); puts("DOC: "); doc_init(); #endif #ifdef CONFIG_BITBANGMII bb_miiphy_init(); #endif #if defined(CONFIG_CMD_NET) WATCHDOG_RESET(); puts("Net: "); eth_initialize(gd->bd); #endif #if ( defined(CONFIG_CMD_NET)) && (0) WATCHDOG_RESET(); # ifdef DEBUG puts ("Reset Ethernet PHY\n"); # endif reset_phy(); #endif #ifdef CONFIG_LAST_STAGE_INIT WATCHDOG_RESET(); /* * Some parts can be only initialized if all others (like * Interrupts) are up and running (i.e. the PC-style ISA * keyboard). */ last_stage_init(); #endif #ifdef CONFIG_POST post_run (NULL, POST_RAM | post_bootmode_get(0)); #endif show_boot_progress(0x29); /* main_loop() can return to retry autoboot, if so just run it again. */ for (;;) { main_loop(); } /* NOTREACHED - no way out of command loop except booting */ }