--- zzzz-none-000/linux-2.6.39.4/kernel/printk.c 2011-08-03 19:43:28.000000000 +0000 +++ puma6-arm-6490-729/linux-2.6.39.4/kernel/printk.c 2021-11-10 13:23:10.000000000 +0000 @@ -40,6 +40,9 @@ #include #include #include +#ifdef CONFIG_AVM_DEBUG +#include +#endif/*--- #ifdef CONFIG_AVM_DEBUG ---*/ #include @@ -148,6 +151,16 @@ static int log_buf_len = __LOG_BUF_LEN; static unsigned logged_chars; /* Number of chars produced since last read+clear operation */ static int saved_console_loglevel = -1; +#ifdef CONFIG_TFFS_PANIC_LOG +unsigned long printk_get_buffer(char **p_log_buf, unsigned long *p_log_end, unsigned long *p_anzahl) { + *p_log_buf = log_buf; + *p_log_end = log_end & LOG_BUF_MASK; + *p_anzahl = log_end; + /*--- printk("[printk_get_buffer] log_buf 0x%p len %d write_pos %ld anzahl %ld\n", log_buf, log_buf_len, log_end & LOG_BUF_MASK, log_end); ---*/ + return log_buf_len; +} +#endif /*--- #ifdef CONFIG_TFFS_PANIC_LOG ---*/ + #ifdef CONFIG_KEXEC /* @@ -210,7 +223,7 @@ #ifdef CONFIG_BOOT_PRINTK_DELAY -static int boot_delay; /* msecs delay after each printk during bootup */ +static unsigned int boot_delay; /* msecs delay after each printk during bootup */ static unsigned long long loops_per_msec; /* based on boot_delay */ static int __init boot_delay_setup(char *str) @@ -476,10 +489,21 @@ /* * Call the console drivers on a range of log_buf */ -static void __call_console_drivers(unsigned start, unsigned end) +static void __call_console_drivers( +#if defined(CONFIG_AVM_DEBUG) + int force_avm_console, +#endif/*--- #if defined(CONFIG_AVM_DEBUG) ---*/ + unsigned start, unsigned end) { struct console *con; +#if defined(CONFIG_AVM_DEBUG) + if(force_avm_console && (avm_debug_console_write(&LOG_BUF(start), end - start) == 0)) { + return; + } +#endif/*--- #if defined(CONFIG_AVM_DEBUG) ---*/ + + for_each_console(con) { if (exclusive_console && con != exclusive_console) continue; @@ -505,18 +529,34 @@ /* * Write out chars from start to end - 1 inclusive */ -static void _call_console_drivers(unsigned start, +static void _call_console_drivers( +#if defined(CONFIG_AVM_DEBUG) + int force_avm_console, +#endif/*--- #if defined(CONFIG_AVM_DEBUG) ---*/ + unsigned start, unsigned end, int msg_log_level) { if ((msg_log_level < console_loglevel || ignore_loglevel) && console_drivers && start != end) { if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) { /* wrapped write */ - __call_console_drivers(start & LOG_BUF_MASK, + __call_console_drivers( +#if defined(CONFIG_AVM_DEBUG) + force_avm_console, +#endif/*--- #if defined(CONFIG_AVM_DEBUG) ---*/ + start & LOG_BUF_MASK, log_buf_len); - __call_console_drivers(0, end & LOG_BUF_MASK); + __call_console_drivers( +#if defined(CONFIG_AVM_DEBUG) + force_avm_console, +#endif/*--- #if defined(CONFIG_AVM_DEBUG) ---*/ + 0, end & LOG_BUF_MASK); } else { - __call_console_drivers(start, end); + __call_console_drivers( +#if defined(CONFIG_AVM_DEBUG) + force_avm_console, +#endif/*--- #if defined(CONFIG_AVM_DEBUG) ---*/ + start, end); } } } @@ -586,12 +626,19 @@ return len; } +#ifdef CONFIG_AVM_DEBUG +static void __console_unlock( int force_avm_console); +#endif/*--- #ifdef CONFIG_AVM_DEBUG ---*/ /* * Call the console drivers, asking them to write out * log_buf[start] to log_buf[end - 1]. * The console_lock must be held. */ -static void call_console_drivers(unsigned start, unsigned end) +static void call_console_drivers( +#ifdef CONFIG_AVM_DEBUG + int force_avm_console, +#endif/*--- #ifdef CONFIG_AVM_DEBUG ---*/ + unsigned start, unsigned end) { unsigned cur_index, start_print; static int msg_level = -1; @@ -620,14 +667,22 @@ */ msg_level = default_message_loglevel; } - _call_console_drivers(start_print, cur_index, msg_level); + _call_console_drivers( +#ifdef CONFIG_AVM_DEBUG + force_avm_console, +#endif/*--- #ifdef CONFIG_AVM_DEBUG ---*/ + start_print, cur_index, msg_level); msg_level = -1; start_print = cur_index; break; } } } - _call_console_drivers(start_print, end, msg_level); + _call_console_drivers( +#ifdef CONFIG_AVM_DEBUG + force_avm_console, +#endif/*--- #ifdef CONFIG_AVM_DEBUG ---*/ + start_print, end, msg_level); } static void emit_log_char(char c) @@ -723,6 +778,59 @@ return r; } +#if !defined(CONFIG_ARM_UNWIND) +/*--------------------------------------------------------------------------------*\ + * bend it ! + * puma: c_backtrace() [backtrace.S] -> printk() to asm_printk() +\*--------------------------------------------------------------------------------*/ +asmlinkage int asm_printk(const char *fmt, ...) { + va_list args; + int r; + + va_start(args, fmt); + r = vprintk(fmt, args); + va_end(args); + + return r; +} +#endif/*--- #if !defined(CONFIG_ARM_UNWIND) ---*/ + + +#if defined(CONFIG_AVM_DEBUG) + +/*--- old avm stuff (depreciated) ---*/ +asmlinkage int (*__printk)(const char * fmt, ...) __attribute__ ((format (printf, 1, 2))) = printk_linux; +asmlinkage int (*_printk)(const char * fmt, ...) __attribute__ ((format (printf, 1, 2))) = printk; +asmlinkage int (*_vprintk)(const char * fmt, va_list args) = vprintk; + +EXPORT_SYMBOL(__printk); /* zeigt auf printk_linux */ +EXPORT_SYMBOL(_printk); +EXPORT_SYMBOL(_vprintk); + +static int force_printk_avm = 0; +#endif/*--- #if defined(CONFIG_AVM_DEBUG) ---*/ + +/*--------------------------------------------------------------------------------*\ + * ret: old-mode: 1 bended, 0: std.printk +\*--------------------------------------------------------------------------------*/ +int printk_avm_console_bend(unsigned int activate) { + int ret = 0; +#ifdef CONFIG_AVM_DEBUG + ret = force_printk_avm; + force_printk_avm = activate ? 1 : 0; +#endif /*--- #ifdef CONFIG_AVM_DEBUG ---*/ + return ret; +} +EXPORT_SYMBOL(printk_avm_console_bend); + +/*--------------------------------------------------------------------------------*\ + old avm stuff (depreciated) +\*--------------------------------------------------------------------------------*/ +void restore_printk(void) { + printk_avm_console_bend(0); +} +EXPORT_SYMBOL(restore_printk); + /* cpu currently holding logbuf_lock */ static volatile unsigned int printk_cpu = UINT_MAX; @@ -794,7 +902,18 @@ } } +unsigned long long printk_sync_offset = 0; +void sync_printk(void) +{ + printk_sync_offset = local_clock(); +} +EXPORT_SYMBOL(sync_printk); + +#if defined(CONFIG_AVM_DEBUG) +static int __vprintk(unsigned int force_avm_console, const char *fmt, va_list args) +#else/*--- #if defined(CONFIG_AVM_DEBUG) ---*/ asmlinkage int vprintk(const char *fmt, va_list args) +#endif/*--- #else ---*//*--- #if defined(CONFIG_AVM_DEBUG) ---*/ { int printed_len = 0; int current_log_level = default_message_loglevel; @@ -895,11 +1014,17 @@ unsigned long nanosec_rem; t = cpu_clock(printk_cpu); + t -= printk_sync_offset; nanosec_rem = do_div(t, 1000000000); tlen = sprintf(tbuf, "[%5lu.%06lu] ", (unsigned long) t, nanosec_rem / 1000); - +/*--- #if defined(CONFIG_AVM_DEBUG) && defined(CONFIG_SMP) ---*/ + if(force_avm_console) { + tlen--; + tlen += sprintf(&tbuf[tlen], "[%x]", raw_smp_processor_id()); + } +/*--- #endif ---*//*--- #if defined(CONFIG_AVM_DEBUG) && defined(CONFIG_SMP) ---*/ for (tp = tbuf; tp < tbuf + tlen; tp++) emit_log_char(*tp); printed_len += tlen; @@ -925,7 +1050,11 @@ * actually gets the semaphore or not. */ if (console_trylock_for_printk(this_cpu)) - console_unlock(); +#if defined(CONFIG_AVM_DEBUG) + __console_unlock(force_avm_console); +#else/*--- #if defined(CONFIG_AVM_DEBUG) ---*/ + console_unlock(); +#endif/*--- #if defined(CONFIG_AVM_DEBUG) ---*/ lockdep_on(); out_restore_irqs: @@ -934,12 +1063,50 @@ preempt_enable(); return printed_len; } +#if defined(CONFIG_AVM_DEBUG) +asmlinkage int vprintk(const char *fmt, va_list args) { + return __vprintk(force_printk_avm, fmt, args); +} +asmlinkage int printk_linux(const char *fmt, ...) { + va_list args; + int r; + + va_start(args, fmt); + r = __vprintk(0, fmt, args); + va_end(args); + return r; +} +EXPORT_SYMBOL(printk_linux); + +asmlinkage int vprintk_avm(const char *fmt, va_list args) { + return __vprintk(1, fmt, args); +} +EXPORT_SYMBOL(vprintk_avm); +#endif/*--- #if defined(CONFIG_AVM_DEBUG) ---*/ EXPORT_SYMBOL(printk); EXPORT_SYMBOL(vprintk); #else -static void call_console_drivers(unsigned start, unsigned end) +#ifdef CONFIG_TFFS_PANIC_LOG +unsigned long printk_get_buffer(char **p_log_buf, unsigned long *p_log_end, unsigned long *p_anzahl) { + static char Buffer[] = "[no debugs available]\n"; + *p_log_buf = Buffer; + *p_log_end = Buffer + sizeof(Buffer) - 1; + *p_anzahl = sizeof(Buffer) - 1; + return *p_anzahl; +} +#endif /*--- #ifdef CONFIG_TFFS_PANIC_LOG ---*/ + +int dummy_printf (const char * fmt __attribute__ ((unused)), ...) { + return 0; +} + +static void call_console_drivers( +#ifdef CONFIG_AVM_DEBUG + int force_avm_console +#endif/*--- #ifdef CONFIG_AVM_DEBUG ---*/ + unsigned start, unsigned end) { } @@ -1209,7 +1376,11 @@ * * console_unlock(); may be called from any context. */ -void console_unlock(void) +#ifdef CONFIG_AVM_DEBUG +static void __console_unlock(int force_avm_console) +#else/*--- #ifdef CONFIG_AVM_DEBUG ---*/ +void console_unlock( void) +#endif/*--- #else ---*//*--- #ifdef CONFIG_AVM_DEBUG ---*/ { unsigned long flags; unsigned _con_start, _log_end; @@ -1232,7 +1403,11 @@ con_start = log_end; /* Flush */ spin_unlock(&logbuf_lock); stop_critical_timings(); /* don't trace print latency */ - call_console_drivers(_con_start, _log_end); + call_console_drivers( +#ifdef CONFIG_AVM_DEBUG + force_avm_console, +#endif/*--- #ifdef CONFIG_AVM_DEBUG ---*/ + _con_start, _log_end); start_critical_timings(); local_irq_restore(flags); } @@ -1247,6 +1422,11 @@ if (wake_klogd) wake_up_klogd(); } +#ifdef CONFIG_AVM_DEBUG +void console_unlock( void) { + __console_unlock( force_printk_avm); +} +#endif/*--- #ifdef CONFIG_AVM_DEBUG ---*/ EXPORT_SYMBOL(console_unlock); /**