Show the "thread id" on each debug message sent from a thread.
Also, cleanup translation dprintf() so it looks nicer withe thread output.
u16 cylinders = GET_GLOBAL(drive_g->pchs.cylinders);
u16 spt = GET_GLOBAL(drive_g->pchs.spt);
u64 sectors = GET_GLOBAL(drive_g->sectors);
+ const char *desc;
- dprintf(1, "ata%d-%d: PCHS=%u/%d/%d translation="
- , channel, slave, cylinders, heads, spt);
switch (translation) {
+ default:
case TRANSLATION_NONE:
- dprintf(1, "none");
+ desc = "none";
break;
case TRANSLATION_LBA:
- dprintf(1, "lba");
+ desc = "lba";
spt = 63;
if (sectors > 63*255*1024) {
heads = 255;
cylinders = sect / heads;
break;
case TRANSLATION_RECHS:
- dprintf(1, "r-echs");
+ desc = "r-echs";
// Take care not to overflow
if (heads==16) {
if (cylinders>61439)
// then go through the large bitshift process
case TRANSLATION_LARGE:
if (translation == TRANSLATION_LARGE)
- dprintf(1, "large");
+ desc = "large";
while (cylinders > 1024) {
cylinders >>= 1;
heads <<= 1;
// clip to 1024 cylinders in lchs
if (cylinders > 1024)
cylinders = 1024;
- dprintf(1, " LCHS=%d/%d/%d\n", cylinders, heads, spt);
+ dprintf(1, "ata%d-%d: PCHS=%u/%d/%d translation=%s LCHS=%d/%d/%d\n"
+ , channel, slave
+ , drive_g->pchs.cylinders, drive_g->pchs.heads, drive_g->pchs.spt
+ , desc
+ , cylinders, heads, spt);
SET_GLOBAL(drive_g->lchs.heads, heads);
SET_GLOBAL(drive_g->lchs.cylinders, cylinders);
#define DEBUG_ISR_hwpic2 5
#define DEBUG_HDL_pnp 1
#define DEBUG_HDL_pmm 1
+#define DEBUG_thread 1
#endif // config.h
putc_screen(struct putcinfo *action, char c)
{
if (CONFIG_SCREEN_AND_DEBUG)
- putc_debug(action, c);
+ putc_debug(&debuginfo, c);
if (c == '\n')
screenc('\r');
screenc(c);
void
__dprintf(const char *fmt, ...)
{
+ if (!MODE16 && CONFIG_THREADS && CONFIG_DEBUG_LEVEL >= DEBUG_thread
+ && *fmt != '\\' && *fmt != '/') {
+ struct thread_info *cur = getCurThread();
+ if (cur != &MainThread) {
+ // Show "thread id" for this debug message.
+ putc_debug(&debuginfo, '|');
+ puthex(&debuginfo, (u32)cur, 8);
+ putc_debug(&debuginfo, '|');
+ putc_debug(&debuginfo, ' ');
+ }
+ }
+
va_list args;
va_start(args, fmt);
bvprintf(&debuginfo, fmt, args);
void *stackpos;
};
-static struct thread_info MainThread = {&MainThread, NULL};
+struct thread_info MainThread = {&MainThread, NULL};
-static struct thread_info *
+struct thread_info *
getCurThread()
{
u32 esp = getesp();
pos = pos->next;
pos->next = old->next;
free(old);
- dprintf(2, "=========== end thread %p\n", old);
+ dprintf(DEBUG_thread, "\\%08x/ End thread\n", (u32)old);
}
void
thread->next = cur->next;
cur->next = thread;
- dprintf(2, "=========== start thread %p\n", thread);
+ dprintf(DEBUG_thread, "/%08x\\ Start thread\n", (u32)thread);
asm volatile(
// Start thread
" pushl $1f\n" // store return pc
// util.c
inline u32 stack_hop(u32 eax, u32 edx, u32 ecx, void *func);
+extern struct thread_info MainThread;
+struct thread_info *getCurThread();
void run_thread(void (*func)(void*), void *data);
void wait_threads();
u8 checksum_far(u16 buf_seg, void *buf_far, u32 len);