--- tme/machine/sun2/sun2-mainbus.c 2018/04/24 16:37:52 1.1.1.1 +++ tme/machine/sun2/sun2-mainbus.c 2018/04/24 16:43:22 1.1.1.5 @@ -1,4 +1,4 @@ -/* $Id: sun2-mainbus.c,v 1.1.1.1 2018/04/24 16:37:52 root Exp $ */ +/* $Id: sun2-mainbus.c,v 1.1.1.5 2018/04/24 16:43:22 root Exp $ */ /* machine/sun2/sun2-mainbus.c - implementation of Sun 2 emulation: */ @@ -34,7 +34,7 @@ */ #include -_TME_RCSID("$Id: sun2-mainbus.c,v 1.1.1.1 2018/04/24 16:37:52 root Exp $"); +_TME_RCSID("$Id: sun2-mainbus.c,v 1.1.1.5 2018/04/24 16:43:22 root Exp $"); /* includes: */ #include "sun2-impl.h" @@ -43,18 +43,6 @@ _TME_RCSID("$Id: sun2-mainbus.c,v 1.1.1. #include #include -/* macros: */ - -/* a sun2 mainbus connection: */ -struct tme_sun2_bus_connection { - - /* the generic bus connection: */ - struct tme_bus_connection tme_sun2_bus_connection; - - /* which bus this is: */ - unsigned int tme_sun2_bus_connection_which; -}; - /* this possibly updates that the interrupt priority level driven to the CPU: */ int _tme_sun2_ipl_check(struct tme_sun2 *sun2) @@ -116,19 +104,17 @@ _tme_sun2_bus_signal(struct tme_bus_conn /* recover our sun2: */ sun2 = (struct tme_sun2 *) conn_bus_raiser->tme_bus_connection.tme_connection_element->tme_element_private; - /* take out the level and edge. all of our signals are active low: */ + /* see whether the signal is asserted or negated: */ signal_asserted = TRUE; switch (signal & TME_BUS_SIGNAL_LEVEL_MASK) { - case TME_BUS_SIGNAL_LEVEL_LOW: - case TME_BUS_SIGNAL_LEVEL_ASSERTED: - break; - case TME_BUS_SIGNAL_LEVEL_HIGH: case TME_BUS_SIGNAL_LEVEL_NEGATED: signal_asserted = FALSE; + case TME_BUS_SIGNAL_LEVEL_ASSERTED: break; + default: + abort(); } - signal &= ~(TME_BUS_SIGNAL_LEVEL_MASK - | TME_BUS_SIGNAL_EDGE); + signal = TME_BUS_SIGNAL_WHICH(signal); /* dispatch on the signal: */ @@ -139,12 +125,12 @@ _tme_sun2_bus_signal(struct tme_bus_conn /* reset: */ else if (signal == TME_BUS_SIGNAL_RESET) { - abort(); + /* XXX reset is just ignored for now: */ } /* an interrupt signal: */ else if (TME_BUS_SIGNAL_IS_INT(signal)) { - ipl = TME_BUS_SIGNAL_WHICH_INT(signal); + ipl = TME_BUS_SIGNAL_INDEX_INT(signal); if (ipl >= TME_M68K_IPL_MIN && ipl <= TME_M68K_IPL_MAX) { @@ -206,6 +192,12 @@ _tme_sun2_bus_intack(struct tme_bus_conn if (rc != ENOENT) { return (rc); } + /* obmem: */ + rc = (*sun2->tme_sun2_obmem->tme_bus_intack) + (sun2->tme_sun2_obmem, signal, vector); + if (rc != ENOENT) { + return (rc); + } if (sun2->tme_sun2_has_vme) { /* VME: */ rc = (*sun2->tme_sun2_vmebus->tme_bus_intack) @@ -286,9 +278,6 @@ _tme_sun2_command(struct tme_element *el if (do_reset) { - /* reset the MMU: */ - _tme_sun2_mmu_reset(sun2); - /* reset the CPU: */ (*sun2->tme_sun2_m68k->tme_m68k_bus_connection.tme_bus_signal) (&sun2->tme_sun2_m68k->tme_m68k_bus_connection, @@ -355,7 +344,7 @@ _tme_sun2_connection_score(struct tme_co /* this must be an m68k chip, and not another bus: */ case TME_CONNECTION_BUS_M68K: - if (conn_bus->tme_bus_tlb_set_allocate == NULL + if (conn_bus->tme_bus_tlb_set_add == NULL && conn_m68k->tme_m68k_bus_tlb_fill == NULL) { score = 10; } @@ -363,7 +352,7 @@ _tme_sun2_connection_score(struct tme_co /* this must be a bus, and not a chip: */ case TME_CONNECTION_BUS_GENERIC: - if (conn_bus->tme_bus_tlb_set_allocate != NULL + if (conn_bus->tme_bus_tlb_set_add != NULL && conn_bus->tme_bus_tlb_fill != NULL && sun2->tme_sun2_buses[conn_sun2->tme_sun2_bus_connection_which] == NULL) { score = 1; @@ -451,7 +440,7 @@ _tme_sun2_connections_new(struct tme_ele /* fill in the generic bus connection: */ conn_bus->tme_bus_signal = _tme_sun2_bus_signal; conn_bus->tme_bus_intack = _tme_sun2_bus_intack; - conn_bus->tme_bus_tlb_set_allocate = _tme_sun2_mmu_tlb_set_allocate; + conn_bus->tme_bus_tlb_set_add = _tme_sun2_mmu_tlb_set_add; /* full in the m68k bus connection: */ conn_m68k->tme_m68k_bus_tlb_fill = _tme_sun2_m68k_tlb_fill; @@ -474,7 +463,7 @@ _tme_sun2_connections_new(struct tme_ele which_bus = TME_SUN2_BUS_OBIO; } - if (sun2->tme_sun2_obio == NULL) { + if (sun2->tme_sun2_obmem == NULL) { tme_output_append(&free_buses, " obmem"); } if (TME_ARG_IS(args[1], "obmem")) { @@ -501,7 +490,7 @@ _tme_sun2_connections_new(struct tme_ele which_bus = TME_SUN2_BUS_MBIO; } - if (sun2->tme_sun2_mbio == NULL) { + if (sun2->tme_sun2_mbmem == NULL) { tme_output_append(&free_buses, " mbmem"); } if (TME_ARG_IS(args[1], "mbmem")) { @@ -549,9 +538,17 @@ _tme_sun2_connections_new(struct tme_ele conn->tme_connection_break = _tme_sun2_connection_break; /* fill in the generic bus connection: */ + if (which_bus == TME_SUN2_BUS_MBMEM) { + conn_bus->tme_bus_subregions.tme_bus_subregion_address_last + = TME_SUN2_DVMA_SIZE_MBMEM; + } + else if (which_bus == TME_SUN2_BUS_VME) { + conn_bus->tme_bus_subregions.tme_bus_subregion_address_last + = TME_SUN2_DVMA_SIZE_VME; + } conn_bus->tme_bus_signal = _tme_sun2_bus_signal; conn_bus->tme_bus_intack = NULL; - conn_bus->tme_bus_tlb_set_allocate = _tme_sun2_mmu_tlb_set_allocate; + conn_bus->tme_bus_tlb_set_add = _tme_sun2_mmu_tlb_set_add; conn_bus->tme_bus_tlb_fill = _tme_sun2_bus_tlb_fill; /* fill in the sun2 connection: */ @@ -662,8 +659,8 @@ TME_ELEMENT_NEW_DECL(tme_machine_sun2) { sun2->tme_sun2_mbmem = NULL; sun2->tme_sun2_vmebus = NULL; - /* we don't have the CPU's reset TLBs yet: */ - sun2->tme_sun2_reset_tlbs = NULL; + /* we don't have the CPU's bus context register yet: */ + sun2->tme_sun2_m68k_bus_context = NULL; /* fill the element: */ element->tme_element_private = sun2; @@ -687,11 +684,11 @@ TME_ELEMENT_SUB_NEW_DECL(tme_machine_sun /* Timer 1 is connected to the bus as ipl 7 (inverted): */ socket.tme_am9513_socket_counter_signals[0] = - TME_BUS_SIGNAL_INT(7) | TME_BUS_SIGNAL_LEVEL_INVERTED; + TME_BUS_SIGNAL_INT(7) | (TME_BUS_SIGNAL_LEVEL_ASSERTED ^ TME_BUS_SIGNAL_LEVEL_HIGH); /* Timer 2 is connected to the bus as ipl 5 (inverted): */ socket.tme_am9513_socket_counter_signals[1] = - TME_BUS_SIGNAL_INT(5) | TME_BUS_SIGNAL_LEVEL_INVERTED; + TME_BUS_SIGNAL_INT(5) | (TME_BUS_SIGNAL_LEVEL_ASSERTED ^ TME_BUS_SIGNAL_LEVEL_HIGH); /* Timer 3 is connected to the bus as ???: */ socket.tme_am9513_socket_counter_signals[2] = TME_BUS_SIGNAL_ABORT; @@ -726,20 +723,22 @@ TME_ELEMENT_SUB_NEW_DECL(tme_machine_sun /* this creates a new Sun-2 z8530: */ TME_ELEMENT_SUB_NEW_DECL(tme_machine_sun2,zs) { - struct tme_z8530_socket socket; + struct tme_z8530_socket socket = TME_SUN_Z8530_SOCKET_INIT; char *sub_args[2]; - /* create the z8530 socket: */ - socket.tme_z8530_socket_version = TME_Z8530_SOCKET_0; - socket.tme_z8530_socket_address_chan_a = 4; - socket.tme_z8530_socket_address_chan_b = 0; - socket.tme_z8530_socket_offset_csr = 0; - socket.tme_z8530_socket_offset_data = 2; + /* override the least lane in the z8530 socket: */ socket.tme_z8530_socket_port_least_lane = 1; /* D15-D8 */ - socket.tme_z8530_socket_pclk = (9600 * 512); + + /* override the socket flags: */ + socket.tme_z8530_socket_flags |= TME_Z8530_SOCKET_FLAG_IEI_TIED_LOW; /* create the z8530: */ sub_args[0] = "tme/ic/z8530"; sub_args[1] = NULL; return (tme_element_new(element, (const char * const *) sub_args, &socket, _output)); } + +/* this creates a new Sun-2 bwtwo: */ +TME_ELEMENT_SUB_NEW_DECL(tme_machine_sun2,bwtwo) { + return (tme_sun_bwtwo(element, args, _output)); +}