static int set_tfe_interface(const char *name, void *param) { if (tfe_interface != NULL && name != NULL && strcmp(name, tfe_interface) == 0) { return 0; } util_string_set(&tfe_interface, name); /* CV: if the last interface name was wrong then allow a retry with new name: */ tfe_cannot_use = 0; if (tfe_enabled) { /* ethernet is enabled, make sure that the new name is taken account of */ if (tfe_deactivate() < 0) { return -1; } if (tfe_activate() < 0) { return -1; } /* virtually reset the LAN chip */ tfe_reset(); } return 0; }
static int set_tfe_enabled(int value, void *param) { int val = value ? 1 : 0; if (!tfe_cannot_use) { if (!val) { /* TFE should be deactived */ if (tfe_enabled) { tfe_enabled = 0; if (tfe_deactivate() < 0) { DBG(("TFE: set disabled: error\n")); return -1; } io_source_unregister(tfe_list_item); tfe_list_item = NULL; export_remove(&export_res); } tfe_clockport_changed(); return 0; } else { if (!tfe_enabled) { tfe_enabled = 1; if (tfe_activate() < 0) { return -1; } export_res.io1 = tfe_current_device; if (export_add(&export_res) < 0) { DBG(("TFE: set enabled: error\n")); tfe_list_item = NULL; tfe_enabled = 0; return -1; } if (machine_class == VICE_MACHINE_VIC20) { /* set correct addresses for masC=uerade */ if (tfe_io_swap) { tfe_current_device->start_address = 0x9c00; tfe_current_device->end_address = 0x9fff; } else { tfe_current_device->start_address = 0x9800; tfe_current_device->end_address = 0x9bff; } } tfe_list_item = io_source_register(tfe_current_device); } tfe_clockport_changed(); return 0; } } return 0; }
void tfe_init(void) { tfe_log = log_open("TFE"); rawnet_set_should_accept_func(cs8900_should_accept); if (cs8900_init() < 0) { tfe_enabled = 0; tfe_cannot_use = 1; } if (should_activate) { should_activate = 0; if (tfe_activate() < 0) { tfe_enabled = 0; tfe_cannot_use = 1; } } }