xref: /freebsd-src/sys/compat/linuxkpi/common/include/linux/devcoredump.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
129923feaSBjoern A. Zeeb /*-
229923feaSBjoern A. Zeeb  * SPDX-License-Identifier: BSD-2-Clause
329923feaSBjoern A. Zeeb  *
429923feaSBjoern A. Zeeb  * Copyright (c) 2020 The FreeBSD Foundation
529923feaSBjoern A. Zeeb  *
629923feaSBjoern A. Zeeb  * This software was developed by Björn Zeeb under sponsorship from
729923feaSBjoern A. Zeeb  * the FreeBSD Foundation.
829923feaSBjoern A. Zeeb  *
929923feaSBjoern A. Zeeb  * Redistribution and use in source and binary forms, with or without
1029923feaSBjoern A. Zeeb  * modification, are permitted provided that the following conditions
1129923feaSBjoern A. Zeeb  * are met:
1229923feaSBjoern A. Zeeb  * 1. Redistributions of source code must retain the above copyright
1329923feaSBjoern A. Zeeb  *    notice, this list of conditions and the following disclaimer.
1429923feaSBjoern A. Zeeb  * 2. Redistributions in binary form must reproduce the above copyright
1529923feaSBjoern A. Zeeb  *    notice, this list of conditions and the following disclaimer in the
1629923feaSBjoern A. Zeeb  *    documentation and/or other materials provided with the distribution.
1729923feaSBjoern A. Zeeb  *
1829923feaSBjoern A. Zeeb  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1929923feaSBjoern A. Zeeb  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2029923feaSBjoern A. Zeeb  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2129923feaSBjoern A. Zeeb  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2229923feaSBjoern A. Zeeb  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2329923feaSBjoern A. Zeeb  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2429923feaSBjoern A. Zeeb  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2529923feaSBjoern A. Zeeb  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2629923feaSBjoern A. Zeeb  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2729923feaSBjoern A. Zeeb  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2829923feaSBjoern A. Zeeb  * SUCH DAMAGE.
2929923feaSBjoern A. Zeeb  */
3029923feaSBjoern A. Zeeb 
31*307f78f3SVladimir Kondratyev #ifndef	_LINUXKPI_LINUX_DEVCOREDUMP_H
32*307f78f3SVladimir Kondratyev #define	_LINUXKPI_LINUX_DEVCOREDUMP_H
3329923feaSBjoern A. Zeeb 
3429923feaSBjoern A. Zeeb #include <linux/slab.h>
3529923feaSBjoern A. Zeeb #include <linux/scatterlist.h>
3629923feaSBjoern A. Zeeb #include <linux/device.h>
3729923feaSBjoern A. Zeeb 
3829923feaSBjoern A. Zeeb static inline void
_lkpi_dev_coredumpsg_free(struct scatterlist * table)3929923feaSBjoern A. Zeeb _lkpi_dev_coredumpsg_free(struct scatterlist *table)
4029923feaSBjoern A. Zeeb {
4129923feaSBjoern A. Zeeb 	struct scatterlist *iter;
4229923feaSBjoern A. Zeeb 	struct page *p;
4329923feaSBjoern A. Zeeb 	int i;
4429923feaSBjoern A. Zeeb 
4529923feaSBjoern A. Zeeb 	iter = table;
4629923feaSBjoern A. Zeeb 	for_each_sg(table, iter, sg_nents(table), i) {
4729923feaSBjoern A. Zeeb 		p = sg_page(iter);
4829923feaSBjoern A. Zeeb 		if (p)
4929923feaSBjoern A. Zeeb 			__free_page(p);
5029923feaSBjoern A. Zeeb 	}
5129923feaSBjoern A. Zeeb 
5229923feaSBjoern A. Zeeb 	/* XXX what about chained tables? */
5329923feaSBjoern A. Zeeb 	kfree(table);
5429923feaSBjoern A. Zeeb }
5529923feaSBjoern A. Zeeb 
5629923feaSBjoern A. Zeeb static inline void
dev_coredumpv(struct device * dev __unused,void * data,size_t datalen __unused,gfp_t gfp __unused)5729923feaSBjoern A. Zeeb dev_coredumpv(struct device *dev __unused, void *data, size_t datalen __unused,
5829923feaSBjoern A. Zeeb     gfp_t gfp __unused)
5929923feaSBjoern A. Zeeb {
6029923feaSBjoern A. Zeeb 
6129923feaSBjoern A. Zeeb 	/* UNIMPLEMENTED */
6229923feaSBjoern A. Zeeb 	vfree(data);
6329923feaSBjoern A. Zeeb }
6429923feaSBjoern A. Zeeb 
6529923feaSBjoern A. Zeeb static inline void
dev_coredumpsg(struct device * dev __unused,struct scatterlist * table,size_t datalen __unused,gfp_t gfp __unused)6629923feaSBjoern A. Zeeb dev_coredumpsg(struct device *dev __unused, struct scatterlist *table,
6729923feaSBjoern A. Zeeb     size_t datalen __unused, gfp_t gfp __unused)
6829923feaSBjoern A. Zeeb {
6929923feaSBjoern A. Zeeb 
7029923feaSBjoern A. Zeeb 	/* UNIMPLEMENTED */
7129923feaSBjoern A. Zeeb 	_lkpi_dev_coredumpsg_free(table);
7229923feaSBjoern A. Zeeb }
7329923feaSBjoern A. Zeeb 
74*307f78f3SVladimir Kondratyev #endif	/* _LINUXKPI_LINUX_DEVCOREDUMP_H */
75