src/osd/osdnet.h
| r13514 | r13515 | |
| 3 | 3 | #ifndef __OSDNET_H__ |
| 4 | 4 | #define __OSDNET_H__ |
| 5 | 5 | |
| 6 | class netdev; |
| 7 | |
| 8 | #define CREATE_NETDEV(name) class netdev *name(const char *ifname, class device_network_interface *ifdev, int rate) |
| 9 | typedef class netdev *(*create_netdev)(const char *ifname, class device_network_interface *ifdev, int rate); |
| 10 | |
| 11 | typedef struct netdev_entry |
| 12 | { |
| 13 | int id; |
| 14 | char name[256]; |
| 15 | char description[256]; |
| 16 | create_netdev func; |
| 17 | struct netdev_entry *m_next; |
| 18 | } netdev_entry_t; |
| 19 | |
| 6 | 20 | class netdev |
| 7 | 21 | { |
| 8 | 22 | public: |
| r13514 | r13515 | |
| 25 | 39 | class device_network_interface *m_dev; |
| 26 | 40 | }; |
| 27 | 41 | |
| 28 | | #define CREATE_NETDEV(name) class netdev *name(const char *ifname, class device_network_interface *ifdev, int rate) |
| 29 | | typedef class netdev *(*create_netdev)(const char *ifname, class device_network_interface *ifdev, int rate); |
| 30 | | |
| 31 | 42 | class netdev *open_netdev(int id, class device_network_interface *ifdev, int rate); |
| 32 | | void add_netdev(const char *name, create_netdev func); |
| 43 | void add_netdev(const char *name, const char *description, create_netdev func); |
| 33 | 44 | void clear_netdev(); |
| 45 | const netdev_entry_t *netdev_first(); |
| 46 | int netdev_count(); |
| 34 | 47 | #endif |
src/osd/osdnet.c
| r13514 | r13515 | |
| 1 | 1 | #include "emu.h" |
| 2 | 2 | #include "osdnet.h" |
| 3 | 3 | |
| 4 | | typedef struct netdev_entry |
| 5 | | { |
| 6 | | int id; |
| 7 | | char name[256]; |
| 8 | | create_netdev func; |
| 9 | | struct netdev_entry *m_next; |
| 10 | | } netdev_entry_t; |
| 11 | | |
| 12 | 4 | static class simple_list<netdev_entry_t> netdev_list; |
| 13 | 5 | |
| 14 | | void add_netdev(const char *name, create_netdev func) |
| 6 | void add_netdev(const char *name, const char *description, create_netdev func) |
| 15 | 7 | { |
| 16 | 8 | netdev_entry_t *entry = global_alloc_clear(netdev_entry_t); |
| 17 | 9 | entry->id = netdev_list.count(); |
| 18 | 10 | strncpy(entry->name, name, 255); |
| 19 | 11 | entry->name[255] = '\0'; |
| 12 | strncpy(entry->description, description, 255); |
| 13 | entry->description[255] = '\0'; |
| 20 | 14 | entry->func = func; |
| 21 | 15 | netdev_list.append(*entry); |
| 22 | 16 | } |
| r13514 | r13515 | |
| 26 | 20 | netdev_list.reset(); |
| 27 | 21 | } |
| 28 | 22 | |
| 23 | const netdev_entry_t *netdev_first() { |
| 24 | return netdev_list.first(); |
| 25 | } |
| 26 | |
| 29 | 27 | class netdev *open_netdev(int id, class device_network_interface *ifdev, int rate) |
| 30 | 28 | { |
| 31 | 29 | netdev_entry_t *entry = netdev_list.first(); |
| r13514 | r13515 | |
| 97 | 95 | return "\0\0\0\0\0\0"; |
| 98 | 96 | } |
| 99 | 97 | |
| 98 | int netdev_count() |
| 99 | { |
| 100 | return netdev_list.count(); |
| 101 | } |
src/emu/network.c
| r0 | r13515 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | network.c |
| 4 | |
| 5 | Core network functions and definitions. |
| 6 | |
| 7 | Copyright Nicola Salmoria and the MAME Team. |
| 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | |
| 10 | ***************************************************************************/ |
| 11 | #include <ctype.h> |
| 12 | |
| 13 | #include "emu.h" |
| 14 | #include "emuopts.h" |
| 15 | #include "network.h" |
| 16 | #include "config.h" |
| 17 | #include "xmlfile.h" |
| 18 | |
| 19 | /*************************************************************************** |
| 20 | INITIALIZATION HELPERS |
| 21 | ***************************************************************************/ |
| 22 | |
| 23 | static void network_load(running_machine &machine, int config_type, xml_data_node *parentnode) |
| 24 | { |
| 25 | xml_data_node *node; |
| 26 | device_network_interface *network = NULL; |
| 27 | if ((config_type == CONFIG_TYPE_GAME) && (parentnode != NULL)) |
| 28 | { |
| 29 | for (node = xml_get_sibling(parentnode->child, "device"); node; node = xml_get_sibling(node->next, "device")) |
| 30 | { |
| 31 | const char *tag = xml_get_attribute_string(node, "tag", NULL); |
| 32 | |
| 33 | if ((tag != NULL) && (tag[0] != '\0')) |
| 34 | { |
| 35 | for (bool gotone = machine.devicelist().first(network); gotone; gotone = network->next(network)) |
| 36 | { |
| 37 | if (!strcmp(tag, network->device().tag())) { |
| 38 | int interface = xml_get_attribute_int(node, "interface", 0); |
| 39 | network->set_interface(interface); |
| 40 | const char *mac_addr = xml_get_attribute_string(node, "mac", NULL); |
| 41 | if (mac_addr != NULL && strlen(mac_addr)==17) { |
| 42 | char mac[7]; |
| 43 | unsigned int mac_num[6]; |
| 44 | sscanf (mac_addr,"%02x:%02x:%02x:%02x:%02x:%02x",&mac_num[0],&mac_num[1],&mac_num[2],&mac_num[3],&mac_num[4],&mac_num[5]); |
| 45 | for (int i=0;i<6;i++) mac[i]=mac_num[i]; |
| 46 | network->set_mac(mac); |
| 47 | } |
| 48 | |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | static void network_save(running_machine &machine, int config_type, xml_data_node *parentnode) |
| 57 | { |
| 58 | xml_data_node *node; |
| 59 | device_network_interface *network = NULL; |
| 60 | |
| 61 | /* only care about game-specific data */ |
| 62 | if (config_type == CONFIG_TYPE_GAME) |
| 63 | { |
| 64 | for (bool gotone = machine.devicelist().first(network); gotone; gotone = network->next(network)) |
| 65 | { |
| 66 | node = xml_add_child(parentnode, "device", NULL); |
| 67 | if (node != NULL) |
| 68 | { |
| 69 | xml_set_attribute(node, "tag", network->device().tag()); |
| 70 | xml_set_attribute_int(node, "interface", network->get_interface()); |
| 71 | const char *mac = network->get_mac(); |
| 72 | char mac_addr[6*3]; |
| 73 | sprintf(mac_addr,"%02x:%02x:%02x:%02x:%02x:%02x",(UINT8)mac[0],(UINT8)mac[1],(UINT8)mac[2],(UINT8)mac[3],(UINT8)mac[4],(UINT8)mac[5]); |
| 74 | xml_set_attribute(node, "mac", mac_addr); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | /*************************************************************************** |
| 81 | INITIALIZATION |
| 82 | ***************************************************************************/ |
| 83 | |
| 84 | /*------------------------------------------------- |
| 85 | network_init - start up the network system |
| 86 | -------------------------------------------------*/ |
| 87 | |
| 88 | void network_init(running_machine &machine) |
| 89 | { |
| 90 | config_register(machine, "network", config_saveload_delegate(FUNC(network_load), &machine), config_saveload_delegate(FUNC(network_save), &machine)); |
| 91 | } |
src/emu/uimain.c
| r13514 | r13515 | |
| 10 | 10 | *********************************************************************/ |
| 11 | 11 | |
| 12 | 12 | #include "emu.h" |
| 13 | #include "osdnet.h" |
| 13 | 14 | #include "emuopts.h" |
| 14 | 15 | #include "ui.h" |
| 15 | 16 | #include "rendutil.h" |
| r13514 | r13515 | |
| 489 | 490 | |
| 490 | 491 | |
| 491 | 492 | /*------------------------------------------------- |
| 493 | menu_network_devices_populate - populates the main |
| 494 | network device menu |
| 495 | -------------------------------------------------*/ |
| 496 | |
| 497 | static void menu_network_devices_populate(running_machine &machine, ui_menu *menu, void *state) |
| 498 | { |
| 499 | device_network_interface *network = NULL; |
| 500 | |
| 501 | /* cycle through all devices for this system */ |
| 502 | for (bool gotone = machine.devicelist().first(network); gotone; gotone = network->next(network)) |
| 503 | { |
| 504 | int curr = network->get_interface(); |
| 505 | const char *title = NULL; |
| 506 | const netdev_entry_t *entry = netdev_first(); |
| 507 | while(entry) { |
| 508 | if(entry->id==curr) { |
| 509 | title = entry->description; |
| 510 | break; |
| 511 | } |
| 512 | entry = entry->m_next; |
| 513 | } |
| 514 | |
| 515 | menu->item_append(network->device().tag(), (title) ? title : "------", MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)network); |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | /*------------------------------------------------- |
| 520 | ui_menu_network_devices - menu that |
| 521 | -------------------------------------------------*/ |
| 522 | |
| 523 | static void ui_menu_network_devices(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 524 | { |
| 525 | const ui_menu_event *menu_event; |
| 526 | |
| 527 | /* if the menu isn't built, populate now */ |
| 528 | if (!menu->populated()) |
| 529 | { |
| 530 | menu_network_devices_populate(machine, menu, state); |
| 531 | } |
| 532 | |
| 533 | /* process the menu */ |
| 534 | menu_event = menu->process(0); |
| 535 | |
| 536 | if (menu_event != NULL && menu_event->itemref != NULL) |
| 537 | { |
| 538 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { |
| 539 | device_network_interface *network = (device_network_interface *)menu_event->itemref; |
| 540 | int curr = network->get_interface(); |
| 541 | if (menu_event->iptkey == IPT_UI_LEFT) curr--; else curr++; |
| 542 | if (curr==-2) curr = netdev_count() - 1; |
| 543 | network->set_interface(curr); |
| 544 | menu->reset(UI_MENU_RESET_REMEMBER_REF); |
| 545 | } |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | /*------------------------------------------------- |
| 492 | 550 | menu_main_populate - populate the main menu |
| 493 | 551 | -------------------------------------------------*/ |
| 494 | 552 | |
| r13514 | r13515 | |
| 558 | 616 | menu->item_append("Slot Devices", NULL, 0, (void*)ui_menu_slot_devices); |
| 559 | 617 | } |
| 560 | 618 | |
| 619 | device_network_interface *network = NULL; |
| 620 | if (machine.devicelist().first(network)) |
| 621 | { |
| 622 | /* add image info menu */ |
| 623 | menu->item_append("Network Devices", NULL, 0, (void*)ui_menu_network_devices); |
| 624 | } |
| 625 | |
| 561 | 626 | /* add keyboard mode menu */ |
| 562 | 627 | if (input_machine_has_keyboard(machine) && inputx_can_post(machine)) |
| 563 | 628 | menu->item_append("Keyboard Mode", NULL, 0, (void *)ui_menu_keyboard_mode); |
src/mess/machine/ne1000.c
| r13514 | r13515 | |
| 28 | 28 | void ne1000_device::device_start() { |
| 29 | 29 | char mac[7]; |
| 30 | 30 | UINT32 num = rand(); |
| 31 | | m_dp8390->set_interface(0); // XXX make user configurable |
| 32 | 31 | memset(m_prom, 0x57, 16); |
| 33 | 32 | sprintf(mac+2, "\x1b%c%c%c", (num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff); |
| 34 | 33 | mac[0] = 0; mac[1] = 0; // avoid gcc warning |
| 35 | 34 | memcpy(m_prom, mac, 6); |
| 35 | m_dp8390->set_mac(mac); |
| 36 | 36 | set_isa_device(); |
| 37 | 37 | m_isa->install_device(0x0300, 0x031f, 0, 0, read8_delegate(FUNC(ne1000_device::ne1000_port_r), this), write8_delegate(FUNC(ne1000_device::ne1000_port_w), this)); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | void ne1000_device::device_reset() { |
| 41 | memcpy(m_prom, m_dp8390->get_mac(), 6); |
| 41 | 42 | } |
| 42 | 43 | |
| 43 | 44 | READ8_MEMBER(ne1000_device::ne1000_port_r) { |
src/mess/machine/x68k_neptunex.c
| r13514 | r13515 | |
| 49 | 49 | UINT32 num = rand(); |
| 50 | 50 | address_space* space = cpu->memory().space(AS_PROGRAM); |
| 51 | 51 | m_slot = dynamic_cast<x68k_expansion_slot_device *>(owner()); |
| 52 | | m_dp8390->set_interface(0); // XXX make user configurable |
| 53 | 52 | memset(m_prom, 0x57, 16); |
| 54 | 53 | sprintf(mac+2, "\x1b%c%c%c", (num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff); |
| 55 | 54 | mac[0] = 0; mac[1] = 0; // avoid gcc warning |
| 56 | 55 | memcpy(m_prom, mac, 6); |
| 56 | m_dp8390->set_mac(mac); |
| 57 | 57 | space->install_readwrite_handler(0xece000,0xece3ff,read16_delegate(FUNC(x68k_neptune_device::x68k_neptune_port_r),this),write16_delegate(FUNC(x68k_neptune_device::x68k_neptune_port_w),this),0xffffffff); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | void x68k_neptune_device::device_reset() { |
| 61 | memcpy(m_prom, m_dp8390->get_mac(), 6); |
| 62 | } |
| 63 | |
| 60 | 64 | READ16_MEMBER(x68k_neptune_device::x68k_neptune_port_r) |
| 61 | 65 | { |
| 62 | 66 | UINT16 data; |
src/mess/machine/3c503.c
| r13514 | r13515 | |
| 30 | 30 | void el2_3c503_device::device_start() { |
| 31 | 31 | char mac[7]; |
| 32 | 32 | UINT32 num = rand(); |
| 33 | | m_dp8390->set_interface(0); // XXX make user configurable |
| 34 | 33 | memset(m_prom, 0x57, 16); |
| 35 | 34 | sprintf(mac, "\x02\x60\x8c%c%c%c", (num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff); |
| 36 | 35 | memcpy(m_prom, mac, 6); |
| 37 | 36 | memset(m_rom, 0, 8*1024); // empty |
| 38 | | |
| 37 | m_dp8390->set_mac(mac); |
| 39 | 38 | set_isa_device(); |
| 40 | 39 | m_isa->install_device(0x0300, 0x030f, 0, 0, read8_delegate(FUNC(el2_3c503_device::el2_3c503_loport_r), this), write8_delegate(FUNC(el2_3c503_device::el2_3c503_loport_w), this)); |
| 41 | 40 | m_isa->install_device(0x0700, 0x070f, 0, 0, read8_delegate(FUNC(el2_3c503_device::el2_3c503_hiport_r), this), write8_delegate(FUNC(el2_3c503_device::el2_3c503_hiport_w), this)); |
| 42 | 41 | } |
| 43 | 42 | |
| 44 | 43 | void el2_3c503_device::device_reset() { |
| 44 | memcpy(m_prom, m_dp8390->get_mac(), 6); |
| 45 | 45 | memset(&m_regs, 0, sizeof(m_regs)); |
| 46 | 46 | m_regs.bcfr = 0x80; // port 0x300 |
| 47 | 47 | m_regs.pcfr = 0x20; // address 0xcc000 |
src/mess/machine/ne2000.c
| r13514 | r13515 | |
| 28 | 28 | void ne2000_device::device_start() { |
| 29 | 29 | char mac[7]; |
| 30 | 30 | UINT32 num = rand(); |
| 31 | | m_dp8390->set_interface(0); // XXX make user configurable |
| 32 | 31 | memset(m_prom, 0x57, 16); |
| 33 | 32 | sprintf(mac+2, "\x1b%c%c%c", (num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff); |
| 34 | 33 | mac[0] = 0; mac[1] = 0; // avoid gcc warning |
| 35 | 34 | memcpy(m_prom, mac, 6); |
| 35 | m_dp8390->set_mac(mac); |
| 36 | 36 | set_isa_device(); |
| 37 | | m_isa->install16_device(0x0300, 0x031f, 0, 0, read16_delegate(FUNC(ne2000_device::ne2000_port_r), this), write16_delegate(FUNC(ne2000_device::ne2000_port_w), this)); |
| 37 | m_isa->install16_device(0x0300, 0x031f, 0, 0, read16_delegate(FUNC(ne2000_device::ne2000_port_r), this), write16_delegate(FUNC(ne2000_device::ne2000_port_w), this)); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | void ne2000_device::device_reset() { |
| 41 | memcpy(m_prom, m_dp8390->get_mac(), 6); |
| 41 | 42 | } |
| 42 | 43 | |
| 43 | 44 | READ16_MEMBER(ne2000_device::ne2000_port_r) { |
src/mess/machine/nubus_asntmc3b.c
| r13514 | r13515 | |
| 106 | 106 | UINT32 slotspace; |
| 107 | 107 | char mac[7]; |
| 108 | 108 | UINT32 num = rand(); |
| 109 | | m_dp83902->set_interface(0); // XXX make user configurable |
| 110 | 109 | memset(m_prom, 0x57, 16); |
| 111 | 110 | sprintf(mac+2, "\x1b%c%c%c", (num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff); |
| 112 | 111 | mac[0] = mac[1] = 0; // avoid gcc warning |
| 113 | 112 | memcpy(m_prom, mac, 6); |
| 114 | | |
| 113 | m_dp83902->set_mac(mac); |
| 115 | 114 | // set_nubus_device makes m_slot valid |
| 116 | 115 | set_nubus_device(); |
| 117 | 116 | install_declaration_rom(this, MAC8390_ROM_REGION, true); |
| r13514 | r13515 | |
| 136 | 135 | { |
| 137 | 136 | m_dp83902->dp8390_reset(0); |
| 138 | 137 | m_dp83902->dp8390_cs(0); |
| 138 | memcpy(m_prom, m_dp83902->get_mac(), 6); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | WRITE8_MEMBER( nubus_mac8390_device::asntm3b_ram_w ) |