diff --git a/elks/arch/i86/drivers/block/bios.c b/elks/arch/i86/drivers/block/bios.c index 517bc3a04..b2e211130 100644 --- a/elks/arch/i86/drivers/block/bios.c +++ b/elks/arch/i86/drivers/block/bios.c @@ -20,6 +20,7 @@ #define RESET_DISK_CHG 1 /* =1 to reset BIOS on drive change fixes QEMU retry */ #define IODELAY 0 /* emulate delay for floppy on QEMU */ +#define abs(v) (((int)(v) >= 0)? (v): -(v)) /* * Indices for fd_types array. Note these match the value returned * by the BIOS in BL less 1, for INT 13h AH=8 (Get Disk Parms) for IBM PC. @@ -125,9 +126,12 @@ int BFPROC bios_disk_rw(unsigned cmd, unsigned num_sectors, unsigned drive, #if IODELAY debug_bios("[%ur%u]", drive, num_sectors); if (drive < 2) { /* emulate floppy delay for QEMU */ - unsigned int ms = 10 + num_sectors; /* 1440k @ 300rpm = 100ms + ~10ms/sector */ + static unsigned lastcyl; + unsigned ms = abs(cylinder - lastcyl) * 4 / 10; + lastcyl = cylinder; + ms += 10 + num_sectors; /* 1440k @300rpm = 100ms + ~10ms/sector + 4ms/tr */ if (drive == 1) - ms = 8 + (num_sectors<<1); /* 360k @ 360rpm = 83ms + ~20ms/sector */ + ms += 8 + (num_sectors<<1); /* 360k @360rpm = 83ms + ~20ms/sector + 3ms/tr */ unsigned long timeout = jiffies + ms*HZ/100; while (!time_after(jiffies, timeout)) continue; } diff --git a/elks/arch/i86/drivers/block/bioshd.c b/elks/arch/i86/drivers/block/bioshd.c index aed609a8c..779edc34a 100644 --- a/elks/arch/i86/drivers/block/bioshd.c +++ b/elks/arch/i86/drivers/block/bioshd.c @@ -57,6 +57,8 @@ #define PER_DRIVE_INFO 1 /* =1 for per-line display of drive info at init */ #define DEBUG_PROBE 0 /* =1 to display more floppy probing information */ #define FORCE_PROBE 0 /* =1 to force floppy probing */ +#define TRACK_SPLIT_BLK 0 /* =1 to read extra sector on track split block */ +#define SPLIT_BLK 0 /* =1 to read extra sector on single split block */ #define FULL_TRACK 0 /* =1 to read full tracks when track caching */ #define MAX_ERRS 5 /* maximum sector read/write error retries */ @@ -499,17 +501,26 @@ static int bioshd_ioctl(struct inode *inode, struct file *file, unsigned int cmd } /* calculate CHS and sectors remaining for track read */ -static void BFPROC get_chst(struct drive_infot *drivep, sector_t *start_sec, unsigned int *c, - unsigned int *h, unsigned int *s, unsigned int *t, int fulltrack) +static void BFPROC get_chst(struct drive_infot *drivep, sector_t *start_sec, + unsigned int *c, unsigned int *h, unsigned int *s, unsigned int *t, int fulltrack) { sector_t start = *start_sec; sector_t tmp; + int extra = 0; *s = (unsigned int) (start % drivep->sectors) + 1; tmp = start / drivep->sectors; *h = (unsigned int) (tmp % drivep->heads); *c = (unsigned int) (tmp / drivep->heads); *t = drivep->sectors - *s + 1; + +#if TRACK_SPLIT_BLK + extra = (drivep->sectors & 1) && *h == 0; + if (extra) (*t)++; +#elif SPLIT_BLK + extra = (drivep->sectors & 1) && *h == 0 && *s == drivep->sectors; + if (extra) (*t)++; +#endif #if FULL_TRACK if (fulltrack) { int save = *s; @@ -524,7 +535,7 @@ static void BFPROC get_chst(struct drive_infot *drivep, sector_t *start_sec, uns *start_sec -= save - *s; } #endif - debug_bios("bioshd: lba %ld is CHS %d/%d/%d remaining sectors %d\n", + if (extra) debug_cache("bioshd: lba %ld is CHS %d/%d/%d remaining sectors %d\n", start, *c, *h, *s, *t); } @@ -547,7 +558,7 @@ static int BFPROC do_readwrite(struct drive_infot *drivep, sector_t start, char if (cmd == READ) debug_bios("bioshd(%x): read lba %ld count %d\n", drive, start, this_pass); - errs = MAX_ERRS; /* BIOS disk reads should be retried at least three times */ + errs = MAX_ERRS; /* BIOS disk reads should be retried at least five times */ do { #pragma GCC diagnostic ignored "-Wshift-count-overflow" usedmaseg = seg >> 16; /* will be nonzero only if XMS configured and XMS buffer */ @@ -611,6 +622,8 @@ static void BFPROC do_readtrack(struct drive_infot *drivep, sector_t start) num_sectors = DMASEGSZ / drivep->sector_size; do { + debug_cache("\nTR %lu(CHS %u,%u,%u-%u) ", start>>1, cylinder, head, sector, + sector+num_sectors-1); debug_bios("bioshd(%x): track read CHS %d/%d/%d count %d\n", drive, cylinder, head, sector, num_sectors); @@ -663,6 +676,7 @@ static int BFPROC do_cache_read(struct drive_infot *drivep, sector_t start, char if (cmd == READ) { cache_tries++; if (cache_valid(drivep, start, buf, seg)) { /* try cache first*/ + debug_cache("CH %lu ", start>>1); cache_hits++; return 1; } diff --git a/elks/fs/buffer.c b/elks/fs/buffer.c index bd0918aae..94f8bd0eb 100644 --- a/elks/fs/buffer.c +++ b/elks/fs/buffer.c @@ -501,6 +501,7 @@ struct buffer_head *getblk32(kdev_t dev, block32_t block) ebh = EBH(bh); ebh->b_dev = dev; ebh->b_blocknr = block; + debug_cache("BM %lu ", block); goto return_it; found_it: @@ -510,6 +511,7 @@ struct buffer_head *getblk32(kdev_t dev, block32_t block) CLR_COUNT(en_bh); en_bh->b_count = 0; /* Release previously created buffer head */ } + if (bh->b_data) debug_cache("L1 %lu ", block); else debug_cache("L2 %lu ", block); ebh = EBH(bh); INR_COUNT(ebh); wait_on_buffer(bh); diff --git a/elks/fs/exec.c b/elks/fs/exec.c index 52c3d340e..8963a3be1 100644 --- a/elks/fs/exec.c +++ b/elks/fs/exec.c @@ -71,7 +71,7 @@ int sys_execve(const char *filename, char *sptr, size_t slen) word_t magic; /* Open the image */ - dprintk("EXEC(%P): '%t' env %d\n", filename, slen); + debug_cache("\nEXEC(%P): '%t' env %d ", filename, slen); retval = open_namei(filename, 0, 0, &inode, NULL); debug("EXEC: open returned %d\n", -retval); diff --git a/elks/fs/open.c b/elks/fs/open.c index 93fc0387c..50550230a 100644 --- a/elks/fs/open.c +++ b/elks/fs/open.c @@ -240,7 +240,7 @@ int sys_open(const char *filename, int flags, mode_t mode) if ((flags + 1) & O_ACCMODE) flag++; if (flag & (O_TRUNC | O_CREAT)) flag |= FMODE_WRITE; - debug_file("OPEN '%t' flags %#x", filename, flags); + debug_cache("\nOPEN '%t' flags %02x ", filename, flags); error = open_namei(filename, flag, mode, &inode, NULL); if (!error) { if ((error = open_fd(flags, inode)) < 0) diff --git a/elks/include/linuxmt/debug.h b/elks/include/linuxmt/debug.h index 40d7292b0..99e7e3a3c 100644 --- a/elks/include/linuxmt/debug.h +++ b/elks/include/linuxmt/debug.h @@ -16,6 +16,7 @@ #define DEBUG_STARTDEF 0 /* default startup debug display*/ #define DEBUG_BIOS 0 /* BIOS driver*/ #define DEBUG_BLK 0 /* block i/o*/ +#define DEBUG_CACHE 0 /* floppy track cache*/ #define DEBUG_ETH 0 /* ethernet*/ #define DEBUG_FAT 0 /* FAT filesystem*/ #define DEBUG_FILE 0 /* sys open and file i/o*/ @@ -54,6 +55,12 @@ void debug_setcallback(int evnum, void (*cbfunc)()); /* callback on debug event* #define debug_blk(...) #endif +#if DEBUG_CACHE +#define debug_cache PRINTK +#else +#define debug_cache(...) +#endif + #if DEBUG_ETH #define debug_eth PRINTK #else diff --git a/elks/include/linuxmt/trace.h b/elks/include/linuxmt/trace.h index 90cb07192..1742423b0 100644 --- a/elks/include/linuxmt/trace.h +++ b/elks/include/linuxmt/trace.h @@ -37,6 +37,16 @@ #endif /* CONFIG_TRACE */ +/* + * Additional options not requiring CONFIG_TRACE: + * + * DEBUG_CACHE - floppy track cache tracing + * IODELAY - emulate floppy disk I/O delays in QEMU (set in bios.c) + * TRACK_SPLIT_BLK - read extra sector on track split block (set in bioshd.c) + * SPLIT_BLK - read extra sector on single split block (set in bioshd.c) + * FULL_TRACK - read full track on cache refill (set in bioshd.c) + * SHOW_STARTUP - show startup time on boot (set in getty.c) + */ /* internal flags for kernel */ #define TRACE_STRACE 0x01 /* system call tracing enabled */ diff --git a/elks/tools/mfs/genfs.c b/elks/tools/mfs/genfs.c index ac4194b3c..79eaba348 100644 --- a/elks/tools/mfs/genfs.c +++ b/elks/tools/mfs/genfs.c @@ -310,7 +310,7 @@ parse_filelist(char *filelist, inode_build_t *parent_inode, char *parent_path) { char *name = filename; - if (name[0] == '#') + if (name[0] == '#' || name[0] == '\n') continue; name[strlen(name)-1] = '\0'; /* remove lf*/ char *child_path = domalloc(strlen(parent_path) + 1 + strlen(name) + 1, -1); @@ -488,7 +488,10 @@ void cmd_genfs(char *filename, int argc,char **argv) { if (numblocks > req_blks) fatalmsg("Blocks required %d, available %d\n", numblocks, req_blks); - fs = new_fs(filename,magic,req_blks,req_inos); + if (opt_appendifexists && access(filename, 0) == 0) + fs = open_fs(filename,opt_fsbad_fatal); + else + fs = new_fs(filename,magic,req_blks,req_inos); err = compile_fs(fs); if (opt_verbose) cmd_sysinfo(fs); close_fs(fs); @@ -515,7 +518,7 @@ void cmd_addfs(char *filename, int argc,char **argv) { if (argc != 2) fatalmsg("Usage: addfs "); dirname = argv[1]; - prefix = 0; + prefix = strlen(argv[1]); if (opt_verbose) printf("Adding files from %s to %s\n", argv[0], dirname); numblocks = 2; /* root inode and first mkdir*/ list_init(&inodes); diff --git a/elks/tools/mfs/iname.c b/elks/tools/mfs/iname.c index a675659e5..e66d4ba88 100644 --- a/elks/tools/mfs/iname.c +++ b/elks/tools/mfs/iname.c @@ -181,7 +181,7 @@ int make_node(struct minix_fs_dat *fs,char *fpath, int mode, char *fname = strrchr(fpath,'/'); int dinode,ninode; - if (find_inode(fs,fpath) != -1) fatalmsg("%s: already exists",fpath); + if (find_inode(fs,fpath) != -1) printf("%s: already exists\n",fpath); if (fname) { *fname++ = 0; } else { diff --git a/elks/tools/mfs/main.c b/elks/tools/mfs/main.c index 971d5afb5..de1b7b612 100644 --- a/elks/tools/mfs/main.c +++ b/elks/tools/mfs/main.c @@ -77,8 +77,8 @@ void usage(const char *name) { "cmd:\n" " mkfs [-1|2] [-i<#inodes>] [-n<#direntlen>] [-s<#blocks>]\n" " boot \n" - " genfs [-1|2] [-i<#inodes>] [-n<#direntlen>] [-s<#blocks>] [-k] \n" - " addfs \n" + " genfs [-1|2] [-i<#inodes>] [-n<#direntlen>] [-s<#blocks>] [-k] [-a] \n" + " addfs \n" " [stat]\n" " ls [-ld] [filelist...]" " cp source_file dest_dir_or_file\n" diff --git a/elks/tools/mfs/mkfs.c b/elks/tools/mfs/mkfs.c index 580ce333e..5ffa55724 100644 --- a/elks/tools/mfs/mkfs.c +++ b/elks/tools/mfs/mkfs.c @@ -29,6 +29,7 @@ #include int opt_nocopyzero = 0; /* don't copy zero-length files starting with . */ +int opt_appendifexists = 0; /* don't create new fs on genfs if exists */ /** * Parse mkfs/genfs command line arguments @@ -54,7 +55,7 @@ void parse_mkfs(int argc,char **argv,int *magic_p,int *nblks_p,int *inodes_p) { optind = 1; while (1) { - c = getoptX(argc,argv,"12vi:n:s:k"); + c = getoptX(argc,argv,"12vi:n:s:ka"); if (c == -1) break; switch (c) { case '1': @@ -78,6 +79,9 @@ void parse_mkfs(int argc,char **argv,int *magic_p,int *nblks_p,int *inodes_p) { case 'k': opt_nocopyzero = 1; break; + case 'a': + opt_appendifexists = 1; + break; default: usage(argv[0]); } diff --git a/elks/tools/mfs/protos.h b/elks/tools/mfs/protos.h index 0c283b9eb..c89e69288 100644 --- a/elks/tools/mfs/protos.h +++ b/elks/tools/mfs/protos.h @@ -75,6 +75,7 @@ extern int opt_fsbad_fatal; extern char *toolname; extern int opt_nocopyzero; +extern int opt_appendifexists; extern char *optarg; extern int opterr; diff --git a/elkscmd/rootfs_template/bootopts b/elkscmd/rootfs_template/bootopts index 13e52ce71..0ea554d82 100644 --- a/elkscmd/rootfs_template/bootopts +++ b/elkscmd/rootfs_template/bootopts @@ -17,6 +17,7 @@ #root=hda1 ro #kstack #strace +#FTRACE=1 #net=ne0 -#debug FTRACE=1 +#debug #console=ttyS0,19200 3 diff --git a/image/Image.all b/image/Image.all new file mode 100644 index 000000000..acabfd98b --- /dev/null +++ b/image/Image.all @@ -0,0 +1,21 @@ +# boot +dev +etc +bin +bin/init +etc/inittab +etc/rc.sys +bin/sh +etc/profile +bin/clock +etc/mount.cfg +bin/date +bin/getty +etc/issue +#etc/net.cfg +bootopts +linux +# login +bin/login +etc/passwd +root diff --git a/image/Make.devices b/image/Make.devices index 674f0f72a..6346fb39b 100755 --- a/image/Make.devices +++ b/image/Make.devices @@ -13,6 +13,10 @@ devices: +# $(MKDEV) /dev/console c 4 254 1 1 0600 +# $(MKDEV) /dev/tty1 c 4 0 +# $(MKDEV) /dev/ttyS0 c 4 64 + ############################################################################## # Create memory devices. diff --git a/image/Make.image b/image/Make.image index 0ff02b6ec..72f3595fa 100644 --- a/image/Make.image +++ b/image/Make.image @@ -77,7 +77,14 @@ endif minixfs: rm -f $(TARGET_FILE) - mfs $(VERBOSE) $(TARGET_FILE) genfs $(MINIX_MKFSOPTS) $(DESTDIR) + mfs $(VERBOSE) $(TARGET_FILE) mkfs $(MINIX_MKFSOPTS) +# mfs -v $(VERBOSE) $(TARGET_FILE) addfs Image.all $(DESTDIR) +# rm -f Filelist +# for f in $$(cd $(DESTDIR); find * -name '*'); do \ +# echo $$f >> FileList; \ +# done +# mfs -v $(VERBOSE) $(TARGET_FILE) addfs Filelist $(DESTDIR) + mfs $(VERBOSE) $(TARGET_FILE) genfs -a $(MINIX_MKFSOPTS) $(DESTDIR) ifdef CONFIG_IMG_DEV # command to make char/block devices in image (no sudo required) $(MAKE) -f Make.devices "MKDEV=mfs $(TARGET_FILE) mknod"