From: Toni Wilen Date: Mon, 22 Jun 2015 14:36:43 +0000 (+0300) Subject: PCI emulation updates. X-Git-Tag: 3200~173 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=138b259f612a77c8095b1a2aa88f1c3a0ef02c5a;p=francis%2Fwinuae.git PCI emulation updates. --- diff --git a/cfgfile.cpp b/cfgfile.cpp index 1d1fe8fd..21c8a5ed 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -303,6 +303,9 @@ static const TCHAR *obsolete[] = { _T("uaehf6%s,%s"), _T("uaehf7%s,%s"), + _T("pcibridge_rom_file"), + _T("pcibridge_rom_options"), + NULL }; @@ -1046,11 +1049,11 @@ static void cfgfile_write_board_rom(struct zfile *f, struct multipath *mp, struc _tcscat(buf2, tmp); } if (br->roms[i].device_settings && ert->settings) { - for (int i = 0; ert->settings[i].name; i++) { - if (br->roms[i].device_settings & (1 << i)) { + for (int j = 0; ert->settings[j].name; j++) { + if (br->roms[i].device_settings & (1 << j)) { if (buf2[0]) _tcscat(buf2, _T(",")); - _tcscat(buf2, ert->settings[i].configname); + _tcscat(buf2, ert->settings[j].configname); } } } diff --git a/expansion.cpp b/expansion.cpp index 0404c764..417212db 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -1111,8 +1111,7 @@ static void fastmem_autoconfig(int boardnum, int zorro, uae_u8 type, uae_u32 ser if (!srt->memory_after) type |= chainedconfig; } - } - else { + } else { if (erc->memory_mid) { mid = erc->memory_mid; pid = erc->memory_pid; @@ -1842,6 +1841,9 @@ void expamem_reset (void) cards[cardno++].map = NULL; } + // add possible non-autoconfig boards + add_cpu_expansions(1); + bool fastmem_after = false; if (currprefs.fastmem_autoconfig) { fastmem_after = add_fastram_after_expansion(2); @@ -2327,34 +2329,31 @@ static const struct expansionsubromtype supra_sub[] = { } }; -static const struct expansionsubromtype pcibridge_sub[] = { - { - _T("Prometheus"), _T("prometheus"), ROMTYPE_NOT | ROMTYPE_PCIBRIDGE - }, +static const struct expansionsubromtype mediator_sub[] = { { - _T("G-REX"), _T("grex"), ROMTYPE_NOT | ROMTYPE_PCIBRIDGE + _T("1200TX"), _T("1200tx"), ROMTYPE_NOT | ROMTYPE_MEDIATOR }, { - _T("Mediator 1200TX 4M"), _T("mediator1200tx4m"), ROMTYPE_NOT | ROMTYPE_PCIBRIDGE + _T("4000MK2"), _T("4000mkii"), ROMTYPE_NOT | ROMTYPE_MEDIATOR }, { - _T("Mediator 1200TX 8M"), _T("mediator1200tx8m"), ROMTYPE_NOT | ROMTYPE_PCIBRIDGE - }, - { - _T("Mediator 4000MK2 256M"), _T("mediator4000mkii256m"), ROMTYPE_NOT | ROMTYPE_PCIBRIDGE - }, + NULL + } +}; +static const struct expansionboardsettings mediator_settings[] = { { - _T("Mediator 4000MK2 512M"), _T("mediator4000mkii512m"), ROMTYPE_NOT | ROMTYPE_PCIBRIDGE + _T("Win Size"), + _T("winsize") }, { - _T("CVision/BVision"), _T("cbvision"), ROMTYPE_NOT | ROMTYPE_PCIBRIDGE + _T("Swap Config"), + _T("swapconfig") }, { NULL } }; - static void fastlane_memory_callback(struct romconfig *rc, uae_u8 *ac, int size) { struct zfile *z = read_device_from_romconfig(rc, NULL); @@ -2418,10 +2417,21 @@ const struct expansionromtype expansionroms[] = { false, EXPANSIONTYPE_SCSI }, { - _T("pcibridge"), _T("PCI Bridges"), _T(""), - pcibridge_init, pcibridge_init2, NULL, ROMTYPE_PCIBRIDGE | ROMTYPE_NONE, 0, 0, 3, false, - pcibridge_sub, 0, + _T("grex"), _T("G-REX"), _T("DCE"), + grex_init, NULL, NULL, ROMTYPE_GREX | ROMTYPE_NOT, 0, 0, 1, true, + }, + { + _T("prometheus"), _T("Prometheus"), _T("Matay"), + prometheus_init, NULL, NULL, ROMTYPE_PROMETHEUS | ROMTYPE_NOT, 0, 0, 3, false, + }, + { + _T("mediator"), _T("Mediator"), _T("Elbox"), + mediator_init, mediator_init2, NULL, ROMTYPE_MEDIATOR | ROMTYPE_NOT, 0, 0, 3, false, + mediator_sub, 0, false, 0, + 0, 0, 0, false, NULL, + false, + mediator_settings }, { _T("a2090a"), _T("A2090a"), _T("Commodore"), @@ -2825,7 +2835,7 @@ static const struct cpuboardsubtype dbk_sub[] = { BOARD_MEMORY_HIGHMEM, 128 * 1024 * 1024, 0, - dkb_wildfire_pci_init, NULL, 2, 0 // fake board + dkb_wildfire_pci_init, NULL, 1, 0 // fake board }, { NULL diff --git a/include/pci.h b/include/pci.h index 585f6989..1448362d 100644 --- a/include/pci.h +++ b/include/pci.h @@ -3,7 +3,10 @@ extern void pci_free(void); extern void pci_reset(void); extern void pci_rethink(void); extern void pci_dump(int); -extern addrbank *dkb_wildfire_pci_init(struct romconfig *rc); -extern addrbank *pcibridge_init(struct romconfig *rc); -extern addrbank *pcibridge_init2(struct romconfig *rc); +extern addrbank *dkb_wildfire_pci_init(struct romconfig *rc); +extern addrbank *prometheus_init(struct romconfig *rc); +extern addrbank *cbvision_init(struct romconfig *rc);; +extern addrbank *grex_init(struct romconfig *rc); +extern addrbank *mediator_init(struct romconfig *rc); +extern addrbank *mediator_init2(struct romconfig *rc); diff --git a/include/rommgr.h b/include/rommgr.h index af69fe72..362a2917 100644 --- a/include/rommgr.h +++ b/include/rommgr.h @@ -74,7 +74,9 @@ extern int decode_cloanto_rom_do (uae_u8 *mem, int size, int real_size); #define ROMTYPE_PTNEXUS 0x0010001c #define ROMTYPE_DATAFLYER 0x0010001d #define ROMTYPE_SUPRADMA 0x0010001e -#define ROMTYPE_PCIBRIDGE 0x0010001f +#define ROMTYPE_GREX 0x0010001f +#define ROMTYPE_PROMETHEUS 0x00100020 +#define ROMTYPE_MEDIATOR 0x00100021 #define ROMTYPE_NOT 0x00800000 #define ROMTYPE_QUAD 0x01000000 diff --git a/od-win32/win32.h b/od-win32/win32.h index 4482c96c..a40ff575 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -25,7 +25,7 @@ #define WINUAEBETA _T("") #endif -#define WINUAEDATE MAKEBD(2015, 6, 18) +#define WINUAEDATE MAKEBD(2015, 6, 22) //#define WINUAEEXTRA _T("AmiKit Preview") //#define WINUAEEXTRA _T("Amiga Forever Edition") diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index a8b16d60..fab55ac2 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -8842,20 +8842,22 @@ static void values_to_kickstartdlg_expansion_roms(HWND hDlg, UAEREG *fkey) fkey = regcreatetree(NULL, _T("DetectedROMs")); keyallocated = true; } - const struct expansionromtype *ert = &expansionroms[scsiromselected]; - int romtype = ert->romtype; - int romtype_extra = ert->romtype_extra; - - brc = get_device_rom(&workprefs, romtype, scsiromselectednum, &index); - if (brc && ert->subtypes) { - const struct expansionsubromtype *esrt = &ert->subtypes[brc->roms[index].subtype]; - if (esrt->romtype) { - romtype = esrt->romtype; - romtype_extra = 0; + if (scsiromselected) { + const struct expansionromtype *ert = &expansionroms[scsiromselected]; + int romtype = ert->romtype; + int romtype_extra = ert->romtype_extra; + + brc = get_device_rom(&workprefs, romtype, scsiromselectednum, &index); + if (brc && ert->subtypes) { + const struct expansionsubromtype *esrt = &ert->subtypes[brc->roms[index].subtype]; + if (esrt->romtype) { + romtype = esrt->romtype; + romtype_extra = 0; + } } + addromfiles(fkey, hDlg, IDC_SCSIROMFILE, brc ? brc->roms[index].romfile : NULL, romtype, romtype_extra); + CheckDlgButton(hDlg, IDC_SCSIROMFILEAUTOBOOT, brc && brc->roms[index].autoboot_disabled); } - addromfiles(fkey, hDlg, IDC_SCSIROMFILE, brc ? brc->roms[index].romfile : NULL, romtype, romtype_extra); - CheckDlgButton(hDlg, IDC_SCSIROMFILEAUTOBOOT, brc && brc->roms[index].autoboot_disabled); if (keyallocated) regclosetree(fkey); } diff --git a/pci.cpp b/pci.cpp index 1cd79e7f..fd4f95f1 100644 --- a/pci.cpp +++ b/pci.cpp @@ -7,6 +7,12 @@ * Hardware information by Radoslaw Kujawa * */ + +#define PCI_DEBUG_IO 0 +#define PCI_DEBUG_MEMORY 0 +#define PCI_DEBUG_CONFIG 1 +#define PCI_DEBUG_BRIDGE 0 + #include "sysconfig.h" #include "sysdeps.h" @@ -18,6 +24,8 @@ #include "pci.h" #include "ncr_scsi.h" #include "newcpu.h" +#include "uae.h" +#include "rommgr.h" #include "qemuvga/qemuuaeglue.h" #include "qemuvga/queue.h" @@ -248,7 +256,9 @@ static struct pci_board_state *get_pci_board_state_config(struct pci_bridge *pci return NULL; struct pci_board_state *pcibs = &pcib->boards[idx]; if (!pcibs->board) { +#if PCI_DEBUG_CONFIG write_log(_T("- Empty slot %d\n"), idx); +#endif return NULL; } return pcibs; @@ -280,11 +290,10 @@ static struct pci_board_state *get_pci_board_state(struct pci_bridge *pcib, uaec return NULL; } -static const pci_addrbank *get_pci_io(uaecptr *addrp, struct pci_board_state **pcibsp, int *endianswap) +static const pci_addrbank *get_pci_io(uaecptr *addrp, struct pci_board_state **pcibsp, int *endianswap, int size) { uaecptr addr = *addrp; int bar; - write_log(_T("get_pci_io %08x %08x\n"), addr, M68K_GETPC); struct pci_bridge *pcib = get_pci_bridge(addr); if (!pcib) return NULL; @@ -296,6 +305,9 @@ static const pci_addrbank *get_pci_io(uaecptr *addrp, struct pci_board_state **p *endianswap = pcib->endian_swap_io; addr -= pcib->io_offset; addr &= (pcibs->bar_size[bar] & ~1) - 1; +#if PCI_DEBUG_IO + write_log(_T("get_pci_io %08x=%08x %c:%d PC=%08x\n"), *addrp, addr, size < 0 ? 'W' : 'R', size < 0 ? -size : size, M68K_GETPC); +#endif *addrp = addr; return &pcibs->board->bars[bar]; } @@ -304,7 +316,9 @@ static const pci_addrbank *get_pci_mem(uaecptr *addrp, struct pci_board_state ** { uaecptr addr = *addrp; int bar; +#if PCI_DEBUG_MEMORY write_log(_T("get_pci_mem %08x %08x\n"), addr, M68K_GETPC); +#endif struct pci_bridge *pcib = get_pci_bridge(addr); if (!pcib) return NULL; @@ -322,6 +336,7 @@ static const pci_addrbank *get_pci_mem(uaecptr *addrp, struct pci_board_state ** static uae_u8 *get_pci_config(uaecptr addr, int size, uae_u32 v, int *endianswap) { +#if PCI_DEBUG_CONFIG if (size < 0) { size = -size; write_log(_T("PCI Config Space %s READ %08x PC=%08x\n"), @@ -330,6 +345,7 @@ static uae_u8 *get_pci_config(uaecptr addr, int size, uae_u32 v, int *endianswap write_log(_T("PCI Config Space %s WRITE %08x = %08x PC=%08x\n"), size == 4 ? _T("LONG") : (size == 2 ? _T("WORD") : _T("BYTE")), addr, v, M68K_GETPC); } +#endif struct pci_bridge *pcib = get_pci_bridge(addr); if (!pcib) return NULL; @@ -337,7 +353,9 @@ static uae_u8 *get_pci_config(uaecptr addr, int size, uae_u32 v, int *endianswap if (!pcibs) return NULL; *endianswap = pcib->endian_swap_config; +#if PCI_DEBUG_CONFIG write_log(_T("- Board %d (%s)\n"), pcibs->index, pcibs->board->label); +#endif create_config_data(pcibs); return pcibs->config_data; } @@ -355,14 +373,18 @@ static void map_pci_banks(struct pci_board_state *pcibs, int type, bool enable) pcibs->bar_end[i] = pcibs->bar_start[i] + (pcibs->bar_size[i] & ~1) - 1; if (enable && pcibs->bar[i] < 0xffff0000) { pcibs->bar_enabled[i] = true; +#if PCI_DEBUG_CONFIG if (pcibs->bar_old[i] != pcibs->bar_start[i]) { write_log(_T("Board %d ('%s') BAR%d: %08x-%08x\n"), pcibs->index, pci->label, i, pcibs->bar_start[i], pcibs->bar_end[i]); } +#endif } else { pcibs->bar_enabled[i] = false; +#if PCI_DEBUG_CONFIG if (pcibs->bar_old[i] != pcibs->bar_start[i]) { write_log(_T("Board %d ('%s') BAR%d: %08x-%08x\n"), pcibs->index, pci->label, i, pcibs->bar_start[i], pcibs->bar_end[i]); } +#endif } pcibs->bar_old[i] = pcibs->bar_start[i]; } @@ -427,7 +449,9 @@ static uae_u32 REGPARAM2 pci_config_lget(uaecptr addr) v |= config[offset + 1] << 8; v |= config[offset + 0] << 0; } +#if PCI_DEBUG_CONFIG write_log(_T("- %08x\n"), v); +#endif } return v; } @@ -448,7 +472,9 @@ static uae_u32 REGPARAM2 pci_config_wget(uaecptr addr) v = config[(offset ^ (endianswap > 0 ? 2 : 0)) + 1] << 8; v |= config[(offset ^ (endianswap > 0 ? 2 : 0)) + 0] << 0; } +#if PCI_DEBUG_CONFIG write_log(_T("- %04x\n"), v); +#endif } return v; } @@ -461,14 +487,15 @@ static uae_u32 REGPARAM2 pci_config_bget(uaecptr addr) int endianswap; uae_u8 *config = get_pci_config(addr, -1, 0, &endianswap); if (config) { - uae_u32 v; uae_u32 offset = addr & 0xff; if (!endianswap) { v = config[offset + 0]; } else { v = config[beswap(endianswap, offset)]; } +#if PCI_DEBUG_CONFIG write_log(_T("- %02x\n"), v); +#endif } return v; } @@ -551,7 +578,7 @@ static uae_u32 REGPARAM2 pci_io_lget(uaecptr addr) uae_u32 v = 0xffffffff; int endianswap; struct pci_board_state *pcibs; - const pci_addrbank *a = get_pci_io(&addr, &pcibs, &endianswap); + const pci_addrbank *a = get_pci_io(&addr, &pcibs, &endianswap, 4); if (a && a->lget) { v = a->lget(pcibs, addr); if (endianswap) @@ -567,7 +594,7 @@ static uae_u32 REGPARAM2 pci_io_wget(uaecptr addr) uae_u32 v = 0xffff; int endianswap; struct pci_board_state *pcibs; - const pci_addrbank *a = get_pci_io(&addr, &pcibs, &endianswap); + const pci_addrbank *a = get_pci_io(&addr, &pcibs, &endianswap, 2); if (a && a->wget) { if (endianswap) { v = a->wget(pcibs, addr ^ (endianswap > 0 ? 2 : 0)); @@ -586,7 +613,7 @@ static uae_u32 REGPARAM2 pci_io_bget(uaecptr addr) uae_u32 v = 0xff; int endianswap; struct pci_board_state *pcibs; - const pci_addrbank *a = get_pci_io(&addr, &pcibs, &endianswap); + const pci_addrbank *a = get_pci_io(&addr, &pcibs, &endianswap, 1); if (a && a->bget) { if (endianswap) { v = a->bget(pcibs, beswap(endianswap, addr)); @@ -603,7 +630,7 @@ static void REGPARAM2 pci_io_lput(uaecptr addr, uae_u32 b) #endif int endianswap; struct pci_board_state *pcibs; - const pci_addrbank *a = get_pci_io(&addr, &pcibs, &endianswap); + const pci_addrbank *a = get_pci_io(&addr, &pcibs, &endianswap, -4); if (a && a->lput) { if (endianswap) b = endianswap_long(b); @@ -617,7 +644,7 @@ static void REGPARAM2 pci_io_wput(uaecptr addr, uae_u32 b) #endif int endianswap; struct pci_board_state *pcibs; - const pci_addrbank *a = get_pci_io(&addr, &pcibs, &endianswap); + const pci_addrbank *a = get_pci_io(&addr, &pcibs, &endianswap, -2); if (a && a->wput) { if (endianswap) { b = endianswap_word(b); @@ -634,7 +661,7 @@ static void REGPARAM2 pci_io_bput(uaecptr addr, uae_u32 b) #endif int endianswap; struct pci_board_state *pcibs; - const pci_addrbank *a = get_pci_io(&addr, &pcibs, &endianswap); + const pci_addrbank *a = get_pci_io(&addr, &pcibs, &endianswap, -1); if (a && a->bput) { if (endianswap) { a->bput(pcibs, beswap(endianswap, addr), b); @@ -751,7 +778,6 @@ static uae_u32 REGPARAM2 pci_bridge_lget(uaecptr addr) special_mem |= S_READ; #endif uae_u32 v = 0; - write_log(_T("pci_bridge_lget %08x PC=%08x\n"), addr, M68K_GETPC); struct pci_bridge *pcib = get_pci_bridge(addr); if (!pcib) return v; @@ -764,6 +790,10 @@ static uae_u32 REGPARAM2 pci_bridge_lget(uaecptr addr) v |= pcib->config[0]; if (pcib == bridges[PCI_BRIDGE_GREX]) v |= 0x02000000; + if (!pcib->irq) + v |= 0x80000000; + if (!pcib->intena) + v |= 0x00000020; break; case 1: v = pcib->intena ? 1 : 0; @@ -776,7 +806,9 @@ static uae_u32 REGPARAM2 pci_bridge_lget(uaecptr addr) break; } } - write_log(_T("=%08x\n"), v); +#if PCI_DEBUG_BRIDGE + write_log(_T("pci_bridge_lget %08x=%08x PC=%08x\n"), addr, v, M68K_GETPC); +#endif return v; } static uae_u32 REGPARAM2 pci_bridge_wget(uaecptr addr) @@ -785,7 +817,9 @@ static uae_u32 REGPARAM2 pci_bridge_wget(uaecptr addr) special_mem |= S_READ; #endif uae_u16 v = 0; +#if PCI_DEBUG_BRIDGE write_log(_T("pci_bridge_wget %08x PC=%08x\n"), addr, M68K_GETPC); +#endif return v; } static uae_u32 REGPARAM2 pci_bridge_bget(uaecptr addr) @@ -807,7 +841,9 @@ static uae_u32 REGPARAM2 pci_bridge_bget(uaecptr addr) int offset = addr & 15; v = pcib->config[offset / 4]; } +#if PCI_DEBUG_BRIDGE write_log(_T("pci_bridge_bget %08x %02x PC=%08x\n"), addr, v, M68K_GETPC); +#endif return v; } static void REGPARAM2 pci_bridge_lput(uaecptr addr, uae_u32 b) @@ -815,7 +851,9 @@ static void REGPARAM2 pci_bridge_lput(uaecptr addr, uae_u32 b) #ifdef JIT special_mem |= S_WRITE; #endif +#if PCI_DEBUG_BRIDGE write_log(_T("pci_bridge_lput %08x %08x PC=%08x\n"), addr, b, M68K_GETPC); +#endif struct pci_bridge *pcib = get_pci_bridge(addr); if (!pcib) return; @@ -824,14 +862,14 @@ static void REGPARAM2 pci_bridge_lput(uaecptr addr, uae_u32 b) switch (reg) { case 0: - pcib->endian_swap_memory = pcib->endian_swap_io = (b & 2) != 0; + pcib->endian_swap_memory = pcib->endian_swap_io = (b & 2) != 0 ? -1 : 0; break; case 1: pcib->intena = (b & 1) ? 0xff : 0x00; break; case 3: pcib->config[0] = b & 1; - pcib->endian_swap_memory = pcib->endian_swap_io = (b & 2) != 0; + pcib->endian_swap_memory = pcib->endian_swap_io = (b & 2) != 0 ? -1 : 0; break; } } @@ -869,7 +907,9 @@ static void REGPARAM2 pci_bridge_wput(uaecptr addr, uae_u32 b) } } } +#if PCI_DEBUG_BRIDGE write_log(_T("pci_bridge_wput %08x %04x PC=%08x\n"), addr, b & 0xffff, M68K_GETPC); +#endif } static void REGPARAM2 pci_bridge_bput(uaecptr addr, uae_u32 b) { @@ -879,7 +919,9 @@ static void REGPARAM2 pci_bridge_bput(uaecptr addr, uae_u32 b) struct pci_bridge *pcib = get_pci_bridge(addr); if (!pcib) return; +#if PCI_DEBUG_BRIDGE write_log(_T("pci_bridge_bput %08x %02x PC=%08x\n"), addr, b & 0xff, M68K_GETPC); +#endif if (!pcib->configured) { uaecptr offset = addr & 65535; if (pcib->bank_zorro == 2) { @@ -929,10 +971,12 @@ static void mediator_set_window_offset(struct pci_bridge *pcib, uae_u16 v) pcib->memory_offset = pcib->window << 16; } pcib->memory_offset -= pcib->baseaddress; +#if PCI_DEBUG_BRIDGE if (pcib->memory_offset != offset) { write_log(_T("Mediator window: %08x offset: %08x\n"), pcib->memory_offset + pcib->baseaddress, pcib->memory_offset); } +#endif } static uae_u32 REGPARAM2 pci_bridge_bget_2(uaecptr addr) @@ -965,7 +1009,9 @@ static uae_u32 REGPARAM2 pci_bridge_bget_2(uaecptr addr) } } } +#if PCI_DEBUG_BRIDGE write_log(_T("pci_bridge_bget_2 %08x %02x PC=%08x\n"), addr, v, M68K_GETPC); +#endif return v; } static uae_u32 REGPARAM2 pci_bridge_wget_2(uaecptr addr) @@ -974,7 +1020,9 @@ static uae_u32 REGPARAM2 pci_bridge_wget_2(uaecptr addr) special_mem |= S_READ; #endif uae_u16 v = 0; +#if PCI_DEBUG_BRIDGE write_log(_T("pci_bridge_wget_2 %08x PC=%08x\n"), addr, M68K_GETPC); +#endif struct pci_bridge *pcib = get_pci_bridge_2(addr); if (!pcib) return v; @@ -994,7 +1042,9 @@ static uae_u32 REGPARAM2 pci_bridge_lget_2(uaecptr addr) special_mem |= S_READ; #endif uae_u32 v = 0; +#if PCI_DEBUG_BRIDGE write_log(_T("pci_bridge_lget_2 %08x PC=%08x\n"), addr, M68K_GETPC); +#endif struct pci_bridge *pcib = get_pci_bridge_2(addr); if (!pcib) return v; @@ -1011,7 +1061,9 @@ static void REGPARAM2 pci_bridge_bput_2(uaecptr addr, uae_u32 b) struct pci_bridge *pcib = get_pci_bridge_2(addr); if (!pcib) return; +#if PCI_DEBUG_BRIDGE write_log(_T("pci_bridge_bput_2 %08x %02x PC=%08x\n"), addr, b & 0xff, M68K_GETPC); +#endif if (!pcib->configured_2) { uaecptr offset = addr & 65535; if (pcib->bank_2_zorro == 2) { @@ -1050,6 +1102,9 @@ static void REGPARAM2 pci_bridge_bput_2(uaecptr addr, uae_u32 b) } } else if (offset == 11) { pcib->intena = b >> 4; + } else if (offset == 0x40) { + // power off + uae_quit(); } } if (pcib->bank_2_zorro == 3) { @@ -1099,14 +1154,18 @@ static void REGPARAM2 pci_bridge_wput_2(uaecptr addr, uae_u32 b) } } } +#if PCI_DEBUG_BRIDGE write_log(_T("pci_bridge_wput_2 %08x %04x PC=%08x\n"), addr, b & 0xffff, M68K_GETPC); +#endif } static void REGPARAM2 pci_bridge_lput_2(uaecptr addr, uae_u32 b) { #ifdef JIT special_mem |= S_WRITE; #endif +#if PCI_DEBUG_BRIDGE write_log(_T("pci_bridge_lput_2 %08x %08x PC=%08x\n"), addr, b, M68K_GETPC); +#endif struct pci_bridge *pcib = get_pci_bridge_2(addr); if (!pcib) return; @@ -1149,7 +1208,7 @@ addrbank pci_bridge_bank_2 = { static void pci_dump_out(const TCHAR *txt, int log) { if (log > 0) - write_log(txt); + write_log(_T("%s"), txt); else if (log == 0) console_out(txt); } @@ -1422,7 +1481,7 @@ static int prometheus_get_index(uaecptr addr) struct pci_bridge *pcib = get_pci_bridge(addr); addr -= pcib->baseaddress; - if ((addr & 0xffff0000) != 0x000f0000) + if ((addr & 0xffff0f00) != 0x000f0000) return -1; int slot = (addr & 0xf000) >> 13; if (slot > 3) @@ -1437,8 +1496,8 @@ static addrbank *prometheus_pci_init(struct romconfig *rc) return &expamem_null; pcib->label = _T("Prometheus"); pcib->endian_swap_config = 1; - pcib->endian_swap_io = 1; - pcib->endian_swap_memory = 1; + pcib->endian_swap_io = -1; + pcib->endian_swap_memory = -1; pcib->intena = 0xff; pcib->intreq_mask = 0x0008; pcib->get_index = prometheus_get_index; @@ -1562,11 +1621,8 @@ static int mediator_get_index_4000(uaecptr addr) return slot; } -static addrbank *mediator_pci_init_1200(struct romconfig *rc) +static void mediator_pci_init_1200(struct pci_bridge *pcib) { - struct pci_bridge *pcib = pci_bridge_alloc_zorro(PCI_BRIDGE_MEDIATOR, rc); - if (!pcib) - return &expamem_null; pcib->label = _T("Mediator 1200"); pcib->endian_swap_config = -1; pcib->endian_swap_io = -1; @@ -1579,34 +1635,56 @@ static addrbank *mediator_pci_init_1200(struct romconfig *rc) pcib->bank_zorro = 2; pcib->bank_2_zorro = 2; mediator_set_window_offset(pcib, 0); +} - add_pci_devices(pcib); - +static addrbank *mediator_pci_init_1200_1(struct romconfig *rc) +{ + struct pci_bridge *pcib; + if (!(rc->device_settings & 2)) { + // io first + pcib = pci_bridge_alloc_zorro(PCI_BRIDGE_MEDIATOR, rc); + if (!pcib) + return &expamem_null; + mediator_pci_init_1200(pcib); + add_pci_devices(pcib); + } else { + pcib = pci_bridge_get_zorro(rc); + if (!pcib) + return &expamem_null; + } memset(pcib->acmemory_2, 0xff, sizeof pcib->acmemory_2); for (int i = 0; i < sizeof autoconfig_mediator_1200tx_1; i++) { ew(pcib->acmemory_2, i * 4, autoconfig_mediator_1200tx_1[i]); } return &pci_bridge_bank_2; } -static addrbank *mediator_pci_init_1200_2(struct romconfig *rc, int size) -{ - struct pci_bridge *pcib = pci_bridge_get_zorro(rc); - if (!pcib) - return &expamem_null; +static addrbank *mediator_pci_init_1200_2(struct romconfig *rc) +{ + struct pci_bridge *pcib; + if (!(rc->device_settings & 2)) { + // memory last + pcib = pci_bridge_get_zorro(rc); + if (!pcib) + return &expamem_null; + } else { + // memory first + pcib = pci_bridge_alloc_zorro(PCI_BRIDGE_MEDIATOR, rc); + if (!pcib) + return &expamem_null; + mediator_pci_init_1200(pcib); + add_pci_devices(pcib); + } memset(pcib->acmemory, 0xff, sizeof pcib->acmemory); - const uae_u8 *ac = size ? autoconfig_mediator_1200tx_2_8m : autoconfig_mediator_1200tx_2_4m; + const uae_u8 *ac = (rc->device_settings & 1) ? autoconfig_mediator_1200tx_2_8m : autoconfig_mediator_1200tx_2_4m; for (int i = 0; i < 16; i++) { ew(pcib->acmemory, i * 4, ac[i]); } return &pci_bridge_bank; } -static addrbank *mediator_pci_init_4000(struct romconfig *rc, int size) +static void mediator_pci_init_4000(struct pci_bridge *pcib) { - struct pci_bridge *pcib = pci_bridge_alloc_zorro(PCI_BRIDGE_MEDIATOR, rc); - if (!pcib) - return &expamem_null; pcib->label = _T("Mediator 4000"); pcib->endian_swap_config = -1; pcib->endian_swap_io = -1; @@ -1619,62 +1697,101 @@ static addrbank *mediator_pci_init_4000(struct romconfig *rc, int size) pcib->bank_zorro = 3; pcib->bank_2_zorro = 3; mediator_set_window_offset(pcib, 0); +} - add_pci_devices(pcib); - - memset(pcib->acmemory, 0xff, sizeof pcib->acmemory); - const uae_u8 *ac = size ? autoconfig_mediator_4000mk2_512m : autoconfig_mediator_4000mk2_256m; - for (int i = 0; i < 16; i++) { - ew(pcib->acmemory, i * 4, ac[i]); +static addrbank *mediator_pci_init_4000_1(struct romconfig *rc) +{ + struct pci_bridge *pcib; + if (!(rc->device_settings & 2)) { + // io first + pcib = pci_bridge_alloc_zorro(PCI_BRIDGE_MEDIATOR, rc); + if (!pcib) + return &expamem_null; + mediator_pci_init_4000(pcib); + add_pci_devices(pcib); + } else { + pcib = pci_bridge_get_zorro(rc); + if (!pcib) + return &expamem_null; } - return pcib->bank; + memset(pcib->acmemory_2, 0xff, sizeof pcib->acmemory_2); + for (int i = 0; i < sizeof autoconfig_mediator_4000mk2_2; i++) { + ew(pcib->acmemory_2, i * 4, autoconfig_mediator_4000mk2_2[i]); + } + return &pci_bridge_bank_2; } static addrbank *mediator_pci_init_4000_2(struct romconfig *rc) { - struct pci_bridge *pcib = pci_bridge_get_zorro(rc); - if (!pcib) - return &expamem_null; + struct pci_bridge *pcib; + if (!(rc->device_settings & 2)) { + // memory last + pcib = pci_bridge_get_zorro(rc); + if (!pcib) + return &expamem_null; + } else { + // memory first + pcib = pci_bridge_alloc_zorro(PCI_BRIDGE_MEDIATOR, rc); + if (!pcib) + return &expamem_null; - memset(pcib->acmemory_2, 0xff, sizeof pcib->acmemory_2); - for (int i = 0; i < sizeof autoconfig_mediator_4000mk2_2; i++) { - ew(pcib->acmemory_2, i * 4, autoconfig_mediator_4000mk2_2[i]); + mediator_pci_init_4000(pcib); + add_pci_devices(pcib); } - return pcib->bank_2; + memset(pcib->acmemory, 0xff, sizeof pcib->acmemory); + const uae_u8 *ac = (rc->device_settings & 1) ? autoconfig_mediator_4000mk2_512m : autoconfig_mediator_4000mk2_256m; + for (int i = 0; i < 16; i++) { + ew(pcib->acmemory, i * 4, ac[i]); + } + return &pci_bridge_bank; } -addrbank *pcibridge_init(struct romconfig *rc) +addrbank *mediator_init(struct romconfig *rc) { switch (rc->subtype) { case 0: - return prometheus_pci_init(rc); + if (rc->device_settings & 2) + return mediator_pci_init_1200_2(rc); + else + return mediator_pci_init_1200_1(rc); case 1: - return grex_pci_init(rc); - case 2: - return mediator_pci_init_1200(rc); - case 3: - return mediator_pci_init_1200(rc); - case 4: - return mediator_pci_init_4000(rc, 0); - case 5: - return mediator_pci_init_4000(rc, 1); - case 6: - return cbvision(rc); + if (rc->device_settings & 2) + return mediator_pci_init_4000_2(rc); + else + return mediator_pci_init_4000_1(rc); } return &expamem_null; } -addrbank *pcibridge_init2(struct romconfig *rc) + +addrbank *mediator_init2(struct romconfig *rc) { switch (rc->subtype) { - case 2: - return mediator_pci_init_1200_2(rc, 0); - case 3: - return mediator_pci_init_1200_2(rc, 1); - case 4: - return mediator_pci_init_4000_2(rc); - case 5: - return mediator_pci_init_4000_2(rc); + case 0: + if (rc->device_settings & 2) + return mediator_pci_init_1200_1(rc); + else + return mediator_pci_init_1200_2(rc); + case 1: + if (rc->device_settings & 2) + return mediator_pci_init_4000_1(rc); + else + return mediator_pci_init_4000_2(rc); } return &expamem_null; } + +addrbank *prometheus_init(struct romconfig *rc) +{ + return prometheus_pci_init(rc); +} + +addrbank *cbvision_init(struct romconfig *rc) +{ + return cbvision(rc); +} + +addrbank *grex_init(struct romconfig *rc) +{ + return grex_pci_init(rc); +} diff --git a/qemuvga/ne2000.cpp b/qemuvga/ne2000.cpp index 9099ce7e..2e99bcd5 100644 --- a/qemuvga/ne2000.cpp +++ b/qemuvga/ne2000.cpp @@ -63,7 +63,6 @@ static struct netdriverdata *td; static void *sysdata; static uae_u8 *transmitbuffer; static volatile int transmitlen; -static volatile int transmitnow; static void ne2000_receive_check(void); @@ -81,7 +80,6 @@ static int getfunc(void *devv, uae_u8 *d, int *len) memcpy(d, transmitbuffer, transmitlen); *len = transmitlen; transmitlen = 0; - transmitnow = 1; return 1; } @@ -115,7 +113,7 @@ static unsigned compute_mcast_idx(const uint8_t *ep) //#include "sysemu/sysemu.h" /* debug NE2000 card */ -#define DEBUG_NE2000 +//#define DEBUG_NE2000 static NetClientState ncs; static NE2000State ne2000state; @@ -365,8 +363,12 @@ static void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val) int offset, page, index; addr &= 0xf; + page = s->cmd >> 6; + offset = addr | (page << 4); + if (addr == E8390_CMD) + page = offset = 0; #ifdef DEBUG_NE2000 - write_log("NE2000: write addr=0x%x val=0x%02x\n", addr, val); + write_log("NE2000: write reg=0x%x val=0x%02x\n", addr, val); #endif if (addr == E8390_CMD) { /* control register */ @@ -375,7 +377,7 @@ static void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val) s->isr &= ~ENISR_RESET; /* test specific case: zero length transfer */ if ((val & (E8390_RREAD | E8390_RWRITE)) && - s->rcnt == 0) { + s->tcnt == 0) { s->isr |= ENISR_RDC; ne2000_update_irq(s); } @@ -392,6 +394,9 @@ static void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val) if (index + s->tcnt <= NE2000_PMEM_END) { transmitbuffer = s->mem + index; transmitlen = s->tcnt; +#ifdef DEBUG_NE2000 + write_log("NE2000: %d byte transmit\n", s->tcnt); +#endif ethernet_trigger(td, sysdata); #if 0 qemu_send_packet(qemu_get_queue(s->nic), s->mem + index, s->tcnt); @@ -481,11 +486,11 @@ static uint32_t ne2000_ioport_read(void *opaque, uint32_t addr) int offset, page, ret; addr &= 0xf; - if (addr == E8390_CMD) { + page = s->cmd >> 6; + offset = addr | (page << 4); + if (addr == E8390_CMD) { ret = s->cmd; } else { - page = s->cmd >> 6; - offset = addr | (page << 4); switch(offset) { case EN0_TSR: ret = s->tsr; @@ -554,7 +559,7 @@ static uint32_t ne2000_ioport_read(void *opaque, uint32_t addr) } ne2000_receive_check(); #ifdef DEBUG_NE2000 - write_log("NE2000: read addr=0x%x val=%02x\n", addr, ret); + write_log("NE2000: read reg=0x%x val=0x%02x\n", offset, ret); #endif return ret; } @@ -649,7 +654,7 @@ static void ne2000_asic_ioport_write(void *opaque, uint32_t addr, uint32_t val) return; if (s->dcfg & 0x01) { /* 16 bit access */ - ne2000_mem_writew(s, s->rsar, val); + ne2000_mem_writew(s, s->rsar, val); ne2000_dma_update(s, 2); } else { /* 8 bit access */ @@ -776,20 +781,27 @@ static uint64_t ne2000_read(void *opaque, hwaddr addr, uint64_t v; NE2000State *s = (NE2000State*)opaque; - if (addr < 0x10 && size == 1) { - v = ne2000_ioport_read(s, addr); - } else if (addr == 0x10) { + if (addr < 0x10) { + if (size == 1) { + v = ne2000_ioport_read(s, addr); + } else { + v = ne2000_ioport_read(s, addr); + v |= ne2000_ioport_read(s, addr) << 8; + } + } else if (addr >= 0x10 && addr <= 0x17) { if (size <= 2) { v = ne2000_asic_ioport_read(s, addr); } else { v = ne2000_asic_ioport_readl(s, addr); } - } else if (addr == 0x1f && size == 1) { + } else if (addr >= 0x18 && addr < 0x20) { v = ne2000_reset_ioport_read(s, addr); } else { v = ((uint64_t)1 << (size * 8)) - 1; } +#if defined(DEBUG_NE2000) write_log(_T("NE2000_READ %08x=%08x %d\n"), addr, (uae_u32)v, size); +#endif return v; } @@ -798,17 +810,24 @@ static void ne2000_write(void *opaque, hwaddr addr, { NE2000State *s = (NE2000State*)opaque; +#if defined(DEBUG_NE2000) write_log(_T("NE2000_WRITE %08x %08x %d\n"), addr, (uae_u32)data, size); - - if (addr < 0x10 && size == 1) { - ne2000_ioport_write(s, addr, data); - } else if (addr == 0x10) { - if (size <= 2) { +#endif + + if (addr < 0x10) { + if (size == 1) { + ne2000_ioport_write(s, addr, data); + } else { + ne2000_ioport_write(s, addr, data); + ne2000_ioport_write(s, addr + 1, data >> 8); + } + } else if (addr >= 0x10 && addr <= 0x17) { + if (size <= 2) { ne2000_asic_ioport_write(s, addr, data); } else { ne2000_asic_ioport_writel(s, addr, data); } - } else if (addr == 0x1f && size == 1) { + } else if (addr >= 0x18 && addr < 0x20) { ne2000_reset_ioport_write(s, addr, data); } } @@ -914,39 +933,44 @@ static void ne2000_register_types(void) type_init(ne2000_register_types) #endif -#define MAX_PACKET_SIZE 2000 -#define RECEIVE_BUFFER_INDEX_MASK 3 +#define MAX_PACKET_SIZE 1600 +#define MAX_RECEIVE_BUFFER_INDEX 256 static int receive_buffer_index; -static uae_u8 receive_buffer[4][MAX_PACKET_SIZE]; +static uae_u8 *receive_buffer; static int receive_buffer_read, receive_buffer_write; -static int receive_buffer_size[4]; +static int receive_buffer_size[MAX_RECEIVE_BUFFER_INDEX]; static void ne2000_receive_check(void) { - while (receive_buffer_read != receive_buffer_write) { - if (receive_buffer_size[receive_buffer_read]) { - if (ne2000state.isr & (ENISR_RX | ENISR_TX)) - return; - if (ne2000_receive(&ncs, receive_buffer[receive_buffer_read], receive_buffer_size[receive_buffer_read]) < 0) - return; - receive_buffer_size[receive_buffer_read] = 0; - receive_buffer_read++; - receive_buffer_read &= RECEIVE_BUFFER_INDEX_MASK; - } + if (receive_buffer_read != receive_buffer_write) { + if (ne2000state.isr & ENISR_RX) + return; + if (ne2000_receive(&ncs, receive_buffer + receive_buffer_read * MAX_PACKET_SIZE, receive_buffer_size[receive_buffer_read]) < 0) + return; +#ifdef DEBUG_NE2000 + write_log("NE2000: %d byte receive accepted (%d %d)\n", receive_buffer_size[receive_buffer_read], receive_buffer_read, receive_buffer_write); +#endif + receive_buffer_read++; + receive_buffer_read &= (MAX_RECEIVE_BUFFER_INDEX - 1); } } static void gotfunc(void *devv, const uae_u8 *databuf, int len) { +#ifdef DEBUG_NE2000 + write_log("NE2000: %d byte received (%d %d)\n", len, receive_buffer_read, receive_buffer_write); +#endif ne2000_receive_check(); - if (len > MAX_PACKET_SIZE) + if (len > MAX_PACKET_SIZE) return; - if (((receive_buffer_write + 1) & RECEIVE_BUFFER_INDEX_MASK) == receive_buffer_read) + if (((receive_buffer_write + 1) & (MAX_RECEIVE_BUFFER_INDEX - 1)) == receive_buffer_read) { + write_log("NE2000: receive buffer full\n"); return; - memcpy(receive_buffer[receive_buffer_write], databuf, len); + } + memcpy(receive_buffer + receive_buffer_write * MAX_PACKET_SIZE, databuf, len); receive_buffer_size[receive_buffer_write] = len; receive_buffer_write++; - receive_buffer_write &= RECEIVE_BUFFER_INDEX_MASK; + receive_buffer_write &= (MAX_RECEIVE_BUFFER_INDEX - 1); ne2000_receive_check(); } @@ -982,8 +1006,6 @@ static void ne2000_reset(struct pci_board_state *pcibs) { ne2000_reset2(&ne2000state); receive_buffer_read = receive_buffer_write = 0; - for (int i = 0; i <= RECEIVE_BUFFER_INDEX_MASK; i++) - receive_buffer_size[i] = 0; } static void ne2000_free(struct pci_board_state *pcibs) @@ -992,6 +1014,8 @@ static void ne2000_free(struct pci_board_state *pcibs) xfree(sysdata); td = NULL; sysdata = NULL; + xfree(receive_buffer); + receive_buffer = NULL; } static bool ne2000_init(struct pci_board_state *pcibs) @@ -1002,6 +1026,10 @@ static bool ne2000_init(struct pci_board_state *pcibs) ncs.ne2000state = &ne2000state; memset(&ne2000state, 0, sizeof ne2000state); + if (!receive_buffer) { + receive_buffer = xcalloc(uae_u8, MAX_PACKET_SIZE * MAX_RECEIVE_BUFFER_INDEX); + } + td = NULL; uae_u8 *m = ncs.ne2000state->c.macaddr.a; memset(m, 0, 6); diff --git a/rommgr.cpp b/rommgr.cpp index 75dd8dc1..6323f37e 100644 --- a/rommgr.cpp +++ b/rommgr.cpp @@ -1712,7 +1712,8 @@ struct boardromconfig *get_device_rom(struct uae_prefs *p, int romtype, int devn return NULL; } int parentrom = ert->parentromtype ? ert->parentromtype : romtype; - *index = ert->parentromtype ? 1 : 0; + if (index) + *index = ert->parentromtype ? 1 : 0; for (int i = 0; i < MAX_EXPANSION_BOARDS; i++) { struct boardromconfig *brc = &p->expansionboard[i]; if (!brc->device_type)