-/* $Id: fsw_efi.c 29125 2010-05-06 09:43:05Z vboxsync $ */
-/** @file
- * fsw_efi.c - EFI host environment code.
- */
-
-/*
- * Copyright (C) 2010 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+/**
+ * \file fsw_efi.c
+ * EFI host environment code.
*/
/*-
- * This code is based on:
- *
* Copyright (c) 2006 Christoph Pfisterer
*
* Redistribution and use in source and binary forms, with or without
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/*
+ * Changes by Roderick Smith are licensed under the preceding terms.
+ */
#include "fsw_efi.h"
#include "fsw_core.h"
#define DEBUG_LEVEL 0
#ifndef FSTYPE
-#error FSTYPE must be defined!
-#endif
-
-#define DEBUG_VBFS 1
-
-#if DEBUG_VBFS==2
-#define DBG(x...) AsciiPrint(x)
-#elif DEBUG_VBFS==1
-#define DBG(x...) BootLog(x)
-#else
-#define DBG(x...)
+/** The file system type name to use. */
+#define FSTYPE ext2
#endif
#ifdef __MAKEWITH_GNUEFI
EFI_GUID gEfiFileInfoGuid = EFI_FILE_INFO_ID;
EFI_GUID gEfiFileSystemInfoGuid = EFI_FILE_SYSTEM_INFO_ID;
EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid = EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID;
-#define SimpleFileSystemProtocol FileSystemProtocol
+#define gEfiSimpleFileSystemProtocolGuid FileSystemProtocol
#endif
/** Helper macro for stringification. */
#define FSW_EFI_STRINGIFY(x) #x
/** Expands to the EFI driver name given the file system type name. */
-#define FSW_EFI_DRIVER_NAME(t) L"rEFInd 0.7.9 " FSW_EFI_STRINGIFY(t) L" File System Driver"
+#define FSW_EFI_DRIVER_NAME(t) L"rEFInd 0.9.1 " FSW_EFI_STRINGIFY(t) L" File System Driver"
// function prototypes
extern struct fsw_fstype_table FSW_FSTYPE_TABLE_NAME(FSTYPE);
-//#include "OverrideFunctions-kabyl.edk2.c.include"
static VOID EFIAPI fsw_efi_clear_cache(VOID) {
int i;
// first, open DiskIO
Status = refit_call6_wrapper(BS->OpenProtocol, ControllerHandle,
- &PROTO_NAME(DiskIoProtocol),
+ &gEfiDiskIoProtocolGuid,
(VOID **) &DiskIo,
This->DriverBindingHandle,
ControllerHandle,
// we were just checking, close it again
refit_call4_wrapper(BS->CloseProtocol, ControllerHandle,
- &PROTO_NAME(DiskIoProtocol),
+ &gEfiDiskIoProtocolGuid,
This->DriverBindingHandle,
ControllerHandle);
// next, check BlockIO without actually opening it
Status = refit_call6_wrapper(BS->OpenProtocol, ControllerHandle,
- &PROTO_NAME(BlockIoProtocol),
+ &gEfiBlockIoProtocolGuid,
NULL,
This->DriverBindingHandle,
ControllerHandle,
// open consumed protocols
Status = refit_call6_wrapper(BS->OpenProtocol, ControllerHandle,
- &PROTO_NAME(BlockIoProtocol),
+ &gEfiBlockIoProtocolGuid,
(VOID **) &BlockIo,
This->DriverBindingHandle,
ControllerHandle,
}
Status = refit_call6_wrapper(BS->OpenProtocol, ControllerHandle,
- &PROTO_NAME(DiskIoProtocol),
+ &gEfiDiskIoProtocolGuid,
(VOID **) &DiskIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER);
if (EFI_ERROR(Status)) {
+ Print(L"Fsw ERROR: OpenProtocol(DiskIo) returned %x\n", Status);
return Status;
}
Volume->FileSystem.Revision = EFI_FILE_IO_INTERFACE_REVISION;
Volume->FileSystem.OpenVolume = fsw_efi_FileSystem_OpenVolume;
Status = refit_call4_wrapper(BS->InstallMultipleProtocolInterfaces, &ControllerHandle,
- &PROTO_NAME(SimpleFileSystemProtocol),
+ &gEfiSimpleFileSystemProtocolGuid,
&Volume->FileSystem,
NULL);
if (EFI_ERROR(Status)) {
FreePool(Volume);
refit_call4_wrapper(BS->CloseProtocol, ControllerHandle,
- &PROTO_NAME(DiskIoProtocol),
+ &gEfiDiskIoProtocolGuid,
This->DriverBindingHandle,
ControllerHandle);
}
// get the installed SimpleFileSystem interface
Status = refit_call6_wrapper(BS->OpenProtocol, ControllerHandle,
- &PROTO_NAME(SimpleFileSystemProtocol),
+ &gEfiSimpleFileSystemProtocolGuid,
(VOID **) &FileSystem,
This->DriverBindingHandle,
ControllerHandle,
// uninstall Simple File System protocol
Status = refit_call4_wrapper(BS->UninstallMultipleProtocolInterfaces, ControllerHandle,
- &PROTO_NAME(SimpleFileSystemProtocol), &Volume->FileSystem,
+ &gEfiSimpleFileSystemProtocolGuid, &Volume->FileSystem,
NULL);
if (EFI_ERROR(Status)) {
// Print(L"Fsw ERROR: UninstallMultipleProtocolInterfaces returned %x\n", Status);
// close the consumed protocols
Status = refit_call4_wrapper(BS->CloseProtocol, ControllerHandle,
- &PROTO_NAME(DiskIoProtocol),
+ &gEfiDiskIoProtocolGuid,
This->DriverBindingHandle,
ControllerHandle);
} // if cache memory allocated
} // if (ReadCache < 0)
- if (Caches[ReadCache].Cache != NULL && Caches[ReadCache].CacheValid == TRUE) {
+ if (Caches[ReadCache].Cache != NULL && Caches[ReadCache].CacheValid == TRUE && vol->phys_blocksize > 0) {
CopyMem(buffer, &Caches[ReadCache].Cache[StartRead - Caches[ReadCache].CacheStart], vol->phys_blocksize);
} else {
ReadOneBlock = TRUE;
* appropriate member of the EFI_FILE_INFO structure that we're filling.
*/
-static void fsw_efi_store_time_posix(struct fsw_dnode_stat *sb, int which, fsw_u32 posix_time)
+void fsw_store_time_posix(struct fsw_dnode_stat *sb, int which, fsw_u32 posix_time)
{
EFI_FILE_INFO *FileInfo = (EFI_FILE_INFO *)sb->host_data;
* adjustments to the EFI_FILE_INFO structure that we're filling.
*/
-static void fsw_efi_store_attr_posix(struct fsw_dnode_stat *sb, fsw_u16 posix_mode)
+void fsw_store_attr_posix(struct fsw_dnode_stat *sb, fsw_u16 posix_mode)
{
EFI_FILE_INFO *FileInfo = (EFI_FILE_INFO *)sb->host_data;
FileInfo->Attribute |= EFI_FILE_READ_ONLY;
}
+void fsw_store_attr_efi(struct fsw_dnode_stat *sb, fsw_u16 attr)
+{
+ EFI_FILE_INFO *FileInfo = (EFI_FILE_INFO *)sb->host_data;
+
+ FileInfo->Attribute |= attr;
+}
+
/**
* Common function to fill an EFI_FILE_INFO with information about a dnode.
*/
// get the missing info from the fs driver
ZeroMem(&sb, sizeof(struct fsw_dnode_stat));
- sb.store_time_posix = fsw_efi_store_time_posix;
- sb.store_attr_posix = fsw_efi_store_attr_posix;
sb.host_data = FileInfo;
Status = fsw_efi_map_status(fsw_dnode_stat(dno, &sb), Volume);
if (EFI_ERROR(Status))