2017-05-30 03:38:38 +02:00
|
|
|
/*
|
2022-10-27 17:08:58 -04:00
|
|
|
* 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.
|
2017-05-30 03:38:38 +02:00
|
|
|
*
|
2022-10-27 17:08:58 -04:00
|
|
|
* This file is part of the 86Box distribution.
|
2017-05-30 03:38:38 +02:00
|
|
|
*
|
2022-10-27 17:08:58 -04:00
|
|
|
* Definitions for the device handler.
|
2017-05-30 03:38:38 +02:00
|
|
|
*
|
2020-03-25 00:46:02 +02:00
|
|
|
*
|
2017-05-30 03:38:38 +02:00
|
|
|
*
|
2022-10-27 17:08:58 -04: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
|
|
|
*
|
2022-10-27 17:08:58 -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.
|
2018-03-19 01:02:04 +01:00
|
|
|
*
|
|
|
|
|
* 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.
|
2017-05-30 03:38:38 +02:00
|
|
|
*/
|
2017-06-04 02:11:19 -04:00
|
|
|
#ifndef EMU_DEVICE_H
|
2022-07-27 17:00:34 -04:00
|
|
|
#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 */
|
2017-06-04 02:11:19 -04:00
|
|
|
|
2017-10-07 00:46:54 -04:00
|
|
|
enum {
|
2023-04-19 23:34:32 +02:00
|
|
|
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-04-19 23:34:32 +02:00
|
|
|
|
2023-10-15 19:47:29 +02:00
|
|
|
DEVICE_ONBOARD = 0x20000000, /* is on-board */
|
2023-04-19 23:34:32 +02:00
|
|
|
DEVICE_EXTPARAMS = 0x40000000, /* accepts extended parameters */
|
|
|
|
|
|
2023-10-20 02:57:50 +02:00
|
|
|
DEVICE_PIT = 0x80000000, /* device is a PIT */
|
|
|
|
|
|
2023-04-19 23:34:32 +02:00
|
|
|
DEVICE_ALL = 0xffffffff /* match all devices */
|
2017-06-04 02:11:19 -04:00
|
|
|
};
|
|
|
|
|
|
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 {
|
2018-02-18 10:32:51 +01:00
|
|
|
const char *description;
|
2022-07-27 17:00:34 -04:00
|
|
|
int value;
|
2016-06-26 00:34:39 +02:00
|
|
|
} device_config_selection_t;
|
|
|
|
|
|
2023-06-28 13:46:28 -04:00
|
|
|
typedef struct device_config_bios_t {
|
2022-07-27 17:00:34 -04:00
|
|
|
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;
|
2022-12-22 02:30:25 +01:00
|
|
|
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 {
|
2020-11-16 00:01:21 +01:00
|
|
|
int16_t min;
|
|
|
|
|
int16_t max;
|
|
|
|
|
int16_t step;
|
2017-08-07 22:57:11 +02:00
|
|
|
} device_config_spinner_t;
|
|
|
|
|
|
2023-06-28 13:46:28 -04:00
|
|
|
typedef struct device_config_t {
|
2022-07-27 17:00:34 -04:00
|
|
|
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];
|
2016-06-26 00:34:39 +02:00
|
|
|
} device_config_t;
|
|
|
|
|
|
2017-10-07 00:46:54 -04:00
|
|
|
typedef struct _device_ {
|
2022-07-27 17:00:34 -04:00
|
|
|
const char *name;
|
2022-01-13 21:06:11 -05:00
|
|
|
const char *internal_name;
|
2022-07-27 17:00:34 -04:00
|
|
|
uint32_t flags; /* system flags */
|
2023-02-19 22:49:30 +06:00
|
|
|
uintptr_t local; /* flags local to device */
|
2017-10-07 00:46:54 -04:00
|
|
|
|
2023-02-19 22:49:30 +06:00
|
|
|
union {
|
|
|
|
|
void *(*init)(const struct _device_ *);
|
|
|
|
|
void *(*init_ext)(const struct _device_ *, void*);
|
|
|
|
|
};
|
2022-07-27 17:00:34 -04:00
|
|
|
void (*close)(void *priv);
|
|
|
|
|
void (*reset)(void *priv);
|
2020-11-16 00:01:21 +01:00
|
|
|
union {
|
2022-07-27 17:00:34 -04:00
|
|
|
int (*available)(void);
|
2023-08-11 22:29:53 +02:00
|
|
|
int (*poll)(void *priv);
|
2020-11-16 00:01:21 +01:00
|
|
|
};
|
2022-07-27 17:00:34 -04:00
|
|
|
void (*speed_changed)(void *priv);
|
|
|
|
|
void (*force_redraw)(void *priv);
|
2017-10-07 00:46:54 -04:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
const device_config_t *config;
|
2016-06-26 00:34:39 +02:00
|
|
|
} device_t;
|
|
|
|
|
|
2023-06-28 13:46:28 -04:00
|
|
|
typedef struct device_context_t {
|
2022-07-27 17:00:34 -04:00
|
|
|
const device_t *dev;
|
|
|
|
|
char name[2048];
|
2023-02-14 20:37:58 -05:00
|
|
|
int instance;
|
2018-10-23 21:14:41 +02:00
|
|
|
} device_context_t;
|
|
|
|
|
|
2017-10-16 04:54:41 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-07-27 17:00:34 -04:00
|
|
|
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);
|
2022-07-27 17:00:34 -04:00
|
|
|
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);
|
2022-07-27 17:00:34 -04:00
|
|
|
extern void device_close_all(void);
|
2023-04-19 23:34:32 +02:00
|
|
|
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);
|
2022-07-27 17:00:34 -04:00
|
|
|
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);
|
2022-07-27 17:00:34 -04:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2022-07-27 17:00:34 -04:00
|
|
|
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);
|
2022-07-27 17:00:34 -04:00
|
|
|
#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);
|
2022-07-27 17:00:34 -04:00
|
|
|
|
|
|
|
|
extern int machine_get_config_int(char *s);
|
|
|
|
|
extern char *machine_get_config_string(char *s);
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2017-10-16 04:54:41 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-07-27 17:00:34 -04:00
|
|
|
#endif /*EMU_DEVICE_H*/
|