+typedef enum {SINGLE, START, MIDDLE, END} dbgmsg_t;
+
+void drv_debug(dbgmsg_t phase, const FLASH char *const fmt, ...) \
+{
+ struct cpm_drive_s *dp = &drv_table[drv];
+
+ if (dp->opt & DRV_OPT_DEBUG) {
+
+ va_list ap;
+ va_start (ap, fmt);
+
+ if (phase == SINGLE || phase == START)
+ printf_P(PSTR("# %7lu dsk%d: "), get_timer(0), drv);
+
+ vfprintf_P (stdout, fmt, ap);
+
+ if (phase == SINGLE || phase == END)
+ putc('\n', stdout);
+
+ va_end (ap);
+ }
+}