From: dv Date: Wed, 16 Jun 2021 16:55:02 +0000 (+0000) Subject: cleanup vmd(8) includes and header files X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6eb4c859e9b6a4a1acf9b5c55557502f5d149733;p=openbsd cleanup vmd(8) includes and header files Lots of organic growth other the years lead to unnecessary includes (proc.h everywhere) and odd dependencies between header files. This cleans things up a bit to help with upcoming cleanup around dhcp code. No functional change. "go for it" mlarkin@ --- diff --git a/usr.sbin/vmd/atomicio.h b/usr.sbin/vmd/atomicio.h index f2c902d377c..1e05973d370 100644 --- a/usr.sbin/vmd/atomicio.h +++ b/usr.sbin/vmd/atomicio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomicio.h,v 1.1 2017/05/08 09:08:40 reyk Exp $ */ +/* $OpenBSD: atomicio.h,v 1.2 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2006 Damien Miller. All rights reserved. @@ -26,6 +26,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include + #ifndef _ATOMICIO_H #define _ATOMICIO_H diff --git a/usr.sbin/vmd/control.c b/usr.sbin/vmd/control.c index ceaf85dd65e..7a1f453be4e 100644 --- a/usr.sbin/vmd/control.c +++ b/usr.sbin/vmd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.36 2021/06/10 19:50:05 dv Exp $ */ +/* $OpenBSD: control.c,v 1.37 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2010-2015 Reyk Floeter @@ -29,10 +29,10 @@ #include #include #include +#include #include #include #include -#include #include "proc.h" #include "vmd.h" diff --git a/usr.sbin/vmd/dhcp.c b/usr.sbin/vmd/dhcp.c index 1288335bcd5..7d7d8d02a26 100644 --- a/usr.sbin/vmd/dhcp.c +++ b/usr.sbin/vmd/dhcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcp.c,v 1.10 2021/06/08 14:37:48 dv Exp $ */ +/* $OpenBSD: dhcp.c,v 1.11 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2017 Reyk Floeter @@ -31,10 +31,9 @@ #include #include -#include "proc.h" -#include "vmd.h" #include "dhcp.h" #include "virtio.h" +#include "vmd.h" #define OPTIONS_OFFSET offsetof(struct dhcp_packet, options) #define OPTIONS_MAX_LEN \ diff --git a/usr.sbin/vmd/fw_cfg.c b/usr.sbin/vmd/fw_cfg.c index 385889fc700..fb4379c8956 100644 --- a/usr.sbin/vmd/fw_cfg.c +++ b/usr.sbin/vmd/fw_cfg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fw_cfg.c,v 1.2 2019/10/11 15:25:40 jsg Exp $ */ +/* $OpenBSD: fw_cfg.c,v 1.3 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2018 Claudio Jeker * @@ -23,7 +23,6 @@ #include #include "atomicio.h" -#include "proc.h" #include "vmd.h" #include "vmm.h" #include "fw_cfg.h" diff --git a/usr.sbin/vmd/fw_cfg.h b/usr.sbin/vmd/fw_cfg.h index d120254280e..a51561bef88 100644 --- a/usr.sbin/vmd/fw_cfg.h +++ b/usr.sbin/vmd/fw_cfg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fw_cfg.h,v 1.1 2018/12/10 21:30:33 claudio Exp $ */ +/* $OpenBSD: fw_cfg.h,v 1.2 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2018 Claudio Jeker * @@ -15,6 +15,11 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "vmd.h" + +#ifndef _FW_CFG_H_ +#define _FW_CFG_H_ + #define FW_CFG_IO_SELECT 0x510 #define FW_CFG_IO_DATA 0x511 #define FW_CFG_IO_DMA_ADDR_HIGH 0x514 @@ -26,3 +31,5 @@ int fw_cfg_restore(int); uint8_t vcpu_exit_fw_cfg(struct vm_run_params *); uint8_t vcpu_exit_fw_cfg_dma(struct vm_run_params *); void fw_cfg_add_file(const char *, const void *, size_t); + +#endif /* _FW_CFG_H_ */ diff --git a/usr.sbin/vmd/i8253.c b/usr.sbin/vmd/i8253.c index 24619ab363b..a745adf6ea0 100644 --- a/usr.sbin/vmd/i8253.c +++ b/usr.sbin/vmd/i8253.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i8253.c,v 1.33 2021/03/29 13:09:41 dv Exp $ */ +/* $OpenBSD: i8253.c,v 1.34 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2016 Mike Larkin * @@ -29,7 +29,6 @@ #include #include "i8253.h" -#include "proc.h" #include "vmd.h" #include "vmm.h" #include "atomicio.h" diff --git a/usr.sbin/vmd/i8259.c b/usr.sbin/vmd/i8259.c index deb731422c9..0b5579dc95c 100644 --- a/usr.sbin/vmd/i8259.c +++ b/usr.sbin/vmd/i8259.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i8259.c,v 1.19 2018/07/12 10:15:44 mlarkin Exp $ */ +/* $OpenBSD: i8259.c,v 1.20 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2016 Mike Larkin * @@ -25,11 +25,11 @@ #include #include -#include "proc.h" -#include "i8259.h" -#include "vmm.h" + #include "atomicio.h" +#include "i8259.h" #include "vmd.h" +#include "vmm.h" struct i8259 { uint8_t irr; diff --git a/usr.sbin/vmd/loadfile.h b/usr.sbin/vmd/loadfile.h index fcc74642f5e..0630c9bd0ee 100644 --- a/usr.sbin/vmd/loadfile.h +++ b/usr.sbin/vmd/loadfile.h @@ -1,5 +1,5 @@ /* $NetBSD: loadfile.h,v 1.1 1999/04/28 09:08:50 christos Exp $ */ -/* $OpenBSD: loadfile.h,v 1.14 2021/04/05 18:09:48 dv Exp $ */ +/* $OpenBSD: loadfile.h,v 1.15 2021/06/16 16:55:02 dv Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -32,6 +32,11 @@ #include +#include "vmd.h" + +#ifndef _LOADFILE_H_ +#define _LOADFILE_H_ + /* * Array indices in the u_long position array */ @@ -78,3 +83,5 @@ int loadfile_elf(gzFile, struct vm_create_params *, struct vcpu_reg_state *); size_t mread(gzFile, paddr_t, size_t); + +#endif /* _LOADFILE_H_ */ diff --git a/usr.sbin/vmd/mc146818.c b/usr.sbin/vmd/mc146818.c index 311dc0c2caa..e3599c68504 100644 --- a/usr.sbin/vmd/mc146818.c +++ b/usr.sbin/vmd/mc146818.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mc146818.c,v 1.23 2021/03/29 13:09:41 dv Exp $ */ +/* $OpenBSD: mc146818.c,v 1.24 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2016 Mike Larkin * @@ -28,12 +28,11 @@ #include #include -#include "vmd.h" +#include "atomicio.h" #include "mc146818.h" -#include "proc.h" #include "virtio.h" +#include "vmd.h" #include "vmm.h" -#include "atomicio.h" #define MC_DIVIDER_MASK 0xe0 #define MC_RATE_MASK 0xf diff --git a/usr.sbin/vmd/ns8250.c b/usr.sbin/vmd/ns8250.c index 24ab70f9a06..6285743c242 100644 --- a/usr.sbin/vmd/ns8250.c +++ b/usr.sbin/vmd/ns8250.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ns8250.c,v 1.30 2021/03/29 13:09:41 dv Exp $ */ +/* $OpenBSD: ns8250.c,v 1.31 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2016 Mike Larkin * @@ -28,11 +28,10 @@ #include #include +#include "atomicio.h" #include "ns8250.h" -#include "proc.h" #include "vmd.h" #include "vmm.h" -#include "atomicio.h" extern char *__progname; struct ns8250_dev com1_dev; diff --git a/usr.sbin/vmd/packet.c b/usr.sbin/vmd/packet.c index 645015fe450..0b9562a7297 100644 --- a/usr.sbin/vmd/packet.c +++ b/usr.sbin/vmd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.3 2021/06/15 10:38:53 claudio Exp $ */ +/* $OpenBSD: packet.c,v 1.4 2021/06/16 16:55:02 dv Exp $ */ /* Packet assembly code, originally contributed by Archie Cobbs. */ @@ -57,7 +57,6 @@ #include "dhcp.h" #include "vmd.h" -#include "proc.h" u_int32_t checksum(unsigned char *, u_int32_t, u_int32_t); u_int32_t wrapsum(u_int32_t); diff --git a/usr.sbin/vmd/parse.y b/usr.sbin/vmd/parse.y index 52815e028e8..896e5c11b04 100644 --- a/usr.sbin/vmd/parse.y +++ b/usr.sbin/vmd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.57 2021/06/02 14:40:46 dv Exp $ */ +/* $OpenBSD: parse.y,v 1.58 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2007-2016 Reyk Floeter @@ -49,7 +49,6 @@ #include #include -#include "proc.h" #include "vmd.h" TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files); @@ -326,7 +325,7 @@ vm : VM string vm_instance { free($3); YYERROR; } - + free($2); name = $3; vmc.vmc_flags |= VMOP_CREATE_INSTANCE; diff --git a/usr.sbin/vmd/pci.c b/usr.sbin/vmd/pci.c index 954235eb63f..e2ec4ed3559 100644 --- a/usr.sbin/vmd/pci.c +++ b/usr.sbin/vmd/pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci.c,v 1.28 2019/10/16 02:47:34 mlarkin Exp $ */ +/* $OpenBSD: pci.c,v 1.29 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -25,6 +25,7 @@ #include #include + #include "vmd.h" #include "pci.h" #include "vmm.h" diff --git a/usr.sbin/vmd/pci.h b/usr.sbin/vmd/pci.h index 08fb6c650c6..ed6ba534536 100644 --- a/usr.sbin/vmd/pci.h +++ b/usr.sbin/vmd/pci.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci.h,v 1.8 2020/09/08 20:09:43 kettenis Exp $ */ +/* $OpenBSD: pci.h,v 1.9 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -16,6 +16,15 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include + +#include + +#include "vmd.h" + +#ifndef _PCI_H_ +#define _PCI_H_ + #define PCI_MODE1_ENABLE 0x80000000UL #define PCI_MODE1_ADDRESS_REG 0x0cf8 #define PCI_MODE1_DATA_REG 0x0cfc @@ -94,3 +103,5 @@ int pci_set_bar_fn(uint8_t, uint8_t, void *, void *); uint8_t pci_get_dev_irq(uint8_t); int pci_dump(int); int pci_restore(int); + +#endif /* _PCI_H_ */ diff --git a/usr.sbin/vmd/proc.h b/usr.sbin/vmd/proc.h index 2e49694a5ff..dba9972dd41 100644 --- a/usr.sbin/vmd/proc.h +++ b/usr.sbin/vmd/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.19 2021/04/20 21:11:56 dv Exp $ */ +/* $OpenBSD: proc.h,v 1.20 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2010-2015 Reyk Floeter @@ -16,12 +16,12 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include #include +#include #include -#include #include +#include #ifndef _PROC_H #define _PROC_H diff --git a/usr.sbin/vmd/vioqcow2.c b/usr.sbin/vmd/vioqcow2.c index cc08b98f3a3..cabe191ae74 100644 --- a/usr.sbin/vmd/vioqcow2.c +++ b/usr.sbin/vmd/vioqcow2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vioqcow2.c,v 1.15 2021/04/29 23:27:10 dv Exp $ */ +/* $OpenBSD: vioqcow2.c,v 1.16 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2018 Ori Bernstein @@ -19,20 +19,18 @@ #include #include -#include #include +#include -#include -#include -#include -#include #include -#include #include #include +#include +#include +#include +#include +#include -#include "vmd.h" -#include "vmm.h" #include "virtio.h" #define QCOW2_COMPRESSED 0x4000000000000000ull diff --git a/usr.sbin/vmd/vioraw.c b/usr.sbin/vmd/vioraw.c index de9ab65258c..27acd94062e 100644 --- a/usr.sbin/vmd/vioraw.c +++ b/usr.sbin/vmd/vioraw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vioraw.c,v 1.5 2018/11/26 10:39:30 reyk Exp $ */ +/* $OpenBSD: vioraw.c,v 1.6 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2018 Ori Bernstein * @@ -18,16 +18,11 @@ #include #include -#include -#include - #include #include #include #include -#include "vmd.h" -#include "vmm.h" #include "virtio.h" static ssize_t diff --git a/usr.sbin/vmd/vioscsi.c b/usr.sbin/vmd/vioscsi.c index 2263c2fbbe5..b21bb4cd32b 100644 --- a/usr.sbin/vmd/vioscsi.c +++ b/usr.sbin/vmd/vioscsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vioscsi.c,v 1.18 2021/05/18 11:06:43 dv Exp $ */ +/* $OpenBSD: vioscsi.c,v 1.19 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2017 Carlos Cardenas @@ -17,6 +17,7 @@ */ #include + #include #include #include diff --git a/usr.sbin/vmd/virtio.c b/usr.sbin/vmd/virtio.c index 1fbef46721d..dd2cabe2577 100644 --- a/usr.sbin/vmd/virtio.c +++ b/usr.sbin/vmd/virtio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio.c,v 1.88 2021/06/11 21:46:00 dv Exp $ */ +/* $OpenBSD: virtio.c,v 1.89 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -40,13 +40,12 @@ #include #include +#include "atomicio.h" #include "pci.h" +#include "vioscsi.h" +#include "virtio.h" #include "vmd.h" #include "vmm.h" -#include "virtio.h" -#include "vioscsi.h" -#include "loadfile.h" -#include "atomicio.h" extern char *__progname; struct viornd_dev viornd; diff --git a/usr.sbin/vmd/virtio.h b/usr.sbin/vmd/virtio.h index d39bc5c6672..e618d4ebc21 100644 --- a/usr.sbin/vmd/virtio.h +++ b/usr.sbin/vmd/virtio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio.h,v 1.38 2021/04/21 18:27:36 dv Exp $ */ +/* $OpenBSD: virtio.h,v 1.39 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -16,8 +16,17 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include + #include +#include + +#include "vmd.h" + +#ifndef _VIRTIO_H_ +#define _VIRTIO_H_ + #define VIRTQUEUE_ALIGN(n) (((n)+(VIRTIO_PAGE_SIZE-1))& \ ~(VIRTIO_PAGE_SIZE-1)) #define ALIGNSZ(sz, align) ((sz + align - 1) & ~(align - 1)) @@ -322,3 +331,5 @@ void vioscsi_update_qa(struct vioscsi_dev *); int vioscsi_notifyq(struct vioscsi_dev *); void virtio_stop(struct vm_create_params *vcp); void virtio_start(struct vm_create_params *vcp); + +#endif /* _VIRTIO_H_ */ diff --git a/usr.sbin/vmd/vm.c b/usr.sbin/vmd/vm.c index 58f441172a0..3d8a8751da9 100644 --- a/usr.sbin/vmd/vm.c +++ b/usr.sbin/vmd/vm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm.c,v 1.62 2021/04/05 18:09:48 dv Exp $ */ +/* $OpenBSD: vm.c,v 1.63 2021/06/16 16:55:02 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -52,18 +52,17 @@ #include #include -#include "vmd.h" -#include "vmm.h" -#include "loadfile.h" -#include "pci.h" -#include "virtio.h" -#include "proc.h" +#include "atomicio.h" +#include "fw_cfg.h" #include "i8253.h" #include "i8259.h" -#include "ns8250.h" +#include "loadfile.h" #include "mc146818.h" -#include "fw_cfg.h" -#include "atomicio.h" +#include "ns8250.h" +#include "pci.h" +#include "virtio.h" +#include "vmd.h" +#include "vmm.h" io_fn_t ioports_map[MAX_PORTS];