This commit is contained in:
OBattler
2025-05-29 09:45:58 +02:00
10 changed files with 83 additions and 77 deletions

View File

@@ -87,6 +87,14 @@ pci_bridge_set_ctl(void *priv, uint8_t ctl)
dev->ctl = ctl;
}
uint8_t
pci_bridge_get_bus_index(void *priv)
{
pci_bridge_t *dev = (pci_bridge_t *) priv;
return dev->bus_index;
}
static void
pci_bridge_write(int func, int addr, uint8_t val, void *priv)
{
@@ -513,11 +521,9 @@ static void *
pci_bridge_init(const device_t *info)
{
uint8_t interrupts[4];
uint8_t interrupt_count;
uint8_t interrupt_mask;
uint8_t add_type;
uint8_t slot_count;
uint8_t dell_slots[3] = { 0x09, 0x0a, 0x0b };
uint8_t dell_interrupts[3][4] = { { 1, 2, 3, 4 }, { 4, 2, 1, 3 }, { 1, 3, 4, 2 } };
pci_bridge_t *dev = (pci_bridge_t *) calloc(1, sizeof(pci_bridge_t));
@@ -527,40 +533,35 @@ pci_bridge_init(const device_t *info)
pci_bridge_reset(dev);
if (info->local == PCI_BRIDGE_DEC_21152)
pci_add_card(PCI_ADD_BRIDGE, pci_bridge_read, pci_bridge_write, dev, &dev->slot);
else
pci_add_bridge(AGP_BRIDGE(dev->local), pci_bridge_read, pci_bridge_write, dev, &dev->slot);
interrupt_count = sizeof(interrupts);
interrupt_mask = interrupt_count - 1;
interrupt_mask = sizeof(interrupts) - 1;
if (dev->slot < 32) {
for (uint8_t i = 0; i < interrupt_count; i++)
for (uint8_t i = 0; i <= interrupt_mask; i++)
interrupts[i] = pci_get_int(dev->slot, PCI_INTA + i);
}
pci_bridge_log("PCI Bridge %d: upstream bus %02X slot %02X interrupts %02X %02X %02X %02X\n",
dev->bus_index, (dev->slot >> 5) & 0xff, dev->slot & 31, interrupts[0],
interrupts[1], interrupts[2], interrupts[3]);
if (info->local == PCI_BRIDGE_DEC_21150)
if (info->local == PCI_BRIDGE_DEC_21150) {
slot_count = 9; /* 9 bus masters */
else if (info->local == PCI_BRIDGE_DEC_21152)
slot_count = 3; /* 3 bus masters */
else
add_type = PCI_ADD_NORMAL;
} else if (info->local == PCI_BRIDGE_DEC_21152) {
slot_count = 0; /* 4 bus masters, but slots are added by the Dell machines */
add_type = PCI_ADD_BRIDGE;
} else {
slot_count = 1; /* AGP bridges always have 1 slot */
add_type = PCI_ADD_AGPBRIDGE;
}
pci_add_bridge(add_type, pci_bridge_read, pci_bridge_write, dev, &dev->slot);
for (uint8_t i = 0; i < slot_count; i++) {
uint8_t slot = i;
if (info->local == PCI_BRIDGE_DEC_21152) {
slot = dell_slots[i];
memcpy(interrupts, dell_interrupts[i], 4);
}
/* Interrupts for bridge slots are assigned in round-robin: ABCD, BCDA, CDAB and so on. */
pci_bridge_log("PCI Bridge %d: downstream slot %02X interrupts %02X %02X %02X %02X\n",
dev->bus_index, slot, interrupts[i & interrupt_mask],
dev->bus_index, i, interrupts[i & interrupt_mask],
interrupts[(i + 1) & interrupt_mask], interrupts[(i + 2) & interrupt_mask],
interrupts[(i + 3) & interrupt_mask]);
pci_register_bus_slot(dev->bus_index, slot, AGP_BRIDGE(dev->local) ? PCI_CARD_AGP : PCI_CARD_NORMAL,
pci_register_bus_slot(dev->bus_index, i, AGP_BRIDGE(dev->local) ? PCI_CARD_AGP : PCI_CARD_NORMAL,
interrupts[i & interrupt_mask],
interrupts[(i + 1) & interrupt_mask],
interrupts[(i + 2) & interrupt_mask],

View File

@@ -36,6 +36,7 @@ static uint16_t postcard_port;
static uint8_t postcard_written[POSTCARDS_NUM];
static uint8_t postcard_ports_num = 1;
static uint8_t postcard_prev_codes[POSTCARDS_NUM];
static uint8_t postcard_dell_mode = 0;
static char postcard_prev_diags[5] = { 0 };
#define UISTR_LEN 32
static char postcard_str[UISTR_LEN]; /* UI output string */
@@ -99,31 +100,23 @@ postcard_setui(void)
ps[1][0], ps[1][1], ps[1][2], ps[1][3]);
break;
}
} else if (strstr(machines[machine].name, " Dell ") &&
((machine_get_chipset(machine) >= MACHINE_CHIPSET_INTEL_430FX) ||
(machine_get_chipset(machine) >= MACHINE_CHIPSET_VLSI_SCAMP))) {
char dell_diags[10] = { 0 };
if (!postcard_written[1])
snprintf(dell_diags, sizeof(dell_diags), "---- ----");
else if (postcard_written[1] == 1)
snprintf(dell_diags, sizeof(dell_diags), "%s ----", postcard_diags);
else
snprintf(dell_diags, sizeof(dell_diags), "%s %s", postcard_diags, postcard_prev_diags);
if (!postcard_written[0])
snprintf(postcard_str, sizeof(postcard_str), "POST: -- -- %s", dell_diags);
else if (postcard_written[0] == 1)
snprintf(postcard_str, sizeof(postcard_str), "POST: %02X -- %s", postcard_codes[0], dell_diags);
else
snprintf(postcard_str, sizeof(postcard_str), "POST: %02X %02X %s", postcard_codes[0], postcard_prev_codes[0], dell_diags);
} else {
char dell_diags[11] = { 0 };
if (postcard_dell_mode) {
if (!postcard_written[1])
snprintf(dell_diags, sizeof(dell_diags), " ---- ----");
else if (postcard_written[1] == 1)
snprintf(dell_diags, sizeof(dell_diags), " %s ----", postcard_diags);
else
snprintf(dell_diags, sizeof(dell_diags), " %s %s", postcard_diags, postcard_prev_diags);
}
if (!postcard_written[0])
snprintf(postcard_str, sizeof(postcard_str), "POST: -- --");
snprintf(postcard_str, sizeof(postcard_str), "POST: -- --%s", dell_diags);
else if (postcard_written[0] == 1)
snprintf(postcard_str, sizeof(postcard_str), "POST: %02X --", postcard_codes[0]);
snprintf(postcard_str, sizeof(postcard_str), "POST: %02X --%s", postcard_codes[0], dell_diags);
else
snprintf(postcard_str, sizeof(postcard_str), "POST: %02X %02X", postcard_codes[0], postcard_prev_codes[0]);
snprintf(postcard_str, sizeof(postcard_str), "POST: %02X %02X%s", postcard_codes[0], postcard_prev_codes[0], dell_diags);
}
ui_sb_bugui(postcard_str);
@@ -225,9 +218,9 @@ postcard_init(UNUSED(const device_t *info))
io_sethandler(postcard_port, postcard_ports_num,
NULL, NULL, NULL, postcard_write, NULL, NULL, NULL);
if (strstr(machines[machine].name, " Dell ") &&
((machine_get_chipset(machine) >= MACHINE_CHIPSET_INTEL_430FX) ||
(machine_get_chipset(machine) >= MACHINE_CHIPSET_VLSI_SCAMP)))
postcard_dell_mode = strstr(machines[machine].name, " Dell ") &&
(machine_get_chipset(machine) >= MACHINE_CHIPSET_INTEL_430FX);
if (postcard_dell_mode)
io_sethandler(is486 ? 0x00e0 : 0x00e4, 0x0001,
NULL, NULL, NULL, NULL, NULL, postcard_writel, NULL);

View File

@@ -513,7 +513,7 @@ extern int machine_at_ga486l_init(const machine_t *);
extern int machine_at_cougar_init(const machine_t *);
extern int machine_at_acc386_init(const machine_t *);
extern int machine_at_asus386_3364k_init(const machine_t *);
extern int machine_at_asus3863364k_init(const machine_t *);
extern int machine_at_asus386_init(const machine_t *);
extern int machine_at_ecs386_init(const machine_t *);
extern int machine_at_spc6000a_init(const machine_t *);
@@ -671,7 +671,7 @@ extern int machine_at_tek932_init(const machine_t *);
extern int machine_at_acerv30_init(const machine_t *);
extern int machine_at_apollo_init(const machine_t *);
extern int machine_at_optiplex_gxl_init(const machine_t *);
extern int machine_at_optiplexgxl_init(const machine_t *);
extern int machine_at_zappa_init(const machine_t *);
extern int machine_at_powermatev_init(const machine_t *);
extern int machine_at_hawk_init(const machine_t *);
@@ -722,6 +722,8 @@ extern int machine_at_vectra54_init(const machine_t *);
extern int machine_at_5sbm2_init(const machine_t *);
/* m_at_socket7.c */
extern void machine_at_optiplex_21152_init(void);
extern int machine_at_acerv35n_init(const machine_t *);
extern int machine_at_p55t2p4_init(const machine_t *);
extern int machine_at_m7shi_init(const machine_t *);
@@ -751,7 +753,7 @@ extern int machine_at_gw2kte_init(const machine_t *);
extern int machine_at_ma23c_init(const machine_t *);
extern int machine_at_nupro592_init(const machine_t *);
extern int machine_at_tx97_init(const machine_t *);
extern int machine_at_optiplex_gn_init(const machine_t *);
extern int machine_at_optiplexgn_init(const machine_t *);
extern int machine_at_ym430tx_init(const machine_t *);
extern int machine_at_thunderbolt_init(const machine_t *);
extern int machine_at_an430tx_init(const machine_t *);
@@ -820,7 +822,7 @@ extern int machine_at_p65up5_cpknd_init(const machine_t *);
extern int machine_at_kn97_init(const machine_t *);
extern int machine_at_lx6_init(const machine_t *);
extern int machine_at_optiplex_gxa_init(const machine_t *);
extern int machine_at_optiplexgxa_init(const machine_t *);
extern int machine_at_spitfire_init(const machine_t *);
extern int machine_at_ma30d_init(const machine_t *);

View File

@@ -283,6 +283,7 @@ extern void pci_init(int flags);
/* PCI bridge stuff. */
extern void pci_bridge_set_ctl(void *priv, uint8_t ctl);
extern uint8_t pci_bridge_get_bus_index(void *priv);
#ifdef EMU_DEVICE_H
extern const device_t dec21150_device;

View File

@@ -73,11 +73,11 @@ machine_at_acc386_init(const machine_t *model)
}
int
machine_at_asus386_3364k_init(const machine_t *model)
machine_at_asus3863364k_init(const machine_t *model)
{
int ret;
ret = bios_load_linear("roms/machines/asus386_3364k/am27c512dip28-64b53c26be3d8160533563.bin",
ret = bios_load_linear("roms/machines/asus3863364k/am27c512dip28-64b53c26be3d8160533563.bin",
0x000f0000, 65536, 0);
if (bios_only || !ret)

View File

@@ -151,11 +151,11 @@ machine_at_lx6_init(const machine_t *model)
}
int
machine_at_optiplex_gxa_init(const machine_t *model)
machine_at_optiplexgxa_init(const machine_t *model)
{
int ret;
ret = bios_load_linear("roms/machines/optiplex_gxa/DELL.ROM",
ret = bios_load_linear("roms/machines/optiplexgxa/DELL.ROM",
0x000c0000, 262144, 0);
if (bios_only || !ret)
@@ -170,14 +170,14 @@ machine_at_optiplex_gxa_init(const machine_t *model)
pci_register_slot(0x11, PCI_CARD_NETWORK, 4, 0, 0, 0);
pci_register_slot(0x0E, PCI_CARD_NORMAL, 3, 4, 2, 1);
pci_register_slot(0x0D, PCI_CARD_NORMAL, 2, 1, 3, 4);
pci_register_slot(0x0F, PCI_CARD_BRIDGE, 1, 2, 3, 4);
pci_register_slot(0x0F, PCI_CARD_BRIDGE, 0, 0, 0, 0);
if (sound_card_current[0] == SOUND_INTERNAL)
device_add(machine_get_snd_device(machine));
device_add(&i440lx_device);
device_add(&piix4_device);
device_add(&dec21152_device);
machine_at_optiplex_21152_init();
device_add_params(&pc87307_device, (void *) (PCX730X_PHOENIX_42 | PCX7307_PC87307));
device_add(&intel_flash_bxt_device);
spd_register(SPD_TYPE_SDRAM, 0x7, 256);

View File

@@ -238,11 +238,11 @@ machine_at_apollo_init(const machine_t *model)
}
int
machine_at_optiplex_gxl_init(const machine_t *model)
machine_at_optiplexgxl_init(const machine_t *model)
{
int ret;
ret = bios_load_linear("roms/machines/optiplex_gxl/DELL.ROM",
ret = bios_load_linear("roms/machines/optiplexgxl/DELL.ROM",
0x000e0000, 131072, 0);
if (bios_only || !ret)

View File

@@ -46,6 +46,15 @@
#include <86box/network.h>
#include <86box/pci.h>
void
machine_at_optiplex_21152_init(void)
{
uint8_t bus_index = pci_bridge_get_bus_index(device_add(&dec21152_device));
pci_register_bus_slot(bus_index, 0x09, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_bus_slot(bus_index, 0x0a, PCI_CARD_NORMAL, 4, 2, 1, 3);
pci_register_bus_slot(bus_index, 0x0b, PCI_CARD_NORMAL, 1, 3, 4, 2);
}
int
machine_at_acerv35n_init(const machine_t *model)
{
@@ -970,11 +979,11 @@ machine_at_tx97_init(const machine_t *model)
}
int
machine_at_optiplex_gn_init(const machine_t *model)
machine_at_optiplexgn_init(const machine_t *model)
{
int ret;
ret = bios_load_linear("roms/machines/optiplex_gn/DELL.ROM",
ret = bios_load_linear("roms/machines/optiplexgn/DELL.ROM",
0x000c0000, 262144, 0);
if (bios_only || !ret)
@@ -989,7 +998,7 @@ machine_at_optiplex_gn_init(const machine_t *model)
pci_register_slot(0x10, PCI_CARD_VIDEO, 4, 0, 0, 0); /* Trio64V2/GX, temporarily Trio64V2/DX is given */
pci_register_slot(0x11, PCI_CARD_NETWORK, 4, 0, 0, 0); /* 3C905, not yet emulated */
pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 4);
pci_register_slot(0x0F, PCI_CARD_BRIDGE, 1, 2, 3, 4);
pci_register_slot(0x0F, PCI_CARD_BRIDGE, 0, 0, 0, 0);
if (gfxcard[0] == VID_INTERNAL)
device_add(machine_get_vid_device(machine));
@@ -999,7 +1008,7 @@ machine_at_optiplex_gn_init(const machine_t *model)
device_add(&i430tx_device);
device_add(&piix4_device);
device_add(&dec21152_device);
machine_at_optiplex_21152_init();
device_add_params(&pc87307_device, (void *) (PCX730X_PHOENIX_42 | PCX7307_PC87307));
device_add(&intel_flash_bxt_device);
spd_register(SPD_TYPE_SDRAM, 0x3, 128);

View File

@@ -5713,10 +5713,10 @@ const machine_t machines[] = {
/* Has Award KBC firmware. */
{
.name = "[SiS 310] ASUS 386/33-64K",
.internal_name = "asus386_3364k",
.internal_name = "asus3863364k",
.type = MACHINE_TYPE_386DX,
.chipset = MACHINE_CHIPSET_SIS_310,
.init = machine_at_asus386_3364k_init,
.init = machine_at_asus3863364k_init,
.p1_handler = NULL,
.gpio_handler = NULL,
.available_flag = MACHINE_AVAILABLE,
@@ -9464,7 +9464,7 @@ const machine_t machines[] = {
.max_multi = 2.0
},
.bus_flags = MACHINE_PS2_PCI,
.flags = MACHINE_IDE_DUAL | MACHINE_APM, /* Machine has internal video: ST STPC Atlas */
.flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_PCI_INTERNAL, /* Machine has internal video: ST STPC Atlas */
.ram = {
.min = 32768,
.max = 163840,
@@ -9505,7 +9505,7 @@ const machine_t machines[] = {
.max_multi = 2.0
},
.bus_flags = MACHINE_PS2_PCI | MACHINE_BUS_USB,
.flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_USB, /* Machine has internal video: ST STPC Atlas */
.flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_PCI_INTERNAL | MACHINE_USB, /* Machine has internal video: ST STPC Atlas */
.ram = {
.min = 32768,
.max = 163840,
@@ -9546,7 +9546,7 @@ const machine_t machines[] = {
.max_multi = 2.0
},
.bus_flags = MACHINE_PS2,
.flags = MACHINE_IDE | MACHINE_APM, /* Machine has internal video: ST STPC Atlas and NIC: Realtek RTL8139C+ */
.flags = MACHINE_IDE | MACHINE_APM | MACHINE_PCI_INTERNAL, /* Machine has internal video: ST STPC Atlas and NIC: Realtek RTL8139C+ */
.ram = {
.min = 32768,
.max = 131072,
@@ -9587,7 +9587,7 @@ const machine_t machines[] = {
.max_multi = 2.0
},
.bus_flags = MACHINE_PS2_PCI,
.flags = MACHINE_IDE_DUAL | MACHINE_APM,
.flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_PCI_INTERNAL,
.ram = {
.min = 32768,
.max = 98304,
@@ -9628,7 +9628,7 @@ const machine_t machines[] = {
.max_multi = 2.0
},
.bus_flags = MACHINE_PS2_PCI,
.flags = MACHINE_IDE_DUAL | MACHINE_APM,
.flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_PCI_INTERNAL,
.ram = {
.min = 32768,
.max = 131072,
@@ -10591,10 +10591,10 @@ const machine_t machines[] = {
/* Has a National Semiconductor PC87332VLJ Super I/O with AMIKey 'F' KBC firmware. */
{
.name = "[i430FX] Dell OptiPlex GXL/GXM",
.internal_name = "optiplex_gxl",
.internal_name = "optiplexgxl",
.type = MACHINE_TYPE_SOCKET5,
.chipset = MACHINE_CHIPSET_INTEL_430FX,
.init = machine_at_optiplex_gxl_init,
.init = machine_at_optiplexgxl_init,
.p1_handler = NULL,
.gpio_handler = NULL,
.available_flag = MACHINE_AVAILABLE,
@@ -13189,10 +13189,10 @@ const machine_t machines[] = {
*/
{
.name = "[i430TX] Dell OptiPlex GN+",
.internal_name = "optiplex_gn",
.internal_name = "optiplexgn",
.type = MACHINE_TYPE_SOCKET7,
.chipset = MACHINE_CHIPSET_INTEL_430TX,
.init = machine_at_optiplex_gn_init,
.init = machine_at_optiplexgn_init,
.p1_handler = NULL,
.gpio_handler = NULL,
.available_flag = MACHINE_AVAILABLE,
@@ -15252,10 +15252,10 @@ const machine_t machines[] = {
firmwares: AMI '5' MegaKey, Phoenix MultiKey/42 1.37, or Phoenix MultiKey/42i 4.16. */
{
.name = "[i440LX] Dell OptiPlex GXa",
.internal_name = "optiplex_gxa",
.internal_name = "optiplexgxa",
.type = MACHINE_TYPE_SLOT1,
.chipset = MACHINE_CHIPSET_INTEL_440LX,
.init = machine_at_optiplex_gxa_init,
.init = machine_at_optiplexgxa_init,
.p1_handler = NULL,
.gpio_handler = NULL,
.available_flag = MACHINE_AVAILABLE,

View File

@@ -855,10 +855,10 @@ pci_register_card(int pci_card)
/* Add an instance of the PCI bridge. */
void
pci_add_bridge(uint8_t agp, uint8_t (*read)(int func, int addr, void *priv), void (*write)(int func, int addr, uint8_t val, void *priv), void *priv, uint8_t *slot)
pci_add_bridge(uint8_t add_type, uint8_t (*read)(int func, int addr, void *priv), void (*write)(int func, int addr, uint8_t val, void *priv), void *priv, uint8_t *slot)
{
pci_card_t *card;
uint8_t bridge_slot = agp ? pci_find_slot(PCI_ADD_AGPBRIDGE, 0xff) : last_normal_pci_card_id;
uint8_t bridge_slot = (add_type == PCI_ADD_NORMAL) ? last_normal_pci_card_id : pci_find_slot(add_type, 0xff);
if (bridge_slot != PCI_CARD_INVALID) {
card = &pci_cards[bridge_slot];