Exemplo n.º 1
0
/**
Processes the core image file to produce a directory tree.

@return KErrNone for successful read or error number if failed 
*/
TInt CCoreImage::ProcessImage()
	{
	iRomFileName = iReader->Filename();
	int result = CreateRootDir();
	if (result == KErrNone)
		{
		if (iReader->Open())
			{
			RCoreImageReader::TImageType imageType = iReader->ReadImageType();
			if (imageType == RCoreImageReader::E_ROFS)
				{
				TRofsHeader header;
				result = iReader->ReadCoreHeader(header);
				if (result == KErrNone)
					{
					SaveDirInfo(header);
					result = ProcessDirectory(0);
					}
				}
			else
				result = KErrNotSupported;
			}
		else
			result = KErrGeneral;
		}
	return result;
	}
Exemplo n.º 2
0
bool SDS(void)
{
  TRACEENTER();

  static dword              Timeout = 0;
  static tHookHandlerState  LastHHS = HHS_Exit;
  static dword              EF00FilterTimeout = 0;

  if(LastHHS != HookHandlerState)
  {
    switch(HookHandlerState)
    {
      case HHS_Init:                WriteLog("HHS_Init"); break;
      case HHS_Idle:                WriteLog("HHS_Idle"); break;
      case HHS_EF00Received:        WriteLog("HHS_EF00Received"); break;
      case HHS_PowerOffCancel:      WriteLog("HHS_PowerOffCancel"); break;
      case HHS_ShutdownTimerDiags:  WriteLog("HHS_ShutdownTimerDiags"); break;
      case HHS_Shutdown:            WriteLog("HHS_Shutdown"); break;
      case HHS_Exit:                WriteLog("HHS_Exit"); break;
    }
    LastHHS = HookHandlerState;
  }

  switch(HookHandlerState)
  {
    case HHS_Init:
    {
      char             *TAPFileName;
      tTAPInfo          TAPInfo;

      CreateRootDir();

      //Init some firmware routines
      if(!__DevFront_PowerOffReply)
      {
        __DevFront_PowerOffReply = (void*)FIS_fwDevFront_PowerOffReply();
        if(!__DevFront_PowerOffReply)
        {
          if(LastStatus != -1) WriteLog("Failed to resolve DevFront_PowerOffReply()");
          LastStatus = -1;
          HookHandlerState = HHS_Exit;

          TRACEEXIT();
          return FALSE;
        }
      }

      if(!__DevFront_PowerOffCancel)
      {
        __DevFront_PowerOffCancel = (void*)FIS_fwDevFront_PowerOffCancel();
        if(!__DevFront_PowerOffCancel)
        {
          if(LastStatus != -2) WriteLog("Failed to resolve DevFront_PowerOffCancel()");
          LastStatus = -2;
          HookHandlerState = HHS_Exit;

          TRACEEXIT();
          return FALSE;
        }
      }

      //Modify the handler pointer of the ef00 event queue
      if(!SetHandler(0xef00, Hooked_ApplEvent_CallHandler, (void*)&OrigHandler))
      {
        TRACEEXIT();
        return FALSE;
      }

      if(!LibInitialized && !InitTAPex())
      {
        TRACEEXIT();
        return FALSE;
      }

      if(HDD_TAP_GetFileNameByIndex(TAP_TableIndex, &TAPFileName))
      {
        if(!HDD_TAP_GetInfo(TAPFileName, &TAPInfo)) strcpy(TAPInfo.TAPName, "???");
      }
      else
        strcpy(TAPInfo.TAPName, "???");
      TAP_SPrint(Log, "SDS has been activated by '%s'", TAPInfo.TAPName);
      WriteLog(Log);

      HookHandlerState = HHS_Idle;
      break;
    }

    case HHS_Idle:
    {
      if(EF00FilterTimeout && TAP_GetTick() > EF00FilterTimeout) EF00FilterTimeout = 0;

      if(ShutdownHooked)
      {
        HookHandlerState = HHS_EF00Received;
        ShutdownHooked = FALSE;
      }
      break;
    }

    case HHS_EF00Received:
    {
      __DevFront_PowerOffReply();

      if(EF00FilterTimeout)
      {
        Timeout = TAP_GetTick() + 50;
        HookHandlerState = HHS_PowerOffCancel;
      }
      else
      {
        dword ret = HDD_TAP_SendEvent(0, TRUE, EVT_STOP, 2, 0);
        if(ret == 0)
        {
          if(LastStatus != -4) WriteLog("A TAP has intercepted the shutdown notfication");
          LastStatus = -4;
          Timeout = TAP_GetTick() + 50;
          HookHandlerState = HHS_PowerOffCancel;
        }
        else
        {
          HookHandlerState = HHS_ShutdownTimerDiags;
        }
      }

      break;
    }

    case HHS_PowerOffCancel:
    {
      if(TAP_GetTick() > Timeout)
      {
        if(LastStatus != -5) WriteLog("The shutdown has been canceled");
        LastStatus = -5;
        __DevFront_PowerOffCancel();
        EF00FilterTimeout = TAP_GetTick() + 200;
        HookHandlerState = HHS_Idle;
      }
      break;
    }

    case HHS_ShutdownTimerDiags:
    {
      if(LastStatus != -6) WriteLog("Notifiying TimerDiags about the shutdown");
      LastStatus = -6;
      HDD_TAP_SendEvent(0x8E0A4224, FALSE, EVT_STOP, 0, 0);
      Timeout = TAP_GetTick() + 200;
      HookHandlerState = HHS_Shutdown;
      break;
    }

    case HHS_Shutdown:
    {
      if(TAP_GetTick() > Timeout)
      {
        if(OrigHandler)
        {
          SetHandler(0xef00, OrigHandler, NULL);
          OrigHandler = NULL;
        }
        if(LastStatus != -7) WriteLog("Notifiying all TAPs about the shutdown");
        LastStatus = -7;
        HDD_TAP_SendEvent(0, FALSE, EVT_STOP, 0, 0);
        //TAP_Exit();
        if(LastStatus != -8) WriteLog("Enqueuing the shutdown event");
        LastStatus = -8;
        Shutdown(TaskPower);
        HookHandlerState = HHS_Exit;
      }
      break;
    }

    case HHS_Exit:
    {
      if(OrigHandler)
      {
        SetHandler(0xef00, OrigHandler, NULL);
        OrigHandler = NULL;
        if(LastStatus != -9) WriteLog("SDS has been deactivated");
        LastStatus = -9;
      }

      TRACEEXIT();
      return FALSE;
    }
  }

  TRACEEXIT();
  return TRUE;
}
Exemplo n.º 3
0
word FSFormat( byte Device, byte PartyID, byte Type )
/*
  - if DataParty==FALSE => swap party is created

  Format:
    - check BR
    - check size ( minimal/maximal size for file system )
    - create system info file in mem
      - nr of groups on volume
      - nr of sectors on volume
      - nr of sectors in last group ( not whole )
      - striping table
    - create groups
    - fill groups bitmaps
    - create and fill group info system file in mem
    - found bad blocks
    - write report to bad blocks system file in mem

    - create ROOT directory
    - create dir ->file system files.system<-
      - create subdir ->transactions.system<- for transactions
	- create file ->logfiles list.system<- list of logfiles
      - create file ->STRIPING TABLE.system<- ( flush it to disk )
      - create file ->GROUP info.system<- ( flush it to disk )
      - create file ->BAD SECs.system<- ( flush it to disk )
      - create file ->BAD GROUPSs.system<- ( flush it to disk ) has bad bitmap sectors
*/

