static void disable_dio() { DBG("Direct IO may not be supported on this file system. Retrying."); dio = 0; reopen = 1; cleanup_disk(); setup_disk(); }
MACHINE_START_MEMBER( nes_state, fds ) { m_ciram = std::make_unique<uint8_t[]>(0x800); m_io_disksel = ioport("FLIPDISK"); setup_disk(m_disk); // register saves save_item(NAME(m_last_frame_flip)); save_pointer(NAME(m_ciram), 0x800); }
/* called once in the master process */ void xnbd_initialize(struct xnbd_info *xnbd) { if (xnbd->proxymode) { int remotefd; if (!(xnbd->remotehost && xnbd->remoteport && xnbd->cachepath && xnbd->cbitmappath)) err("insuffcient info"); remotefd = net_tcp_connect(xnbd->remotehost, xnbd->remoteport); if (remotefd < 0) err("connecting %s:%s failed", xnbd->remotehost, xnbd->remoteport); /* check the remote server and get a disksize */ xnbd->disksize = nbd_negotiate_with_server(remotefd); nbd_client_send_disc_request(remotefd); close(remotefd); xnbd->nblocks = get_disk_nblocks(xnbd->disksize); xnbd->cbitmap = bitmap_open_file(xnbd->cbitmappath, xnbd->nblocks, &xnbd->cbitmaplen, 0, 1); // xnbd->cbitmapopened = 1; /* setup cachefile */ setup_cachedisk(xnbd, xnbd->disksize, xnbd->cachepath); info("proxymode mode %s %s cache %s cachebitmap %s", xnbd->remotehost, xnbd->remoteport, xnbd->cachepath, xnbd->cbitmappath); } else { if (!xnbd->diskpath) err("insuffcient info"); if (xnbd->cow) { xnbd->ds = open_cow_disk(xnbd->diskpath, 1, 0); xnbd->disksize = xnbd->ds->disksize; } else setup_disk(xnbd->diskpath, xnbd); xnbd->nblocks = get_disk_nblocks(xnbd->disksize); } // monitor_init(xnbd->nblocks); info("xnbd master initialization done"); }
MACHINE_START_MEMBER( nes_state, famitwin ) { // start the base nes stuff machine_start(); // if there is no cart inserted, setup the disk expansion instead if (!m_cartslot->exists()) { setup_disk(m_disk); // replace the famicom disk ROM with the famicom twin one (until we modernize the floppy drive) m_maincpu->space(AS_PROGRAM).install_read_bank(0xe000, 0xffff, "ftbios"); membank("ftbios")->set_base(machine().root_device().memregion("maincpu")->base() + 0xe000); } }
int main(int argc, const char *argv[], const char *env[]) { HANG_LIMIT(20000000); setup_console(); fb_new_page(); welcome_msg(); if(setup_disk() != 0) { console_write_msg(STDERR_FILENO, "*couldn't setup disk\n"); HANG(); } console_print("*disk set up\n"); HANG(); return 0; }
static int setup(void) { return (method == LIME_METHOD_TCP) ? setup_tcp() : setup_disk(); }
/***************************************************************** Start here *****************************************************************/ int main(int np, char **p) { char src_drive[NAME_LENGTH] = "/dev/hda", /* source drive */ dst_drive[NAME_LENGTH] = "/dev/hdb"; /* destination drive */ int help = 0, /* set to true to indicate problem with command line */ ask_for_partitions = 1, /* default is true; set to false if partitions given on command line */ status, /* error return on I/O operations */ i; /* loop index */ static disk_control_block *src_disk,*dst_disk; static off_t lba = 0, /* a sector LBA address usually found as a loop index */ common, /* number of sectors common to source & destination */ diffs = 0, /* count of sectors that don't match */ src_lba, /* address of current sector on source */ dst_lba, /* address of current sector on destination */ byte_diffs = 0, /* count of bytes that differ between src and dst */ match = 0, /* number of matching sectors */ /* zero .. other apply to dst sectors beyond common area */ zero = 0, /* number of zero filled sectors */ sfill = 0, /* number of sectors filled with src fill char */ dfill = 0, /* number of sectors filled with dst fill char */ ofill = 0, /* number of sectors filled with some other fill char */ other = 0; /* number of remaining (unfilled) sectors */ static unsigned long nz, /* number of zero filled bytes in a sector */ nfill; /* number of fill bytes in a sector */ int big_src = 0, /* true if src bigger than dst */ big_dst = 0, /* true if dst bigger than src */ is_diff, boot_track_too = 0; /* include boot track in compare */ int src_status, dst_status; /* I/O error returns */ static unsigned char *src_buff,*dst_buff; /* sector buffers */ static time_t from; /* run start time */ FILE *log; /* log file */ int is_debug = 0, log_diffs = 0; unsigned char src_fill_char, dst_fill_char; /* fill characters */ int fill_char; int src_px,dst_px; /* partition table indices from command line */ off_t src_base, /* LBA address of source partition */ src_n, /* size (number of sectors in) source partition */ dst_base, /* ditto dst */ dst_n; /* range_ptr is used to track a list of ranges. In this case the ranges are disk areas specified in LBA addresses */ range_ptr d_r = create_range_list(), /* common area sectors that don't match */ zf_r = create_range_list(), /* zero filled sectors */ sf_r = create_range_list(), /* sectors with src-fill */ df_r = create_range_list(), /* sectors with dst-fill */ of_r = create_range_list(), /* sectors with some other fill */ o_r = create_range_list(); /* other (unfilled) sectors */ static char comment[NAME_LENGTH] = "", log_name[NAME_LENGTH] = "cmpptlog.txt", access[2] = "a"; /***************************************************************** get start run time and decode command line *****************************************************************/ time(&from); if (np < 8) { printf ("%s: Missing parameters\n",p[0]); print_help(p[0]); return 1; } /***************************************************************** get fill characters from command line *****************************************************************/ sscanf (p[5],"%2x",&fill_char); src_fill_char = fill_char; sscanf (p[7],"%2x",&fill_char); dst_fill_char = fill_char; /***************************************************************** get options from command line *****************************************************************/ for (i = 8; i < np; i++) { if (strcmp (p[i],"-h") == 0) help = 1; /* ask for help */ else if (strcmp (p[i],"-select") == 0) { /* /select src_ix dst_ix */ i = i + 2; if (i >= np) { printf ("%s -select requires two parameters: src partition index\n", p[0]); printf ("and dst partition index\n"); help = 1; } else { sscanf (p[i-1],"%d",&src_px); sscanf (p[i],"%d",&dst_px); ask_for_partitions = 0; /* we got 'em so don't ask */ } } else if (strcmp (p[i],"-new_log")== 0) access[0] = 'w'; else if (strcmp (p[i], "-log_name") == 0) { if(++i >= np) { printf("%s: -log_name option requires a logfile name\n", p[0]); help = 1; } else strncpy(log_name, p[i], NAME_LENGTH - 1); } else if (strcmp (p[i],"-boot")== 0) boot_track_too = 1; else if (strcmp (p[i],"-comment")== 0) { i++; if ( i>=np){ printf ("%s: comment required with -comment\n", p[0]); help = 1; } else strncpy (comment,p[i], NAME_LENGTH - 1); } else { printf("Invalid parameter: %s\n", p[i]); help = 1; } } /***************************************************************** get source and destination drives (in hex) from command line *****************************************************************/ strncpy(src_drive, p[4], NAME_LENGTH - 1); strncpy(dst_drive, p[6], NAME_LENGTH - 1); if (!strcmp(src_drive, dst_drive)) { help = 1; printf ("Source and destination drives must be different\n"); } /***************************************************************** If there is a problem on command line, then print help message *****************************************************************/ if (help) { print_help(p[0]); return 0; } /***************************************************************** Open log file, source disk and destination disk *****************************************************************/ log = log_open (log_name, access, comment, SCCS_ID, np, p); status = setup_disk (src_drive, "Source disk", log, p, ask_for_partitions, src_px, &src_base, &src_n, &src_disk); status = status || setup_disk (dst_drive, "Destination disk", log, p, ask_for_partitions, dst_px, &dst_base, &dst_n, &dst_disk); if (status) return 1; /***************************************************************** get ready to do the compare see which is bigger: src or dst *****************************************************************/ if (src_n != dst_n) { if ( src_n < dst_n) { common = src_n; big_dst = 1; } else { common = dst_n; big_src = 1; } } else common = src_n; printf ("Source disk fill byte %2X\n", src_fill_char); printf ("Destination disk fill byte %2X\n", dst_fill_char); fprintf (log, "Source disk fill byte %2X\n", src_fill_char); fprintf (log, "Destination disk fill byte %2X\n", dst_fill_char); src_lba = src_base; dst_lba = dst_base; if (boot_track_too) { common += 63; src_lba -= 63; dst_lba -= 63; src_base -= 63; dst_base -= 63; src_n += 63; dst_n += 63; } fprintf (log,"Source base sector %llu Destination base sector %llu\n", src_base,dst_base); /***************************************************************** Main compare loop: for each sector in common read src sector read dst sector if match then increment match count else increment different count *****************************************************************/ for (lba = 0; lba < common; lba++) { feedback (from, 0, lba, big_dst ? dst_n : common); /* give progress feedback to user */ is_diff = 0; src_status = read_lba(src_disk, src_lba++, &src_buff); dst_status = read_lba(dst_disk, dst_lba++, &dst_buff); if (src_status || dst_status) { fprintf (log,"read error at sector %llu: src %d dst %d\n", lba, src_status, dst_status); printf ("read error at lba %llu: src %d dst %d\n", lba, src_status, dst_status); return 1; } /***************************************************************** Compare corresponding sectors *****************************************************************/ for (i = 0; i < BYTES_PER_SECTOR; i++) { if (src_buff[i] != dst_buff[i]) { is_diff = 1; byte_diffs++; } } if (is_diff) { diffs++; add_to_range (d_r,lba); if (log_diffs && (diffs <= 50)) { fprintf (log,"%12llu ",lba); if ((diffs%5) == 0) fprintf (log,"\n"); } } else { match++; } } /***************************************************************** Log results for corresponding sectors *****************************************************************/ if (log_diffs && (diffs)) fprintf (log,"\n"); fprintf (log,"Sectors compared: %12llu\n",common); fprintf (log,"Sectors match: %12llu\n",match); fprintf (log,"Sectors differ: %12llu\n",diffs); fprintf (log,"Bytes differ: %12llu\n",byte_diffs); print_range_list(log,"Diffs range: ",d_r); if (big_src) { fprintf (log,"Source (%llu) has %llu more sectors than destination (%llu)\n", src_n, src_n - dst_n, dst_n); } /***************************************************************** If the destination is larger than the source then look at the remainder of the destination *****************************************************************/ else if (big_dst) { fprintf (log,"Source (%llu) has %llu fewer sectors than destination (%llu)\n", src_n, dst_n - src_n, dst_n); zero = 0; ofill = sfill = dfill = 0; other = 0; printf ("Destination larger than source; scanning %llu sectors\n", dst_n-common); for (lba = common; lba < dst_n; is_debug?(lba+=100):lba++){ feedback (from, 0, lba, dst_n); if((dst_status = read_lba(dst_disk, dst_lba++, &dst_buff))) { fprintf (log,"read error at sector %llu: dst %d\n", lba, dst_status); printf ("read error at lba %llu: dst %d\n", lba, dst_status); } nz = 0; nfill = 0; /***************************************************************** classify sector: count zero bytes and fill bytes how to count fill bytes? the rule is: all bytes after byte [23] are the same. i.e., 488 bytes of the sector are the same. We use 480 to give some slack. *****************************************************************/ for (i = 0; i < BYTES_PER_SECTOR; i++) { if ( dst_buff[i] == 0) nz++; else if (dst_buff[i] == dst_buff[BUFF_OFF]) nfill++; } if (nz == BYTES_PER_SECTOR) { zero++; add_to_range(zf_r,lba); } else if (nfill > 480) { if (dst_buff[BUFF_OFF] == src_fill_char) { sfill++; add_to_range(sf_r,lba); } else if (dst_buff[BUFF_OFF] == dst_fill_char) { dfill++; add_to_range(df_r,lba); } else { ofill++; add_to_range(of_r,lba); } } else { other++; add_to_range (o_r,lba); } } /***************************************************************** log results to log file *****************************************************************/ if (log_diffs && (other)) fprintf (log, "\n"); fprintf (log,"Zero fill: %llu\n", zero); fprintf (log,"Src Byte fill (%02X): %llu\n", src_fill_char, sfill); if (src_fill_char == dst_fill_char) fprintf (log, "Dst Fill Byte same as Src Fill Byte\n"); else fprintf (log, "Dst Byte fill (%02X): %lu\n", dst_fill_char, dfill); fprintf (log,"Other fill: %llu\n", ofill); fprintf (log,"Other no fill: %llu\n", other); print_range_list(log,"Zero fill range: ", zf_r); print_range_list(log,"Src fill range: ", sf_r); print_range_list(log,"Dst fill range: ", df_r); print_range_list(log,"Other fill range: ", of_r); print_range_list(log,"Other not filled range: ", o_r); } log_close(log, from); return 0; }
void setup_status() { #ifdef INFO char buffer[256]; sprintf(buffer, "Setup Status: draw Memory %s", sbar_status_symbols[DrawMemory].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); sprintf(buffer, "Setup Status: draw Battery %s", sbar_status_symbols[DrawBattery].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); sprintf(buffer, "Setup Status: draw Uptime %s", sbar_status_symbols[DrawUptime].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); sprintf(buffer, "Setup Status: draw Termal %s", sbar_status_symbols[DrawTermal].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); #ifdef NF310_A01 sprintf(buffer, "Setup Status: draw Backlight %s", sbar_status_symbols[DrawBacklight].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); #endif sprintf(buffer, "Setup Status: draw Net %s", sbar_status_symbols[DrawNet].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); #endif // setup disks setup_disk(); #ifdef INFO log_str("Setup Status Disk", LOG_INFO); #endif // setup uptime if(sbar_status_symbols[DrawUptime].active) { setup_uptime(); #ifdef INFO log_str("Setup Status Uptime", LOG_INFO); #endif } // setup net if(sbar_status_symbols[DrawNet].active) { setup_net(); #ifdef INFO log_str("Setup Status Net", LOG_INFO); #endif } // setup audio if(sbar_status_symbols[DrawAudio].active) { setup_audio(); #ifdef INFO log_str("Setup Status Audio", LOG_INFO); #endif } #ifdef NF310_A01 // setup backlight if(sbar_status_symbols[DrawBacklight].active) { backlight.on = True; #ifdef INFO log_str("Setup Status Backlight", LOG_INFO); #endif } #endif // setup cpu setup_cpu(); #ifdef INFO log_str("Setup Status CPU", LOG_INFO); #endif }