Andrey Petrov | 491c016 | 2016-03-02 15:09:27 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2015 Intel Corp. |
| 5 | * (Written by Andrey Petrov <andrey.petrov@intel.com> for Intel Corp.) |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
Martin Roth | ebabfad | 2016-04-10 11:09:16 -0600 | [diff] [blame] | 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
Andrey Petrov | 491c016 | 2016-03-02 15:09:27 -0800 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <arch/io.h> |
| 19 | #include <cbmem.h> |
| 20 | #include <device/pci.h> |
| 21 | #include <soc/northbridge.h> |
| 22 | #include <soc/pci_devs.h> |
Hannah Williams | d9c84ca | 2016-05-13 00:47:14 -0700 | [diff] [blame^] | 23 | #include <soc/smm.h> |
Andrey Petrov | 491c016 | 2016-03-02 15:09:27 -0800 | [diff] [blame] | 24 | |
| 25 | static uintptr_t smm_region_start(void) |
| 26 | { |
| 27 | return ALIGN_DOWN(pci_read_config32(NB_DEV_ROOT, TSEG), 1*MiB); |
| 28 | } |
| 29 | |
Hannah Williams | d9c84ca | 2016-05-13 00:47:14 -0700 | [diff] [blame^] | 30 | static size_t smm_region_size(void) |
| 31 | { |
| 32 | uintptr_t smm_end = |
| 33 | ALIGN_DOWN(pci_read_config32(NB_DEV_ROOT, BGSM), 1*MiB); |
| 34 | return smm_end - smm_region_start(); |
| 35 | } |
| 36 | |
Andrey Petrov | 491c016 | 2016-03-02 15:09:27 -0800 | [diff] [blame] | 37 | void *cbmem_top(void) |
| 38 | { |
| 39 | return (void *)smm_region_start(); |
| 40 | } |
Hannah Williams | d9c84ca | 2016-05-13 00:47:14 -0700 | [diff] [blame^] | 41 | |
| 42 | void smm_region(void **start, size_t *size) |
| 43 | { |
| 44 | *start = (void *)smm_region_start(); |
| 45 | *size = smm_region_size(); |
| 46 | } |