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@
This commit is contained in:
dv 2021-06-16 16:55:02 +00:00
parent 5bc2278e8d
commit 6eb4c859e9
21 changed files with 91 additions and 67 deletions

View File

@ -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 <sys/uio.h>
#ifndef _ATOMICIO_H
#define _ATOMICIO_H

View File

@ -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 <reyk@openbsd.org>
@ -29,10 +29,10 @@
#include <errno.h>
#include <event.h>
#include <fcntl.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include "proc.h"
#include "vmd.h"

View File

@ -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 <reyk@openbsd.org>
@ -31,10 +31,9 @@
#include <string.h>
#include <stddef.h>
#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 \

View File

@ -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 <claudio@openbsd.org>
*
@ -23,7 +23,6 @@
#include <unistd.h>
#include "atomicio.h"
#include "proc.h"
#include "vmd.h"
#include "vmm.h"
#include "fw_cfg.h"

View File

@ -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 <claudio@openbsd.org>
*
@ -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_ */

View File

@ -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 <mlarkin@openbsd.org>
*
@ -29,7 +29,6 @@
#include <unistd.h>
#include "i8253.h"
#include "proc.h"
#include "vmd.h"
#include "vmm.h"
#include "atomicio.h"

View File

@ -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 <mlarkin@openbsd.org>
*
@ -25,11 +25,11 @@
#include <unistd.h>
#include <pthread.h>
#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;

View File

@ -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 <zlib.h>
#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_ */

View File

@ -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 <mlarkin@openbsd.org>
*
@ -28,12 +28,11 @@
#include <time.h>
#include <unistd.h>
#include "vmd.h"
#include "mc146818.h"
#include "proc.h"
#include "virtio.h"
#include "vmm.h"
#include "atomicio.h"
#include "mc146818.h"
#include "virtio.h"
#include "vmd.h"
#include "vmm.h"
#define MC_DIVIDER_MASK 0xe0
#define MC_RATE_MASK 0xf

View File

@ -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 <mlarkin@openbsd.org>
*
@ -28,11 +28,10 @@
#include <string.h>
#include <unistd.h>
#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;

View File

@ -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);

View File

@ -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 <reyk@openbsd.org>
@ -49,7 +49,6 @@
#include <pwd.h>
#include <grp.h>
#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;

View File

@ -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 <mlarkin@openbsd.org>
@ -25,6 +25,7 @@
#include <string.h>
#include <unistd.h>
#include "vmd.h"
#include "pci.h"
#include "vmm.h"

View File

@ -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 <mlarkin@openbsd.org>
@ -16,6 +16,15 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <dev/pci/pcireg.h>
#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_ */

View File

@ -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 <reyk@openbsd.org>
@ -16,12 +16,12 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/socket.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <imsg.h>
#include <event.h>
#include <imsg.h>
#ifndef _PROC_H
#define _PROC_H

View File

@ -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 <ori@eigenstate.org>
@ -19,20 +19,18 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <machine/vmmvar.h>
#include <dev/pci/pcireg.h>
#include <machine/vmmvar.h>
#include <assert.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
#include <libgen.h>
#include <err.h>
#include <errno.h>
#include "vmd.h"
#include "vmm.h"
#include "virtio.h"
#define QCOW2_COMPRESSED 0x4000000000000000ull

View File

@ -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 <ori@eigenstate.org>
*
@ -18,16 +18,11 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <machine/vmmvar.h>
#include <dev/pci/pcireg.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "vmd.h"
#include "vmm.h"
#include "virtio.h"
static ssize_t

View File

@ -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 <ccardenas@openbsd.org>
@ -17,6 +17,7 @@
*/
#include <sys/types.h>
#include <dev/pci/virtio_pcireg.h>
#include <dev/pv/vioscsireg.h>
#include <scsi/scsi_all.h>

View File

@ -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 <mlarkin@openbsd.org>
@ -40,13 +40,12 @@
#include <string.h>
#include <unistd.h>
#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;

View File

@ -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 <mlarkin@openbsd.org>
@ -16,8 +16,17 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <dev/pv/virtioreg.h>
#include <event.h>
#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_ */

View File

@ -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 <mlarkin@openbsd.org>
@ -52,18 +52,17 @@
#include <unistd.h>
#include <util.h>
#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];