1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2014-2015 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 /**
25  * @file
26  * @brief DEBUG module implementation for Unix kernelspace.
27  */
28 #ifndef _NVPORT_DEBUG_UNIX_KERNEL_OS_H_
29 #define _NVPORT_DEBUG_UNIX_KERNEL_OS_H_
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #if !PORT_IS_KERNEL_BUILD
35 #error "This file can only be compiled as part of the kernel build."
36 #endif
37 #if !NVOS_IS_UNIX
38 #error "This file can only be compiled on Unix."
39 #endif
40 
41 #include "nv-kernel-interface-api.h"
42 void NV_API_CALL os_dbg_breakpoint(void);
43 void NV_API_CALL out_string(const char *str);
44 int  NV_API_CALL nv_printf(NvU32 debuglevel, const char *format, ...);
45 void NV_API_CALL os_dump_stack(void);
46 
47 // No init/shutdown needed
48 #define portDbgInitialize()
49 #define portDbgShutdown()
50 
51 
52 PORT_DEBUG_INLINE void
portDbgPrintString(const char * str,NvLength length)53 portDbgPrintString
54 (
55     const char *str,
56     NvLength length
57 )
58 {
59     out_string(str);
60 }
61 
62 #define portDbgPrintf(fmt, ...) nv_printf(0xFFFFFFFF, fmt, ##__VA_ARGS__)
63 #undef portDbgPrintf_SUPPORTED
64 #define portDbgPrintf_SUPPORTED 1
65 
66 #define portDbgExPrintfLevel(level, fmt, ...) nv_printf(level, fmt, ##__VA_ARGS__)
67 #undef portDbgExPrintfLevel_SUPPORTED
68 #define portDbgExPrintfLevel_SUPPORTED 1
69 
70 #define PORT_BREAKPOINT() os_dbg_breakpoint()
71 #define PORT_DUMP_STACK() os_dump_stack()
72 
73 #ifdef __cplusplus
74 }
75 #endif //__cplusplus
76 #endif // _NVPORT_DEBUG_UNIX_KERNEL_OS_H_
77