int32 UT_os_setup_fs()
{
    int32 res=OS_FS_SUCCESS;
    char text[UT_OS_LG_TEXT_LEN];

    res = OS_mkfs(g_fsAddrPtr, g_devName, " ", 512, 20);
    if (res != OS_FS_SUCCESS)
        goto UT_os_setup_fs_exit_tag;

    res = OS_mount(g_devName, g_mntName);
    if (res != OS_FS_SUCCESS)
    {
        OS_rmfs(g_devName);
        goto UT_os_setup_fs_exit_tag;
    }

UT_os_setup_fs_exit_tag:
    memset(text, '\0', sizeof(text));
    UT_os_sprintf(text, "\nUT_os_setup_fs() returns %d\n", (int)res);
    UT_OS_LOG_MACRO(text);

    return (res);
}
Beispiel #2
0
void OS_Application_Startup(void)
{
    int32  status;
    uint32 SymAddress;
  
    printf("Symbol and Symbol Table Dump test\n");

    /* Make the file system */
    status = OS_mkfs(0,"/ramdev0","RAM",512,2048);
    printf("status after mkfs = %d\n",status);

    if ( status != OS_SUCCESS )
    {
       printf("symtest Error. OS_mkfs failed\n");
       return;
    }

    status = OS_mount("/ramdev0","/ram");
    printf("status after mount = %d\n",status);
 
   /*
   ** dump the symbol table with a 32768 byte limit
   */
   printf("Dumping symbol table with a limit of 32768 bytes\n");
   status = OS_SymbolTableDump("/ram/SymbolTable32k.dat", 32768);
   if ( status == OS_SUCCESS )
   {
      printf("Symbol table dump complete\n");
   }
   else
   {
      printf("Error calling OS_SymbolTableDump\n");
   }

   /*
   ** dump the symbol table with a 128k byte limit
   */
   printf("Dumping symbol table with a limit of 131072 bytes\n");
   status = OS_SymbolTableDump("/ram/SymbolTable128k.dat", 131072);
   if ( status == OS_SUCCESS )
   {
      printf("Symbol table dump complete\n");
   }
   else
   {
      printf("Error calling OS_SymbolTableDump\n");
   }

   /*
   ** dump the symbol table with a 512k byte limit
   */
   printf("Dumping symbol table with a limit of 524288 bytes\n");
   status = OS_SymbolTableDump("/ram/SymbolTable512k.dat", 524288);
   if ( status == OS_SUCCESS )
   {
      printf("Symbol table dump complete\n");
   }
   else
   {
      printf("Error calling OS_SymbolTableDump\n");
   }

   /*
   ** Test the symbol lookup
   */
   status =  OS_SymbolLookup (&SymAddress, "OS_BSPMain" );
   if ( status == OS_SUCCESS )
   {
      printf("SymbolLookup --> OS_BSPMain symbol = 0x%08X\n",SymAddress);     
   }
   else
   {
      printf("Error calling OS_SymbolLookup\n");
   }

   /*
   ** Test a symbol lookup that does not exist
   */
   status = OS_SymbolLookup(&SymAddress, "ShouldNotExist");
   if ( status == OS_SUCCESS )
   {
      printf("SymbolLookup --> ShouldNotExist symbol = 0x%08X\n",SymAddress);     
   }
   else
   {
      printf("Expected Error calling OS_SymbolLookup\n");
   }

   printf("Complete: Symbol Table files should be in the RAM drive ( use devs cmd )\n"); 

} /* end OS_Application Startup */
Beispiel #3
0
/*
** Name: CFE_ES_InitializeFileSystems
**
** Purpose: This function initializes the file systems used in the cFE core.
**
*/
void CFE_ES_InitializeFileSystems(uint32 start_type)
{
   int32   RetStatus;
   uint32 *RamDiskMemoryAddress;
   uint32  RamDiskMemorySize;
   int32   BlocksFree;
   int32   PercentFree;
 
   /* 
   ** Get the memory area for the RAM disk 
   */
   RetStatus = CFE_PSP_GetVolatileDiskMem(&(RamDiskMemoryAddress), &(RamDiskMemorySize));

   if ( RetStatus != OS_FS_SUCCESS )
   {
      CFE_ES_WriteToSysLog("ES Startup: Cannot Get Memory for Volatile Disk. EC = 0x%08X\n",RetStatus);

      /*
      ** Delay to allow the message to be read
      */
      OS_TaskDelay(CFE_ES_PANIC_DELAY);
      
      /* 
      ** cFE Cannot continue to start up.  
      */
      CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK);

   }      
   
   /*
   ** Next, either format, or just initialize the RAM disk depending on
   ** the reset type
   */
   if ( start_type == CFE_ES_POWERON_RESET )
   {
      RetStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_ES_RAM_DISK_SECTOR_SIZE, CFE_ES_RAM_DISK_NUM_SECTORS );
      if ( RetStatus != OS_FS_SUCCESS )
      {
         CFE_ES_WriteToSysLog("ES Startup: Error Creating Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus);

         /*
         ** Delay to allow the message to be read
         */
         OS_TaskDelay(CFE_ES_PANIC_DELAY);
      
         /* 
         ** cFE Cannot continue to start up.  
         */
         CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK);
      }
   }
   else
   {
      RetStatus = OS_initfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_ES_RAM_DISK_SECTOR_SIZE, CFE_ES_RAM_DISK_NUM_SECTORS );
      if ( RetStatus != OS_FS_SUCCESS )
      {
         CFE_ES_WriteToSysLog("ES Startup: Error Initializing Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus);
         CFE_ES_WriteToSysLog("ES Startup: Formatting Volatile(RAM) Volume.\n");
         
         RetStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_ES_RAM_DISK_SECTOR_SIZE, CFE_ES_RAM_DISK_NUM_SECTORS );
         if ( RetStatus != OS_SUCCESS )
         {
            CFE_ES_WriteToSysLog("ES Startup: Error Creating Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus);

            /*
            ** Delay to allow the message to be read
            */
            OS_TaskDelay(CFE_ES_PANIC_DELAY);
      
            /* 
            ** cFE Cannot continue to start up.  
            */
            CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK);
         }
         
      }
   }

   /*
   ** Now, mount the RAM disk
   */
   RetStatus = OS_mount("/ramdev0", CFE_ES_RAM_DISK_MOUNT_STRING);
   if ( RetStatus != OS_FS_SUCCESS )
   {
      CFE_ES_WriteToSysLog("ES Startup: Error Mounting Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus);
      /*
      ** Delay to allow the message to be read
      */
      OS_TaskDelay(CFE_ES_PANIC_DELAY);
      
      /* 
      ** cFE Cannot continue to start up.  
      */
      CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK);
   }


   /*
   ** During a Processor reset, if the RAM disk has less than a defined 
   ** amount of free space, reformat and re-mount it.
   ** The parameter being checked is CFE_ES_RAM_DISK_PERCENT_RESERVED
   ** Note: When CFE_ES_RAM_DISK_PERCENT_RESERVED is set to 0, this feature is 
   **       disabled.
   */
   if ((start_type == CFE_ES_PROCESSOR_RESET) && (CFE_ES_RAM_DISK_PERCENT_RESERVED > 0))
   {
      /*
      ** See how many blocks are free in the RAM disk
      */
      BlocksFree = OS_fsBlocksFree(CFE_ES_RAM_DISK_MOUNT_STRING);   
      if ( BlocksFree >= 0 )
      {
         /*
         ** Need a sanity check for the desktop systems.
         ** Because the desktop ports map the volatile disk to the host 
         ** hard disk, it will report more free blocks than the defined number
         ** of sectors ( blocks ). Therefore it must be truncated.
         */
         if ( BlocksFree > CFE_ES_RAM_DISK_NUM_SECTORS )
         {
             BlocksFree = CFE_ES_RAM_DISK_NUM_SECTORS - 1;
         }
         
         /*
         ** Determine if the disk is too full 
         */
         BlocksFree = BlocksFree * 100;
         PercentFree = BlocksFree / CFE_ES_RAM_DISK_NUM_SECTORS;
         CFE_ES_WriteToSysLog("Volatile Disk has %d Percent free space.\n",PercentFree);

         if ( PercentFree < CFE_ES_RAM_DISK_PERCENT_RESERVED )
         {
            CFE_ES_WriteToSysLog("ES Startup: Insufficent Free Space on Volatile Disk, Reformatting.\n");
          
            /*
            ** First, unmount the disk
            */
            RetStatus = OS_unmount(CFE_ES_RAM_DISK_MOUNT_STRING);
            if ( RetStatus == OS_FS_SUCCESS )
            {

               /*
               ** Remove the file system from the OSAL
               */
               RetStatus = OS_rmfs("/ramdev0");
               if ( RetStatus == OS_FS_SUCCESS )
               {
               
                  /*
                  ** Next, make a new file system on the disk
                  */
                  RetStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", 
                                      "RAM", CFE_ES_RAM_DISK_SECTOR_SIZE, 
                                       CFE_ES_RAM_DISK_NUM_SECTORS );
                  if ( RetStatus == OS_FS_SUCCESS )
                  {
                     /*
                     ** Last, remount the disk
                     */
                     RetStatus = OS_mount("/ramdev0", CFE_ES_RAM_DISK_MOUNT_STRING);
                     if ( RetStatus != OS_FS_SUCCESS )
                     {
                        CFE_ES_WriteToSysLog("ES Startup: Error Re-Mounting Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus);
                        /*
                        ** Delay to allow the message to be read
                        */
                        OS_TaskDelay(CFE_ES_PANIC_DELAY);
                     
                        /* 
                        ** cFE Cannot continue to start up.  
                        */
                        CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK);
                     
                     } /* end if mount */
                  }
                  else
                  {

                     CFE_ES_WriteToSysLog("ES Startup: Error Re-Formating Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus);
                     /*
                     ** Delay to allow the message to be read
                     */
                     OS_TaskDelay(CFE_ES_PANIC_DELAY);
      
                     /* 
                     ** cFE Cannot continue to start up.  
                     */
                     CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK);
                                 
                  } /* end if mkfs */

              }
              else /* could not Remove File system */
              {

                  CFE_ES_WriteToSysLog("ES Startup: Error Removing Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus);
                  /*
                  ** Delay to allow the message to be read
                  */
                  OS_TaskDelay(CFE_ES_PANIC_DELAY);
      
                  /* 
                  ** cFE Cannot continue to start up.  
                  */
                  CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK);

              } /* end if OS_rmfs */

            }
            else /* could not un-mount disk */
            {
               CFE_ES_WriteToSysLog("ES Startup: Error Un-Mounting Volatile(RAM) Volume. EC = 0x%08X\n",RetStatus);
               /*
               ** Delay to allow the message to be read
               */
               OS_TaskDelay(CFE_ES_PANIC_DELAY);
               
               /* 
               ** cFE Cannot continue to start up.  
               */
               CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK);            
            }
            
         } /* end if enough free space */
         
      }
      else  /* could not determine free blocks */
      {         
         /* Log error message -- note that BlocksFree returns the error code in this case */
         CFE_ES_WriteToSysLog("ES Startup: Error Determining Blocks Free on Volume. EC = 0x%08X\n",BlocksFree);

         /*
         ** Delay to allow the message to be read
         */
         OS_TaskDelay(CFE_ES_PANIC_DELAY);

         /* 
         ** cFE Cannot continue to start up.  
         */
         CFE_PSP_Panic(CFE_PSP_PANIC_VOLATILE_DISK);
         
      } /* end if BlocksFree */
   
   } /* end if processor reset */
     
} /* end function */