/* @(#)79 1.6 src/bos/kernel/kdb/kdb_kext.h, kdb, bos720 3/23/09 11:46:57 */ /* * COMPONENT_NAME: (KDB) Kernel Debugger * * FUNCTIONS: db_register() * db_unregister() * db_expr() * db_expr_ad() * db_printf() * db_read_mem() * db_read_word() * db_read_halfword() * db_read_byte() * * ORIGINS: 131 * * Copyright (C) Bull S.A. 1997, 1999 * LEVEL 1, 5 Years Bull Confidential Information */ #ifndef _KDB_KEXT_H #define _KDB_KEXT_H #include #include /* KDB parser argument */ #define NUM16 16 /* hexdecimal value is parsed */ #define NUM10 10 /* decimal value is parsed */ #define SYMB 0 /* symbol or hexadecimal value */ #define SYMB_DEC 1 /* symbol or decimal value */ /* KDB parser errors */ #define EROK 0 /* no error */ #define NOTEXT 1 /* found end of line */ #define NOEXPR 2 /* found delimiter rather than expression */ #define AMBIG_SYMB 3 /* non unique symbol */ #define EXPECTEDDECIMAL 4 /* decimal value not found */ #define MAXBUFLEN 256 /* maximum buffer length */ #define MAXCMDLEN 24 /* maximum command name length */ #if !defined(__64BIT__) && defined(_KERNEL) /* ==================================================== * Kernel extension I/F to manage new command * db_register() db_unregister() db_expr() db_expr_ad() * ==================================================== */ /* * NAME: db_register( * char *cmd, command name (up to MAXCMDLEN chars) * char *alias1, 1st alias name (up to MAXCMDLEN chars * char *alias2, 2nd alias name (up to MAXCMDLEN chars * char *help, command summary * char *option, option syntax * int (*func)()) function to be called * NAME: db_unregister( * int (*func)()) function to be removed * * FUNCTION: how to [un]register new commands. * function call interface will be: * func(uchar_t *buff, int *buffix, int linelen) * - buff is command line (command is included) * - buffix is set to 1 char past of command * - linelen is command line length * * The code of the function should be pinned in memory. * KDB calls it in virtual mode, page fault is not allowed. * Arguments passed to the function can be analysed by the * db_expr..() function. Addresses are real effective addresses. * * RETURN VALUE: TRUE or FALSE */ #define db_register(cmd, alias1, alias2, help, option, func) \ if (kdb_is_avail()) \ brkpoint(DB_REGISTER, cmd, alias1, alias2, help, option, func) #define db_unregister(func) \ if (kdb_is_avail()) \ brkpoint(DB_UNREGISTER, func) /* * NAME: db_expr( * int flag, SYMB NUM16 NUM10 * unsigned char *buff, Should be real effective address * int *buffix, Should be real effective address * int max, Less or equal to MAXBUFLEN * int *value) Should be word aligned address * * FUNCTION: symbol/expression handler * If flag=SYMB, lookup symbol or integer * If flag=NUM16, NUM10, lookup only integer * * If find symbol or integer then lookup expression * * on exit, buffix is +1 char after last char parsed. * if last char is at end of line, buffix = max + 1 * Only 32 bits value are supported. * * limitations: * must be of the form: * number [+|-|*|/ number]... * can't handle parentheses * don't detect arithmetic overflow * * RETURN VALUE: EROK no error * NOTEXT found end of line * NOEXPR found delimiter rather than expression * AMBIG_SYMB non unique symbol * EXPECTEDDECIMAL decimal value not found */ #define db_expr(flag, buff, buffix, max, value) \ brkpoint(DB_EXPR, flag, buff, buffix, max, value) /* * NAME: db_expr_ad( * int flag, SYMB NUM16 NUM10 * unsigned char *buff, Should be real effective address * int *buffix, Should be real effective address * int max, Less or equal to MAXBUFLEN * void **value) Should be correctly aligned * * FUNCTION: symbol/expression handler * If flag=SYMB, lookup symbol or integer * If flag=NUM16, NUM10, lookup only integer * * If find symbol or integer then lookup expression * * on exit, buffix is +1 char after last char parsed. * if last char is at end of line, buffix = max + 1 * 64-bit addresses are supported in 64-bit mode. * * limitations: * must be of the form: * number [+|-|*|/ number]... * can't handle parentheses * don't detect arithmetic overflow * * RETURN VALUE: EROK no error * NOTEXT found end of line * NOEXPR found delimiter rather than expression * AMBIG_SYMB non unique symbol * EXPECTEDDECIMAL decimal value not found */ #define db_expr_ad(flag, buff, buffix, max, value) \ brkpoint(DB_EXPR_AD, flag, buff, buffix, max, value) /* ======================================================= * Kdb extended I/F used by kernext display modules * db_printf() db_read_mem() * db_read_word() db_read_halfword() db_read_byte() * ======================================================= * * Memory access interfaces for kernel extension: * * db_read_mem(__ulong32_t vaddr, unsigned char *buf, unsigned len) * -- read [len] bytes at virtual memory location [vaddr] in buffer [buf] * -- page crossing is allowed * -- faulting addresses are detected before access. * * word = db_read_word(__ulong32_t vaddr) * -- read 4 bytes word at virtual memory location * -- page crossing is not allowed * -- faulting addresses are detected before access. * * half_word = db_read_halfword(__ulong32_t vaddr) * -- read 2 bytes half word at virtual memory location * -- page crossing is not allowed * -- faulting addresses are detected before access. * * byte = db_read_byte(__ulong32_t vaddr) * -- read 1 byte at virtual memory location * -- page crossing is not allowed * -- faulting addresses are detected before access. * */ /* * NAME: db_printf * * FUNCTION: This is a minimal printf. * * RETURN VALUE: none */ #define db_printf brkpoint /* * NAME: unsigned int db_read_mem(void *vaddr, void *local_addr, * unsigned int size_in_bytes) * * FUNCTION: * -- read [size_in_bytes] bytes at virtual memory location [vaddr] * in buffer [local_addr] * -- page crossing is allowed * -- faulting addresses are detected before access. * * INPUT: virtual address, buffer address and in bytes * * RETURN: number of bytes actually read, no return if the address is not valid */ #define db_read_mem(vad, lad, siz) brkpoint(DB_READ_MEM, vad, lad, siz) /* * NAME: * - unsigned int db_read_word(void *vaddr) * -- unsigned short db_read_halfword(void *vaddr) * --- unsigned char db_read_byte(void *vaddr) * * FUNCTION: * - read 4 bytes at virtual memory location [vaddr] * -- read 2 bytes at virtual memory location [vaddr] * --- read 1 byte at virtual memory location [vaddr] * page crossing is not allowed * faulting addresses are detected before access. * * INPUT: virtual address * * RETURN: * - 4 bytes read * -- 2 bytes read * --- 1 byte read * no return if the address is not valid */ #define db_read_word(vad) brkpoint(DB_READ_WORD, vad) #define db_read_halfword(vad) brkpoint(DB_READ_HALFWORD, vad) #define db_read_byte(vad) brkpoint(DB_READ_BYTE, vad) #endif /* !__64BIT__ && _KERNEL*/ #endif /* _KDB_KEXT_H */