From b63407619f15f85469f9c688fbdd38d1c205dc79 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 20 Feb 2021 18:19:12 +0200 Subject: [PATCH] Development test HD IDE controller. --- expansion.cpp | 8 ++++ ide.cpp | 6 +-- idecontrollers.cpp | 88 ++++++++++++++++++++++++++++++++++++++-- include/idecontrollers.h | 3 ++ include/rommgr.h | 1 + 5 files changed, 99 insertions(+), 7 deletions(-) diff --git a/expansion.cpp b/expansion.cpp index 52b6629f..f534a8bf 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -5788,6 +5788,14 @@ const struct expansionromtype expansionroms[] = { false, 0, x86_rt1000_settings }, +#ifndef NDEBUG + { + _T("dev_ide"), _T("DEV IDE"), NULL, + NULL, dev_hd_init, NULL, dev_hd_add_ide_unit, ROMTYPE_DEVHD | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true, + NULL, 0, + false, EXPANSIONTYPE_CUSTOM | EXPANSIONTYPE_IDE | EXPANSIONTYPE_SCSI + }, +#endif /* PC Bridgeboards */ diff --git a/ide.cpp b/ide.cpp index 4736efa8..d95db8fa 100644 --- a/ide.cpp +++ b/ide.cpp @@ -842,7 +842,7 @@ static void process_rw_command (struct ide_hdf *ide) static void process_packet_command (struct ide_hdf *ide) { setbsy (ide); - write_comm_pipe_u32 (&ide->its->requests, ide->num | 0x100, 1); + write_comm_pipe_u32 (&ide->its->requests, ide->num | 0x8000, 1); } static void atapi_data_done (struct ide_hdf *ide) @@ -1566,8 +1566,8 @@ static void ide_thread (void *idedata) struct ide_hdf *ide; if (its->state == 0 || unit == 0xfffffff) break; - ide = its->idetable[unit & 0xff]; - if (unit & 0x100) + ide = its->idetable[unit & 0x7fff]; + if (unit & 0x8000) do_process_packet_command (ide); else do_process_rw_command (ide); diff --git a/idecontrollers.cpp b/idecontrollers.cpp index 2058137f..381a2cb5 100644 --- a/idecontrollers.cpp +++ b/idecontrollers.cpp @@ -56,7 +56,8 @@ #define TRIFECTA_IDE (IVST500AT_IDE + MAX_DUPLICATE_EXPANSION_BOARDS) #define TANDEM_IDE (TRIFECTA_IDE + MAX_DUPLICATE_EXPANSION_BOARDS) #define DOTTO_IDE (TANDEM_IDE + MAX_DUPLICATE_EXPANSION_BOARDS) -#define TOTAL_IDE (DOTTO_IDE + MAX_DUPLICATE_EXPANSION_BOARDS) +#define DEV_IDE (DOTTO_IDE + MAX_DUPLICATE_EXPANSION_BOARDS) +#define TOTAL_IDE (DEV_IDE + MAX_DUPLICATE_EXPANSION_BOARDS) #define ALF_ROM_OFFSET 0x0100 #define GVP_IDE_ROM_OFFSET 0x8000 @@ -120,13 +121,19 @@ static struct ide_board *accessx_board[MAX_DUPLICATE_EXPANSION_BOARDS]; static struct ide_board *ivst500at_board[MAX_DUPLICATE_EXPANSION_BOARDS]; static struct ide_board *trifecta_board[MAX_DUPLICATE_EXPANSION_BOARDS]; static struct ide_board *tandem_board[MAX_DUPLICATE_EXPANSION_BOARDS]; -static struct ide_board *dotto_board[MAX_DUPLICATE_EXPANSION_BOARDS]; +static struct ide_board* dotto_board[MAX_DUPLICATE_EXPANSION_BOARDS]; +static struct ide_board* dev_board[MAX_DUPLICATE_EXPANSION_BOARDS]; static struct ide_hdf *idecontroller_drive[TOTAL_IDE * 2]; static struct ide_thread_state idecontroller_its; static struct ide_board *ide_boards[MAX_IDE_UNITS + 1]; +static int dev_hd_io_base, dev_hd_io_total; +static int dev_hd_io_size; +static int dev_hd_data_base; +static int dev_hd_io_secondary; + static void freencrunit(struct ide_board *ide) { if (!ide) @@ -593,6 +600,21 @@ static int get_ivst500at_reg(uaecptr addr, struct ide_board *board, int *portnum return reg; } +static int get_dev_hd_reg(uaecptr addr, struct ide_board* board) +{ + int reg = -1; + if (addr >= dev_hd_io_base && addr < dev_hd_io_base + dev_hd_io_total) { + reg = (addr - dev_hd_io_base) / dev_hd_io_size; + reg &= 7; + if (addr & dev_hd_io_secondary) { + reg |= IDE_SECONDARY; + } + } else if (addr >= dev_hd_data_base && addr < dev_hd_data_base + 4) { + reg = 0; + } + return reg; +} + static int getidenum(struct ide_board *board, struct ide_board **arr) { for (int i = 0; i < MAX_DUPLICATE_EXPANSION_BOARDS; i++) { @@ -967,6 +989,12 @@ static uae_u32 ide_read_byte(struct ide_board *board, uaecptr addr) } } + } else if (board->type == DEV_IDE) { + + int reg = get_dev_hd_reg(addr, board); + if (reg >= 0) { + v = get_ide_reg(board, reg); + } } return v; @@ -1269,6 +1297,13 @@ static uae_u32 ide_read_word(struct ide_board *board, uaecptr addr) } } + } else if (board->type == DEV_IDE) { + + int reg = get_dev_hd_reg(addr, board); + if (reg == IDE_DATA) { + v = get_ide_reg(board, reg); + } + } } @@ -1567,8 +1602,14 @@ static void ide_write_byte(struct ide_board *board, uaecptr addr, uae_u8 v) put_ide_reg(board, regnum, v); } - } + } else if (board->type == DEV_IDE) { + int reg = get_dev_hd_reg(addr, board); + if (reg >= 0) { + put_ide_reg(board, reg, v); + } + + } } } @@ -1770,6 +1811,13 @@ static void ide_write_word(struct ide_board *board, uaecptr addr, uae_u16 v) v = adide_encode_word(v); put_ide_reg(board, regnum, v >> 8); } + } else if (board->type == DEV_IDE) { + + int reg = get_dev_hd_reg(addr, board); + if (reg == IDE_DATA) { + put_ide_reg(board, reg, v); + } + } } } @@ -1954,7 +2002,6 @@ bool gvp_ide_rom_autoconfig_init(struct autoconfig_info *aci) ide->bank = &gvp_ide_rom_bank; ide->rom_size = 16384; } - ide->configured = 0; ide->mask = 65536 - 1; ide->type = GVP_IDE; ide->configured = 0; @@ -2898,6 +2945,39 @@ void dotto_add_ide_unit(int ch, struct uaedev_config_info *ci, struct romconfig add_ide_standard_unit(ch, ci, rc, dotto_board, DOTTO_IDE, false, true, 2); } +bool dev_hd_init(struct autoconfig_info* aci) +{ + const struct expansionromtype* ert = get_device_expansion_rom(ROMTYPE_DEVHD); + ide_add_reset(); + + // fake + aci->start = 0xe90000; + aci->size = 0x10000; + dev_hd_io_base = 0x4000; + dev_hd_io_size = 4; + dev_hd_data_base = 0x4800; + dev_hd_io_secondary = 0x1000; + dev_hd_io_total = 0x2000; + if (!aci->doinit) { + return true; + } + struct ide_board *ide = getide(aci); + + ide->bank = &ide_bank_generic; + ide->mask = 65536 - 1; + ide->configured = 1; + ide->baseaddress = aci->start; + map_banks(ide->bank, aci->start >> 16, aci->size >> 16, 0); + + aci->addrbank = ide->bank; + return true; +} + +void dev_hd_add_ide_unit(int ch, struct uaedev_config_info* ci, struct romconfig* rc) +{ + add_ide_standard_unit(ch, ci, rc, dev_board, DEV_IDE, false, true, 2); +} + extern void x86_xt_ide_bios(struct zfile*, struct romconfig*); static bool x86_at_hd_init(struct autoconfig_info *aci, int type) diff --git a/include/idecontrollers.h b/include/idecontrollers.h index d0c414b7..afabe2aa 100644 --- a/include/idecontrollers.h +++ b/include/idecontrollers.h @@ -64,6 +64,9 @@ void tandem_add_ide_unit(int ch, struct uaedev_config_info *ci, struct romconfig void dotto_add_ide_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc); bool dotto_init(struct autoconfig_info *aci); +void dev_hd_add_ide_unit(int ch, struct uaedev_config_info* ci, struct romconfig* rc); +bool dev_hd_init(struct autoconfig_info* aci); + uae_u32 REGPARAM3 apollo_ide_lget (uaecptr addr) REGPARAM; uae_u32 REGPARAM3 apollo_ide_wget (uaecptr addr) REGPARAM; uae_u32 REGPARAM3 apollo_ide_bget (uaecptr addr) REGPARAM; diff --git a/include/rommgr.h b/include/rommgr.h index a5e9c897..a3182943 100644 --- a/include/rommgr.h +++ b/include/rommgr.h @@ -201,6 +201,7 @@ extern int decode_cloanto_rom_do (uae_u8 *mem, int size, int real_size); #define ROMTYPE_S3VIRGE 0x00100089 #define ROMTYPE_VOODOO5 0x0010008a #define ROMTYPE_HD20A 0x0010008b +#define ROMTYPE_DEVHD 0x0010008c #define ROMTYPE_NOT 0x00800000 #define ROMTYPE_QUAD 0x01000000 -- 2.47.3