/*********************************************************************
*
*             GUI_VNC_X_StartServer
*
* Function description
*   To start the server, the following steps are executed
*   - Make sure the TCP-IP stack is up and running
*   - Init the server context and attach it to the layer
*   - Start the thread (task) which runs the VNC server
* Notes:
*   (1) The first part of the code initializes the TCP/IP stack. In a typical
*       application, this is not required, since the stack should have already been
*       initialized some other place.
*       This could be done in a different module. (TCPIP_AssertInit() ?)
*/
int GUI_VNC_X_StartServer(int LayerIndex, int ServerIndex) {
  /* Make sure the TCP/IP stack is initialized.  (1) */
  if (xn_rtip_init() != 0) {
    OS_SendString("GUI_VNC_X_StartServer: Init failed\n");
    return 1;                    /* Error */
  }
  {
    int interface;
    xn_bind_cs(0);                                        /* append interface to device table */
    interface = xn_interface_open_config(CS89X0_DEVICE, 0, (IOADDRESS)0x20000300,5,0);   /* open interface */
    if (interface < 0) {
      OS_SendString("GUI_VNC_X_StartServer: Can not open interface\n");
      return 1;                                           /* Error */
    }
    xn_set_ip(interface, (PFBYTE)&_IPLocal[0], (PFBYTE)&_IPMask[0]);      /* set IP address of interface */
    HW_EnableEthernetIRQ();                               /* Enable ethernet IRQ. Make sure it is done after xn_interface_open_config() */  
  }

  /* Init VNC context and attach to layer (so context is updated if the display-layer-contents change */
  GUI_VNC_AttachToLayer(&_Context, LayerIndex);
  _Context.ServerIndex = ServerIndex;

  /* Create task for VNC Server */
  OS_CREATETASK(&_VNCServer_TCB, "VNC Server", _ServerTask, 50, _StackVNCServer);
  return 0;                                               /* O.k., server has been started */
}
int LPC24XX_EMAC_Driver::Open()
{
    int use_default_multicast = 1;
    
    memset(&g_LPC24XX_EMAC_Driver.m_currentDhcpSession, 0, sizeof(g_LPC24XX_EMAC_Driver.m_currentDhcpSession));

    /* Open the interface first */
    g_LPC24XX_EMAC_Driver.m_interfaceNumber = xn_interface_open_config (LPC24XX_EMAC_DEVICE, 
                                                                        0,              /*  minor_number        */
                                                                        0,              /*  ioaddress           */
                                                                        0,              /*  irq value           */
                                                                        0               /*  mem_address)        */
                                                    );
    
    if (g_LPC24XX_EMAC_Driver.m_interfaceNumber == -1)
    {
        return -1;    
    }

    if (xn_interface_opt(g_LPC24XX_EMAC_Driver.m_interfaceNumber, 
                        IO_DEFAULT_MCAST,
                        (RTP_PFCCHAR)&use_default_multicast,
                        sizeof(int)) == -1)
    {
        /* Failed to set the default multicast interface */
        debug_printf("LPC24XX_EMAC_Driver::Open: Failed to set the default multicast interface\r\n");
    }
    
       
    /* Enable the INTERRUPT */                            
    CPU_INTC_ActivateInterrupt(LPC24XX_VIC::c_IRQ_INDEX_EMAC, LPC24XX_EMAC_interrupt, NULL);

    return g_LPC24XX_EMAC_Driver.m_interfaceNumber;    
}
int ENC28J60_Driver::Open( ENC28J60_DRIVER_CONFIG* config, int index )
{
    NATIVE_PROFILE_HAL_DRIVERS_ETHERNET();
    int use_default_multicast = 1;

    if(config == NULL) return -1;
    
    memset(&g_ENC28J60_Driver.m_currentDhcpSession, 0, sizeof(g_ENC28J60_Driver.m_currentDhcpSession));

    /* Enable the CHIP SELECT pin */
    if (CPU_GPIO_EnableInputPin (config->SPI_Config.DeviceCS, 
                            FALSE, 
                            NULL,
                            GPIO_INT_NONE,
                            RESISTOR_PULLUP) == FALSE)
    {
        return -1;                          
    }
    
    /* Open the interface first */
    g_ENC28J60_Driver.m_interfaceNumber = xn_interface_open_config(ENC28J60_DEVICE, 
                                                    index,          /*  minor_number        */
                                                    0,              /*  ioaddress           */
                                                    0,              /*  irq value           */
                                                    0               /*  mem_address)        */
                                                    );
    
    if (g_ENC28J60_Driver.m_interfaceNumber == -1)
    {
        return -1;    
    }

    if(index == 0) // default debugger port is index 0
    {
        if (xn_interface_opt(g_ENC28J60_Driver.m_interfaceNumber, 
                            IO_DEFAULT_MCAST,
                            (RTP_PFCCHAR)&use_default_multicast,
                            sizeof(int)) == -1)
        {
            /* Failed to set the default multicast interface */
        }
    }
    
       
    /* Enable the INTERRUPT pin */                            
    if (CPU_GPIO_EnableInputPin2(config->INT_Pin, 
                              FALSE,                                                    /* Glitch filter enable */
                              (GPIO_INTERRUPT_SERVICE_ROUTINE) &enc28j60_pre_interrupt, /* ISR                  */
                              0,                                                        /* minor number         */
                              GPIO_INT_EDGE_LOW ,                                       /* Interrupt edge       */
                              RESISTOR_PULLUP) == FALSE)                                /* Resistor State       */
    {
        return -1;
    }
    
    return g_ENC28J60_Driver.m_interfaceNumber;
    
}
Example #4
0
/****************************************************
 * Initialize socket for RTIP
 ****************************************************/
