struct gdb_transport *gdbudp_configure ( const char *name, struct sockaddr_in *addr ) { struct settings *settings; /* Release old network device */ netdev_put ( netdev ); netdev = find_netdev ( name ); if ( !netdev ) { return NULL; } /* Hold network device */ netdev_get ( netdev ); /* Source UDP port */ source_addr.sin_port = ( addr && addr->sin_port ) ? addr->sin_port : htons ( DEFAULT_PORT ); /* Source IP address */ if ( addr && addr->sin_addr.s_addr ) { source_addr.sin_addr.s_addr = addr->sin_addr.s_addr; } else { settings = netdev_settings ( netdev ); fetch_ipv4_setting ( settings, &ip_setting, &source_addr.sin_addr ); if ( source_addr.sin_addr.s_addr == 0 ) { netdev_put ( netdev ); netdev = NULL; return NULL; } } return &udp_gdb_transport; }
/** * Set network device as current PXE network device * * @v netdev Network device, or NULL */ void pxe_set_netdev ( struct net_device *netdev ) { if ( pxe_netdev ) netdev_put ( pxe_netdev ); pxe_netdev = NULL; if ( netdev ) pxe_netdev = netdev_get ( netdev ); }
/** * Execute PXE image * * @v image PXE image * @ret rc Return status code */ static int pxe_exec ( struct image *image ) { userptr_t buffer = real_to_user ( 0, 0x7c00 ); struct net_device *netdev; int rc; /* Verify and prepare segment */ if ( ( rc = prep_segment ( buffer, image->len, image->len ) ) != 0 ) { DBGC ( image, "IMAGE %p could not prepare segment: %s\n", image, strerror ( rc ) ); return rc; } /* Copy image to segment */ memcpy_user ( buffer, 0, image->data, 0, image->len ); /* Arbitrarily pick the most recently opened network device */ if ( ( netdev = last_opened_netdev() ) == NULL ) { DBGC ( image, "IMAGE %p could not locate PXE net device\n", image ); return -ENODEV; } netdev_get ( netdev ); /* Activate PXE */ pxe_activate ( netdev ); /* Construct fake DHCP packets */ pxe_fake_cached_info(); /* Set PXE command line */ pxe_cmdline = image->cmdline; /* Reset console since PXE NBP will probably use it */ console_reset(); /* Disable IRQ, if applicable */ if ( netdev_irq_supported ( netdev ) && netdev->dev->desc.irq ) disable_irq ( netdev->dev->desc.irq ); /* Start PXE NBP */ rc = pxe_start_nbp(); /* Clear PXE command line */ pxe_cmdline = NULL; /* Deactivate PXE */ pxe_deactivate(); /* Try to reopen network device. Ignore errors, since the NBP * may have called PXENV_STOP_UNDI. */ netdev_open ( netdev ); netdev_put ( netdev ); return rc; }
/** * Set network device as current PXE network device * * @v netdev Network device, or NULL */ void pxe_set_netdev ( struct net_device *netdev ) { if ( pxe_netdev ) { netdev_rx_unfreeze ( pxe_netdev ); netdev_put ( pxe_netdev ); } pxe_netdev = NULL; if ( netdev ) pxe_netdev = netdev_get ( netdev ); }