Some support definitions and routines of NLKD, the latter primarily to isolate the debugger code from the rest of the kernel. Signed-Off-By: Jan Beulich Index: 2.6.14-nlkd/debug/nlkd/dbgutil.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ 2.6.14-nlkd/debug/nlkd/dbgutil.c 2005-06-27 11:57:55.000000000 +0200 @@ -0,0 +1,89 @@ +/***************************************************************************** + * + * File Name: dbgutil.c + * Created by: Jan Beulich + * Date created: 21Jul1999 + * + * %version: 5 % + * %derived_by: jbeulich % + * %date_modified: Mon Jun 27 03:57:44 2005 % + * + *****************************************************************************/ +/***************************************************************************** + * * + * Copyright (c) 1999-2005 Novell, Inc. All Rights Reserved. * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of version 2 of the GNU General Public License * + * as published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, contact Novell, Inc. * + * * + * To contact Novell about this file by physical or electronic mail, * + * you may find current contact information at www.novell.com. * + * * + *****************************************************************************/ +/***************************************************************************** + * + * File Description: + * + *****************************************************************************/ + +#include + +#if !defined(_M_IA64) && !defined(__ia64__) \ + && !defined(_M_IX86) && !defined(__i386__) \ + && !defined(_M_AMD64) && !defined(__x86_64__) +asmlinkage DbgQuotRemS dbgDivideS(nint_t numer, nint_t denom) { + DbgQuotRemS sd; + + if (denom == 1) + { + sd.quot = numer; + sd.rem = 0; + } + else if (denom == -1) + { + sd.quot = -numer; + sd.rem = 0; + } + else + { + sd.quot = numer / denom; + sd.rem = numer % denom; + } + + return sd; +} + +asmlinkage DbgQuotRemU dbgDivideU(nuint_t numer, nuint_t denom) { + DbgQuotRemU ud; + + if (denom == 1) + { + ud.quot = numer; + ud.rem = 0; + } + else + { + ud.quot = numer / denom; + ud.rem = numer % denom; + } + return ud; +} +#endif + +asmlinkage char*dbgCatStr(char*dst, const char*src) { + dbgCopyStr(dst + dbgCountStr(dst), src); + return dst; +} + +#include +#define DEBUGRTL_EXPORT(type, name, ...) EXPORT_SYMBOL(name) +#include Index: 2.6.14-nlkd/include/linux/debugrtl.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ 2.6.14-nlkd/include/linux/debugrtl.h 2005-11-03 12:03:04.000000000 +0100 @@ -0,0 +1,170 @@ +/***************************************************************************** + * + * File Name: debugrtl.h + * Created by: Jan Beulich + * Date created: 21Jul1999 + * + * %version: 9 % + * %derived_by: jbeulich % + * %date_modified: Thu Nov 03 04:02:51 2005 % + * + *****************************************************************************/ +/***************************************************************************** + * * + * Copyright (c) 1999-2005 Novell, Inc. All Rights Reserved. * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of version 2 of the GNU General Public License * + * as published by the Free Software Foundation. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, contact Novell, Inc. * + * * + * To contact Novell about this file by physical or electronic mail, * + * you may find current contact information at www.novell.com. * + * * + *****************************************************************************/ +/***************************************************************************** + * + * File Description: + * + *****************************************************************************/ +#if !defined(_LINUX_DEBUGRTL_H) || defined(DEBUGRTL_EXPORT) + +#ifndef _LINUX_DEBUGRTL_H + +# include +# include +# include + +# define mkalign(d, a) (((d) + ((a) - 1)) & ~((a) - 1)) +# define countof(a) (sizeof(a) / sizeof(*a)) +# define field_sizeof(t, f) (sizeof(((t*)0)->f)) +# define field_countof(t, a) (countof(((t*)0)->a)) +# define field_end(t, f) (offsetof(t, f) + field_sizeof(t, f)) +# define field_typeof(t, f) __typeof__(((t*)0)->f) + +# ifdef CONFIG_64BIT +typedef uint64_t bitvec_t; +# define BITVEC_INDEX_SHIFT 6 +# else +typedef uint32_t bitvec_t; +# define BITVEC_INDEX_SHIFT 5 +# endif + +# define BITVEC_INDEX_MASK ((1U << BITVEC_INDEX_SHIFT) - 1) + +# define BITVEC_SZ(n) (((n) + BITVEC_INDEX_MASK) >> BITVEC_INDEX_SHIFT) +# define BITVEC_CLR(p, n) (((bitvec_t*)(p))[(n) >> BITVEC_INDEX_SHIFT] &= ~((bitvec_t)1 << ((n) & BITVEC_INDEX_MASK))) +# define BITVEC_SET(p, n) (((bitvec_t*)(p))[(n) >> BITVEC_INDEX_SHIFT] |= ((bitvec_t)1 << ((n) & BITVEC_INDEX_MASK))) +# define BITVEC_TST(p, n) ((((bitvec_t*)(p))[(n) >> BITVEC_INDEX_SHIFT] >> ((n) & BITVEC_INDEX_MASK)) & 1) + +typedef struct { + nint_t quot; + nint_t rem; +} DbgQuotRemS; + +typedef struct { + nuint_t quot; + nuint_t rem; +} DbgQuotRemU; + +# define DEBUGRTL_EXPORT(type, name, ...) type name(__VA_ARGS__) + +# ifdef __cplusplus +extern "C" { +# endif + +#endif /* _LINUX_DEBUGRTL_H */ + +DEBUGRTL_EXPORT(asmlinkage char*, dbgCatStr, char*, const char*); +DEBUGRTL_EXPORT(asmlinkage int, dbgCompareMem, const void*, const void*, size_t); +DEBUGRTL_EXPORT(asmlinkage int, dbgCompareStr, const char*, const char*); +DEBUGRTL_EXPORT( void*, dbgCopyMem, void*, const void*, size_t); +DEBUGRTL_EXPORT(asmlinkage char*, dbgCopyStr, char*, const char*); +DEBUGRTL_EXPORT(asmlinkage char*, dbgCopyStrP, char*, const char*); +DEBUGRTL_EXPORT(asmlinkage unsigned, dbgCountBits, uint64_t); +DEBUGRTL_EXPORT(asmlinkage size_t, dbgCountStr, const char*); +DEBUGRTL_EXPORT(asmlinkage size_t, dbgCountWstr, const wchar_t*); +DEBUGRTL_EXPORT(asmlinkage DbgQuotRemS, dbgDivideS, nint_t, nint_t); +DEBUGRTL_EXPORT(asmlinkage DbgQuotRemU, dbgDivideU, nuint_t, nuint_t); +DEBUGRTL_EXPORT( void*, dbgFillMem, void*, int, size_t); +DEBUGRTL_EXPORT(asmlinkage void*, dbgFindByte, const void*, int, size_t); +DEBUGRTL_EXPORT(asmlinkage char*, dbgFindChar, const char*, int); +DEBUGRTL_EXPORT(asmlinkage uint8_t*, dbgFindInt8, const uint8_t*, uint8_t, size_t); +DEBUGRTL_EXPORT(asmlinkage uint16_t*, dbgFindInt16, const uint16_t*, uint16_t, size_t); +DEBUGRTL_EXPORT(asmlinkage uint32_t*, dbgFindInt32, const uint32_t*, uint32_t, size_t); +#ifdef CONFIG_64BIT +DEBUGRTL_EXPORT(asmlinkage uint64_t*, dbgFindInt64, const uint64_t*, uint64_t, size_t); +#endif +DEBUGRTL_EXPORT(asmlinkage nuint_t*, dbgFindIntN, const nuint_t*, nuint_t, size_t); +DEBUGRTL_EXPORT(asmlinkage void**, dbgFindPtr, const void*const*, const void*, size_t); +DEBUGRTL_EXPORT(asmlinkage wchar_t*, dbgFindWchar, const wchar_t*, wchar_t); +#undef dbgLower +DEBUGRTL_EXPORT(asmlinkage int, dbgLower, int); +DEBUGRTL_EXPORT(asmlinkage nint_t, dbgLog2, uint64_t); +DEBUGRTL_EXPORT(asmlinkage uint64_t, dbgMultiply, uint64_t, uint64_t, uint64_t*overflow); +DEBUGRTL_EXPORT(asmlinkage uint8_t, dbgRotl8, uint8_t, nuint_t); +DEBUGRTL_EXPORT(asmlinkage uint16_t, dbgRotl16, uint16_t, nuint_t); +DEBUGRTL_EXPORT(asmlinkage uint32_t, dbgRotl32, uint32_t, nuint_t); +DEBUGRTL_EXPORT(asmlinkage uint64_t, dbgRotl64, uint64_t, nuint_t); +DEBUGRTL_EXPORT(asmlinkage uint8_t, dbgRotr8, uint8_t, nuint_t); +DEBUGRTL_EXPORT(asmlinkage uint16_t, dbgRotr16, uint16_t, nuint_t); +DEBUGRTL_EXPORT(asmlinkage uint32_t, dbgRotr32, uint32_t, nuint_t); +DEBUGRTL_EXPORT(asmlinkage uint64_t, dbgRotr64, uint64_t, nuint_t); +#undef dbgUpper +DEBUGRTL_EXPORT(asmlinkage int, dbgUpper, int); +DEBUGRTL_EXPORT(asmlinkage char*, dbgWstr2Str, char*, const wchar_t*); +DEBUGRTL_EXPORT( void*, dbgZeroMem, void*, size_t); + +#ifndef _LINUX_DEBUGRTL_H + +# ifdef __cplusplus + +inline int dbgLower(int c) { return c >= 'A' && c <= 'Z' ? c + 'a' - 'A' : c; } +inline int dbgUpper(int c) { return c >= 'a' && c <= 'z' ? c + 'A' - 'a' : c; } + +} + +# endif + +//todo The .global in the following constructs is just a workaround for a bug +// in binutils shipped with SL 10.0. This will *ONLY* work if the producer +// doesn't include this file (which currently is the case because all +// producers are assembly files) - otherwise we'll end up with, say, a +// global memcpy defined there and colliding with or overriding the real +// one from the kernel's strings library code. +__asm__(".equiv memcpy, dbgCopyMem\n\t.global memcpy"); +__asm__(".equiv memset, dbgFillMem\n\t.global memset"); + +# define DEBUGRTL_ALIAS(name) __asm__(".equiv " #name ", dbg" #name "\n\t.global " #name) + +# define _LINUX_DEBUGRTL_H + +#else + +# define DEBUGRTL_ALIAS(name) void dbg##name(void); DEBUGRTL_EXPORT(void, dbg##name, void) + +#endif /* _LINUX_DEBUGRTL_H */ + +#ifndef __cplusplus +# define dbgLower(c) ((c) >= 'A' && (c) <= 'Z' ? (c) + 'a' - 'A' : (c)) +# define dbgUpper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + 'A' - 'a' : (c)) +#endif + +#if defined(__i386__) +DEBUGRTL_ALIAS(__divdi3); +DEBUGRTL_ALIAS(__moddi3); +DEBUGRTL_ALIAS(__udivdi3); +DEBUGRTL_ALIAS(__umoddi3); +#endif + +#undef DEBUGRTL_ALIAS +#undef DEBUGRTL_EXPORT + +#endif /* !_LINUX_DEBUGRTL_H || DEBUGRTL_EXPORT */