int SOCK_Init (void)
{
    int iface;
    byte tnet_localHost[4] = {192, 168, 1, 43};
    byte tnet_maskip[4] = {255, 255, 255, 0};

    PRINTF (("about to init xn_rtip\n"));
    /*   px_init ();   */
    if(xn_rtip_init()!=0)
    {
        PRINTF (("SOCK_Init: Error in xn_rtip_init\n"));
        return -1;
    }

    PRINTF (("about to open xn_interface config\n"));
    /* packard bell                                                               */
/*  iface = xn_interface_open_config (NE2000_DEVICE, MINOR_0, 0x220, 10, 0);      */
    /* IntelliStation                                                             */
/*  iface = xn_interface_open_config (I82559_DEVICE, MINOR_0, 0x78e0, 8, 0xf000); */
    /* Toshiba                                                                    */
    iface = xn_interface_open_config (CE3_PCMCIA_DEVICE, MINOR_0, 0x110, 10, 0);

    if(iface < 0)
    {
        PRINTF (("SOCK_Init: Interface Open Failed - returned %s\n",
            xn_geterror_string (xn_getlasterror ())));
        return -1;
    }

        PRINTF (("about to set ip\n"));
    if(xn_set_ip(iface, tnet_localHost, tnet_maskip))
    {
        PRINTF (("SOCK_Init: xn_set_ip error\n"));
        return -1;
    }

    rtsmb_srv_init (tnet_localHost, tnet_maskip, NULL, NULL);
    rtsmb_cli_init (tnet_localHost, tnet_maskip);

    return 0;
}
int AT91_EMAC_Driver::Open()
{
    int use_default_multicast;

    memset(&g_AT91_EMAC_Driver.m_currentDhcpSession, 0, sizeof(g_AT91_EMAC_Driver.m_currentDhcpSession));

    // PHY Power Up
    CPU_GPIO_EnableOutputPin(g_AT91_EMAC_Config.PHY_PD_GPIO_Pin, FALSE);

     /* Open the interface first */
    g_AT91_EMAC_Driver.m_interfaceNumber = xn_interface_open_config(AT91EMAC_DEVICE, 
                                                    0,              /*  minor_number        */
                                                    0,              /*  ioaddress           */
                                                    0,              /*  irq value           */
                                                    0               /*  mem_address)        */
                                                    );

    if (g_AT91_EMAC_Driver.m_interfaceNumber == -1)
    {
        return -1;    
    }
    
    use_default_multicast = 1;
    if (xn_interface_opt(g_AT91_EMAC_Driver.m_interfaceNumber, 
                        IO_DEFAULT_MCAST,
                        (RTP_PFCCHAR)&use_default_multicast,
                        sizeof(int)) == -1)
    {
        /* Failed to set the default multicast interface */
        debug_printf("EMAC: Failed to set the default multicast interface\r\n");
    }

    CPU_INTC_ActivateInterrupt(AT91C_ID_EMAC, AT91_EMAC_interrupt, NULL);

    return g_AT91_EMAC_Driver.m_interfaceNumber;
}