コード例 #1
0
ファイル: scan.c プロジェクト: Fuhuiang/rscheme
obj rstore_scan_pob( struct RStore *store, obj ptr, obj other_failures,
		     obj with_reloc )
{
  struct Scanning ctx;
  struct PHeapHdr *p;
  UINT_32 N;

  store->reloc_table = with_reloc;

  assert( OBJ_ISA_PTR(ptr) );

  ctx.failures = other_failures;
  ctx.store = store;
  ctx.source = ptr;

  /* set the save pointer to NULL to tell us not to bother
   * remembering the translated pointers.  If we didn't
   * do this, we would have to make a bigger buffer, because
   * ctx.xlated_ptrs is only big enough for a page's worth of
   * pointers, and an object may be quite a bit larger and full
   * of pointers
   */
  ctx.pscan = NULL;

  p = PTR_TO_PHH( ptr );

  notice_obj( &ctx, &p->rs_header.pob_class );
  N = p->rs_header.pob_size;
  
  scan_mem( &ctx, p, p+1, 0, N );

  store->reloc_table = FALSE_OBJ;
  return ctx.failures;
}
コード例 #2
0
int
main(void) {
  while (1) {
    scanf("%lld", &n);
    scanf("%lld\n", &m);
    if (!n && !m) break;
    scan_mem();
    produce();
  }
  return 0;
}
コード例 #3
0
/* Load the smbios.plist override config file if any */
static void setupSmbiosConfigFile()
{
  const char * value = getStringForKey(kSMBIOS, &bootInfo->bootConfig);
  extern void scan_mem();

    if (!value)  value = "/Extra/smbios.plist";
    if (loadConfigFile(value, &bootInfo->smbiosConfig) == -1) {
      verbose("No SMBIOS replacement found\n");
    }

    // get a chance to scan mem dynamically if user asks for it while having the config options loaded as well
    // as opposed to when it was in scan_platform(), also load the orig. smbios so that we can access dmi info without
    // patching the smbios yet
    getSmbios(SMBIOS_ORIGINAL);
    scan_mem(); 
    smbios_p = (EFI_PTR32) getSmbios(SMBIOS_PATCHED);	// process smbios asap
}
コード例 #4
0
ファイル: fake_efi.c プロジェクト: Trauma/Chameleon-ATI
static void setupSmbiosConfigFile(const char *filename)
{
	char		dirSpecSMBIOS[128] = "";
	const char *override_pathname = NULL;
	int			len = 0, err = 0;
	extern void scan_mem();
	
	// Take in account user overriding
	if (getValueForKey(kSMBIOSKey, &override_pathname, &len, &bootInfo->bootConfig) && len > 0)
	{
		// Specify a path to a file, e.g. SMBIOS=/Extra/macProXY.plist
		sprintf(dirSpecSMBIOS, override_pathname);
		err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig);
	}
	else
	{
		// Check selected volume's Extra.
		sprintf(dirSpecSMBIOS, "/Extra/%s", filename);
		if (err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig))
		{
			// Check booter volume/rdbt Extra.
			sprintf(dirSpecSMBIOS, "bt(0,0)/Extra/%s", filename);
			err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig);
		}
	}

	if (err)
	{
		verbose("No SMBIOS replacement found.\n");
	}

	// get a chance to scan mem dynamically if user asks for it while having the config options loaded as well,
	// as opposed to when it was in scan_platform(); also load the orig. smbios so that we can access dmi info without
	// patching the smbios yet
	getSmbios(SMBIOS_ORIGINAL);
	scan_mem(); 
	smbios_p = (EFI_PTR32)getSmbios(SMBIOS_PATCHED);	// process smbios asap
}
コード例 #5
0
ファイル: scan.c プロジェクト: Fuhuiang/rscheme
static void scan_page( struct Scanning *ctx,
		       struct VMPageRecord *page )
{
  struct PHeapHdr *p;
  unsigned i;
  
  if (page->ref.first)
    {
      struct PHeapHdr *limit;
      struct FirstPageHdr *fph = (struct FirstPageHdr *)page->mem_address; 
      obj tmp;

      /*
       *  write out the page's allocation-area pointer
       */

      tmp = DATAPTR_TO_PTR(fph->area);

      ctx->source = tmp;
      notice_obj( ctx, &tmp );

      /*
       *  traverse / write out the objects on the page
       */

      p = first_on_first( page );
      limit = (struct PHeapHdr *)((char *)page->mem_address + MM_PAGE_SIZE);
      while (p < limit)
	{
	  UINT_32 N, i;

	  /* check for an early end of the page */
	  if (p->mem_size == 0)
	    {
	      break;
	    }

	  /* p points to the PHeapHdr of an object on this page */
          if (p->pstore_flags != PFLAGS_FREE_OBJ)
            {
              ctx->source = PHH_TO_PTR( p );
              notice_obj( ctx, &p->rs_header.pob_class );
              
              N = p->rs_header.pob_size;
              
              if (page->ref.nth_page > 1)
                {
                  /* clip the length to go only to the end of the page */
                  N = MM_PAGE_SIZE - sizeof(struct PHeapHdr) 
                    - sizeof(struct FirstPageHdr);
                }
              
              scan_mem( ctx, p, p+1, 0, N );
            }
	  /* go on to the next object */
	  p = (struct PHeapHdr *)((char *)p + p->mem_size);
	}
    }
  else
    {
      UINT_32 i, M, N;
      struct PHeapHdr *p;
      
      p = large_object_hdr( page ); 
      ctx->source = PHH_TO_PTR( p );
      
      /* figure out how many bytes to decode */

      M = page->ref.nth_page * MM_PAGE_SIZE;
      N = p->rs_header.pob_size 
	  + sizeof(struct PHeapHdr)
	  + sizeof(struct FirstPageHdr);

/*      printf( "save interior page %08x: at %08x\n",
	     page->ref.base_page_num + page->ref.nth_page,
	     page->mem_address );
  */    
      if (N > M)
	{
	  N -= M;
	  
	  /* there is at least SOMETHING to do */
	  
	  if (N >= MM_PAGE_SIZE)
	    {
	      /*  we're completely inside, so do only this page worth */
	      N = MM_PAGE_SIZE;
	    }
	  scan_mem( ctx, p, 
		    page->mem_address, 
		    (char *)page->mem_address - (char *)(p+1),
		    N );
	}
    }
}