Exemple #1
0
EFI_STATUS EFIAPI efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab) {

	InitializeLib(image_handle, systab);
	EFI_STATUS Status;
	systab->ConOut->ClearScreen(systab->ConOut); // CLEAR!

    EFI_GUID simplefs_guid = SIMPLE_FILE_SYSTEM_PROTOCOL; // a simple file system protocol in efi
	                      // (different from UEFI specification. In specification, this is called EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID )

	EFI_FILE_IO_INTERFACE *simplefs;                      // the simple file system's interface
	                      // (different from UEFI specification. In specification, this is called EFI_SIMPLE_FILE_SYSTEM_PROTOCOL)
	EFI_FILE *root;               //  root directory
	EFI_FILE *dir;
	CHAR16 *dirname=L"\\stories"; // name of the directory where bmp pictures are put

	status=systab->BootServices->LocateProtocol(&simplefs_guid, NULL, (VOID **)&simplefs);
	if(EFI_ERROR(status)) Print(L"locate protocol failed \n");

	status=simplefs->OpenVolume(simplefs, &root);
	if(EFI_ERROR(status)) Print(L"open volume failed\n");

	status=root->Open(root, &dir, dirname, EFI_FILE_MODE_READ, EFI_FILE_READ_ONLY);
	if(EFI_ERROR(status)) Print(L"open directory failed\n");

	VOID *buf;
	INT32 index=1;
	status = readFile(dir, index, systab, buf); // Put the contents of 1.story into buf
	Print(L"%s", buf);

    WaitForSingleEvent(ST->ConIn->WaitForKey, 0);
	uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &Key);

    return Status;
}
static void init(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE* system_table)
{
    InitializeLib(image_handle, system_table);

    IH = image_handle;

    EFI_STATUS status = EFI_SUCCESS;

    if ((NULL == ST->ConIn) || (EFI_SUCCESS != (status = ST->ConIn->Reset(ST->ConIn, 0)))){

        error_print(L"Input device unavailable.\n", ST->ConIn ? &status : NULL);
    }

    status = BS->OpenProtocol(
        image_handle, &LoadedImageProtocol, &loaded_image,
        image_handle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL
    );

    if (EFI_ERROR(status)){

        error_print(L"OpenProtocol() LoadedImageProtocol failed.\n", &status);
    }

    set_uefi_handle_if(image_handle, loaded_image);
}
Exemple #3
0
/**
 * Image entry point. Installs the Driver Binding and Component Name protocols
 * on the image's handle. Actually mounting a file system is initiated through
 * the Driver Binding protocol at the firmware's request.
 */
EFI_STATUS EFIAPI fsw_efi_main(IN EFI_HANDLE         ImageHandle,
                               IN EFI_SYSTEM_TABLE   *SystemTable)
{
    EFI_STATUS  Status;

#ifndef VBOX
    InitializeLib(ImageHandle, SystemTable);
#endif

    // complete Driver Binding protocol instance
    fsw_efi_DriverBinding_table.ImageHandle          = ImageHandle;
    fsw_efi_DriverBinding_table.DriverBindingHandle  = ImageHandle;
    // install Driver Binding protocol
    Status = BS->InstallProtocolInterface(&fsw_efi_DriverBinding_table.DriverBindingHandle,
                                          &PROTO_NAME(DriverBindingProtocol),
                                          EFI_NATIVE_INTERFACE,
                                          &fsw_efi_DriverBinding_table);
    if (EFI_ERROR (Status)) {
        return Status;
    }

    // install Component Name protocol
    Status = BS->InstallProtocolInterface(&fsw_efi_DriverBinding_table.DriverBindingHandle,
                                          &PROTO_NAME(ComponentNameProtocol),
                                          EFI_NATIVE_INTERFACE,
                                          &fsw_efi_ComponentName_table);
    if (EFI_ERROR (Status)) {
        return Status;
    }

    return EFI_SUCCESS;
}
Exemple #4
0
; ןונגוירא� ןנמדנאללא הכ� UEFI
EFI_STATUS efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
	InitializeLib(image, systab);
	UINTN mms=65536;
	int i;
	int s;
	EFI_MEMORY_DESCRIPTOR *mm;
