diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2009-10-24 19:56:11 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2009-10-24 19:56:11 -0400 |
commit | c604f2f6be0ad729c8e25958c946a8535ca391ee (patch) | |
tree | 561c46af38c11dbc55685f525202b7a9d0c12e09 /src | |
parent | a5826b5ad482f44d293387dc7513e5e98802a54e (diff) | |
download | seabios-hppa-c604f2f6be0ad729c8e25958c946a8535ca391ee.zip seabios-hppa-c604f2f6be0ad729c8e25958c946a8535ca391ee.tar.gz seabios-hppa-c604f2f6be0ad729c8e25958c946a8535ca391ee.tar.bz2 |
Improve debugging output from threads.
Show the "thread id" on each debug message sent from a thread.
Also, cleanup translation dprintf() so it looks nicer withe thread output.
Diffstat (limited to 'src')
-rw-r--r-- | src/block.c | 18 | ||||
-rw-r--r-- | src/config.h | 1 | ||||
-rw-r--r-- | src/output.c | 14 | ||||
-rw-r--r-- | src/util.c | 8 | ||||
-rw-r--r-- | src/util.h | 2 |
5 files changed, 31 insertions, 12 deletions
diff --git a/src/block.c b/src/block.c index a62536c..0a65ae6 100644 --- a/src/block.c +++ b/src/block.c @@ -86,15 +86,15 @@ setup_translation(struct drive_s *drive_g) 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; @@ -116,7 +116,7 @@ setup_translation(struct drive_s *drive_g) 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) @@ -127,7 +127,7 @@ setup_translation(struct drive_s *drive_g) // 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; @@ -141,7 +141,11 @@ setup_translation(struct drive_s *drive_g) // 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); diff --git a/src/config.h b/src/config.h index ab243de..3033133 100644 --- a/src/config.h +++ b/src/config.h @@ -187,5 +187,6 @@ #define DEBUG_ISR_hwpic2 5 #define DEBUG_HDL_pnp 1 #define DEBUG_HDL_pmm 1 +#define DEBUG_thread 1 #endif // config.h diff --git a/src/output.c b/src/output.c index e860b0b..7f74a69 100644 --- a/src/output.c +++ b/src/output.c @@ -115,7 +115,7 @@ static void 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); @@ -325,6 +325,18 @@ panic(const char *fmt, ...) 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); @@ -134,9 +134,9 @@ struct thread_info { 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(); @@ -187,7 +187,7 @@ __end_thread(struct thread_info *old) 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 @@ -206,7 +206,7 @@ run_thread(void (*func)(void*), void *data) 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 @@ -139,6 +139,8 @@ static inline u8 readb(const void *addr) { // 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); |