From 69d5ef9d143afbd9904507dd02d32148c40c6474 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Sun, 11 Nov 2018 12:43:48 +0100 Subject: mb/emulation/qemu-i440fx|q35: Link memory.c Link memory.c instead of including it. Change-Id: I2bc461b13332ec5885c33c87828a5fd023f8e730 Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/29574 Tested-by: build bot (Jenkins) Reviewed-by: Felix Held Reviewed-by: Arthur Heymans --- src/mainboard/emulation/qemu-i440fx/Makefile.inc | 2 ++ src/mainboard/emulation/qemu-i440fx/memory.c | 20 ++++++++++++++++--- src/mainboard/emulation/qemu-i440fx/memory.h | 24 +++++++++++++++++++++++ src/mainboard/emulation/qemu-i440fx/northbridge.c | 15 +------------- src/mainboard/emulation/qemu-i440fx/romstage.c | 2 +- src/mainboard/emulation/qemu-q35/Makefile.inc | 2 ++ src/mainboard/emulation/qemu-q35/romstage.c | 2 +- 7 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 src/mainboard/emulation/qemu-i440fx/memory.h (limited to 'src') diff --git a/src/mainboard/emulation/qemu-i440fx/Makefile.inc b/src/mainboard/emulation/qemu-i440fx/Makefile.inc index f9cf252b8a..c986667f17 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 b8109e53fb..dea96f275d 100644 --- a/src/mainboard/emulation/qemu-i440fx/memory.c +++ b/src/mainboard/emulation/qemu-i440fx/memory.c @@ -14,6 +14,8 @@ */ #include +#include +#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 0000000000..d3b21a6673 --- /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 + * Copyright (C) 2018 Patrick Rudolph + * + * 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 aa309de907..0795012bc5 100644 --- a/src/mainboard/emulation/qemu-i440fx/northbridge.c +++ b/src/mainboard/emulation/qemu-i440fx/northbridge.c @@ -23,26 +23,13 @@ #include #include #include -#include +#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 ce12a8bc6a..d41213a81c 100644 --- a/src/mainboard/emulation/qemu-i440fx/romstage.c +++ b/src/mainboard/emulation/qemu-i440fx/romstage.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -25,7 +26,6 @@ #include #include -#include "memory.c" void *asmlinkage romstage_main(unsigned long bist) { diff --git a/src/mainboard/emulation/qemu-q35/Makefile.inc b/src/mainboard/emulation/qemu-q35/Makefile.inc index fc4374ca83..923a28ed34 100644 --- a/src/mainboard/emulation/qemu-q35/Makefile.inc +++ b/src/mainboard/emulation/qemu-q35/Makefile.inc @@ -1,3 +1,5 @@ cpu_incs-y += $(src)/mainboard/emulation/qemu-i440fx/cache_as_ram.inc ramstage-y += ../qemu-i440fx/northbridge.c +ramstage-y += ../qemu-i440fx/memory.c ramstage-y += ../qemu-i440fx/fw_cfg.c +romstage-y += ../qemu-i440fx/memory.c diff --git a/src/mainboard/emulation/qemu-q35/romstage.c b/src/mainboard/emulation/qemu-q35/romstage.c index 870dd07762..846fcf312a 100644 --- a/src/mainboard/emulation/qemu-q35/romstage.c +++ b/src/mainboard/emulation/qemu-q35/romstage.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -27,7 +28,6 @@ #include #include -#include "../qemu-i440fx/memory.c" void * asmlinkage romstage_main(unsigned long bist) { -- cgit v1.2.3