Skip to content

Commit

Permalink
Merge pull request #2081 from ghaerr/df
Browse files Browse the repository at this point in the history
[directfd] Add track cache debug code to directfd driver
  • Loading branch information
ghaerr authored Oct 17, 2024
2 parents 4ecd2c0 + 5493f9f commit 2f4d53d
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 24 deletions.
11 changes: 7 additions & 4 deletions elks/arch/i86/drivers/block/bioshd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
Expand Down
18 changes: 12 additions & 6 deletions elks/arch/i86/drivers/block/directfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);
Expand All @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions elks/arch/i86/drivers/block/ll_rw_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions elks/fs/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion elks/include/linuxmt/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion elks/include/linuxmt/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions elks/init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions elks/kernel/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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*/

Expand All @@ -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])
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion elks/kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
2 changes: 1 addition & 1 deletion elkscmd/rootfs_template/bootopts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
#strace
#FTRACE=1
#net=ne0
#debug
#debug=1
#console=ttyS0,19200 3

0 comments on commit 2f4d53d

Please sign in to comment.