Example #1
0
void lcd_init (void)
{
    // Reset the SDRAM.
    meminit (cpu_frequency (1));

    puts ("LCD setup:");
    static const unsigned pins[] = {
        // Setup the PLL0AUDIO to give 74.75MHz off 50MHz ethernet clock.
        // ndec=122, mdec=13107, pdec=66
        // selr=0, seli=48, selp=24
        // pllfract = 47.839996,0x17eb85
        // pre-divider=16, feedback div=47, post-div=2
        // fcco=299MHz, fout=74.749994MHz.
        WORD_WRITE32n(PLL0AUDIO->ctrl, 4,
                      0x03001811,       // CTRL
                      13107,            // MDIV
                      66 + (122 << 12), // NP_DIV
                      0x17eb85),        // FRAC

        BIT_RESET(PLL0AUDIO->ctrl, 0),

        // Wait for lock.
        BIT_WAIT_ZERO(PLL0AUDIO->stat, 0),

        // The lcd clock is outclk11.  PLL0AUDIO is clock source 8.
        WORD_WRITE32(*BASE_LCD_CLK, 0x08000800),

        // Reset the lcd.
        WORD_WRITE32(RESET_CTRL[0], 1<<16),
        BIT_WAIT_SET(RESET_ACTIVE_STATUS[0], 16),

        // 1024x1024 59.90 Hz (CVT) hsync: 63.13 kHz; pclk: 74.75 MHz
        // Modeline "1024x1024R" 74.75  1024 1072 1104 1184  1024 1027 1037 1054
        // +hsync -vsync
        // horizontal 1024 48 32 80
        // vertical 1024 3 10 17

        WORD_WRITE32n(LCD->timh, 7,
                      (79 << 24) + (47 << 8) + (31 << 16) + 0xfc, // TIMH
                      (16 << 24) + (2 << 16) + (9 << 10) + 1023,  // TIMV
                      // PCD_LO = 0, Clock divisor = 0.
                      // CLK_SEL = 1, LCDCLKIN.
                      // ACB = 0, N/A.
                      // IVS=0, IHS=1, positive vsync, negative hsync (!?)
                      // IPC=1, falling clock edge.
                      // IOE=0, out enable positive.
                      // CPL=1023.
                      // BCD=1, no clock divider.
                      // PCD_HI=0.
                      0x07ff3020,                                 // POL
                      0,                                          // LE
                      (unsigned) FRAME_BUFFER,                    // UPBASE
                      (unsigned) FRAME_BUFFER,                    // LPBASE
                      LCD_CONTROL),

        // PIN_OUT_FAST(4,1,2),            // A1  LCD_VD0
        // PIN_OUT_FAST(4,3,2),            // C2  LCD_VD2
        // PIN_OUT_FAST(4,4,2),            // B1  LCD_VD1
        // PIN_OUT_FAST(4,8,2),            // E2  LCD_VD9
        // PIN_OUT_FAST(7,2,3),            // A16 LCD_VD18
        // PIN_OUT_FAST(7,3,3),            // C13 LCD_VD17
        // PIN_OUT_FAST(7,4,3),            // C8  LCD_VD16
        // PIN_OUT_FAST(7,5,3),            // A7  LCD_VD8
        //PIN_OUT_FAST(,,), // B16 LCD_LE
        //PIN_OUT_FAST(,,), // B6  LCD_PWR
        PIN_OUT_FAST(3,4,7)             // A15 LCD_VD13
        + PIN_EXTRA(1),                 // C12 LCD_VD12
        PIN_OUT_FAST(4,2,2),            // D3  LCD_VD3
        PIN_OUT_FAST(4,5,2)             // D2  LCD_FP
        + PIN_EXTRA(1),                 // C1  LCD_ENAB/LCDM
        PIN_OUT_FAST(4,9,2)             // L2  LCD_VD11
        + PIN_EXTRA(1),                 // M3  LCD_VD10
        PIN_OUT_FAST(7,1,4),            // C14 LCD_VD7
        PIN_OUT_FAST(7,6,3),            // C7  LCD_LP
        PIN_OUT_FAST(8,5,3)             // J1  LCD_VD6
        + PIN_EXTRA(2),                 // K3  LCD_VD5, K1  LCD_VD4
        PIN_OUT_FAST(11,0,2)            // B15 LCD_VD23
        + PIN_EXTRA(6),         // ... A13 VD20, B11 VD15, A12 VD14, A6 VD19
        PIN_OUT_FAST(12,0,4),           // D4  LCD_DCLK

        // Enable the lcd.
        BIT_SET(LCD->ctrl, 0), // TFT, 16bpp, 565, watermark=8.

        // Enable the frame interrupt.
        WORD_WRITE(LCD->intmsk, 4),
    };

    configure(pins, sizeof pins / sizeof pins[0]);

    NVIC_ISER[0] = 1 << m4_lcd;

    puts (" done\n");
}
Example #2
0
int
HandleNetoidEmail(Command *comm, int argc, char **argv)
{
	char fn[] = "HandleNetoidEmail():";
   	char *serNo, *ports, *temps,*ptrptr, *tok;
	unsigned long port = 0, portH = 0;
	NetoidSNKey key;
	NetoidInfoEntry *netInfo = NULL;
	CacheTableInfo cacheInfoEntry;
	int rc = xleOk, obtainedRegid = 0;
	if (argc < 2)
    {
	 	/* Here we prompt the user for the rest of the 
	  	* information
	  	*/
	 	HandleCommandUsage(comm, argc, argv);
	 	return -xleInsuffArgs;
    }


    /* Registration No */
    serNo = argv[0];
     
	ports = temps = strdup(argv[1]);
   	tok = strtok_r(temps, "-", &ptrptr);
   	if (tok)
   	{
		port = atoi(tok);
		tok = strtok_r(NULL, "-", &ptrptr);
		if(tok){
	 	portH = atoi(tok);
	}
   		else{
	 	portH = port;
   	}
	}
	free(ports);

    argc -= 2;
    argv += 2;

	strncpy(key.regid, serNo, REG_ID_LEN);

    while (port <= portH)
    {
	 	key.uport = port;
	 
		CacheAttach();

		if (!obtainedRegid)
		{
			CliGetRegid(serNo, key.regid);
			obtainedRegid = 1;
		}

		// Look up the entry in the cache
		if (CacheFind(regCache, &key, &cacheInfoEntry, sizeof(cacheInfoEntry)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}
		else if (ExtractIedge ((char *)&key, &cacheInfoEntry.data, 
										sizeof(cacheInfoEntry.data)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}

		CacheDetach();

        if (!netInfo)
        {
     	    CLIPRINTF((stdout, "%s: Unable to find the iedge %s\n", 
					fn, serNo));
	      	return -xleNoEntry;
        }

	 	if (argc -- > 0)
	 	{
	      	/* This port has a specified phone num */
	      
	      	strncpy(netInfo->email, argv[0], EMAIL_LEN);
			if (strlen(netInfo->email))
			{
	      		BIT_SET(netInfo->sflags, ISSET_EMAIL);
			}
			else
			{
	      		BIT_RESET(netInfo->sflags, ISSET_EMAIL);
			}

	      	argv ++;
	 	}

	 	netInfo->stateFlags &= ~CL_REGISTERED;
	 	netInfo->mTime = time(0);

	 	/* If this netoid is in the cache, delete it */
	 	if (UpdateNetoidInCache(netInfo) < 0)
		{
			rc = -xleExists;
			goto _error;
		}

	 	if (OpenDatabases((DefCommandData *)comm->data) < 0)
	 	{
			return -xleOpNoPerm;
	 	}

	 	/* Read the Vpn information here */
	 	if (DbStoreInfoEntry(GDBMF(comm->data, DB_eNetoids), netInfo, 
			      (char *)netInfo, sizeof(NetoidSNKey)) < 0)
	 	{
	      NETERROR(MCLI, ("database store error\n"));
	 	}

	 	CloseDatabases((DefCommandData *)comm->data);

_error:
	 	netInfo = NULL;
	 	port ++;
	 	if (rc < 0)
	 	{
			return rc;
	 	}
     }

     return rc;
}
Example #3
0
int
HandleNetoidReg(Command *comm, int argc, char **argv)
{
   	char *serNo, *ports, *temps,*ptrptr, *tok;
    unsigned long port = 0, portH = 0;
    NetoidInfoEntry *netInfo = 0;
	CacheTableInfo cacheInfoEntry;
    NetoidSNKey key;
    char storeb[1024];
	long portsState = ~0, portsStateOr = 0;
	int rc = xleOk, regn, obtainedRegid = 0;
    if (argc < 2)
    {
		/* Here we prompt the user for the rest of the 
	  	* information
	  	*/
	 	HandleCommandUsage(comm, argc, argv);
	 	return -xleInsuffArgs;
    }

    /* Registration No */
    serNo = argv[0];
    log(LOG_DEBUG, 0, "Ser No is %s\n", serNo);
     
	ports = temps = strdup(argv[1]);
   	tok = strtok_r(temps, "-", &ptrptr);
   	if (tok)
   	{
		port = atoi(tok);
		tok = strtok_r(NULL, "-", &ptrptr);
		if(tok){
	 	portH = atoi(tok);
	}
   		else{
	 	portH = port;
   	}
	}
	free(ports);

    argc -= 2;
    argv += 2;

    strncpy(key.regid, serNo, REG_ID_LEN);

    while (port <= portH)
    {
		regn = 0;
	 	key.uport = port;

		CacheAttach();

		if (!obtainedRegid)
		{
			CliGetRegid(serNo, key.regid);
			obtainedRegid = 1;
		}

		// Look up the entry in the cache
		if (CacheFind(regCache, &key, &cacheInfoEntry, sizeof(cacheInfoEntry)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}
		else if (ExtractIedge ((char *)&key, &cacheInfoEntry.data, 
										sizeof(cacheInfoEntry.data)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}

		CacheDetach();

		// At this point of the entry is not found, its an error
		// if its found, then we are going to be agnostic to where
		// it came from
	 	if (netInfo == NULL)
	 	{
			CLIPRINTF((stdout, "iedge Not found in Cache/Database\n"));
			rc = -xleNoEntry;
			goto _error;
	 	}

	 	if (argc > 0)
	 	{
			GetNetoidAttrPairs(comm->name, &argc, &argv, 
				netInfo, NULL);
			goto _storedb;	
	 	}

	 	if (cliLibFlags == 0) 
		{
			/* we should not be getting here... */
			NETERROR(MCLI, ("Invalid arguments passed from jserver\n"));
			rc = -xleInvalArgs;
			goto _error;
	 	}

	 	CLIPRINTF((stdout, "ser # %s port %lu:\n", serNo, port));

		// Either the reg ip or the contact should
		// be sufficient to activate the registration

	 	CLIPRINTF((stdout, "Registration IP [%s?none]: ", 
			FormatIpAddress(netInfo->ipaddress.l, storeb)));
	 	GetInput(stdin, storeb, CLIENT_ATTR_LEN);
	 	if (strlen(storeb) > 0) 
	 	{
			if (!strcmp(storeb, "none"))
	 		{
				netInfo->stateFlags &= ~(CL_ACTIVE|CL_REGISTERED);
	 		}
	 		else /* User entered an ip address */
			{
				netInfo->ipaddress.l = inet_addr(storeb);
				netInfo->ipaddress.l = ntohl(netInfo->ipaddress.l);

				regn = 1;

				netInfo->stateFlags |= CL_ACTIVE;
				netInfo->stateFlags |= CL_REGISTERED;

				BIT_SET(netInfo->sflags, ISSET_IPADDRESS);
				netInfo->rasip = netInfo->ipaddress.l;
			}
			time(&netInfo->rTime);	
	 	}
	 
		CLIPRINTF((stdout, "SIP Enable? [%s]: ", 
			(BIT_TEST(netInfo->cap, CAP_SIP)?"true":"false")));
	
		GetInput(stdin, storeb, 25);
		if (strlen(storeb) > 0) 
		{
			if (!strcmp(storeb, "true"))
			{
				BIT_SET(netInfo->cap, CAP_SIP);
			}
			else
			{
				BIT_RESET(netInfo->cap, CAP_SIP);
			}
		}
	
		CLIPRINTF((stdout, "H323 Enable? [%s]: ", 
			(BIT_TEST(netInfo->cap, CAP_H323)?"true":"false")));
	
		GetInput(stdin, storeb, 25);
		if (strlen(storeb) > 0) 
		{
			if (!strcmp(storeb, "true"))
			{
				BIT_SET(netInfo->cap, CAP_H323);
			}
			else
			{
				BIT_RESET(netInfo->cap, CAP_H323);
			}
		}
	
		if (BIT_TEST(netInfo->cap, CAP_H323))
		{
		 	CLIPRINTF((stdout, "Q.931 port [%d]: ", netInfo->callsigport));
		 	GetInput(stdin, storeb, CLIENT_ATTR_LEN);
		 	if (strlen(storeb) > 0) 
		 	{
				netInfo->callsigport = atoi(storeb);
		 	}
		}
	
		if (BIT_TEST(netInfo->cap, CAP_SIP))
		{
		 	CLIPRINTF((stdout, "Contact [%s]: ", netInfo->contact));
		 	GetInput(stdin, storeb, SIPURL_LEN);
		 	if (strlen(storeb) > 0) 
		 	{
				  if (!strcmp(storeb, "none"))
				  {
						memset(netInfo->contact, 0, SIPURL_LEN);
						if (!regn)
						{
							netInfo->stateFlags &= ~(CL_ACTIVE|CL_REGISTERED);
						}
				  }
				  else
				  {
		 				strcpy(netInfo->contact, storeb);
						netInfo->stateFlags |= CL_ACTIVE;
						netInfo->stateFlags |= CL_REGISTERED;
						time(&netInfo->rTime);	
				  }
		 	}
		}
	
		if (netInfo->stateFlags&CL_DND)
		{
		 	CLIPRINTF((stdout, "DND [enable]: "));
		}
		else
		{
		 	CLIPRINTF((stdout, "DND [disable]: "));
		}
	
		GetInput(stdin, storeb, 25);
		if (strlen(storeb) > 0) 
		{
			  if (!strcmp(storeb, "enable"))
			  {
				netInfo->stateFlags |= CL_DND;
			  }
			  else
			  {
				netInfo->stateFlags &= ~CL_DND;
			  }
		}
	
		if (BIT_TEST(netInfo->cap, CAP_IGATEWAY))
		{
		 	CLIPRINTF((stdout, "Gateway [enable]: "));
		}
		else
		{
		 	CLIPRINTF((stdout, "Gateway [disable]: "));
		}
	
		GetInput(stdin, storeb, 25);
		if (strlen(storeb) > 0) 
		{
			  if (!strcmp(storeb, "enable"))
			  {
				BIT_SET(netInfo->cap, CAP_IGATEWAY);
			  }
			  else
			  {
				BIT_RESET(netInfo->cap, CAP_IGATEWAY);
			  }
		}
	
		CLIPRINTF((stdout, "Current Calls [%d]: ", IedgeCalls(netInfo)));
		GetInput(stdin, storeb, 10);
		if (strlen(storeb) > 0) 
		{
			IedgeCalls(netInfo) = atoi(storeb);
		}
	
	_storedb:
	
		if (UpdateNetoidInCache(netInfo) < 0)
		{
			rc = -xleExists;
			goto _error;
		}
	
		UpdateNetoidPorts(serNo, UpdateNetoidState, &portsState, 
			&portsStateOr, netInfo->ipaddress.l?&netInfo->ipaddress.l:NULL);

		UpdateNetoidDatabase(netInfo);
	
	_continue:	 
	_error:
		port ++;
	
	    netInfo = NULL;
	
		if (rc < 0)
		{
			return rc;
		}

    }
  
	if (argc > 0)
    {
		/* All arguments not exhausted... */
		CLIPRINTF((stdout, "%s: Error: Insufficient Arguments \n", comm->name));
		return -xleInvalArgs;
    }

	return xleOk;
}     
Example #4
0
int
HandleNetoidPhones(Command *comm, int argc, char **argv)
{
    char fn[] = "HandleNetoidPhones():";
   	char *serNo, *ports, *temps,*ptrptr, *tok;
    unsigned long port = 0, portH = 0;
    NetoidSNKey key;
    NetoidInfoEntry *netInfo = NULL;
	CacheTableInfo cacheInfoEntry;
	VpnEntry vpnKey = { 0 }, *vpnEntry = NULL;
	int rc = xleOk, obtainedRegid = 0;
	long portsState = ~CL_REGISTERED;
     
    if (argc < 2)
    {
	 	/* Here we prompt the user for the rest of the 
	  	* information
	  	*/
	 	HandleCommandUsage(comm, argc, argv);
	 	return -xleInsuffArgs;
    }

     /* Registration No */
     serNo = argv[0];
     
	ports = temps = strdup(argv[1]);
   	tok = strtok_r(temps, "-", &ptrptr);
   	if (tok)
   	{
		port = atoi(tok);
		tok = strtok_r(NULL, "-", &ptrptr);
		if(tok){
	 	portH = atoi(tok);
	}
   		else{
	 	portH = port;
   	}
	}
	free(ports);

     argc -= 2;
     argv += 2;

	 strncpy(key.regid, serNo, REG_ID_LEN);

     while (port <= portH)
     {
	 	key.uport = port;
	 
		CacheAttach();

		if (!obtainedRegid)
		{
			CliGetRegid(serNo, key.regid);
			obtainedRegid = 1;
		}

		// Look up the entry in the cache
		if (CacheFind(regCache, &key, &cacheInfoEntry, sizeof(cacheInfoEntry)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}
		else if (ExtractIedge ((char *)&key, &cacheInfoEntry.data, 
										sizeof(cacheInfoEntry.data)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}

		CacheDetach();

	 if (OpenDatabases((DefCommandData *)comm->data) < 0)
	 {
		return -xleOpNoPerm;
	 }

	 if (netInfo)
	 {
		strcpy(vpnKey.vpnName, netInfo->vpnName);
	 }

	 if (strlen(vpnKey.vpnName))
	 {
	 	vpnEntry = DbFindVpnEntry(GDBMF(comm->data, DB_eVpns),
						(char *)&vpnKey, sizeof(VpnKey));
	 }

	 CloseDatabases((DefCommandData *)comm->data);

     if (!netInfo)
     {
		/* vpn entry exists only if netInfo existed!! */
	 	return -xleNoEntry;
     }

	 if (argc -- > 0)
	 {
	    strcpy(netInfo->vpnPhone, argv[0]);

		if (strlen(netInfo->vpnPhone))
		{
	      		BIT_SET(netInfo->sflags, ISSET_VPNPHONE);
				netInfo->vpnExtLen = strlen(netInfo->vpnPhone);
		}
		else
		{
	      		BIT_RESET(netInfo->sflags, ISSET_VPNPHONE);
				netInfo->vpnExtLen = 0;
		}

		AssignIedgePhone(netInfo, vpnEntry);

	    argv ++;
	 }

	 netInfo->stateFlags &= ~CL_REGISTERED;
	 netInfo->mTime = time(0);

	 /* If this netoid is in the cache, delete it */
	 if (UpdateNetoidInCache(netInfo) < 0)
	 {
		rc = -xleExists;
		goto _error;
	 }

	 UpdateNetoidPorts(serNo, UpdateNetoidState, &portsState, NULL, NULL);

	 UpdateNetoidDatabase(netInfo);

	 netInfo = NULL;
	 if (vpnEntry)
	 {
		free(vpnEntry);
		vpnEntry = NULL;
	 }

	 port ++;
     }

     return xleOk;

_error:
	if (netInfo)
	{
		free(netInfo);
	}
		
	if (vpnEntry)
	{
		free(vpnEntry);
	}

	return rc;
}