uefi_call_wrapper(systab->BootServices->AllocatePool,
				3,
				EfiLoaderData,
				sizeof(EFI_MEMORY_DESCRIPTOR)*65536,
				((void*)&mm));
	UINTN mk,ds,dv;
	
	uefi_call_wrapper(systab->BootServices->GetMemoryMap,
				5,
				&mms,
				mm,
				&mk,
				&ds,
				&dv);
	s=0;
	for (i=0;i<mms;i++)
		if((mm[i].Type == EfiBootServicesCode)
		||(mm[i].Type == EfiBootServicesData)
		||(mm[i].Type == EfiConventionalMemory)
		||(mm[i].Type == EfiACPIReclaimMemory)
		)s+=mm[i].NumberOfPages;
		
	Print(L"%d\r\n",s);
	
	return EFI_SUCCESS;
}
Exemple #5
0
/**
 *  UGA Draw Protocol Test Driver Entry point.
 *  @param ImageHandle the driver image handle.
 *  @param SystemTable the system table.
 *  @return EFI_SUCCESS the driver is loaded successfully.
 */
EFI_STATUS
InitializeBBTestUgaDraw (
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
  )
{
  EfiInitializeTestLib (ImageHandle, SystemTable);
  InitializeLib (ImageHandle, SystemTable);
  EfiInitializeDriverLib (ImageHandle, SystemTable);

  //
  // Initialize Demo Data
  //
  DemoResolutionMax  = sizeof (DemoResolution) / sizeof (DEMO_RESOLUTION_TYPE);
  DemoRefreshRateMax = sizeof (DemoRefreshRate) / sizeof (DEMO_REFRESH_RATE_TYPE);
  DemoColorDepthMax  = sizeof (DemoColorDepth) / sizeof (DEMO_COLOR_DEPTH_TYPE);

  gtBS->CreateEvent (EFI_EVENT_TIMER, 0, NULL, NULL, &TimerEvent);

  return EfiInitAndInstallBBTestInterface (
           &ImageHandle,
           &gBBTestProtocolField,
           gBBTestEntryField,
           BBTestUgaDrawProtocolUnload,
           &gBBTestProtocolInterface
           );
}
EFI_STATUS
InitializeGraphicsOutputBBTest (
    IN EFI_HANDLE             ImageHandle,
    IN EFI_SYSTEM_TABLE       *SystemTable
)
/*++

Routine Description:

   GraphicsOutput Protocol Test Driver Entry point.

Arguments:

  ImageHandle - The driver image handle
  SystemTable - The system table

Returns:

  EFI_SUCCESS - The driver is loaded successfully.

--*/
{
    EfiInitializeTestLib (ImageHandle, SystemTable);
    InitializeLib (ImageHandle, SystemTable);
    EfiInitializeDriverLib (ImageHandle, SystemTable);

    return EfiInitAndInstallIHVBBTestInterface (
               &ImageHandle,
               &gBBTestProtocolField,
               gBBTestEntryField,
               UnloadEfiGraphicsOutputBBTest,
               &gBBTestProtocolInterface
           );

}
Exemple #7
0
EFI_STATUS
efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
	EFI_STATUS rc;

	InitializeLib(image, systab);

	rc = uefi_call_wrapper(BS->HandleProtocol, 3, image, &LoadedImageProtocol, (void *)&this_image);
	if (EFI_ERROR(rc)) {
		Print(L"Error: could not find loaded image: %d\n", rc);
		return rc;
	}

	Print(L"System BootOrder not found.  Initializing defaults.\n");

	set_boot_order();

	rc = find_boot_options(this_image->DeviceHandle);
	if (EFI_ERROR(rc)) {
		Print(L"Error: could not find boot options: %d\n", rc);
		return rc;
	}

	try_start_first_option(image);

	Print(L"Reset System\n");
	uefi_call_wrapper(RT->ResetSystem, 4, EfiResetCold,
			  EFI_SUCCESS, 0, NULL);

	return EFI_SUCCESS;
}
EFI_STATUS
InitializeBBTestDeviceIo (
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
  )
