diff --git a/Makefile.hw b/Makefile.hw
index f4b4469..b9e6646 100644
--- a/Makefile.hw
+++ b/Makefile.hw
@@ -36,6 +36,7 @@ obj-$(CONFIG_ESP) += esp.o

 obj-y += dma-helpers.o sysbus.o isa-bus.o
 obj-$(CONFIG_QDEV_ADDR) += qdev-addr.o
+obj-$(CONFIG_LOADER_I386) += loader-i386.o

 all: $(HWLIB)
 # Dummy command so that make thinks it has done something
diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 15586a0..887dab8 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -1 +1,3 @@
 # Default configuration for i386-softmmu
+
+CONFIG_LOADER_I386=y
diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
index ec98af2..d287861 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -1 +1,3 @@
 # Default configuration for x86_64-softmmu
+
+CONFIG_LOADER_I386=y
diff --git a/hw/loader-i386.c b/hw/loader-i386.c
new file mode 100644
index 0000000..320d79d
--- /dev/null
+++ b/hw/loader-i386.c
@@ -0,0 +1,17 @@
+/*
+ * target specific rom code -- i386
+ */
+
+#include "hw.h"
+#include "config-all-devices.h"
+#include "loader.h"
+
+int rom_add_vga(const char *file)
+{
+    return rom_add_file(file, PC_ROM_MIN_VGA, PC_ROM_MAX, PC_ROM_ALIGN);
+}
+
+int rom_add_option(const char *file)
+{
+    return rom_add_file(file, PC_ROM_MIN_OPTION, PC_ROM_MAX, PC_ROM_ALIGN);
+}
diff --git a/hw/loader.h b/hw/loader.h
index 945c662..62a6ac7 100644
--- a/hw/loader.h
+++ b/hw/loader.h
@@ -38,9 +38,12 @@ void do_info_roms(Monitor *mon);
 #define PC_ROM_ALIGN       0x800
 #define PC_ROM_SIZE        (PC_ROM_MAX - PC_ROM_MIN_VGA)

-#define rom_add_vga(_f)                                                 \
-    rom_add_file(_f, PC_ROM_MIN_VGA,    PC_ROM_MAX, PC_ROM_ALIGN)
-#define rom_add_option(_f)                                              \
-    rom_add_file(_f, PC_ROM_MIN_OPTION, PC_ROM_MAX, PC_ROM_ALIGN)
+#ifdef CONFIG_LOADER_I386
+int rom_add_vga(const char *file);
+int rom_add_option(const char *file);
+#else
+#define rom_add_vga(_file) 0
+#define rom_add_option(_file) 0
+#endif

 #endif
