Skip to content

Commit

Permalink
build a proper driver version for the EFI Component Name
Browse files Browse the repository at this point in the history
* Also simplify setup for grub_<fs>_init/grub_<fs>_fini calls
  • Loading branch information
pbatard committed Jun 29, 2014
1 parent ac0490d commit caeb77f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
For detailed information about the changes below, please see the git log or
visit: https://github.com/pbatard/efifs

2014-06-29: v0.4
* Initial ALPHA release (NTFS only)
4 changes: 2 additions & 2 deletions Make.common
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GNUEFILIB = /usr/lib
EFILIB = /usr/lib
EFICRT0 = /usr/lib
# Directory where you want the driver files to be copied into with 'make install'
INSTALL_DIR = /boot/efi
INSTALL_DIR = /boot/efi/EFI/refind/drivers_x64/

# You shouldn't have to edit anything below this
HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
Expand All @@ -19,7 +19,7 @@ CPPFLAGS = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol -I$(SRCDI
-DGNU_EFI_USE_MS_ABI -DGRUB_MACHINE_EFI -DGRUB_KERNEL -DGRUB_FILE=\"$(subst $(srcdir)/,,$<)\"

OPTIMFLAGS = -O2 -fno-strict-aliasing
DEBUGFLAGS = -Wall -Wunused -Wno-pointer-sign -Werror-implicit-function-declaration -Wshadow
DEBUGFLAGS = -Wall -Wunused -Wno-pointer-sign -Wshadow
CFLAGS = $(ARCH3264) $(OPTIMFLAGS) -fno-stack-protector -fpic -fshort-wchar -mno-red-zone $(DEBUGFLAGS)
ASFLAGS = $(ARCH3264)
LDFLAGS = -nostdlib -znocombreloc -zdefs
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ drivers, based on the GRUB 2.0 read-only drivers.
Boot into the EFI shell and run the following:
* `load fs0:\ntfs_x64.efi` or wherever your driver was copied
* `map -r` this should make a new `fs#` available, eg `fs2:`
* `dir fs2:` this should list the NTFS content
* You should now be able to navigate and access NTFS content (in read-only mode)
* For logging output, set the `FS_LOGGING` shell variable to 1 or more
* To unload use the `drivers` command, then `unload` with the driver ID

Expand Down
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ifeq ($(ARCH),x86_64)
LD_CODE = elf_x86_64
endif

LOCAL_CPPFLAGS = -DGRUB_FS_INIT=grub_$(DRIVERNAME)_init -DGRUB_FS_FINI=grub_$(DRIVERNAME)_fini $(ARCH_C_FLAGS) -I$(SRCDIR)/../include -I$(SRCDIR)/../grub -I$(SRCDIR)/../grub/include
LOCAL_CPPFLAGS = -DDRIVERNAME=$(DRIVERNAME) $(ARCH_C_FLAGS) -I$(SRCDIR)/../include -I$(SRCDIR)/../grub -I$(SRCDIR)/../grub/include
LOCAL_LIBS = -lgrub
LOCAL_LDFLAGS = -L.
OBJS = fs_driver.o grubberize.o ../grub/grub-core/fs/$(DRIVERNAME).o
Expand Down
7 changes: 4 additions & 3 deletions src/fs_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,8 @@ static EFI_STATUS EFIAPI
FSGetDriverName(EFI_COMPONENT_NAME_PROTOCOL *This,
CHAR8 *Language, CHAR16 **DriverName)
{
*DriverName = L"FS driver";
*DriverName = WIDEN(STRINGIFY(DRIVERNAME)) L" driver v" WIDEN(STRINGIFY(FS_DRIVER_VERSION_MAJOR)) \
L"." WIDEN(STRINGIFY(FS_DRIVER_VERSION_MINOR)) L" (" WIDEN(PACKAGE_STRING) L")";
return EFI_SUCCESS;
}

Expand Down Expand Up @@ -1021,7 +1022,7 @@ FSDriverUninstall(EFI_HANDLE ImageHandle)
NULL);

/* Unregister the relevant grub module */
GRUB_FS_FINI();
GRUB_FS_CALL(DRIVERNAME, fini)();

/* Uninstall our mutex (we're the only instance that can run this code) */
LibUninstallProtocolInterfaces(MutexHandle,
Expand Down Expand Up @@ -1120,7 +1121,7 @@ FSDriverInstall(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable)
LoadedImage->Unload = FSDriverUninstall;

/* Register the relevant grub module */
GRUB_FS_INIT();
GRUB_FS_CALL(DRIVERNAME, init)();

PrintDebug(L"FS driver installed.\n");
return EFI_SUCCESS;
Expand Down
15 changes: 12 additions & 3 deletions src/fs_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

/* Driver version */
#define FS_DRIVER_VERSION_MAJOR 0
#define FS_DRIVER_VERSION_MINOR 3
#define FS_DRIVER_VERSION_MINOR 4

#undef offsetof
#if defined(__GNUC__) && (__GNUC__ > 3)
Expand Down Expand Up @@ -81,6 +81,12 @@ extern void PrintStatusError(EFI_STATUS Status, const CHAR16 *Format, ...);
#define MIN(x,y) ((x)<(y)?(x):(y))
#endif

#define _STRINGIFY(s) #s
#define STRINGIFY(s) _STRINGIFY(s)

#define _WIDEN(s) L ## s
#define WIDEN(s) _WIDEN(s)

/* Forward declaration */
struct _EFI_FS;

Expand All @@ -105,8 +111,11 @@ typedef struct _EFI_FS {
EFI_GRUB_FILE RootFile;
} EFI_FS;

extern void GRUB_FS_INIT(void);
extern void GRUB_FS_FINI(void);
/* Setup generic function calls for grub_<fs>_init and grub_<fs>_exit */
#define MAKE_FN_NAME(drivername, suffix) grub_ ## drivername ## _ ## suffix
#define GRUB_FS_CALL(drivername, suffix) MAKE_FN_NAME(drivername, suffix)
extern void GRUB_FS_CALL(DRIVERNAME, init)(void);
extern void GRUB_FS_CALL(DRIVERNAME, fini)(void);

extern EFI_HANDLE EfiImageHandle;
extern EFI_GUID ShellVariable;
Expand Down

0 comments on commit caeb77f

Please sign in to comment.