mb/emulation/qemu-i440fx|q35: Link memory.c

Link memory.c instead of including it.

Change-Id: I2bc461b13332ec5885c33c87828a5fd023f8e730
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-on: https://review.coreboot.org/29574
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/src/mainboard/emulation/qemu-i440fx/Makefile.inc b/src/mainboard/emulation/qemu-i440fx/Makefile.inc
index f9cf252..c986667 100644
--- a/src/mainboard/emulation/qemu-i440fx/Makefile.inc
+++ b/src/mainboard/emulation/qemu-i440fx/Makefile.inc
@@ -1,3 +1,5 @@
 cpu_incs-y += $(src)/mainboard/emulation/qemu-i440fx/cache_as_ram.inc
 ramstage-y += northbridge.c
 ramstage-y += fw_cfg.c
+romstage-y += memory.c
+ramstage-y += memory.c
\ No newline at end of file
diff --git a/src/mainboard/emulation/qemu-i440fx/memory.c b/src/mainboard/emulation/qemu-i440fx/memory.c
index b8109e5..dea96f2 100644
--- a/src/mainboard/emulation/qemu-i440fx/memory.c
+++ b/src/mainboard/emulation/qemu-i440fx/memory.c
@@ -14,6 +14,8 @@
  */
 
 #include <cbmem.h>
+#include <arch/io.h>
+#include "memory.h"
 
 #define CMOS_ADDR_PORT 0x70
 #define CMOS_DATA_PORT 0x71
@@ -25,12 +27,24 @@
 #define MID_HIGHRAM_ADDR 0x5c
 #define LOW_HIGHRAM_ADDR 0x5b
 
-static unsigned long qemu_get_memory_size(void)
+unsigned long qemu_get_high_memory_size(void)
+{
+	unsigned long high;
+	outb(HIGH_HIGHRAM_ADDR, CMOS_ADDR_PORT);
+	high = ((unsigned long) inb(CMOS_DATA_PORT)) << 22;
+	outb(MID_HIGHRAM_ADDR, CMOS_ADDR_PORT);
+	high |= ((unsigned long) inb(CMOS_DATA_PORT)) << 14;
+	outb(LOW_HIGHRAM_ADDR, CMOS_ADDR_PORT);
+	high |= ((unsigned long) inb(CMOS_DATA_PORT)) << 6;
+	return high;
+}
+
+unsigned long qemu_get_memory_size(void)
 {
 	unsigned long tomk;
-	outb (HIGH_RAM_ADDR, CMOS_ADDR_PORT);
+	outb(HIGH_RAM_ADDR, CMOS_ADDR_PORT);
 	tomk = ((unsigned long) inb(CMOS_DATA_PORT)) << 14;
-	outb (LOW_RAM_ADDR, CMOS_ADDR_PORT);
+	outb(LOW_RAM_ADDR, CMOS_ADDR_PORT);
 	tomk |= ((unsigned long) inb(CMOS_DATA_PORT)) << 6;
 	tomk += 16 * 1024;
 	return tomk;
diff --git a/src/mainboard/emulation/qemu-i440fx/memory.h b/src/mainboard/emulation/qemu-i440fx/memory.h
new file mode 100644
index 0000000..d3b21a6
--- /dev/null
+++ b/src/mainboard/emulation/qemu-i440fx/memory.h
@@ -0,0 +1,24 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2004 Stefan Reinauer <stefan.reinauer@coreboot.org>
+ * Copyright (C) 2018 Patrick Rudolph <siro@das-labor.org>
+ *
+ * This program 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; version 2 of the License.
+ *
+ * This program 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.
+ */
+
+
+#ifndef __QEMU_MEMORY_H_
+#define __QEMU_MEMORY_H_
+
+unsigned long qemu_get_high_memory_size(void);
+unsigned long qemu_get_memory_size(void);
+
+#endif
diff --git a/src/mainboard/emulation/qemu-i440fx/northbridge.c b/src/mainboard/emulation/qemu-i440fx/northbridge.c
index aa309de..0795012 100644
--- a/src/mainboard/emulation/qemu-i440fx/northbridge.c
+++ b/src/mainboard/emulation/qemu-i440fx/northbridge.c
@@ -23,26 +23,13 @@
 #include <string.h>
 #include <delay.h>
 #include <smbios.h>
-#include <cbmem.h>
+#include "memory.h"
 
 #include "fw_cfg.h"
 #include "fw_cfg_if.h"
 
-#include "memory.c"
 #include "acpi.h"
 
-static unsigned long qemu_get_high_memory_size(void)
-{
-	unsigned long high;
-	outb (HIGH_HIGHRAM_ADDR, CMOS_ADDR_PORT);
-	high = ((unsigned long) inb(CMOS_DATA_PORT)) << 22;
-	outb (MID_HIGHRAM_ADDR, CMOS_ADDR_PORT);
-	high |= ((unsigned long) inb(CMOS_DATA_PORT)) << 14;
-	outb (LOW_HIGHRAM_ADDR, CMOS_ADDR_PORT);
-	high |= ((unsigned long) inb(CMOS_DATA_PORT)) << 6;
-	return high;
-}
-
 static void qemu_reserve_ports(struct device *dev, unsigned int idx,
 			       unsigned int base, unsigned int size,
 			       const char *name)
diff --git a/src/mainboard/emulation/qemu-i440fx/romstage.c b/src/mainboard/emulation/qemu-i440fx/romstage.c
index ce12a8b..d41213a 100644
--- a/src/mainboard/emulation/qemu-i440fx/romstage.c
+++ b/src/mainboard/emulation/qemu-i440fx/romstage.c
@@ -18,6 +18,7 @@
 #include <device/pci_ids.h>
 #include <arch/io.h>
 #include <device/pnp_def.h>
+#include <cbmem.h>
 #include <console/console.h>
 #include <cpu/x86/bist.h>
 #include <cpu/intel/romstage.h>
@@ -25,7 +26,6 @@
 #include <delay.h>
 #include <cpu/x86/lapic.h>
 
-#include "memory.c"
 
 void *asmlinkage romstage_main(unsigned long bist)
 {