/*++

Routine Description:
  Creates/installs the BlackBox Interface and eminating Entry Point node list.

Arguments:
  ImageHandle:  NULL
  *SystemTable: Pointer to System Table

Returns:
  EFI_SUCCESS:              Indicates the interface was installed.
  EFI_OUT_OF_RESOURCES:     Indicates space for the new handle could not be allocated
  EFI_INVALID_PARAMETER:    One of the parameters has an invalid value.

--*/
{
  EfiInitializeTestLib (ImageHandle, SystemTable);
  InitializeLib (ImageHandle, SystemTable);
  GetSystemDevicePathAndFilePath (ImageHandle);

  return  EfiInitAndInstallIHVBBTestInterface (
            &ImageHandle,
            &gBBTestProtocolField,
            gBBTestEntryField,
            BBTestDeviceIoUnload,
            &gBBTestProtocolInterface
            );

}
Exemple #9
0
EFI_STATUS
efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
{
	EFI_STATUS status;
	UINT64 MaximumVariableStorageSize,
		RemainingVariableStorageSize,
		MaximumVariableSize;

	InitializeLib(image_handle, systab);

	status = systab->RuntimeServices->QueryVariableInfo(
				EFI_VARIABLE_NON_VOLATILE |
				EFI_VARIABLE_BOOTSERVICE_ACCESS |
				EFI_VARIABLE_RUNTIME_ACCESS,
				&MaximumVariableStorageSize,
				&RemainingVariableStorageSize,
				&MaximumVariableSize);
	Print(L"Maximum Variable Storage Size: %lld\r\n",
		MaximumVariableStorageSize);
	Print(L"Remaining Variable Storage Size: %lld\r\n",
		RemainingVariableStorageSize);
	Print(L"Maximum Variable Size: %lld\r\n",
		MaximumVariableSize);

	return status;
}
Exemple #10
0
EFI_STATUS
efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
	InitializeLib(image, systab);
	DebugHook();
	return EFI_SUCCESS;
}
EFI_STATUS
efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
	EFI_STATUS status;
	CHAR16 name[256], *val, fmt[20];
	EFI_GUID vendor;
	UINTN size;

	InitializeLib(image, systab);

	name[0] = 0;
	vendor = NullGuid;

	Print(L"GUID                                Variable Name        Value\n");
	Print(L"=================================== ==================== ========\n");

	StrCpy(fmt, L"%.-35g %.-20s %s\n");
	while (1) {
		size = sizeof(name);
		status = uefi_call_wrapper(RT->GetNextVariableName, 3, &size, name, &vendor);
		if (status != EFI_SUCCESS)
			break;

		val = LibGetVariable(name, &vendor);
		Print(fmt, &vendor, name, val);
		FreePool(val);
	}
	return EFI_SUCCESS;
}
/**
 *  Creates/installs the BlackBox Interface and eminating Entry Point
 *  node list.
 *  @param  ImageHandle The test driver image handle
 *  @param  SystemTable Pointer to System Table
 *  @return EFI_SUCCESS Indicates the interface was installed
 *  @return EFI_OUT_OF_RESOURCES Indicates space for the new handle could not be allocated
 *  @return EFI_INVALID_PARAMETER: One of the parameters has an invalid value.
 */
EFI_STATUS
InitializeBBTestProtocolHandlerBootServices (
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
  )
{
  EFI_STATUS              Status;

  EfiInitializeTestLib (ImageHandle, SystemTable);

  //
  // initialize test utility lib
  //
  InitializeLib (ImageHandle, SystemTable);

  mImageHandle = ImageHandle;

  Status = InitializeGlobalData ();
  if (EFI_ERROR (Status)) {
    return Status;
  }

  return EfiInitAndInstallBBTestInterface (
           &ImageHandle,
           &gBBTestProtocolField,
           gBBTestEntryField,
           BBTestProtocolHandlerBootServicesUnload,
           &gBBTestProtocolInterface
           );
}
Exemple #13
0
EFI_STATUS
efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
    EFI_STATUS rc = EFI_SUCCESS;
    UINT32 Attr;
    UINT64 MaxStoreSize = 0;
    UINT64 RemainStoreSize = 0;
    UINT64 MaxSize = 0;

    InitializeLib(image, systab);

    Attr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD;

    rc = uefi_call_wrapper(RT->QueryVariableInfo, 4, 
                           Attr, &MaxStoreSize, &RemainStoreSize, &MaxSize);

    if (rc != EFI_SUCCESS) {
        Print(L"ERROR: Failed to get store sizes: %d\n", rc);
    } else {
        Print(L"Max Storage Size: %ld\n", MaxStoreSize);
        Print(L"Remaining Storage Size: %ld\n", RemainStoreSize);
        Print(L"Max Variable Size: %ld\n", MaxSize);
    }

    return rc;
}
Exemple #14
0
EFI_STATUS
efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
	EFI_LOADED_IMAGE *loaded_image = NULL;
