2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2010-2015, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 #ifndef __DEBUG_PRIVATE_H_INCLUDED__
16 #define __DEBUG_PRIVATE_H_INCLUDED__
18 #include "debug_public.h"
22 #define __INLINE_ISP__
25 #include "memory_access.h"
27 #include "assert_support.h"
29 STORAGE_CLASS_DEBUG_C bool is_debug_buffer_empty(void)
31 return (debug_data_ptr->head == debug_data_ptr->tail);
34 STORAGE_CLASS_DEBUG_C hrt_data debug_dequeue(void)
38 assert(debug_buffer_address != ((hrt_address)-1));
42 if (!is_debug_buffer_empty()) {
43 value = debug_data_ptr->buf[debug_data_ptr->head];
44 debug_data_ptr->head = (debug_data_ptr->head + 1) & DEBUG_BUF_MASK;
45 sp_dmem_store_uint32(SP0_ID, debug_buffer_address + DEBUG_DATA_HEAD_ADDR, debug_data_ptr->head);
51 STORAGE_CLASS_DEBUG_C void debug_synch_queue(void)
53 uint32_t remote_tail = sp_dmem_load_uint32(SP0_ID, debug_buffer_address + DEBUG_DATA_TAIL_ADDR);
54 /* We could move the remote head after the upload, but we would have to limit the upload w.r.t. the local head. This is easier */
55 if (remote_tail > debug_data_ptr->tail) {
56 size_t delta = remote_tail - debug_data_ptr->tail;
57 sp_dmem_load(SP0_ID, debug_buffer_address + DEBUG_DATA_BUF_ADDR + debug_data_ptr->tail*sizeof(uint32_t), (void *)&(debug_data_ptr->buf[debug_data_ptr->tail]), delta*sizeof(uint32_t));
58 } else if (remote_tail < debug_data_ptr->tail) {
59 size_t delta = DEBUG_BUF_SIZE - debug_data_ptr->tail;
60 sp_dmem_load(SP0_ID, debug_buffer_address + DEBUG_DATA_BUF_ADDR + debug_data_ptr->tail*sizeof(uint32_t), (void *)&(debug_data_ptr->buf[debug_data_ptr->tail]), delta*sizeof(uint32_t));
61 sp_dmem_load(SP0_ID, debug_buffer_address + DEBUG_DATA_BUF_ADDR, (void *)&(debug_data_ptr->buf[0]), remote_tail*sizeof(uint32_t));
62 } /* else we are up to date */
63 debug_data_ptr->tail = remote_tail;
66 STORAGE_CLASS_DEBUG_C void debug_synch_queue_isp(void)
68 uint32_t remote_tail = isp_dmem_load_uint32(ISP0_ID, DEBUG_BUFFER_ISP_DMEM_ADDR + DEBUG_DATA_TAIL_ADDR);
69 /* We could move the remote head after the upload, but we would have to limit the upload w.r.t. the local head. This is easier */
70 if (remote_tail > debug_data_ptr->tail) {
71 size_t delta = remote_tail - debug_data_ptr->tail;
72 isp_dmem_load(ISP0_ID, DEBUG_BUFFER_ISP_DMEM_ADDR + DEBUG_DATA_BUF_ADDR + debug_data_ptr->tail*sizeof(uint32_t), (void *)&(debug_data_ptr->buf[debug_data_ptr->tail]), delta*sizeof(uint32_t));
73 } else if (remote_tail < debug_data_ptr->tail) {
74 size_t delta = DEBUG_BUF_SIZE - debug_data_ptr->tail;
75 isp_dmem_load(ISP0_ID, DEBUG_BUFFER_ISP_DMEM_ADDR + DEBUG_DATA_BUF_ADDR + debug_data_ptr->tail*sizeof(uint32_t), (void *)&(debug_data_ptr->buf[debug_data_ptr->tail]), delta*sizeof(uint32_t));
76 isp_dmem_load(ISP0_ID, DEBUG_BUFFER_ISP_DMEM_ADDR + DEBUG_DATA_BUF_ADDR, (void *)&(debug_data_ptr->buf[0]), remote_tail*sizeof(uint32_t));
77 } /* else we are up to date */
78 debug_data_ptr->tail = remote_tail;
81 STORAGE_CLASS_DEBUG_C void debug_synch_queue_ddr(void)
85 mmgr_load(debug_buffer_ddr_address + DEBUG_DATA_TAIL_DDR_ADDR, &remote_tail, sizeof(uint32_t));
86 /* We could move the remote head after the upload, but we would have to limit the upload w.r.t. the local head. This is easier */
87 if (remote_tail > debug_data_ptr->tail) {
88 size_t delta = remote_tail - debug_data_ptr->tail;
89 mmgr_load(debug_buffer_ddr_address + DEBUG_DATA_BUF_DDR_ADDR + debug_data_ptr->tail*sizeof(uint32_t), (void *)&(debug_data_ptr->buf[debug_data_ptr->tail]), delta*sizeof(uint32_t));
90 } else if (remote_tail < debug_data_ptr->tail) {
91 size_t delta = DEBUG_BUF_SIZE - debug_data_ptr->tail;
92 mmgr_load(debug_buffer_ddr_address + DEBUG_DATA_BUF_DDR_ADDR + debug_data_ptr->tail*sizeof(uint32_t), (void *)&(debug_data_ptr->buf[debug_data_ptr->tail]), delta*sizeof(uint32_t));
93 mmgr_load(debug_buffer_ddr_address + DEBUG_DATA_BUF_DDR_ADDR, (void *)&(debug_data_ptr->buf[0]), remote_tail*sizeof(uint32_t));
94 } /* else we are up to date */
95 debug_data_ptr->tail = remote_tail;
98 #endif /* __DEBUG_PRIVATE_H_INCLUDED__ */