SYS_registration.c File Reference


Detailed Description

This module provides various Neuros registration support.

REVISION

Definition in file SYS_registration.c.

#include "../feature.h"
#include "../fat/fat.h"
#include "../GENERIC/eeprom.h"
#include "../GENERIC/generic.h"
#include "../MENU/tmplt.h"
#include "sys_main.h"
#include "sys_hardware.h"

Include dependency graph for SYS_registration.c:

Include dependency graph

Go to the source code of this file.

Functions

BOOL SYS_regist (void)
 Function checks to regist Neuros for various feature support.
void SYS_checkRegistration (void)
 Function checks to pull registration information out of EEPROM.


Function Documentation

BOOL SYS_regist void   ) 
 

Function checks to regist Neuros for various feature support.

Returns:
TRUE if successfully registered.

Definition at line 43 of file SYS_registration.c.

References FAT_cd(), FAT_delete(), FAT_fclose(), FAT_fopen(), FAT_fread(), GEN_checksum(), GEN_eepromRead(), GEN_eepromWrite(), GEN_strUnpack(), NEUROS_REGISTRATION, and rb.

00044 {   
00045 #if 1
00046     int             ii;
00047     BOOL            ret = FALSE;
00048     char            fname[16];
00049     char            ownerName[12];
00050     unsigned short  key[_KEYLEN];
00051     File *          fp;
00052     
00053     // Is registration file present?
00054     GEN_readXstr((ULONG)text_regfname, (USHORT *)fname, 16);
00055     
00056     if(SYS_isHDDpresent())  FAT_cd(strDISKC);
00057     else                    FAT_cd(strDISKD);
00058     
00059     fp = FAT_fopen(fname, rb);
00060     if( NULL == fp ) return FALSE;
00061     
00062     // Read key.
00063     if(_KEYLEN == FAT_fread(fp, key, _KEYLEN))
00064     {
00065         unsigned short buf[6];
00066         
00067         // Retrieve to byte array and pack to 16 bit integer.
00068         for(ii = 0; ii < _KEYLEN; ii += 2)
00069         {
00070             key[ii/2] = _hex2ch(key[ii])<<8;
00071             key[ii/2]|= _hex2ch(key[ii+1]);
00072         }
00073         
00074         buf[0] = key[0];
00075         
00076         // Read back Neuros serial number and validate registration key.
00077         GEN_eepromRead(SERIAL_NUMBER_BEGIN, 10, (int *)&buf[1]);    
00078         if(GEN_checksum(buf, 6) == key[1])
00079         {
00080             key[2] ^= key[0];
00081             key[3] ^= key[0];
00082             
00083             ret = TRUE;
00084             FAT_fread(fp, (unsigned short *)&ownerName[0], 6);          
00085         }
00086     }
00087     
00088     FAT_fclose(fp);
00089     
00090     if(TRUE == ret)
00091     {
00092         unsigned short tmp, checkSum;
00093         unsigned short reg[4];
00094         
00095         // Check registration data.
00096         memcpy(reg, &key[2], 2);
00097 
00098         // Unpack to bytes.
00099         for( ii = 1; ii >= 0; ii--)
00100         {
00101             tmp = reg[ii];
00102             reg[ii*2] = (tmp>>8)&0x0ff;
00103             reg[ii*2+1] = tmp&0x0ff;
00104         }
00105         
00106         // Calculate checksum to validate registration.
00107         checkSum = reg[0];
00108         for( ii = 1; ii < 3; ii++ )
00109         {
00110             tmp = (checkSum & 0x01)? 0x80 : 0;      
00111             checkSum >>= 1;     
00112             checkSum += tmp + reg[ii];
00113             checkSum &= 0x0ff;
00114         }   
00115         
00116         if(reg[3] == checkSum)
00117         {
00118             GEN_eepromWrite(NEUROS_REGISTRATION, 4, (int*)&key[2]);
00119             
00120             // Check to write owner name.
00121             // Unpack.
00122             GEN_strUnpack((UINT16*)ownerName, 6);
00123             if((ownerName[0]== '[')&&(ownerName[1] != ']') )
00124             {
00125                 unsigned short owner[5];
00126                 unsigned char * pC;
00127                 
00128                 pC = (unsigned char *)ownerName + 1;
00129                 ii = 0;
00130                 while( ii < 5 )
00131                 {
00132                     if(*pC == ']') break;
00133                     owner[ii] = (*pC++)<<8;
00134                     if(*pC == ']') {ii++; break;}
00135                     owner[ii++]|= *pC++;
00136                 }
00137                 if(ii < 5) owner[ii] = 0;
00138                 GEN_eepromWrite(OWNER_NAME, ii*2, (int*)&owner[0]);
00139             }
00140             
00141             // Done with registration, delete registration file.
00142             FAT_delete(fname);
00143         }
00144         else ret = FALSE;       
00145     }
00146     
00147     return ret;
00148 #endif  
00149 }

Here is the call graph for this function:


Generated on Wed Jan 19 01:13:19 2005 for neuros-firmware by  doxygen 1.3.9.1