#if 0
	EFI_DEVICE_PATH *dev_path;
#endif
	EFI_STATUS status;

	InitializeLib(image, systab);
	status = uefi_call_wrapper(systab->BootServices->HandleProtocol,
				3,
				image, 
				&LoadedImageProtocol, 
				(void **) &loaded_image);
	if (EFI_ERROR(status)) {
		Print(L"handleprotocol: %r\n", status);
	}

#if 0
	BS->HandleProtocol(loaded_image->DeviceHandle, &DevicePathProtocol, (void **) &dev_path);

	Print(L"Image device      : %s\n", DevicePathToStr(dev_path));
	Print(L"Image file        : %s\n", DevicePathToStr(loaded_image->FilePath));
#endif
	Print(L"Image base        : %lx\n", loaded_image->ImageBase);
	Print(L"Image size        : %lx\n", loaded_image->ImageSize);
	Print(L"Load options size : %lx\n", loaded_image->LoadOptionsSize);
	Print(L"Load options      : %s\n", loaded_image->LoadOptions);

	return EFI_SUCCESS;
}
/**
 *  Creates/installs the BlackBox Interface and eminating Entry Point node list.
 *  @param  ImageHandle The test driver image handle
 *  @param  SystemTable Pointer to System Table
 *  @return EFI_SUCCESS Indicates the interface was installed
 *  @return EFI_OUT_OF_RESOURCES Indicates space for the new handle could not be allocated
 *  @return EFI_INVALID_PARAMETER: One of the parameters has an invalid value.
 */
EFI_STATUS
InitializeBBTestPxeBCProtocol (
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
  )
{
  EFI_STATUS Status;

  EfiInitializeTestLib (ImageHandle, SystemTable);
  InitializeLib (ImageHandle, SystemTable);
  EfiInitializeDriverLib (ImageHandle, SystemTable);

  Status = gtBS->CreateEvent (EFI_EVENT_TIMER, 0, NULL, NULL, &TimerEvent);
  if (EFI_ERROR(Status)) {
    return Status;
  }

  Status = GetSystemDevicePathAndFilePath (ImageHandle);
  if (EFI_ERROR(Status)) {
    return Status;
  }

  return EfiInitAndInstallBBTestInterface (
           &ImageHandle,
           &gEfiPxeBcTestProtField,
           gPxeTestEntryField,
           BBTestPxeBcUnload,
           &gBBTestProtocolInterface
           );
}
Exemple #16
0
EFI_STATUS
efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
	EFI_STATUS status;
	int argc, i;
	CHAR16 **ARGV;
	CHAR16 descr[64];

	InitializeLib(image, systab);

	status = argsplit(image, &argc, &ARGV);
	if (status != EFI_SUCCESS) {
		StatusToString (descr, status);
		Print (L"error %s\n", descr);
	}

	Print (L"argc %d\n", argc);

	for (i = 0; i < argc; i++)
		Print (L"argv[%d]: %s\n", i, ARGV[i]);

	Print (L"\nPress any key to continue\n");
	efi_pause();

	return EFI_SUCCESS;
}
Exemple #17
0
/*********************************************************************************
 *  Creates/installs the BlackBox Interface and eminating Entry Point node list.
 *  @param  ImageHandle The test driver image handle
 *  @param  SystemTable Pointer to System Table
 *  @return EFI_SUCCESS Indicates the interface was installed
 *  @return EFI_OUT_OF_RESOURCES Indicates space for the new handle could not be allocated
 *  @return EFI_INVALID_PARAMETER: One of the parameters has an invalid value.
 ********************************************************************************/
