blob: bc9fc602b309d9516d49da845593a96a913793e6 [file] [log] [blame]
Stefan Reinauer597ff872013-01-07 13:21:22 -08001/*
2 * This file is part of the coreboot project.
3 *
Stefan Reinauer597ff872013-01-07 13:21:22 -08004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Stefan Reinauer597ff872013-01-07 13:21:22 -080013 */
14
15#include <cbmem.h>
Patrick Rudolph69d5ef92018-11-11 12:43:48 +010016#include <arch/io.h>
Kyösti Mälkkif0a3d442019-08-18 08:02:23 +030017#include <arch/romstage.h>
Patrick Rudolph69d5ef92018-11-11 12:43:48 +010018#include "memory.h"
Thomas Heijligen8d010db2019-01-10 19:45:47 +010019#include "fw_cfg.h"
Stefan Reinauer597ff872013-01-07 13:21:22 -080020
21#define CMOS_ADDR_PORT 0x70
22#define CMOS_DATA_PORT 0x71
Gerd Hoffmann9839a382013-06-17 12:26:17 +020023
Stefan Reinauer597ff872013-01-07 13:21:22 -080024#define HIGH_RAM_ADDR 0x35
25#define LOW_RAM_ADDR 0x34
26
Gerd Hoffmann9839a382013-06-17 12:26:17 +020027#define HIGH_HIGHRAM_ADDR 0x5d
28#define MID_HIGHRAM_ADDR 0x5c
29#define LOW_HIGHRAM_ADDR 0x5b
30
Patrick Rudolph69d5ef92018-11-11 12:43:48 +010031unsigned long qemu_get_high_memory_size(void)
32{
33 unsigned long high;
34 outb(HIGH_HIGHRAM_ADDR, CMOS_ADDR_PORT);
35 high = ((unsigned long) inb(CMOS_DATA_PORT)) << 22;
36 outb(MID_HIGHRAM_ADDR, CMOS_ADDR_PORT);
37 high |= ((unsigned long) inb(CMOS_DATA_PORT)) << 14;
38 outb(LOW_HIGHRAM_ADDR, CMOS_ADDR_PORT);
39 high |= ((unsigned long) inb(CMOS_DATA_PORT)) << 6;
40 return high;
41}
42
43unsigned long qemu_get_memory_size(void)
Stefan Reinauer597ff872013-01-07 13:21:22 -080044{
45 unsigned long tomk;
Patrick Rudolph69d5ef92018-11-11 12:43:48 +010046 outb(HIGH_RAM_ADDR, CMOS_ADDR_PORT);
Stefan Reinauer597ff872013-01-07 13:21:22 -080047 tomk = ((unsigned long) inb(CMOS_DATA_PORT)) << 14;
Patrick Rudolph69d5ef92018-11-11 12:43:48 +010048 outb(LOW_RAM_ADDR, CMOS_ADDR_PORT);
Stefan Reinauer597ff872013-01-07 13:21:22 -080049 tomk |= ((unsigned long) inb(CMOS_DATA_PORT)) << 6;
50 tomk += 16 * 1024;
51 return tomk;
52}
53
Arthur Heymans340e4b82019-10-23 17:25:58 +020054void *cbmem_top_chipset(void)
Stefan Reinauer597ff872013-01-07 13:21:22 -080055{
Thomas Heijligen8d010db2019-01-10 19:45:47 +010056 uintptr_t top = 0;
57
58 top = fw_cfg_tolud();
59 if (!top)
60 top = (uintptr_t)qemu_get_memory_size() * 1024;
61
62 return (void *)top;
Stefan Reinauer597ff872013-01-07 13:21:22 -080063}
Kyösti Mälkkif0a3d442019-08-18 08:02:23 +030064
65/* Nothing to do, MTRRs are no-op on QEMU. */
66void fill_postcar_frame(struct postcar_frame *pcf)
67{
68}