status_t periph_safe_exec(scsi_periph_device_info *device, scsi_ccb *request) { err_res res; int retries = 0; do { device->scsi->sync_io(request); // ask generic peripheral layer what to do now res = periph_check_error(device, request); if (res.action == err_act_start) { // backup request, as we need it temporarily for sending "start" // (we cannot allocate a new cdb as there may be no more cdb and // waiting for one to become empty may lead to deadlock if everyone // does that) uint32 backup_flags; uint8 backup_cdb[SCSI_MAX_CDB_SIZE]; uchar backup_cdb_len; int64 backup_sort; bigtime_t backup_timeout; uchar *backup_data; const physical_entry *backup_sg_list; uint16 backup_sg_count; uint32 backup_data_len; backup_flags = request->flags; memcpy(backup_cdb, request->cdb, SCSI_MAX_CDB_SIZE); backup_cdb_len = request->cdb_length; backup_sort = request->sort; backup_timeout = request->timeout; backup_data = request->data; backup_sg_list = request->sg_list; backup_sg_count = request->sg_count; backup_data_len = request->data_length; SHOW_INFO0( 2, "Sending start to init LUN" ); res = periph_send_start_stop(device, request, 1, device->removable); request->flags = backup_flags; memcpy(request->cdb, backup_cdb, SCSI_MAX_CDB_SIZE); request->cdb_length = backup_cdb_len; request->sort = backup_sort; request->timeout = backup_timeout; request->data = backup_data; request->sg_list = backup_sg_list; request->sg_count = backup_sg_count; request->data_length = backup_data_len; if (res.action == err_act_ok) res.action = err_act_retry; } } while ((res.action == err_act_retry && retries++ < 3) || (res.action == err_act_many_retries && retries++ < 30)); return res.error_code; }
int rtl8169_detect(rtl8169 **rtl8169_list) { unsigned int i, j; //pci_module_hooks *pci; //pci_info pinfo; rtl8169 *r; *rtl8169_list = NULL; if(module_get(PCI_BUS_MODULE_NAME, 0, (void **)(void *)&pci) < 0) { SHOW_INFO0(1, "rtl8169_detect: no pci bus found..\n"); return -1; } for (i = 0; pci->get_nth_pci_info(i, &pinfo) >= NO_ERROR; i++) { for (j = 0; j < sizeof(match)/sizeof(match[0]); j++) { if (pinfo.vendor_id == match[j].vendor && pinfo.device_id == match[j].device) { // we found one SHOW_INFO(1, "rtl8169_detect: found device at pci %d:%d:%d\n", pinfo.bus, pinfo.device, pinfo.function); r = kmalloc(sizeof(rtl8169)); if (r == NULL) { SHOW_ERROR0(1, "rtl8169_detect: error allocating memory for rtl8169 structure\n"); continue; } memset(r, 0, sizeof(rtl8169)); r->irq = pinfo.u.h0.interrupt_line; // find the memory-mapped base int range; for (range = 0; range < 6; range++) { if (pinfo.u.h0.base_registers[range] > 0xffff) { r->phys_base = pinfo.u.h0.base_registers[range]; r->phys_size = pinfo.u.h0.base_register_sizes[range]; break; } else if (pinfo.u.h0.base_registers[range] > 0) { r->io_port = pinfo.u.h0.base_registers[range]; } } if (r->phys_base == 0) { kfree(r); r = NULL; continue; } SHOW_INFO(1, "detected rtl8169 at irq %d, memory base 0x%lx, size 0x%lx, io base 0x%lx\n", r->irq, r->phys_base, r->phys_size, r->io_port); // add it to the list r->next = *rtl8169_list; *rtl8169_list = r; } } } module_put(PCI_BUS_MODULE_NAME); return *rtl8169_list ? 0 : ERR_NOT_FOUND; }
status_t init_hardware(void) { SHOW_INFO0(0, RADEON_DRIVER_VERSION); if (Radeon_CardDetect() == B_OK) return B_OK; return B_ERROR; }
int do_test_userland(const char *test_parm) { (void) test_parm; char testdata[5]; int res; int32_t code; strcpy(testdata, "abcd"); SHOW_INFO0( 0, "port_create()"); uland_port = port_create(1, "__regress_test_port"); test_check_ge(uland_port,0); SHOW_INFO0( 0, "port_write()"); res = port_write(uland_port, 1, &testdata, sizeof(testdata)); test_check_eq(res,0); testdata[0] = 0; SHOW_INFO0( 0, "port_read()"); res = port_read_etc(uland_port, &code, &testdata, sizeof(testdata), PORT_FLAG_TIMEOUT, 1000000); test_check_eq(res,5); test_check_eq(code,0xAA); test_check_eq( strcmp(testdata, "abcd"), 0); SHOW_INFO0( 0, "port_read() - wait for userland to finish"); res = port_read_etc(uland_port, &code, &testdata, sizeof(testdata), PORT_FLAG_TIMEOUT, 1000000); test_check_ge(res,0); test_check_eq(code,0x55); SHOW_INFO0( 0, "close port"); res = port_close(uland_port); test_check_ne(res,0); #if 0 SHOW_INFO0( 0, "delete port"); res = port_delete(test_p2); test_check_eq(res,0); #endif SHOW_INFO0( 0, "end test"); return 0; }
// check, whether there is *any* supported card plugged in bool Radeon_CardDetect( void ) { long pci_index = 0; pci_info pcii; bool found_one = FALSE; if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci_bus) != B_OK) return B_ERROR; while ((*pci_bus->get_nth_pci_info)(pci_index, &pcii) == B_NO_ERROR) { int vendor = 0; while (SupportedVendors[vendor].vendor_id) { if (SupportedVendors[vendor].vendor_id == pcii.vendor_id) { RadeonDevice *devices = SupportedVendors[vendor].devices; while (devices->device_id) { if (devices->device_id == pcii.device_id ) { rom_info ri; if( Radeon_MapBIOS( &pcii, &ri ) == B_OK ) { Radeon_UnmapBIOS( &ri ); SHOW_INFO( 0, "found supported device pci index %ld, device 0x%04x/0x%04x", pci_index, pcii.vendor_id, pcii.device_id ); found_one = TRUE; goto done; } } devices++; } } vendor++; } pci_index++; } SHOW_INFO0( 0, "no supported devices found" ); done: put_module(B_PCI_MODULE_NAME); return (found_one ? B_OK : B_ERROR); }
void if_simple_setup(ifnet *interface, int addr, int netmask, int bcast, int net, int router, int def_router) { ifaddr *address; //addr = htonl(addr); //netmask = htonl(netmask); //bcast = htonl(bcast); // set the ip address for this net interface address = malloc(sizeof(ifaddr)); address->addr.len = 4; address->addr.type = ADDR_TYPE_IP; //NETADDR_TO_IPV4(address->addr) = htonl(addr); NETADDR_TO_IPV4(address->addr) = addr; address->netmask.len = 4; address->netmask.type = ADDR_TYPE_IP; //NETADDR_TO_IPV4(address->netmask) = htonl(netmask); NETADDR_TO_IPV4(address->netmask) = netmask; address->broadcast.len = 4; address->broadcast.type = ADDR_TYPE_IP; //NETADDR_TO_IPV4(address->broadcast) = htonl(bcast); NETADDR_TO_IPV4(address->broadcast) = bcast; if_bind_address(interface, address); #if 1 printf("if a "); dump_ipv4_addr(addr); printf(" mask "); dump_ipv4_addr(netmask); printf(" broad "); dump_ipv4_addr(bcast); printf("\n"); #endif // set up an initial routing table int rc; if( (rc = ipv4_route_add( net, netmask, router, interface->id) ) ) { SHOW_ERROR( 1, "Adding route - failed, rc = %d", rc); } else { SHOW_INFO0( 2, "Adding route - ok"); } SHOW_INFO0( 2, "Adding default route..."); if( (rc = ipv4_route_add_default( router, interface->id, def_router ) ) ) { SHOW_ERROR( 1, "Adding route - failed, rc = %d", rc); } else { SHOW_INFO0( 2, "Adding route - ok"); } #if 0 hal_start_kernel_thread_arg( bootp_thread, interface ); #else // Now try to get something real :) bootp(interface); #endif }
/*! Decode sense data and generate error code. */ static err_res check_sense(scsi_periph_device_info *device, scsi_ccb *request) { scsi_sense *sense = (scsi_sense *)request->sense; if ((request->subsys_status & SCSI_AUTOSNS_VALID) == 0) { SHOW_ERROR0(2, "No auto-sense (but there should be)"); // shouldn't happen (cam_status should be CAM_AUTOSENSE_FAIL // as we asked for autosense) return MK_ERROR(err_act_fail, B_ERROR); } if (SCSI_MAX_SENSE_SIZE - request->sense_resid < (int)offsetof(scsi_sense, add_sense_length) + 1) { SHOW_ERROR(2, "sense too short (%d bytes)", SCSI_MAX_SENSE_SIZE - request->sense_resid); // that's a bit too short return MK_ERROR(err_act_fail, B_ERROR); } switch (sense->error_code) { case SCSIS_DEFERRED_ERROR: // we are doomed - some previous request turned out to have failed // we neither know which one nor can we resubmit it SHOW_ERROR0(2, "encountered DEFERRED ERROR - bye, bye"); return MK_ERROR(err_act_ok, B_OK); case SCSIS_CURR_ERROR: // we start with very specific and finish very general error infos switch ((sense->asc << 8) | sense->ascq) { case SCSIS_ASC_AUDIO_PLAYING: SHOW_INFO0(2, "busy because playing audio"); // we need something like "busy" return MK_ERROR(err_act_fail, B_DEV_NOT_READY); case SCSIS_ASC_LUN_NEED_INIT: SHOW_INFO0(2, "LUN needs init"); // reported by some devices that are idle and spun down // sending START UNIT should awake them return MK_ERROR(err_act_start, B_NO_INIT); case SCSIS_ASC_LUN_NEED_MANUAL_HELP: SHOW_ERROR0(2, "LUN needs manual help"); return MK_ERROR(err_act_fail, B_DEV_NOT_READY); case SCSIS_ASC_LUN_FORMATTING: SHOW_INFO0(2, "LUN is formatting"); // we could wait, but as formatting normally takes quite long, // we give up without any further retries return MK_ERROR(err_act_fail, B_DEV_NOT_READY); case SCSIS_ASC_MEDIUM_CHANGED: SHOW_FLOW0(3, "Medium changed"); periph_media_changed(device, request); return MK_ERROR(err_act_fail, B_DEV_MEDIA_CHANGED); case SCSIS_ASC_WRITE_ERR_AUTOREALLOC: SHOW_ERROR0(2, "Recovered write error - block got reallocated automatically"); return MK_ERROR(err_act_ok, B_OK); case SCSIS_ASC_ID_RECOV: SHOW_ERROR0(2, "Recovered ID with ECC"); return MK_ERROR(err_act_ok, B_OK); case SCSIS_ASC_REMOVAL_REQUESTED: SHOW_INFO0(2, "Removal requested"); mutex_lock(&device->mutex); device->removal_requested = true; mutex_unlock(&device->mutex); return MK_ERROR(err_act_retry, B_DEV_MEDIA_CHANGE_REQUESTED); case SCSIS_ASC_LUN_BECOMING_READY: SHOW_INFO0(2, "Becoming ready"); // wait a bit - the device needs some time snooze(100000); return MK_ERROR(err_act_many_retries, B_DEV_NOT_READY); case SCSIS_ASC_WAS_RESET: SHOW_INFO0(2, "Unit was reset"); // TBD: need a better error code here // as some earlier command led to the reset, we are innocent return MK_ERROR(err_act_retry, B_DEV_NOT_READY); } switch (sense->asc) { case SCSIS_ASC_DATA_RECOV_NO_ERR_CORR >> 8: case SCSIS_ASC_DATA_RECOV_WITH_CORR >> 8: // these are the groups of recovered data with or without correction // we should print at least a warning here SHOW_ERROR(0, "Recovered data, asc=0x%2x, ascq=0x%2x", sense->asc, sense->ascq); return MK_ERROR(err_act_ok, B_OK); case SCSIS_ASC_WRITE_PROTECTED >> 8: SHOW_ERROR0( 2, "Write protected" ); // isn't there any proper "write protected" error code? return MK_ERROR(err_act_fail, B_READ_ONLY_DEVICE); case SCSIS_ASC_NO_MEDIUM >> 8: SHOW_FLOW0(2, "No medium"); return MK_ERROR(err_act_fail, B_DEV_NO_MEDIA); } // we issue this info very late, so we don't clutter syslog with // messages about changed or missing media SHOW_ERROR(3, "0x%04x", (sense->asc << 8) | sense->ascq); switch (sense->sense_key) { case SCSIS_KEY_NO_SENSE: SHOW_ERROR0(2, "No sense"); // we thought there was an error, huh? return MK_ERROR(err_act_ok, B_OK); case SCSIS_KEY_RECOVERED_ERROR: SHOW_ERROR0(2, "Recovered error"); // we should probably tell about that; perhaps tomorrow return MK_ERROR(err_act_ok, B_OK); case SCSIS_KEY_NOT_READY: return MK_ERROR(err_act_retry, B_DEV_NOT_READY); case SCSIS_KEY_MEDIUM_ERROR: SHOW_ERROR0(2, "Medium error"); return MK_ERROR( err_act_retry, B_DEV_RECALIBRATE_ERROR); case SCSIS_KEY_HARDWARE_ERROR: SHOW_ERROR0(2, "Hardware error"); return MK_ERROR(err_act_retry, B_DEV_SEEK_ERROR); case SCSIS_KEY_ILLEGAL_REQUEST: SHOW_ERROR0(2, "Illegal request"); return MK_ERROR(err_act_invalid_req, B_ERROR); case SCSIS_KEY_UNIT_ATTENTION: SHOW_ERROR0(2, "Unit attention"); return MK_ERROR( err_act_retry, B_DEV_NOT_READY); case SCSIS_KEY_DATA_PROTECT: SHOW_ERROR0(2, "Data protect"); // we could set "permission denied", but that's probably // irritating to the user return MK_ERROR(err_act_fail, B_NOT_ALLOWED); case SCSIS_KEY_BLANK_CHECK: SHOW_ERROR0(2, "Is blank"); return MK_ERROR(err_act_fail, B_DEV_UNREADABLE); case SCSIS_KEY_VENDOR_SPECIFIC: return MK_ERROR(err_act_fail, B_ERROR); case SCSIS_KEY_COPY_ABORTED: // we don't use copy, so this is really wrong return MK_ERROR(err_act_fail, B_ERROR); case SCSIS_KEY_ABORTED_COMMAND: // proper error code? return MK_ERROR(err_act_retry, B_ERROR); case SCSIS_KEY_EQUAL: case SCSIS_KEY_MISCOMPARE: // we don't search, so this is really wrong return MK_ERROR(err_act_fail, B_ERROR); case SCSIS_KEY_VOLUME_OVERFLOW: // not the best return code, but this error doesn't apply // to devices we currently support return MK_ERROR(err_act_fail, B_DEV_SEEK_ERROR); case SCSIS_KEY_RESERVED: default: return MK_ERROR(err_act_fail, B_ERROR); } default: // shouldn't happen - there are only 2 error codes defined SHOW_ERROR(2, "Invalid sense type (0x%x)", sense->error_code); return MK_ERROR(err_act_fail, B_ERROR); } }
bool scsi_get_dma_buffer(scsi_ccb *request) { scsi_device_info *device = request->device; dma_buffer *buffer; request->buffered = false; // perhaps we have luck and no buffering is needed if( is_sg_list_dma_safe( request )) return true; SHOW_FLOW0(1, "Buffer is not DMA safe" ); dump_sg_table(request->sg_list, request->sg_count); // only one buffer at a time acquire_sem(device->dma_buffer_owner); // make sure, clean-up daemon doesn't bother us ACQUIRE_BEN(&device->dma_buffer_lock); // there is only one buffer, so no further management buffer = &device->dma_buffer; buffer->inuse = true; RELEASE_BEN(&device->dma_buffer_lock); // memorize buffer for cleanup request->dma_buffer = buffer; // enlarge buffer if too small if (buffer->size < request->data_length) { if (!scsi_alloc_dma_buffer(buffer, &device->bus->dma_params, request->data_length)) goto err; } // create S/G to original data (necessary for copying from-buffer on end // of request, but also used during copying to-buffer in a second because // of lazyness) scsi_dma_buffer_compose_sg_orig(&device->dma_buffer, request); // copy data to buffer if ((request->flags & SCSI_DIR_MASK) == SCSI_DIR_OUT) { if (!scsi_copy_dma_buffer( request, request->data_length, true)) goto err; } // replace data address, so noone notices that a buffer is used buffer->orig_data = request->data; buffer->orig_sg_list = request->sg_list; buffer->orig_sg_count = request->sg_count; request->data = buffer->address; request->sg_list = buffer->sg_list; request->sg_count = buffer->sg_count; SHOW_INFO(1, "bytes: %" B_PRIu32, request->data_length); SHOW_INFO0(3, "we can start now"); request->buffered = true; return true; err: SHOW_INFO0(3, "error setting up DMA buffer"); ACQUIRE_BEN(&device->dma_buffer_lock); // some of this is probably not required, but I'm paranoid buffer->inuse = false; RELEASE_BEN(&device->dma_buffer_lock); release_sem(device->dma_buffer_owner); return false; }
phantom_device_t * driver_lanc111_probe( int port, int irq, int stage ) { (void) stage; lanc111_nic_t *nic = NULL; SHOW_INFO0( 0, "probe"); nic = calloc( 1, sizeof(lanc111_nic_t) ); assert(nic != NULL); hal_sleep_msec(10); if(LancInit(nic) < 0) { SHOW_ERROR0( 0, "init failed"); goto free1; } // Disable NIC interrupt. //cbi(EIMSK, LANC111_SIGNAL_IRQ); phantom_device_t * dev = calloc(1, sizeof(phantom_device_t)); dev->name = "lanc111"; dev->seq_number = seq_number++; dev->drv_private = nic; //NutEtherInput, /*!< \brief Routine to pass received data to, if_recv(). */ //LancOutput, /*!< \brief Driver output routine, if_send(). */ //NutEtherOutput /*!< \brief Media output routine, if_output(). */ //dev->dops.read = pcnet32_read; //dev->dops.write = pcnet32_write; //dev->dops.get_address = pcnet32_get_address; dev->iobase = port; dev->irq = irq; //dev->iomem = ; //dev->iomemsize = ; if( hal_irq_alloc( irq, &NicInterrupt, dev, HAL_IRQ_SHAREABLE ) ) { SHOW_ERROR( 0, "IRQ %d is busy", irq ); goto free2; } static CONST uint8_t mac[6] = { 0x52, 0x54, 0x00, 0x12, 0x34, 0x86 }; // QEMU's range if( NicStart(dev, mac) ) goto free2; /* * Start the receiver thread. * */ //NutThreadCreate("rxi5", NicRxLanc, dev, (NUT_THREAD_LANCRXSTACK * NUT_THREAD_STACK_MULT) + NUT_THREAD_STACK_ADD); ifnet *interface; if( if_register_interface( IF_TYPE_ETHERNET, &interface, dev) ) { SHOW_ERROR( 0, "Failed to register interface for %s", dev->name ); } else { if_simple_setup(interface, WIRED_ADDRESS, WIRED_NETMASK, WIRED_BROADCAST, WIRED_NET, WIRED_ROUTER, DEF_ROUTE_ROUTER ); } return dev; free2: free( dev ); free1: free( nic ); return 0; }
errno_t bootp(ifnet *iface) { struct bootp_state _bstate; void * udp_sock; struct bootp_state *bstate = &_bstate; memset( &_bstate, 0, sizeof(struct bootp_state) ); _bstate.expected_dhcpmsgtype = -1; int err = iface->dev->dops.get_address(iface->dev, &_bstate.mac_addr, sizeof(_bstate.mac_addr)); if(err < 0) { SHOW_ERROR0( 0, "can't get interface MAC address"); return ENXIO; } if( xid == 0 ) xid = (int)time(0) ^ 0x1E0A4F; // Some strange number :) int tries = 3; errno_t e; do { if( udp_open(&udp_sock) ) { SHOW_ERROR0( 0, "UDP - can't prepare endpoint"); return ENOTSOCK; } e = do_bootp( bstate, udp_sock, 0); udp_close(udp_sock); } while( e && (tries-- > 0) ); if(e) SHOW_ERROR( 0, "error %d", e); else { SHOW_FLOW( 1, "DHCP netmask: 0x%08X", bstate->smask); SHOW_FLOW( 1, "DHCP ip: %s", inet_ntoa(bstate->myip) ); SHOW_FLOW( 2, "gateway ip: %s", inet_ntoa(bstate->gateip) ); SHOW_FLOW( 2, "root ip: %s", inet_ntoa(bstate->rootip) ); SHOW_FLOW( 2, "server ip: %s", inet_ntoa(bstate->servip) ); SHOW_FLOW( 2, "rootpath: '%s'", bstate->rootpath ); SHOW_FLOW( 2, "hostname: '%s'", bstate->hostname ); SHOW_FLOW( 2, "bootfile: '%s'", bstate->bootfile ); // Now apply it to interface ifaddr *address; // set the ip address for this net interface address = malloc(sizeof(ifaddr)); address->addr.len = 4; address->addr.type = ADDR_TYPE_IP; NETADDR_TO_IPV4(address->addr) = bstate->myip.s_addr; address->netmask.len = 4; address->netmask.type = ADDR_TYPE_IP; NETADDR_TO_IPV4(address->netmask) = bstate->smask; u_int32_t bcast = (bstate->myip.s_addr) | bstate->smask; address->broadcast.len = 4; address->broadcast.type = ADDR_TYPE_IP; NETADDR_TO_IPV4(address->broadcast) = bcast; if_bind_address(iface, address); u_int32_t net = (bstate->myip.s_addr) & ~(bstate->smask); int rc; if( (rc = ipv4_route_add( net, ~(bstate->smask), bstate->myip.s_addr, iface->id) ) ) { SHOW_ERROR( 1, "Adding route - failed, rc = %d", rc); } else { SHOW_INFO0( 1, "Adding route - ok"); } if( (rc = ipv4_route_add_default( bstate->myip.s_addr, iface->id, bstate->gateip.s_addr ) ) ) { SHOW_ERROR( 1, "Adding default route - failed, rc = %d", rc); } else { SHOW_INFO0( 1, "Adding default route - ok"); } // At least one char! if(*bstate->hostname) strlcpy( phantom_uname.nodename, bstate->hostname, _UTSNAME_NODENAME_LENGTH ); } return e; }
static void GetDriverSettings(void) { void *settings_handle = NULL; SHOW_FLOW0( 1, "" ); // init settings to defaults; current_settings = def_settings; // get driver/accelerant settings, apsed settings_handle = load_driver_settings ("radeon.settings"); if (settings_handle != NULL) { const char *item; char *end; uint32 value; item = get_driver_parameter (settings_handle, "loginfo", "2", "2"); value = strtoul (item, &end, 0); if (*end == '\0' && value <= 4) { current_settings.loginfo = value; SHOW_INFO( 1, "Log Info Level now %ld/4", value ); } item = get_driver_parameter (settings_handle, "logflow", "2", "2"); value = strtoul (item, &end, 0); if (*end == '\0' && value <= 4) { current_settings.logflow = value; SHOW_INFO( 1, "Log Flow Level now %ld/4", value ); } item = get_driver_parameter (settings_handle, "logerror", "2", "2"); value = strtoul (item, &end, 0); if (*end == '\0' && value <= 4) { current_settings.logerror = value; SHOW_INFO( 1, "Log Error Level now %ld/4", value ); } current_settings.switchhead = get_driver_boolean_parameter (settings_handle, "switchhead", false, false); current_settings.force_lcd = get_driver_boolean_parameter (settings_handle, "force_lcd", false, false); current_settings.dynamic_clocks = get_driver_boolean_parameter (settings_handle, "dynamic_clocks", true, true); current_settings.force_pci = get_driver_boolean_parameter (settings_handle, "force_pci", true, true); current_settings.unhide_fastwrites = get_driver_boolean_parameter (settings_handle, "unhide_fw", false, false); current_settings.force_acc_dma = get_driver_boolean_parameter (settings_handle, "force_acc_dma", false, false); current_settings.force_acc_mmio = get_driver_boolean_parameter (settings_handle, "force_acc_mmio", false, false); current_settings.acc_writeback = get_driver_boolean_parameter (settings_handle, "acc_writeback", false, false); if ( current_settings.switchhead != def_settings.switchhead ) SHOW_INFO0( 1, "Switch Head = True" ); if ( current_settings.force_lcd != def_settings.force_lcd ) SHOW_INFO0( 1, "Force LCD ON" ); if ( current_settings.dynamic_clocks != def_settings.dynamic_clocks ) SHOW_INFO0( 1, "Mobility Power Saving Disabled (Dynamic Clocks)" ); if ( current_settings.force_pci != def_settings.force_pci ) SHOW_INFO0( 1, "Force PCI = True" ); if ( current_settings.unhide_fastwrites != def_settings.unhide_fastwrites ) SHOW_INFO0( 1, "use Fastwrites ON" ); if ( current_settings.force_acc_dma != def_settings.force_acc_dma ) SHOW_INFO0( 1, "DMA ACC Enabled" ); if ( current_settings.force_acc_mmio != def_settings.force_acc_mmio ) SHOW_INFO0( 1, "DMA ACC Disabled" ); if ( current_settings.acc_writeback != def_settings.acc_writeback ) SHOW_INFO0( 1, "DMA WriteBack Disabled" ); unload_driver_settings (settings_handle); } }
void phantom_thread_in_interrupt_fork() { SHOW_INFO0( 10, "ifork in..."); assert( forkLock.lock != 0 ); hal_spin_lock(&schedlock); child = get_thread(GET_CURRENT_THREAD()->child_tid); parent = GET_CURRENT_THREAD(); //#warning cli // Save to me, switch to me SHOW_INFO0( 10, "ifork save..."); phantom_switch_context(parent, parent, &schedlock ); SHOW_INFO0( 10, "ifork saved..."); // (OLD) phantom_switch_context() below returns here in old thread!! if(!(parent->thread_flags & THREAD_FLAG_PREFORK)) { set_esp(old_sp); SHOW_INFO0( 10, "ifork in old..."); // Second return. We're in old tread and done with fork; //GET_CURRENT_THREAD() = parent; SET_CURRENT_THREAD(parent); // Let child be elegible to run child->sleep_flags &= ~THREAD_SLEEP_LOCKED; t_enqueue_runq(child); return; } SHOW_INFO0( 10, "ifork cont..."); parent->thread_flags &= ~THREAD_FLAG_PREFORK; //GET_CURRENT_THREAD() = child; SET_CURRENT_THREAD(child); // Now switch stack and copy some 512 bytes there to make sure // new one will have some place to return to int cp_size = 512; void *from = (void*) (old_sp = get_esp()); void *to = (child->stack) - cp_size - 1; SHOW_INFO0( 10, "ifork memmove..."); memmove(to, from, cp_size); //printf("set ESP...\n"); SHOW_INFO0( 10, "set ESP..."); set_esp((int)to); //#warning sti // Save to new, switch to me -- WILL RETURN TO (X) //printf("ifork GO...\n"); phantom_switch_context(child, parent, &schedlock ); // (NEW) phantom_switch_context() below returns here in new thread!! //printf("ifork in NEW...\n"); }