EFI_STATUS
InitializeTapeTest (
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
  )
{
  EFI_STATUS Status;
  
  
  EfiInitializeTestLib (ImageHandle, SystemTable);
  InitializeLib (ImageHandle, SystemTable);
  EfiInitializeDriverLib (ImageHandle, SystemTable);
  
  //
  // Make sure the Protocol is not already installed in the system
  //
  //ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiTapeIoProtocolGuid);  
  
  Status = gtBS->CreateEvent (EFI_EVENT_TIMER, 0, NULL, NULL, &TimerEvent);
  if (EFI_ERROR(Status)) {
    return Status;
  }

  Status = EfiInitAndInstallBBTestInterface (
           &ImageHandle,
           &gEfiTapeTestProtField,
           gTapeTestEntryField,
           UnloadTapeTest,
           &gTapeTestProtocol
           );  
  return Status;  
         
}
Exemple #18
0
EFI_STATUS
EFIAPI
efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
    InitializeLib(ImageHandle, SystemTable);
    Print(L"Hello, world!\n");
    return EFI_SUCCESS;
}
EFI_STATUS
efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
    InitializeLib(image, systab);

    print_memory_map();

    return EFI_SUCCESS;
}
Exemple #20
0
EFI_STATUS
efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
	InitializeLib(image, systab);
	Print(L"HelloLib application started\n");
	Print(L"\n\n\nHit any key to exit this image\n");
	WaitForSingleEvent(ST->ConIn->WaitForKey, 0);
	uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L"\n\n");
	return EFI_SUCCESS;
}
EFI_expressionUS 
efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab )
{
	InitializeLib(image_handle, systab);
	
	EFI_expressionUS err;
	UINTN memorymapsize, mapkey, descriptorsize;;
	UINT32 descriptorversion;
	EFI_MEMORY_DESCRIPTOR *memorymap;
	
	
	int i,z;
	long long int memtouse=0;	
	
	err=uefi_call_wrapper(systab->BootServices->GetMemoryMap,5,&memorymapsize, memorymap, &mapkey, &descriptorsize, &descriptorversion);  
	if(err!=EFI_BUFFER_TOO_SMALL)
		{
		Print(L"Error in getting memory map\n");
		return EFI_SUCCESS;
		}

	err=uefi_call_wrapper(systab->BootServices->AllocatePool,3, EfiLoaderData,memorymapsize, ((void*)&memorymap));  
	if(err!=EFI_SUCCESS)
		{
		Print(L"Error in allocating memory\n");
		return EFI_SUCCESS;
		}

	err=uefi_call_wrapper(systab->BootServices->GetMemoryMap, 5, &memorymapsize, memorymap, &mapkey, &descriptorsize, &descriptorversion);  
	
	if(err!=EFI_SUCCESS)
		{
		Print(L"Error in getting memory map\n");
		return EFI_SUCCESS;
		}

	z=memorymapsize/(sizeof(EFI_MEMORY_DESCRIPTOR));	
	for(i=0;i<z;i++){
		if((memorymap[i].Type==EfiBootServicesCode)|| (memorymap[i].Type==EfiBootServicesData) ||(memorymap[i].Type==EfiConventionalMemory))
		{memtouse+=memorymap[i].NumberOfPages;}
	}
	memtouse=memtouse*4096;

	err=uefi_call_wrapper(systab->BootServices->FreePool, 1, ((void*)memorymap));
	
	if(err!=EFI_SUCCESS)
		{
		Print(L"Error in free pool fuction\n");
		return err;
		}


	Print(L"%d bytes of memory is avaliable for general use\n",memtouse);
	return EFI_SUCCESS;
}
Exemple #22
0
EFI_STATUS
EFIAPI
efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
  EFI_INPUT_KEY efi_input_key;

  int a = 10, b = 20;

  InitializeLib(ImageHandle, SystemTable);
  //Print(L"Hello, world!\n");
  terra_main(L"Hello, Terra from C!\n");
  Print(L"%d + %d = %d\n", a, b, terra_add(a,b));

  Print(L"%s\n", SystemTable->FirmwareVendor);

  EFI_STATUS status;
  EFI_GRAPHICS_OUTPUT_PROTOCOL *gop;

  status = LibLocateProtocol(&GraphicsOutputProtocol, (void **)&gop);

  if(EFI_ERROR(status))
    return status;

  status = uefi_call_wrapper(SystemTable->BootServices->LocateProtocol, 3, &GraphicsOutputProtocol, NULL, &gop);

  Print(L"Framebuffer base is at %lx\n", gop->Mode->FrameBufferBase);
  
  print_modes(gop);

  Print(L"\n\n\nHit any key\n");
  WaitForSingleEvent(SystemTable->ConIn->WaitForKey, 0);
  status = uefi_call_wrapper(SystemTable->ConIn->ReadKeyStroke, 2, SystemTable->ConIn, &efi_input_key);
 
  paint_screen(gop, (UINT32)0x00FF0000);
  uefi_call_wrapper(BS->Stall, 1, 2 * 1000 * 1000);
 
  paint_screen(gop, (UINT32)0x0000FF00);
  uefi_call_wrapper(BS->Stall, 1, 2 * 1000 * 1000);
 
  paint_screen(gop, (UINT32)0x000000FF0);

  // FROM: https://github.com/vathpela/gnu-efi/blob/master/apps/t7.c

  Print(L"\n\n\nHit any key to exit this image\n");

  WaitForSingleEvent(SystemTable->ConIn->WaitForKey, 0);
  
  uefi_call_wrapper(SystemTable->ConOut->OutputString, 2, SystemTable->ConOut, L"\n\n");
  
  status = uefi_call_wrapper(SystemTable->ConIn->ReadKeyStroke, 2, SystemTable->ConIn, &efi_input_key);
  
  Print(L"ScanCode: %xh  UnicodeChar: %xh\n", efi_input_key.ScanCode, efi_input_key.UnicodeChar);

  return EFI_SUCCESS;
}
Exemple #23
0
EFI_STATUS
efi_main (EFI_HANDLE *image, EFI_SYSTEM_TABLE *systab)
{
    UINTN index;

    InitializeLib(image, systab);
    uefi_call_wrapper(systab->ConOut->OutputString, 2, systab->ConOut, L"Hello application started\r\n");
    uefi_call_wrapper(systab->ConOut->OutputString, 2, systab->ConOut, L"\r\n\r\n\r\nHit any key to exit\r\n");
    uefi_call_wrapper(systab->BootServices->WaitForEvent, 3, 1, &systab->ConIn->WaitForKey, &index);
    return EFI_SUCCESS;
}
Exemple #24
0
Fichier : main.c Projet : ld86/os
EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
    EFI_MEMORY_DESCRIPTOR *descriptors;
    EFI_STATUS status;
    UINTN neededMemory = 0, actualSize, descriptors_size;
    UINT64 totalMemory = 0;

    InitializeLib(ImageHandle, SystemTable);
    status = uefi_call_wrapper(SystemTable->BootServices->GetMemoryMap, 
            5, 
            &neededMemory, NULL, NULL, NULL, NULL);
    if ( status != EFI_BUFFER_TOO_SMALL )
    {
        Print(L"Something going wrong\n");
        return EFI_SUCCESS;
    }

    status = uefi_call_wrapper(SystemTable->BootServices->AllocatePool,
            3, 
            EfiLoaderData, neededMemory, &descriptors);
    if (status != EFI_SUCCESS)
    {
        Print (L"AllocatePool failed\n");
        return EFI_SUCCESS;
    }

    status = uefi_call_wrapper(
            SystemTable->BootServices->GetMemoryMap,
            5, 
            &descriptors_size, descriptors, NULL, &actualSize, NULL);

    if ( status == EFI_SUCCESS )
    {
        UINTN count = descriptors_size / actualSize;
        UINTN i;
        for ( i = 0; i < count; ++i )
        {
            if ( descriptors[i].Type == EfiLoaderData ||
                    descriptors[i].Type == EfiBootServicesData || 
                    descriptors[i].Type == EfiRuntimeServicesData ||
                    descriptors[i].Type == EfiConventionalMemory)
            {
                totalMemory += descriptors[i].NumberOfPages * 4096;
            }
        }
        Print(L"%d\n", totalMemory);
    }        

    uefi_call_wrapper(SystemTable->BootServices->FreePool, 1, descriptors);
    return EFI_SUCCESS;
}
Exemple #25
0
EFI_STATUS
efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
{
	INT32 i;

	InitializeLib(image_handle, systab);

	for (i = 0; i < ST->ConOut->Mode->MaxMode; i++) {
		set_console_mode (i);
		Print (L"\nPress any key to continue...\n");
		efi_pause ();
	}

	return EFI_SUCCESS;
}
Exemple #26
0
EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) {
	// Initialize the library
	InitializeLib(image, systab);

	// Get how much space is needed for the memory map
	UINTN mapBytes = 0;
	EFI_STATUS retstat;
	retstat = uefi_call_wrapper(BS->GetMemoryMap, 5, &mapBytes, NULL, NULL, NULL,
			NULL);
	if (retstat == EFI_BUFFER_TOO_SMALL) {
		Print(L"The memory map requires %d bytes\n\r", mapBytes);
	}
	// Convert bytes to 4KiB pages (rounded up), plus a little extra to be safe
	mapBytes += 512;
	UINTN numPages = EFI_SIZE_TO_PAGES(mapBytes);

	// Allocate
	EFI_PHYSICAL_ADDRESS mapDescPages = 0;
	retstat = uefi_call_wrapper(BS->AllocatePages, 4, AllocateAnyPages,
			EfiLoaderData, numPages, &mapDescPages);
	if (retstat != EFI_SUCCESS) {
		Print(L"Something went wrong allocating %d pages: %r\r\n", numPages, retstat);
		Print(L"Descs: %x\r\n", mapDescPages);
		goto exit0;
	} else {
		Print(L"Allocation succeeded: 0x%lx\r\n", mapDescPages);
	}

	// Get the memory map
	UINTN descSize;
	UINT8 *mapDescBuffer = (UINT8 *)mapDescPages;
	retstat = uefi_call_wrapper(BS->GetMemoryMap, 5, &mapBytes, mapDescBuffer,
			NULL, &descSize, NULL);
	if (retstat != EFI_SUCCESS) {
		Print(L"BS->GetMemoryMap(...): %r\n\r", retstat);
		goto exit1;
	}

	// Dump the memory map
	printMemoryMap(mapDescBuffer, mapBytes, descSize);


exit1:
	uefi_call_wrapper(BS->FreePages, 2, mapDescPages, numPages);
exit0:
	return EFI_SUCCESS;
}
Exemple #27
0
EFI_STATUS
efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
	EFI_STATUS rc = EFI_SUCCESS;
	int i;

	InitializeLib(image, systab);

	rc = show_signature_support(systab);
	dumpvar(systab, &EfiGlobalVariable, L"SetupMode");
	dumpvar(systab, &EfiGlobalVariable, L"SecureBoot");
	dumpvar(systab, &EfiGlobalVariable, EFI_PLATFORM_KEY_NAME);
	dumpvar(systab, &EfiGlobalVariable, EFI_KEY_EXCHANGE_KEY_NAME);
	dumpvar(systab, &gEfiImageSecurityDatabaseGuid,	EFI_IMAGE_SECURITY_DATABASE);
	dumpvar(systab, &gEfiImageSecurityDatabaseGuid,	EFI_IMAGE_SECURITY_DATABASE1);
	return rc;
}
EFI_STATUS
InitializeEfiCompliantBbTest (
  IN EFI_HANDLE         ImageHandle,
  IN EFI_SYSTEM_TABLE   *SystemTable
  )
{
  EfiInitializeTestLib (ImageHandle, SystemTable);
  InitializeLib (ImageHandle, SystemTable);

  return EfiInitAndInstallBBTestInterface (
           &ImageHandle,
           &gBBTestProtocolField,
           gBBTestEntryField,
           EfiCompliantBbTestUnload,
           &gBBTestProtocolInterface
           );
}
Exemple #29
0
// Application entrypoint
EFI_STATUS EfiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
	EFI_INPUT_KEY Key;

	InitializeLib(ImageHandle, SystemTable);

	Print(L"\n*** UEFI:SIMPLE ***\n\n");

	Print(L"\nPress any key to exit.\n");
	SystemTable->ConIn->Reset(SystemTable->ConIn, FALSE);
	while (SystemTable->ConIn->ReadKeyStroke(SystemTable->ConIn, &Key) == EFI_NOT_READY);
#if defined(_DEBUG)
	// If running in debug mode, use the EFI shut down call to close QEMU
	RT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);
#endif

	return EFI_SUCCESS;
}
/**
 *  Scsi Pass Through Protocol Test Driver Entry point.
 *  @param ImageHandle the driver image handle.
 *  @param SystemTable the system table.
 *  @return EFI_SUCCESS the driver is loaded successfully.
 */
EFI_STATUS
InitializeBBTestScsiPassThru (
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
  )
{
  EfiInitializeTestLib (ImageHandle, SystemTable);
  InitializeLib (ImageHandle, SystemTable);


  return EfiInitAndInstallBBTestInterface (
           &ImageHandle,
           &gBBTestProtocolField,
           gBBTestEntryField,
           BBTestScsiPassThruProtocolUnload,
           &gBBTestProtocolInterface
           );
}