diff --git a/elks/arch/i86/drivers/block/bioshd.c b/elks/arch/i86/drivers/block/bioshd.c index 779edc34a..21954cf28 100644 --- a/elks/arch/i86/drivers/block/bioshd.c +++ b/elks/arch/i86/drivers/block/bioshd.c @@ -106,6 +106,7 @@ static struct gendisk bioshd_gendisk = { static void BFPROC set_cache_invalid(void) { + if (cache_drive) debug_cache2("INV%d ", cache_drive - drive_info); cache_drive = NULL; } @@ -535,7 +536,7 @@ static void BFPROC get_chst(struct drive_infot *drivep, sector_t *start_sec, *start_sec -= save - *s; } #endif - if (extra) debug_cache("bioshd: lba %ld is CHS %d/%d/%d remaining sectors %d\n", + if (extra) debug_cache2("bioshd: lba %ld is CHS %d/%d/%d remaining sectors %d\n", start, *c, *h, *s, *t); } @@ -580,6 +581,8 @@ static int BFPROC do_readwrite(struct drive_infot *drivep, sector_t start, char segment = (seg_t)seg; offset = (unsigned) buf; } + debug_cache("%s%d CHS %d/%d/%d count %d\n", + cmd==WRITE? "WR": "RD", drive, cylinder, head, sector, this_pass); debug_bios("bioshd(%x): cmd %d CHS %d/%d/%d count %d\n", drive, cmd, cylinder, head, sector, this_pass); @@ -622,8 +625,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_cache("\nTR%d %lu(CHS %u,%u,%u-%u) ", drive, 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); @@ -676,7 +679,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); + debug_cache2("CH %lu ", start >> 1); cache_hits++; return 1; } diff --git a/elks/arch/i86/drivers/block/directfd.c b/elks/arch/i86/drivers/block/directfd.c index ae8ae729b..72cfc7d6a 100644 --- a/elks/arch/i86/drivers/block/directfd.c +++ b/elks/arch/i86/drivers/block/directfd.c @@ -773,10 +773,11 @@ static void rw_interrupt(void) static void DFPROC setup_rw_floppy(void) { DEBUG("setup_rw-"); +#if IODELAY || DEBUG_CACHE + int num_sectors = read_track + ? floppy->sect + (floppy->sect & 1 && !head) - sector + : CURRENT->rq_nr_sectors; #if IODELAY - int num_sectors = read_track? floppy->sect + (floppy->sect & 1 && !head) - : CURRENT->rq_nr_sectors; - DEBUG("[%ur%u]", current_drive, num_sectors); static unsigned lasttrack; unsigned ms = abs(track - lasttrack) * 4 / 10; lasttrack = track; @@ -786,6 +787,10 @@ static void DFPROC setup_rw_floppy(void) 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; +#endif + debug_cache("%s%d %lu(CHS %u,%u,%u-%u)\n", + read_track? "TR": (command == FD_WRITE? "WR": "RD"), + current_drive, CURRENT->rq_sector>>1, track, head, sector+1, sector+num_sectors); #endif do_floppy = rw_interrupt; setup_DMA(); @@ -1184,7 +1189,7 @@ static void DFPROC redo_fd_request(void) goto repeat; } floppy = &minor_types[tmp]; - if (!recalibrate) + if (!recalibrate && probing) printk("df%d: auto-probe #%d %s\n", drive, probing, floppy->name); } } @@ -1209,7 +1214,7 @@ static void DFPROC redo_fd_request(void) command = (req->rq_cmd == READ)? FD_READ: FD_WRITE; DEBUG("df%d: %s sector %d CHS %d/%d/%d max %d stretch %d seek %d\n", DEVICE_NR(req->rq_dev), req->rq_cmd==READ? "read": "write", - start, track, head, sector, floppy->sect, floppy->stretch, seek_track); + start, track, head, sector+1, floppy->sect, floppy->stretch, seek_track); /* restart timer for hung operations, 6 secs probably too long ... */ del_timer(&fd_timeout); @@ -1224,7 +1229,8 @@ static void DFPROC redo_fd_request(void) * number of sectors (full blocks). When head=1 we read the entire track * and ignore the first sector. */ - DEBUG("bufrd chs %d/%d/%d\n", seek_track, head, sector); + DEBUG("cache CHS %d/%d/%d\n", seek_track, head, sector); + debug_cache2("CH %d ", start >> 1); char *buf_ptr = (char *) (sector << 9); if (command == FD_READ) { /* requested data is in buffer */ xms_fmemcpyw(req->rq_buffer, req->rq_seg, buf_ptr, DMASEG, BLOCK_SIZE/2); diff --git a/elks/arch/i86/drivers/block/ll_rw_blk.c b/elks/arch/i86/drivers/block/ll_rw_blk.c index 8c96cf766..0ad819620 100644 --- a/elks/arch/i86/drivers/block/ll_rw_blk.c +++ b/elks/arch/i86/drivers/block/ll_rw_blk.c @@ -161,6 +161,14 @@ static void add_request(struct blk_dev_struct *dev, struct request *req) req->rq_next = tmp->rq_next; tmp->rq_next = req; set_irq(); +#if DEBUG_CACHE + if (debug_level) { + int n = 0; + for (tmp = dev->current_request; tmp->rq_next; tmp = tmp->rq_next) + n++; + if (n > 1) printk("REQS %d ", n); + } +#endif #else panic("add_request"); /* non-empty request queue */ #endif diff --git a/elks/fs/buffer.c b/elks/fs/buffer.c index 94f8bd0eb..18879d663 100644 --- a/elks/fs/buffer.c +++ b/elks/fs/buffer.c @@ -501,7 +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); + debug_cache2("BM %lu ", block); goto return_it; found_it: @@ -511,7 +511,8 @@ 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); + if (bh->b_data) { debug_cache2("L1 %lu ", block); } + else { debug_cache2("L2 %lu ", block); } ebh = EBH(bh); INR_COUNT(ebh); wait_on_buffer(bh); diff --git a/elks/include/linuxmt/debug.h b/elks/include/linuxmt/debug.h index 99e7e3a3c..9d900c1e5 100644 --- a/elks/include/linuxmt/debug.h +++ b/elks/include/linuxmt/debug.h @@ -13,7 +13,7 @@ * Kernel debug options, set =1 to turn on. Works across multiple files. */ #define DEBUG_EVENT 1 /* generate debug events on CTRLN-CTRLP*/ -#define DEBUG_STARTDEF 0 /* default startup debug display*/ +#define DEBUG_LEVEL 0 /* default startup debug level*/ #define DEBUG_BIOS 0 /* BIOS driver*/ #define DEBUG_BLK 0 /* block i/o*/ #define DEBUG_CACHE 0 /* floppy track cache*/ @@ -57,8 +57,10 @@ void debug_setcallback(int evnum, void (*cbfunc)()); /* callback on debug event* #if DEBUG_CACHE #define debug_cache PRINTK +#define debug_cache2 if (debug_level > 1) PRINTK #else #define debug_cache(...) +#define debug_cache2(...) #endif #if DEBUG_ETH diff --git a/elks/include/linuxmt/kernel.h b/elks/include/linuxmt/kernel.h index 55eeb0f6a..61dbd368f 100644 --- a/elks/include/linuxmt/kernel.h +++ b/elks/include/linuxmt/kernel.h @@ -19,7 +19,7 @@ extern char running_qemu; extern dev_t dev_console; -extern int dprintk_on; +extern int debug_level; extern void do_exit(int) noreturn; diff --git a/elks/init/main.c b/elks/init/main.c index 9e692eeb7..9d02091bb 100644 --- a/elks/init/main.c +++ b/elks/init/main.c @@ -491,10 +491,6 @@ static int INITPROC parse_options(void) root_mountflags &= ~MS_RDONLY; continue; } - if (!strcmp(line,"debug")) { - dprintk_on = 1; - continue; - } if (!strcmp(line,"strace")) { tracing |= TRACE_STRACE; continue; @@ -520,6 +516,10 @@ static int INITPROC parse_options(void) parse_nic(line+4, &netif_parms[ETH_EL3]); continue; } + if (!strncmp(line,"debug=", 6)) { + debug_level = (int)simple_strtol(line+6, 10); + continue; + } if (!strncmp(line,"buf=",4)) { nr_ext_bufs = (int)simple_strtol(line+4, 10); continue; diff --git a/elks/kernel/printk.c b/elks/kernel/printk.c index cf4c20ad3..861b0fa85 100644 --- a/elks/kernel/printk.c +++ b/elks/kernel/printk.c @@ -326,7 +326,7 @@ void panic(const char *error, ...) halt(); } -int dprintk_on = DEBUG_STARTDEF; /* toggled by debug events*/ +int debug_level = DEBUG_LEVEL; /* set with debug= or toggled by debug events */ #if DEBUG_EVENT static void (*debug_cbfuncs[3])(); /* debug event callback function*/ @@ -338,8 +338,8 @@ void debug_setcallback(int evnum, void (*cbfunc)()) void debug_event(int evnum) { - if (evnum == 2) { /* CTRLP toggles dprintk*/ - dprintk_on = !dprintk_on; + if (evnum == 2) { /* CTRLP toggles debug */ + debug_level = !debug_level; kill_all(SIGURG); } if (debug_cbfuncs[evnum]) @@ -350,7 +350,7 @@ void dprintk(const char *fmt, ...) { va_list p; - if (!dprintk_on) + if (!debug_level) return; va_start(p, fmt); vprintk(fmt, p); diff --git a/elks/kernel/sysctl.c b/elks/kernel/sysctl.c index e4c1a26ff..76dccb39e 100644 --- a/elks/kernel/sysctl.c +++ b/elks/kernel/sysctl.c @@ -15,7 +15,7 @@ static int malloc_debug; static int net_debug; struct sysctl sysctl[] = { - { "kern.debug", &dprintk_on }, /* debug (^P) on/off */ + { "kern.debug", &debug_level }, /* debug level (^P toggled) */ { "kern.strace", &tracing }, /* strace=1, kstack=2 */ { "kern.console", (int *)&dev_console }, /* console */ { "malloc.debug", &malloc_debug }, diff --git a/elkscmd/rootfs_template/bootopts b/elkscmd/rootfs_template/bootopts index 0ea554d82..3114650fe 100644 --- a/elkscmd/rootfs_template/bootopts +++ b/elkscmd/rootfs_template/bootopts @@ -19,5 +19,5 @@ #strace #FTRACE=1 #net=ne0 -#debug +#debug=1 #console=ttyS0,19200 3