Index: boot/arch/ia64/loader/gefi/apps/Makefile
===================================================================
--- boot/arch/ia64/loader/gefi/apps/Makefile	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
+++ boot/arch/ia64/loader/gefi/apps/Makefile	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
@@ -0,0 +1,44 @@
+#
+#  Copyright (C) 1999-2001 Hewlett-Packard Co.
+#	Contributed by David Mosberger <davidm@hpl.hp.com>
+#	Contributed by Stephane Eranian <eranian@hpl.hp.com>
+#
+# This file is part of the gnu-efi package.
+#
+#  GNU-EFI is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2, or (at your option)
+#  any later version.
+#
+#  GNU-EFI is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with GNU-EFI; see the file COPYING.  If not, write to the Free
+#  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+#  02111-1307, USA.
+#
+
+include ../Make.defaults
+CDIR=$(TOPDIR)/..
+LINUX_HEADERS	= /usr/src/sys/build
+CPPFLAGS	+= -D__KERNEL__ -I$(LINUX_HEADERS)/include
+CRTOBJS		= ../gnuefi/crt0-efi-$(ARCH).o
+LDSCRIPT	= ../gnuefi/elf_$(ARCH)_efi.lds
+LDFLAGS		+= -T $(LDSCRIPT) -shared -Bsymbolic -L../lib -L../gnuefi $(CRTOBJS)
+LOADLIBES	= -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name)
+FORMAT		= efi-app-$(ARCH)
+
+TARGETS = t.efi t2.efi t3.efi t4.efi t5.efi t6.efi printenv.efi t7.efi
+
+all:	$(TARGETS)
+
+
+clean:
+	rm -f $(TARGETS) *~ *.o *.so
+
+.PHONY: install
+
+include ../Make.rules
Index: boot/arch/ia64/loader/gefi/apps/printenv.c
===================================================================
--- boot/arch/ia64/loader/gefi/apps/printenv.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
+++ boot/arch/ia64/loader/gefi/apps/printenv.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
@@ -0,0 +1,32 @@
+#include <efi.h>
+#include <efilib.h>
+
+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 = RT->GetNextVariableName(&size, name, &vendor);
+		if (status != EFI_SUCCESS)
+			break;
+
+		val = LibGetVariable(name, &vendor);
+		Print(fmt, &vendor, name, val);
+		FreePool(val);
+	}
+	return EFI_SUCCESS;
+}
Index: boot/arch/ia64/loader/gefi/apps/t.c
===================================================================
--- boot/arch/ia64/loader/gefi/apps/t.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
+++ boot/arch/ia64/loader/gefi/apps/t.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
@@ -0,0 +1,71 @@
+#define EFI_SUCCESS		0
+
+typedef short			CHAR16;
+typedef unsigned long		UINTN;
+typedef unsigned long long	UINT64;
+typedef unsigned int		UINT32;
+typedef void *			EFI_HANDLE;
+typedef UINTN			EFI_STATUS;
+
+typedef struct _EFI_TABLE_HEARDER {
+    UINT64                      Signature;
+    UINT32                      Revision;
+    UINT32                      HeaderSize;
+    UINT32                      CRC32;
+    UINT32                      Reserved;
+} EFI_TABLE_HEADER;
+
+typedef EFI_STATUS (*EFI_TEXT_STRING) (void *This, CHAR16 *String);
+
+typedef struct _SIMPLE_TEXT_OUTPUT_INTERFACE {
+    void *                  Reset;
+
+    EFI_TEXT_STRING                 OutputString;
+} SIMPLE_TEXT_OUTPUT_INTERFACE;
+
+typedef struct _EFI_SYSTEM_TABLE {
+    EFI_TABLE_HEADER                Hdr;
+
+    CHAR16                          *FirmwareVendor;
+    UINT32                          FirmwareRevision;
+
+    EFI_HANDLE                      ConsoleInHandle;
+ /*SIMPLE_INPUT_INTERFACE*/ void    *ConIn;
+
+    EFI_HANDLE                      ConsoleOutHandle;
+    SIMPLE_TEXT_OUTPUT_INTERFACE    *ConOut;
+
+    EFI_HANDLE                      StandardErrorHandle;
+    SIMPLE_TEXT_OUTPUT_INTERFACE    *StdErr;
+
+ /*EFI_RUNTIME_SERVICES*/ void            *RuntimeServices;
+ /*EFI_BOOT_SERVICES*/ void               *BootServices;
+
+    UINTN                           NumberOfTableEntries;
+ /*EFI_CONFIGURATION_TABLE*/void         *ConfigurationTable;
+
+} EFI_SYSTEM_TABLE;
+
+static CHAR16 *
+a2u (char *str)
+{
+	static CHAR16 mem[2048];
+	int i;
+
+	for (i = 0; str[i]; ++i)
+		mem[i] = (CHAR16) str[i];
+	mem[i] = 0;
+	return mem;
+}
+
+EFI_STATUS
+efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
+{
+	SIMPLE_TEXT_OUTPUT_INTERFACE *conout;
+
+	conout = systab->ConOut;
+	conout->OutputString(conout, (CHAR16 *)L"Hello World!\n\r");
+	conout->OutputString(conout, a2u("Hello World!\n\r"));
+
+	return EFI_SUCCESS;
+}
Index: boot/arch/ia64/loader/gefi/apps/t2.c
===================================================================
--- boot/arch/ia64/loader/gefi/apps/t2.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
+++ boot/arch/ia64/loader/gefi/apps/t2.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
@@ -0,0 +1,13 @@
+#include <efi.h>
+#include <efilib.h>
+
+EFI_STATUS
+efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
+{
+	SIMPLE_TEXT_OUTPUT_INTERFACE *conout;
+
+	conout = systab->ConOut;
+	conout->OutputString(conout, L"Hello World!\n\r");
+
+	return EFI_SUCCESS;
+}
Index: boot/arch/ia64/loader/gefi/apps/t3.c
===================================================================
--- boot/arch/ia64/loader/gefi/apps/t3.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
+++ boot/arch/ia64/loader/gefi/apps/t3.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
@@ -0,0 +1,93 @@
+#include <efi.h>
+#include <efilib.h>
+
+EFI_STATUS
+efi_main(
+	EFI_HANDLE image_handle,
+	EFI_SYSTEM_TABLE *systab
+)
+{
+	EFI_GUID loaded_image_protocol = LOADED_IMAGE_PROTOCOL;
+	EFI_STATUS efi_status;
+	EFI_LOADED_IMAGE *li;
+	UINTN pat = PoolAllocationType;
+	VOID *void_li_p;
+
+	InitializeLib(image_handle, systab);
+	PoolAllocationType = 2; /* klooj */
+
+	Print(L"Hello World! (0xd=0x%x, 13=%d)\n", 13, 13);
+
+	Print(L"before InitializeLib(): PoolAllocationType=%d\n",
+		pat);
+
+	Print(L" after InitializeLib(): PoolAllocationType=%d\n",
+		PoolAllocationType);
+
+	/*
+	 * Locate loaded_image_handle instance.
+	 */
+
+	Print(L"BS->HandleProtocol()  ");
+
+	efi_status = BS->HandleProtocol(
+		image_handle,
+		&loaded_image_protocol,
+		&void_li_p);
+	li = void_li_p;
+
+	Print(L"%xh (%r)\n", efi_status, efi_status);
+
+	if (efi_status != EFI_SUCCESS) {
+		return efi_status;
+	}
+
+	Print(L"  li: %xh\n", li);
+
+	if (!li) {
+		return EFI_UNSUPPORTED;
+	}
+
+	Print(L"  li->Revision:        %xh\n", li->Revision);
+	Print(L"  li->ParentHandle:    %xh\n", li->ParentHandle);
+	Print(L"  li->SystemTable:     %xh\n", li->SystemTable);
+	Print(L"  li->DeviceHandle:    %xh\n", li->DeviceHandle);
+	Print(L"  li->FilePath:        %xh\n", li->FilePath);
+	Print(L"  li->Reserved:        %xh\n", li->Reserved);
+	Print(L"  li->LoadOptionsSize: %xh\n", li->LoadOptionsSize);
+	Print(L"  li->LoadOptions:     %xh\n", li->LoadOptions);
+	Print(L"  li->ImageBase:       %xh\n", li->ImageBase);
+	Print(L"  li->ImageSize:       %xh\n", li->ImageSize);
+	Print(L"  li->ImageCodeType:   %xh\n", li->ImageCodeType);
+	Print(L"  li->ImageDataType:   %xh\n", li->ImageDataType);
+	Print(L"  li->Unload:          %xh\n", li->Unload);
+
+#if 0
+typedef struct {
+    UINT32                          Revision;
+    EFI_HANDLE                      ParentHandle;
+    struct _EFI_SYSTEM_TABLE        *SystemTable;
+
+    // Source location of image
+    EFI_HANDLE                      DeviceHandle;
+    EFI_DEVICE_PATH                 *FilePath;
+    VOID                            *Reserved;
+
+    // Images load options
+    UINT32                          LoadOptionsSize;
+    VOID                            *LoadOptions;
+
+    // Location of where image was loaded
+    VOID                            *ImageBase;
+    UINT64                          ImageSize;
+    EFI_MEMORY_TYPE                 ImageCodeType;
+    EFI_MEMORY_TYPE                 ImageDataType;
+
+    // If the driver image supports a dynamic unload request
+    EFI_IMAGE_UNLOAD                Unload;
+
+} EFI_LOADED_IMAGE;
+#endif
+
+	return EFI_SUCCESS;
+}
Index: boot/arch/ia64/loader/gefi/apps/t4.c
===================================================================
--- boot/arch/ia64/loader/gefi/apps/t4.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
+++ boot/arch/ia64/loader/gefi/apps/t4.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
@@ -0,0 +1,13 @@
+#include <efi.h>
+#include <efilib.h>
+
+EFI_STATUS
+efi_main (EFI_HANDLE *image, EFI_SYSTEM_TABLE *systab)
+{
+	UINTN index;
+
+	systab->ConOut->OutputString(systab->ConOut, L"Hello application started\r\n");
+	systab->ConOut->OutputString(systab->ConOut, L"\r\n\r\n\r\nHit any key to exit\r\n");
+	systab->BootServices->WaitForEvent(1, &systab->ConIn->WaitForKey, &index);
+	return EFI_SUCCESS;
+}
Index: boot/arch/ia64/loader/gefi/apps/t5.c
===================================================================
--- boot/arch/ia64/loader/gefi/apps/t5.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
+++ boot/arch/ia64/loader/gefi/apps/t5.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
@@ -0,0 +1,13 @@
+#include <efi.h>
+#include <efilib.h>
+
+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);
+	ST->ConOut->OutputString(ST->ConOut, L"\n\n");
+	return EFI_SUCCESS;
+}
Index: boot/arch/ia64/loader/gefi/apps/t6.c
===================================================================
--- boot/arch/ia64/loader/gefi/apps/t6.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
+++ boot/arch/ia64/loader/gefi/apps/t6.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
@@ -0,0 +1,39 @@
+#include <efi.h>
+#include <efilib.h>
+
+typedef EFI_STATUS (*foo_t)(EFI_HANDLE, EFI_GUID *, VOID **);
+typedef struct {
+	unsigned long addr;
+	unsigned long gp;
+} fdesc_t;
+
+EFI_LOADED_IMAGE my_loaded;
+
+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 = systab->BootServices->HandleProtocol(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;
+}
Index: boot/arch/ia64/loader/gefi/apps/t7.c
===================================================================
--- boot/arch/ia64/loader/gefi/apps/t7.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
+++ boot/arch/ia64/loader/gefi/apps/t7.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
@@ -0,0 +1,25 @@
+#include <efi.h>
+#include <efilib.h>
+
+EFI_STATUS
+efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
+{
+	EFI_INPUT_KEY efi_input_key;
+	EFI_STATUS efi_status;
+
+	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);
+
+	ST->ConOut->OutputString(ST->ConOut, L"\n\n");
+
+	efi_status = ST->ConIn->ReadKeyStroke(ST->ConIn, &efi_input_key);
+
+	Print(L"ScanCode: %xh  UnicodeChar: %xh\n",
+		efi_input_key.ScanCode, efi_input_key.UnicodeChar);
+
+	return EFI_SUCCESS;
+}
Index: boot/arch/ia64/loader/gefi/apps/tpause.c
===================================================================
--- boot/arch/ia64/loader/gefi/apps/tpause.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
+++ boot/arch/ia64/loader/gefi/apps/tpause.c	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
@@ -0,0 +1,9 @@
+#include <efi.h>
+#include <efilib.h>
+
+EFI_STATUS
+efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
+{
+	Print(L"Press `q' to quit, any other key to continue:\n");
+	
+}
Index: boot/arch/ia64/loader/gefi/apps/trivial.S
===================================================================
--- boot/arch/ia64/loader/gefi/apps/trivial.S	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
+++ boot/arch/ia64/loader/gefi/apps/trivial.S	(revision 7208b6cc46de53e520a0beb3636047d8e17c072c)
@@ -0,0 +1,43 @@
+	.text
+	.align 4
+
+	.globl _start
+_start:
+#if 0
+        pushl %ebp
+        movl %esp,%ebp
+        pushl %ebx		# save ebx
+        movl 12(%ebp),%eax	# eax <- systab
+	movl 24(%eax),%ebx	# ebx <- systab->FirmwareVendor
+	pushl %ebx
+        movl 44(%eax),%ebx	# ebx <- systab->ConOut
+        pushl %ebx
+        movl 4(%ebx),%eax	# eax <- conout->OutputString
+        call *%eax
+        movl -4(%ebp),%ebx	# restore ebx
+        leave
+        ret
+
+#else
+
+        pushl %ebp
+        movl %esp,%ebp
+        pushl %ebx
+	call 0f
+0:	popl %eax
+	addl $hello-0b,%eax
+	pushl %eax
+        movl 12(%ebp),%eax	# eax <- systab
+        movl 44(%eax),%ebx	# ebx <- systab->ConOut
+        pushl %ebx
+        movl 4(%ebx),%eax	# eax <- conout->OutputString
+        call *%eax
+        movl -4(%ebp),%ebx
+        leave
+        ret
+
+	.section .rodata
+	.align 2
+hello:	.byte 'h',0,'e',0,'l',0,'l',0,'o',0,'\n',0,'\r',0,0,0
+
+#endif
