Karthikeyan Ramasubramanian | e1f4f73 | 2011-08-08 13:34:47 -0600 | [diff] [blame] | 1 | /* Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | #ifndef _IPC_LOGGING_H |
| 14 | #define _IPC_LOGGING_H |
| 15 | |
| 16 | struct ipc_log_page_header { |
| 17 | uint32_t magic; |
| 18 | uint32_t nmagic; /* inverse of magic number */ |
| 19 | uint32_t log_id; /* owner of log */ |
| 20 | uint32_t page_num; |
| 21 | uint16_t read_offset; |
| 22 | uint16_t write_offset; |
| 23 | struct list_head list; |
| 24 | }; |
| 25 | |
| 26 | struct ipc_log_page { |
| 27 | struct ipc_log_page_header hdr; |
| 28 | char data[PAGE_SIZE - sizeof(struct ipc_log_page_header)]; |
| 29 | }; |
| 30 | |
| 31 | struct ipc_log_context { |
| 32 | struct list_head list; |
| 33 | struct list_head page_list; |
| 34 | struct ipc_log_page *first_page; |
| 35 | struct ipc_log_page *last_page; |
| 36 | struct ipc_log_page *write_page; |
| 37 | struct ipc_log_page *read_page; |
| 38 | uint32_t write_avail; |
| 39 | struct dentry *dent; |
| 40 | struct list_head dfunc_info_list; |
| 41 | spinlock_t ipc_log_context_lock; |
| 42 | struct completion read_avail; |
| 43 | }; |
| 44 | |
| 45 | struct dfunc_info { |
| 46 | struct list_head list; |
| 47 | int type; |
| 48 | void (*dfunc) (struct encode_context *, struct decode_context *); |
| 49 | }; |
| 50 | |
| 51 | enum { |
| 52 | TSV_TYPE_INVALID, |
| 53 | TSV_TYPE_TIMESTAMP, |
| 54 | TSV_TYPE_POINTER, |
| 55 | TSV_TYPE_INT32, |
| 56 | TSV_TYPE_BYTE_ARRAY, |
| 57 | }; |
| 58 | |
| 59 | enum { |
| 60 | OUTPUT_DEBUGFS, |
| 61 | }; |
| 62 | |
| 63 | #define IPC_LOGGING_MAGIC_NUM 0x52784425 |
| 64 | #define MIN(x, y) ((x) < (y) ? (x) : (y)) |
| 65 | #define IS_MSG_TYPE(x) (((x) > TSV_TYPE_MSG_START) && \ |
| 66 | ((x) < TSV_TYPE_MSG_END)) |
| 67 | |
| 68 | extern spinlock_t ipc_log_context_list_lock; |
| 69 | |
| 70 | extern int msg_read(struct ipc_log_context *ilctxt, |
| 71 | struct encode_context *ectxt); |
| 72 | |
| 73 | static inline int is_ilctxt_empty(struct ipc_log_context *ilctxt) |
| 74 | { |
| 75 | if (!ilctxt) |
| 76 | return -EINVAL; |
| 77 | |
| 78 | return ((ilctxt->read_page == ilctxt->write_page) && |
| 79 | (ilctxt->read_page->hdr.read_offset == |
| 80 | ilctxt->write_page->hdr.write_offset)); |
| 81 | } |
| 82 | |
| 83 | #if (defined(CONFIG_DEBUG_FS)) |
| 84 | void check_and_create_debugfs(void); |
| 85 | |
| 86 | void create_ctx_debugfs(struct ipc_log_context *ctxt, |
| 87 | const char *mod_name); |
| 88 | #else |
| 89 | void check_and_create_debugfs(void) |
| 90 | { |
| 91 | } |
| 92 | |
| 93 | void create_ctx_debugfs(struct ipc_log_context *ctxt, const char *mod_name) |
| 94 | { |
| 95 | } |
| 96 | #endif |
| 97 | |
| 98 | #endif |