Files
86Box/src/include/86box/device.h

230 lines
9.1 KiB
C
Raw Normal View History

/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Definitions for the device handler.
*
2020-03-25 00:46:02 +02:00
*
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
2023-01-06 15:36:29 -05:00
* Sarah Walker, <https://pcem-emulator.co.uk/>
2017-10-16 04:54:41 -04:00
*
* Copyright 2017-2019 Fred N. van Kempen.
* Copyright 2016-2019 Miran Grca.
* Copyright 2008-2019 Sarah Walker.
2023-02-14 20:37:58 -05:00
* Copyright 2021 Andreas J. Reichel.
* Copyright 2021-2022 Jasmine Iwanek.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the:
*
* Free Software Foundation, Inc.
* 59 Temple Place - Suite 330
* Boston, MA 02111-1307
* USA.
*/
#ifndef EMU_DEVICE_H
#define EMU_DEVICE_H
2023-10-15 19:47:29 +02:00
#define CONFIG_END -1
#define CONFIG_STRING 0
#define CONFIG_INT 1
#define CONFIG_BINARY 2
#define CONFIG_SELECTION 3
#define CONFIG_MIDI_OUT 4
#define CONFIG_FNAME 5
#define CONFIG_SPINNER 6
#define CONFIG_HEX16 7
#define CONFIG_HEX20 8
#define CONFIG_MAC 9
#define CONFIG_MIDI_IN 10
#define CONFIG_BIOS 11
#define CONFIG_SERPORT 12
#define CONFIG_ONBOARD 256 /* only avaialble on the on-board variant */
#define CONFIG_STANDALONE 257 /* not available on the on-board variant */
enum {
DEVICE_PCJR = 2, /* requires an IBM PCjr */
2023-08-15 01:27:16 +02:00
DEVICE_XTKBC = 4, /* requires an XT-compatible keyboard controller */
DEVICE_AT = 8, /* requires an AT-compatible system */
DEVICE_ATKBC = 0x10, /* requires an AT-compatible keyboard controller */
DEVICE_PS2 = 0x20, /* requires a PS/1 or PS/2 system */
DEVICE_ISA = 0x40, /* requires the ISA bus */
DEVICE_CBUS = 0x80, /* requires the C-BUS bus */
DEVICE_PCMCIA = 0x100, /* requires the PCMCIA bus */
DEVICE_MCA = 0x200, /* requires the MCA bus */
DEVICE_HIL = 0x400, /* requires the HP HIL bus */
DEVICE_EISA = 0x800, /* requires the EISA bus */
2023-10-15 19:47:29 +02:00
DEVICE_AT32 = 0x1000, /* requires the Mylex AT/32 local bus */
DEVICE_OLB = 0x2000, /* requires the OPTi local bus */
DEVICE_VLB = 0x4000, /* requires the VLB bus */
DEVICE_PCI = 0x8000, /* requires the PCI bus */
DEVICE_CARDBUS = 0x10000, /* requires the CardBus bus */
DEVICE_USB = 0x20000, /* requires the USB bus */
DEVICE_AGP = 0x40000, /* requires the AGP bus */
DEVICE_AC97 = 0x80000, /* requires the AC'97 bus */
DEVICE_COM = 0x100000, /* requires a serial port */
DEVICE_LPT = 0x200000, /* requires a parallel port */
DEVICE_KBC = 0x400000, /* is a keyboard controller */
2023-10-15 19:47:29 +02:00
DEVICE_ONBOARD = 0x20000000, /* is on-board */
DEVICE_EXTPARAMS = 0x40000000, /* accepts extended parameters */
2023-10-20 02:57:50 +02:00
DEVICE_PIT = 0x80000000, /* device is a PIT */
DEVICE_ALL = 0xffffffff /* match all devices */
};
2022-09-18 17:15:38 -04:00
#define BIOS_NORMAL 0
#define BIOS_INTERLEAVED 1
#define BIOS_INTERLEAVED_SINGLEFILE 2
#define BIOS_INTERLEAVED_QUAD 3
#define BIOS_INTERLEAVED_QUAD_SINGLEFILE 4
#define BIOS_INTEL_AMI 5
#define BIOS_INTERLEAVED_INVERT 8
#define BIOS_HIGH_BIT_INVERT 16
2022-07-30 23:42:41 +02:00
2023-06-28 13:46:28 -04:00
typedef struct device_config_selection_t {
const char *description;
int value;
} device_config_selection_t;
2023-06-28 13:46:28 -04:00
typedef struct device_config_bios_t {
const char *name;
const char *internal_name;
int bios_type;
int files_no;
2023-06-26 12:47:04 -04:00
uint32_t local;
uint32_t size;
void *dev1;
void *dev2;
const char *files[9];
2022-07-23 00:00:03 -04:00
} device_config_bios_t;
2023-06-28 13:46:28 -04:00
typedef struct device_config_spinner_t {
WARNING: CONFIGS MIGHT PARTIALLY BREAK WHERE DEVICE NAMES HAVE CHANGED. Changes to device_t struct to accomodate the upcoming PCI IRQ arbitration rewrite; Added device.c/h API to obtain name from the device_t struct; Significant changes to win/win_settings.c to clean up the code a bit and fix bugs; Ported all the CPU and AudioPCI commits from PCem; Added an API call to allow ACPI soft power off to gracefully stop the emulator; Removed the Siemens PCD-2L from the Dev branch because it now works; Removed the Socket 5 HP Vectra from the Dev branch because it now works; Fixed the Compaq Presario and the Micronics Spitfire; Give the IBM PC330 its own list of 486 CPU so it can have DX2's with CPUID 0x470; SMM fixes; Rewrote the SYSENTER, SYSEXIT, SYSCALL, and SYSRET instructions; Changed IDE reset period to match the specification, fixes #929; The keyboard input and output ports are now forced in front of the queue when read, fixes a number of bugs, including the AMI Apollo hanging on soft reset; Added the Intel AN430TX but Dev branched because it does not work; The network code no longer drops packets if the emulated network card has failed to receive them (eg. when the buffer is full); Changes to PCI card adding and renamed some PCI slot types, also added proper AGP bridge slot types; USB UHCI emulation is no longer a stub (still doesn't fully work, but at least Windows XP chk with Debug no longer ASSERT's on it); Fixed NVR on the the SMC FDC37C932QF and APM variants; A number of fixes to Intel 4x0 chipsets, including fixing every register of the 440LX and 440EX; Some ACPI changes.
2020-11-16 00:01:21 +01:00
int16_t min;
int16_t max;
int16_t step;
} device_config_spinner_t;
2023-06-28 13:46:28 -04:00
typedef struct device_config_t {
const char *name;
const char *description;
int type;
const char *default_string;
int default_int;
const char *file_filter;
const device_config_spinner_t spinner;
2023-02-14 20:37:58 -05:00
const device_config_selection_t selection[32];
2023-01-04 06:25:33 -05:00
const device_config_bios_t bios[32];
} device_config_t;
typedef struct _device_ {
const char *name;
const char *internal_name;
uint32_t flags; /* system flags */
uintptr_t local; /* flags local to device */
union {
void *(*init)(const struct _device_ *);
void *(*init_ext)(const struct _device_ *, void*);
};
void (*close)(void *priv);
void (*reset)(void *priv);
WARNING: CONFIGS MIGHT PARTIALLY BREAK WHERE DEVICE NAMES HAVE CHANGED. Changes to device_t struct to accomodate the upcoming PCI IRQ arbitration rewrite; Added device.c/h API to obtain name from the device_t struct; Significant changes to win/win_settings.c to clean up the code a bit and fix bugs; Ported all the CPU and AudioPCI commits from PCem; Added an API call to allow ACPI soft power off to gracefully stop the emulator; Removed the Siemens PCD-2L from the Dev branch because it now works; Removed the Socket 5 HP Vectra from the Dev branch because it now works; Fixed the Compaq Presario and the Micronics Spitfire; Give the IBM PC330 its own list of 486 CPU so it can have DX2's with CPUID 0x470; SMM fixes; Rewrote the SYSENTER, SYSEXIT, SYSCALL, and SYSRET instructions; Changed IDE reset period to match the specification, fixes #929; The keyboard input and output ports are now forced in front of the queue when read, fixes a number of bugs, including the AMI Apollo hanging on soft reset; Added the Intel AN430TX but Dev branched because it does not work; The network code no longer drops packets if the emulated network card has failed to receive them (eg. when the buffer is full); Changes to PCI card adding and renamed some PCI slot types, also added proper AGP bridge slot types; USB UHCI emulation is no longer a stub (still doesn't fully work, but at least Windows XP chk with Debug no longer ASSERT's on it); Fixed NVR on the the SMC FDC37C932QF and APM variants; A number of fixes to Intel 4x0 chipsets, including fixing every register of the 440LX and 440EX; Some ACPI changes.
2020-11-16 00:01:21 +01:00
union {
int (*available)(void);
2023-08-11 22:29:53 +02:00
int (*poll)(void *priv);
WARNING: CONFIGS MIGHT PARTIALLY BREAK WHERE DEVICE NAMES HAVE CHANGED. Changes to device_t struct to accomodate the upcoming PCI IRQ arbitration rewrite; Added device.c/h API to obtain name from the device_t struct; Significant changes to win/win_settings.c to clean up the code a bit and fix bugs; Ported all the CPU and AudioPCI commits from PCem; Added an API call to allow ACPI soft power off to gracefully stop the emulator; Removed the Siemens PCD-2L from the Dev branch because it now works; Removed the Socket 5 HP Vectra from the Dev branch because it now works; Fixed the Compaq Presario and the Micronics Spitfire; Give the IBM PC330 its own list of 486 CPU so it can have DX2's with CPUID 0x470; SMM fixes; Rewrote the SYSENTER, SYSEXIT, SYSCALL, and SYSRET instructions; Changed IDE reset period to match the specification, fixes #929; The keyboard input and output ports are now forced in front of the queue when read, fixes a number of bugs, including the AMI Apollo hanging on soft reset; Added the Intel AN430TX but Dev branched because it does not work; The network code no longer drops packets if the emulated network card has failed to receive them (eg. when the buffer is full); Changes to PCI card adding and renamed some PCI slot types, also added proper AGP bridge slot types; USB UHCI emulation is no longer a stub (still doesn't fully work, but at least Windows XP chk with Debug no longer ASSERT's on it); Fixed NVR on the the SMC FDC37C932QF and APM variants; A number of fixes to Intel 4x0 chipsets, including fixing every register of the 440LX and 440EX; Some ACPI changes.
2020-11-16 00:01:21 +01:00
};
void (*speed_changed)(void *priv);
void (*force_redraw)(void *priv);
const device_config_t *config;
} device_t;
2023-06-28 13:46:28 -04:00
typedef struct device_context_t {
const device_t *dev;
char name[2048];
2023-02-14 20:37:58 -05:00
int instance;
} device_context_t;
2017-10-16 04:54:41 -04:00
#ifdef __cplusplus
extern "C" {
#endif
extern void device_init(void);
2023-08-21 20:26:11 -04:00
extern void device_set_context(device_context_t *c, const device_t *dev, int inst);
extern void device_context(const device_t *dev);
extern void device_context_inst(const device_t *dev, int inst);
extern void device_context_restore(void);
extern void *device_add(const device_t *d);
2023-08-21 20:26:11 -04:00
extern void *device_add_parameters(const device_t *dev, void *params);
extern void device_add_ex(const device_t *dev, void *priv);
extern void device_add_ex_parameters(const device_t *dev, void *priv, void *params);
extern void *device_add_inst(const device_t *dev, int inst);
extern void *device_add_inst_parameters(const device_t *dev, int inst, void *params);
extern void device_add_inst_ex(const device_t *dev, void *priv, int inst);
extern void device_add_inst_ex_parameters(const device_t *dev, void *priv, int inst, void *params);
extern void *device_cadd(const device_t *dev, const device_t *cd);
extern void *device_cadd_parameters(const device_t *dev, const device_t *cd, void *params);
extern void device_cadd_ex(const device_t *dev, const device_t *cd, void *priv);
extern void device_cadd_ex_parameters(const device_t *dev, const device_t *cd, void *priv, void *params);
extern void *device_cadd_inst(const device_t *dev, const device_t *cd, int inst);
extern void *device_cadd_inst_parameters(const device_t *dev, const device_t *cd, int inst, void *params);
extern void device_cadd_inst_ex(const device_t *dev, const device_t *cd, void *priv, int inst);
extern void device_cadd_inst_ex_parameters(const device_t *dev, const device_t *cd, void *priv, int inst, void *params);
extern void device_close_all(void);
extern void device_reset_all(uint32_t match_flags);
2023-10-20 02:57:50 +02:00
extern void *device_find_first_priv(uint32_t match_flags);
2023-08-21 20:26:11 -04:00
extern void *device_get_priv(const device_t *dev);
extern int device_available(const device_t *dev);
extern int device_poll(const device_t *dev);
extern void device_speed_changed(void);
extern void device_force_redraw(void);
2023-08-21 20:26:11 -04:00
extern void device_get_name(const device_t *dev, int bus, char *name);
extern int device_has_config(const device_t *dev);
extern const char *device_get_bios_file(const device_t *dev, const char *internal_name, int file_no);
extern int device_is_valid(const device_t *, int m);
2024-01-10 01:26:50 +06:00
extern const device_t* device_context_get_device(void);
extern int device_get_config_int(const char *name);
extern int device_get_config_int_ex(const char *s, int dflt_int);
extern int device_get_config_hex16(const char *name);
extern int device_get_config_hex20(const char *name);
extern int device_get_config_mac(const char *name, int dflt_int);
extern void device_set_config_int(const char *s, int val);
extern void device_set_config_hex16(const char *s, int val);
extern void device_set_config_hex20(const char *s, int val);
extern void device_set_config_mac(const char *s, int val);
extern const char *device_get_config_string(const char *name);
2023-02-14 20:37:58 -05:00
extern const int device_get_instance(void);
#define device_get_config_bios device_get_config_string
2023-08-21 20:26:11 -04:00
extern const char *device_get_internal_name(const device_t *dev);
extern int machine_get_config_int(char *s);
extern char *machine_get_config_string(char *s);
2017-10-16 04:54:41 -04:00
#ifdef __cplusplus
}
#endif
#endif /*EMU_DEVICE_H*/