Lines Matching refs:cd
63 static inline void adjust_end(struct console_data *cd) in adjust_end() argument
65 u32 last_byte = readl(&cd->hdr->last_byte); in adjust_end()
67 cd->end_of_data = cd->start_addr + LAST_BYTE(last_byte); in adjust_end()
91 static ssize_t dpaa2_console_size(struct console_data *cd) in dpaa2_console_size() argument
95 if (cd->cur_ptr <= cd->end_of_data) in dpaa2_console_size()
96 size = cd->end_of_data - cd->cur_ptr; in dpaa2_console_size()
98 size = (cd->end_addr - cd->cur_ptr) + in dpaa2_console_size()
99 (cd->end_of_data - cd->start_addr); in dpaa2_console_size()
110 struct console_data *cd; in dpaa2_generic_console_open() local
114 cd = kmalloc(sizeof(*cd), GFP_KERNEL); in dpaa2_generic_console_open()
115 if (!cd) in dpaa2_generic_console_open()
124 cd->map_addr = ioremap(base_addr + offset, size); in dpaa2_generic_console_open()
125 if (!cd->map_addr) { in dpaa2_generic_console_open()
131 cd->hdr = (struct log_header __iomem *)cd->map_addr; in dpaa2_generic_console_open()
132 read_magic = readl(&cd->hdr->magic_word); in dpaa2_generic_console_open()
133 last_byte = readl(&cd->hdr->last_byte); in dpaa2_generic_console_open()
134 buf_start = readl(&cd->hdr->buf_start); in dpaa2_generic_console_open()
135 buf_length = readl(&cd->hdr->buf_length); in dpaa2_generic_console_open()
144 cd->start_addr = cd->map_addr + buf_start - offset_delta; in dpaa2_generic_console_open()
145 cd->end_addr = cd->start_addr + buf_length; in dpaa2_generic_console_open()
149 adjust_end(cd); in dpaa2_generic_console_open()
150 if (wrapped && cd->end_of_data != cd->end_addr) in dpaa2_generic_console_open()
151 cd->cur_ptr = cd->end_of_data + 1; in dpaa2_generic_console_open()
153 cd->cur_ptr = cd->start_addr; in dpaa2_generic_console_open()
155 fp->private_data = cd; in dpaa2_generic_console_open()
160 iounmap(cd->map_addr); in dpaa2_generic_console_open()
164 kfree(cd); in dpaa2_generic_console_open()
185 struct console_data *cd = fp->private_data; in dpaa2_console_close() local
187 iounmap(cd->map_addr); in dpaa2_console_close()
188 kfree(cd); in dpaa2_console_close()
195 struct console_data *cd = fp->private_data; in dpaa2_console_read() local
196 size_t bytes = dpaa2_console_size(cd); in dpaa2_console_read()
197 size_t bytes_end = cd->end_addr - cd->cur_ptr; in dpaa2_console_read()
203 adjust_end(cd); in dpaa2_console_read()
205 if (cd->end_of_data == cd->cur_ptr) in dpaa2_console_read()
216 memcpy_fromio(kbuf, cd->cur_ptr, bytes_end); in dpaa2_console_read()
222 cd->cur_ptr = cd->start_addr; in dpaa2_console_read()
227 memcpy_fromio(kbuf, cd->cur_ptr, bytes); in dpaa2_console_read()
232 cd->cur_ptr += bytes; in dpaa2_console_read()