{
 MasterBootRecord BR;
 dword		  GroupStatisticSectors;

 // load partition boot record
 #ifdef DEBUG
  printf("\n\n Party %d on device 0x%x will be FORMATED...", PartyID, Device );
  printf("\n Loading BR...");
 #endif

 if( LoadBoot( Device, PartyID, &BR ) )
 {
  #ifdef DEBUG
   printf("\n Error reading BR..." );
  #endif
  return ERR_FS_FATAL_ERROR;
 }
 else
 {
  #ifdef DEBUG
   printf(" OK..." );
  #endif
 }

 // fill format specific structures ( use them for something useful... )
 BR.BPB.CATCopies	        =0;	// filled with format - not used
 BR.BPB.RootRecords	        =0;	// filled with format - not used
 BR.BPB.SizeOfCat		=0; 	// filled with format - not used

 BR.BPB.RootFNODEAddr		=0; 	// filled with format
 // BR.BPB.NrOfGroups		=0; 	// init in call CreateNrOfGroups


 BR.BPB.DirtyFlag		=PARTY_IS_CLEAN;


 // fill magic word

 // far copy
 byte i,
      MagicData[]={RFS_MAGIC_WORD_DATA_PARTY},
      MagicSwap[]={RFS_MAGIC_WORD_SWAP_PARTY};

 if( Type==RFS_DATA )
 {
  for(i=0; i<=7; i++ ) BR.OSID.ID[i]=MagicData[i];
 }
 else
 {
  for(i=0; i<=7; i++ ) BR.OSID.ID[i]=MagicSwap[i];
 }


 // create groups

 TheSecondBoot SecondBoot;	// statistic of party => the second boot

 SecondBoot.MagicBegin= SecondBoot.MagicEnd  = 0xCDAB;
 // PartyStat.FreeSecs initialized in CreateNrOfGroups
 SecondBoot.Label[0]  =0;
 strcpy( SecondBoot.Label, "Party label not used!" );

 // - BR.BPB.HiddenSectors == first logical sector of party
 // - use NrOfGroups to change nr. of reserved sectors
 //   ( The second boot + group statistic added here )

 // change hidden sectors
 BR.BPB.ReservedSectors += 1u;	// reserving sector for the second boot


 CreateNrOfGroups(
		   Device,
		   (dword)((dword)BR.BPB.HiddenSectors+(dword)BR.BPB.ReservedSectors),
		   (dword)((dword)BR.BPB.TotalSectors-(dword)BR.BPB.ReservedSectors),
		   BR.BPB.NrOfGroups,
		   SecondBoot.FreeSecs,	 // free space on party in secs
		   GroupStatisticSectors // nr of secs with group statistic
		 );


 SecondBoot.StatSectors=GroupStatisticSectors;

 // reserving sectors for group statistic
 BR.BPB.ReservedSectors += (word)GroupStatisticSectors;
				// nr. of sectors used for group statistic,
				// each groups needs two bytes:
				// in this is nr of free sectors in group

 // copy BPB
 movmem((const void *)&(BR.BPB), (void *)&(SecondBoot.BPB), sizeof(BIOSParameterBlock) );


 // Write The Second Boot

 // HiddenSectors == first logical sector of party because of logic. address
 if( WriteLogicalSector( Device,
			 BR.BPB.HiddenSectors+1lu,// stat is 2. sec in party
			 MK_FP( FP_SEG(&SecondBoot), FP_OFF(&SecondBoot) ) )
		      )
 {
  #ifdef SEE_ERROR
   printf("\n Error writing The Second Boot..." );
  #endif

 }


 #ifdef DEBUG
  printf("\n Party STATISTIC saved:"
	 "\n  Free     : %lu sectors"
	 "\n  it is    : %lu bytes"
	 "\n  Label    : %s"
	 ,
	 SecondBoot.FreeSecs,
	 SecondBoot.FreeSecs*512lu,
	 SecondBoot.Label );
 #endif


 if( SaveBoot( Device, PartyID, &BR ) )
 {
  #ifdef DEBUG
   printf(" error writing MBR..." );
  #endif
  return ERR_FS_FATAL_ERROR;
 }

 Device&=0x0F;

 // Creating of root dir here...
 CreateRootDir( Device, PartyID, BR.BPB.RootFNODEAddr );

 // copy BPB
 movmem((const void *)&(BR.BPB), (void *)&(SecondBoot.BPB), sizeof(BIOSParameterBlock) );


 if( SaveBoot( Device, PartyID, &BR ) )
 {
  #ifdef DEBUG
   printf(" error writing MBR..." );
  #endif
  return ERR_FS_FATAL_ERROR;
 }



 // Write The Second Boot
 if( WriteLogicalSector( Device,
			 BR.BPB.HiddenSectors+1lu,// stat is 2. sec in party
			 MK_FP( FP_SEG(&SecondBoot), FP_OFF(&SecondBoot) ) )
		      )
 {
  #ifdef SEE_ERROR
   printf("\n Error writing The Second Boot..." );
  #endif
 }



 #ifdef DEBUG
  printf("\n Format results:" );
  LoadBoot( Device, PartyID, &BR );
  printf("\n Format OK..." );
 #endif

 return ERR_FS_NO_ERROR;
}