Vaibhav Shankar (vaibhav.shankar(a)intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/16233
-gerrit
commit c43a2ab91b52f7fa03fc33538a41cfd468308775
Author: Vaibhav Shankar <vaibhav.shankar(a)intel.com>
Date: Mon Aug 15 11:32:26 2016 -0700
soc/intel/apollolake: Add ASL methods for eMMC
Implement PS0 and PS3 methods to support eMMC power gate
in S0ix suspend and resume.
BUG=chrome-os-partner:53876
TEST=Suspend and Resume using 'echo freeze > /sys/power/state'.
System should resume from S0ix.
Change-Id: Ia974e9ed67ee520d16f6d6a60294bc62a120fd76
Signed-off-by: Vaibhav Shankar <vaibhav.shankar(a)intel.com>
---
src/soc/intel/apollolake/acpi/scs.asl | 69 +++++++++++++++++++++++++++
src/soc/intel/apollolake/acpi/southbridge.asl | 3 ++
2 files changed, 72 insertions(+)
diff --git a/src/soc/intel/apollolake/acpi/scs.asl b/src/soc/intel/apollolake/acpi/scs.asl
new file mode 100644
index 0000000..52779f1
--- /dev/null
+++ b/src/soc/intel/apollolake/acpi/scs.asl
@@ -0,0 +1,69 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 Intel Corporation.
+ *
+ * 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.
+ */
+
+Scope (\_SB.PCI0) {
+ /* 0xD6- is the port address */
+ /* 0x600- is the dynamic clock gating control register offset (GENR) */
+ OperationRegion (SBMM, SystemMemory,
+ OR( OR (CONFIG_IOSF_BASE_ADDRESS,
+ ShiftLeft(0xD6, 16)), 0x0600), 0x18)
+ Field (SBMM, DWordAcc, NoLock, Preserve)
+ {
+ GENR, 32,
+ }
+
+ /* SCC power gate control method, this method must be serialized as
+ * multiple device will control the GENR register
+ *
+ * Arguments: (2)
+ * Arg0: 0-AND 1-OR
+ * Arg1: Value
+ */
+ Method (SCPG, 2, Serialized)
+ {
+ if (LEqual(Arg0, 0x1)) {
+ Or (^GENR, Arg1, ^GENR)
+ } ElseIf (LEqual(Arg0, 0x0)){
+ And (^GENR, Arg1, ^GENR)
+ }
+ }
+
+ /* eMMC */
+ Device (SDHA) {
+ Name (_ADR, 0x001C0000)
+ Name (_DDN, "Intel(R) eMMC Controller - 80865ACC")
+ Name (_UID, 1)
+
+ Method (_PS0, 0, NotSerialized)
+ {
+ /* Clear clock gate
+ * Clear bit 6 and 0
+ */
+ ^^SCPG(0,0xFFFFFFBE)
+ /* Sleep 2 ms */
+ Sleep (2)
+ }
+
+ Method (_PS3, 0, NotSerialized)
+ {
+ /* Enable power gate
+ * Restore clock gate
+ * Restore bit 6 and 0
+ */
+ ^^SCPG(1,0x00000041)
+ }
+ } /* Device (SDHA) */
+
+}
diff --git a/src/soc/intel/apollolake/acpi/southbridge.asl b/src/soc/intel/apollolake/acpi/southbridge.asl
index 5b29abb..391a531 100644
--- a/src/soc/intel/apollolake/acpi/southbridge.asl
+++ b/src/soc/intel/apollolake/acpi/southbridge.asl
@@ -31,5 +31,8 @@
/* LPC */
#include "lpc.asl"
+/* eMMC */
+#include "scs.asl"
+
/* PCI _OSC */
#include <soc/intel/common/acpi/pci_osc.asl>
Vaibhav Shankar (vaibhav.shankar(a)intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/16233
-gerrit
commit 132ed1e755ee42d944b4eb9d9eff49df6cf74fc5
Author: Vaibhav Shankar <vaibhav.shankar(a)intel.com>
Date: Mon Aug 15 11:32:26 2016 -0700
soc/intel/apollolake: Add ASL methods for eMMC
Implement PS0 and PS3 methods to support eMMC power gate
in S0ix suspend and resume.
BUG=chrome-os-partner:53876
TEST=Suspend and Resume using 'echo freeze > /sys/power/state'.
System should resume from S0ix.
Change-Id: Ia974e9ed67ee520d16f6d6a60294bc62a120fd76
Signed-off-by: Vaibhav Shankar <vaibhav.shankar(a)intel.com>
---
src/soc/intel/apollolake/acpi/scs.asl | 70 +++++++++++++++++++++++++++
src/soc/intel/apollolake/acpi/southbridge.asl | 3 ++
2 files changed, 73 insertions(+)
diff --git a/src/soc/intel/apollolake/acpi/scs.asl b/src/soc/intel/apollolake/acpi/scs.asl
new file mode 100644
index 0000000..6fc1f4f
--- /dev/null
+++ b/src/soc/intel/apollolake/acpi/scs.asl
@@ -0,0 +1,70 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 Intel Corporation.
+ *
+ * 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.
+ */
+Scope (\_SB.PCI0) {
+ /* 0xD6- is the port address */
+ /* 0x600- is the dynamic clock gating control register offset (GENR) */
+ OperationRegion (SBMM, SystemMemory,
+ OR( OR (CONFIG_IOSF_BASE_ADDRESS,
+ ShiftLeft(0xD6, 16)), 0x0600), 0x18)
+ Field (SBMM, DWordAcc, NoLock, Preserve)
+ {
+ GENR, 32,
+ }
+
+ /* SCC power gate control method, this method must be serialized as multiple
+ * device will control the GENR register
+ */
+
+ /*
+ * Arguments: (2)
+ * Arg0: 0-AND 1-OR
+ * Arg1: Value
+ */
+ Method (SCPG, 2, Serialized)
+ {
+ if (LEqual(Arg0, 0x1)) {
+ Or (^GENR, Arg1, ^GENR)
+ } ElseIf (LEqual(Arg0, 0x0)){
+ And (^GENR, Arg1, ^GENR)
+ }
+ }
+
+ /* eMMC */
+ Device (SDHA) {
+ Name (_ADR, 0x001C0000)
+ Name (_DDN, "Intel(R) eMMC Controller - 80865ACC")
+ Name (_UID, 1)
+
+ Method (_PS0, 0, NotSerialized)
+ {
+ /* Clear clock gate
+ * Clear bit 6 and 0
+ */
+ ^^SCPG(0,0xFFFFFFBE)
+ /* Sleep 2 ms */
+ Sleep (2)
+ }
+
+ Method (_PS3, 0, NotSerialized)
+ {
+ /* Enable power gate
+ * Restore clock gate
+ * Restore bit 6 and 0
+ */
+ ^^SCPG(1,0x00000041)
+ }
+ } /* Device (SDHA) */
+
+}
diff --git a/src/soc/intel/apollolake/acpi/southbridge.asl b/src/soc/intel/apollolake/acpi/southbridge.asl
index 5b29abb..391a531 100644
--- a/src/soc/intel/apollolake/acpi/southbridge.asl
+++ b/src/soc/intel/apollolake/acpi/southbridge.asl
@@ -31,5 +31,8 @@
/* LPC */
#include "lpc.asl"
+/* eMMC */
+#include "scs.asl"
+
/* PCI _OSC */
#include <soc/intel/common/acpi/pci_osc.asl>
Vaibhav Shankar (vaibhav.shankar(a)intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/16233
-gerrit
commit fbe6d1a66660df933fc3bef49dd291d6aeb6a0d7
Author: Vaibhav Shankar <vaibhav.shankar(a)intel.com>
Date: Mon Aug 15 11:32:26 2016 -0700
soc/intel/apollolake: Add ASL methods for eMMC
Implement PS0 and PS3 methods to support eMMC power gate
in S0ix suspend and resume.
BUG=chrome-os-partner:53876
TEST=Suspend and Resume using 'echo freeze > /sys/power/state'.
System should resume from S0ix.
Change-Id: Ia974e9ed67ee520d16f6d6a60294bc62a120fd76
Signed-off-by: Vaibhav Shankar <vaibhav.shankar(a)intel.com>
---
src/soc/intel/apollolake/acpi/scs.asl | 83 +++++++++++++++++++++++++++
src/soc/intel/apollolake/acpi/southbridge.asl | 3 +
2 files changed, 86 insertions(+)
diff --git a/src/soc/intel/apollolake/acpi/scs.asl b/src/soc/intel/apollolake/acpi/scs.asl
new file mode 100644
index 0000000..764917a
--- /dev/null
+++ b/src/soc/intel/apollolake/acpi/scs.asl
@@ -0,0 +1,83 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 Intel Corporation.
+ *
+ * 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.
+ */
+Scope (\_SB.PCI0) {
+ /* 0xD6- is the port address */
+ /* 0x600- is the dynamic clock gating control register offset (GENR) */
+ OperationRegion (SBMM, SystemMemory,
+ OR( OR (CONFIG_IOSF_BASE_ADDRESS,
+ ShiftLeft(0xD6, 16)), 0x0600), 0x18)
+ Field (SBMM, DWordAcc, NoLock, Preserve)
+ {
+ GENR, 32,
+ Offset (0x08),
+ , 5,
+ GRR3, 1,
+ }
+
+ /* SCC power gate control method, this method must be serialized as multiple
+ * device will control the GENR register
+ */
+
+ /*
+ * Arguments: (2)
+ * Arg0: 0-AND 1-OR
+ * Arg1: Value
+ */
+ Method (SCPG, 2, Serialized)
+ {
+ Name (TMP, 0x0)
+ if (LEqual(Arg0, 0x1)) {
+ Store (^GENR, TMP)
+ Or (TMP, Arg1, ^GENR)
+
+ } ElseIf (LEqual(Arg0, 0x0)){
+ Store (^GENR, TMP)
+ And (TMP, Arg1, ^GENR)
+ }
+ }
+
+ /* eMMC */
+ Device (SDHA) {
+ Name (_ADR, 0x001C0000)
+ Name (_DDN, "Intel(R) eMMC Controller - 80865ACC")
+ Name (_UID, 1)
+ /* Method for port80 debug */
+ OperationRegion (POST, SystemIO, 0x80, 1)
+ Field (POST, ByteAcc, Lock, Preserve)
+ {
+ DBG0, 8
+ }
+
+ Method (_PS0, 0, NotSerialized)
+ {
+ /* Clear clock gate
+ * Clear bit 6 and 0
+ */
+ ^^SCPG(0,0xFFFFFFBE)
+ /* Sleep 2 ms */
+ Sleep (2)
+ }
+
+ Method (_PS3, 0, NotSerialized)
+ {
+ /* Enable power gate
+ * Restore clock gate
+ * Restore bit 6 and 0
+ */
+ ^^SCPG(1,0x00000041)
+ }
+ } /* Device (SDHA) */
+
+}
diff --git a/src/soc/intel/apollolake/acpi/southbridge.asl b/src/soc/intel/apollolake/acpi/southbridge.asl
index 5b29abb..391a531 100644
--- a/src/soc/intel/apollolake/acpi/southbridge.asl
+++ b/src/soc/intel/apollolake/acpi/southbridge.asl
@@ -31,5 +31,8 @@
/* LPC */
#include "lpc.asl"
+/* eMMC */
+#include "scs.asl"
+
/* PCI _OSC */
#include <soc/intel/common/acpi/pci_osc.asl>
Jonathan Neuschäfer (j.neuschaefer(a)gmx.net) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/16015
-gerrit
commit 877ded79fe0e3cc1e76d0396f77ae2c67af66bd3
Author: Jonathan Neuschäfer <j.neuschaefer(a)gmx.net>
Date: Mon Aug 22 19:37:15 2016 +0200
arch/riscv: Print the page table structure after construction
A new Kconfig option, DEBUG_PRINT_PAGE_TABLES, is added to control this
behaviour. It is currently only available on RISC-V, but other
architectures can use it, too, should the need arise.
Change-Id: I52a863d8bc814ab3ed3a1f141d0a77edc6e4044d
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer(a)gmx.net>
---
src/Kconfig | 8 ++++
src/arch/riscv/include/vm.h | 2 +-
src/arch/riscv/virtual_memory.c | 85 +++++++++++++++++++++++++++++++++++++----
3 files changed, 86 insertions(+), 9 deletions(-)
diff --git a/src/Kconfig b/src/Kconfig
index 7db491f..64da061 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -1127,6 +1127,14 @@ config DEBUG_BOOT_STATE
Control debugging of the boot state machine. When selected displays
the state boundaries in ramstage.
+config DEBUG_PRINT_PAGE_TABLES
+ bool "Print the page tables after construction"
+ default n
+ depends on ARCH_RISCV
+ help
+ After the page tables have been built, print them on the debug
+ console.
+
endmenu
# These probably belong somewhere else, but they are needed somewhere.
diff --git a/src/arch/riscv/include/vm.h b/src/arch/riscv/include/vm.h
index 5bf03c7..cc26b13 100644
--- a/src/arch/riscv/include/vm.h
+++ b/src/arch/riscv/include/vm.h
@@ -63,7 +63,7 @@ size_t pte_ppn(pte_t pte);
pte_t ptd_create(uintptr_t ppn);
pte_t pte_create(uintptr_t ppn, int prot, int user);
-void walk_page_table(void);
+void print_page_table(void);
void init_vm(uintptr_t virtMemStart, uintptr_t physMemStart, uintptr_t pageTableStart);
void mstatus_init(void); // need to setup mstatus so we know we have virtual memory
diff --git a/src/arch/riscv/virtual_memory.c b/src/arch/riscv/virtual_memory.c
index bbbba7a..bea552d 100644
--- a/src/arch/riscv/virtual_memory.c
+++ b/src/arch/riscv/virtual_memory.c
@@ -23,11 +23,77 @@
pte_t* root_page_table;
-void walk_page_table(void) {
- // TODO: implement a full walk to make sure memory was set up
- //const size_t pte_per_page = RISCV_PGSIZE/sizeof(void*);
- pte_t* t = root_page_table;
- printk(BIOS_DEBUG, "root_page_table: %p\n", t);
+/* Indent the following text by 2*level spaces */
+static void indent(int level)
+{
+ int i;
+ for (i = 0; i < level; i++)
+ printk(BIOS_DEBUG, " ");
+}
+
+/*
+ * Convert a page table index at a given page table level to a virtual address
+ * offset
+ */
+static uintptr_t index_to_virt_addr(int index, int level)
+{
+ /*
+ * Index is at most RISCV_PGLEVEL_BITS bits wide (not considering the
+ * leading zeroes. If level==0, the below expression thus shifts index
+ * into the highest bits of a 64-bit number, and then shifts it down
+ * with sign extension.
+ *
+ * If level>0, then the expression should work as expected, without any
+ * magic.
+ */
+ return ((intptr_t)index)
+ << (64 - RISCV_PGLEVEL_BITS - level * RISCV_PGLEVEL_BITS)
+ >> (64 - VA_BITS);
+}
+
+/* Dump the page table structures to the console -- helper function */
+static void print_page_table_at(pte_t *pt, intptr_t virt_addr, int level)
+{
+ int i;
+
+ indent(level);
+ printk(BIOS_DEBUG, "Level %d page table at 0x%p\n", level, pt);
+
+ for (i = 0; i < RISCV_PGSIZE / sizeof(pte_t); i++) {
+ char urwx[8];
+ uintptr_t pointer;
+ intptr_t next_virt_addr;
+
+ if (!(pt[i] & PTE_V))
+ continue;
+
+ urwx[0] = (pt[i] & PTE_U)? 'u' : '-';
+ urwx[1] = (pt[i] & PTE_R)? 'r' : '-';
+ urwx[2] = (pt[i] & PTE_W)? 'w' : '-';
+ urwx[3] = (pt[i] & PTE_X)? 'x' : '-';
+ urwx[4] = '\0';
+
+ next_virt_addr = virt_addr + index_to_virt_addr(i, level);
+
+ pointer = ((uintptr_t)pt[i] >> 10) << RISCV_PGSHIFT;
+
+ indent(level + 1);
+ printk(BIOS_DEBUG, "Valid PTE at index %d (0x%016zx -> 0x%zx), ",
+ i, (size_t) next_virt_addr, (size_t) pointer);
+ if (PTE_TABLE(pt[i]))
+ printk(BIOS_DEBUG, "page table\n");
+ else
+ printk(BIOS_DEBUG, "protections %s\n", urwx);
+
+ if (PTE_TABLE(pt[i])) {
+ print_page_table_at((pte_t *)pointer, next_virt_addr, level + 1);
+ }
+ }
+}
+
+/* Print the page table structures to the console */
+void print_page_table(void) {
+ print_page_table_at(root_page_table, 0, 0);
}
void flush_tlb(void)
@@ -124,14 +190,17 @@ void initVirtualMemory(void) {
uintptr_t pageTableStart = 0x1400000;
init_vm(virtualStart, physicalStart, pageTableStart);
mb();
+
+#if IS_ENABLED(CONFIG_DEBUG_PRINT_PAGE_TABLES)
printk(BIOS_DEBUG, "Finished initializing virtual memory, starting walk...\n");
- walk_page_table();
+ print_page_table();
+#else
+ printk(BIOS_DEBUG, "Finished initializing virtual memory\n");
+#endif
}
void mstatus_init(void)
{
- // supervisor support is required
-
uintptr_t ms = 0;
ms = INSERT_FIELD(ms, MSTATUS_FS, 3);
ms = INSERT_FIELD(ms, MSTATUS_XS, 3);
Jonathan Neuschäfer (j.neuschaefer(a)gmx.net) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/16263
-gerrit
commit 1a8868533256efd97610bf4a6889f7febd2ab23d
Author: Jonathan Neuschäfer <j.neuschaefer(a)gmx.net>
Date: Mon Aug 22 19:37:16 2016 +0200
arch/riscv: Map the kernel space into RAM (2GiB+)
Change-Id: I273e9d20e02f0333f28e0fc2adcc7940578ea93e
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer(a)gmx.net>
---
src/arch/riscv/virtual_memory.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/arch/riscv/virtual_memory.c b/src/arch/riscv/virtual_memory.c
index 74b3825..be8b488 100644
--- a/src/arch/riscv/virtual_memory.c
+++ b/src/arch/riscv/virtual_memory.c
@@ -186,9 +186,9 @@ void initVirtualMemory(void) {
}
printk(BIOS_DEBUG, "Initializing virtual memory...\n");
- uintptr_t physicalStart = 0x1000000; // TODO: Figure out how to grab this from cbfs
- uintptr_t virtualStart = 0xffffffff81000000;
- uintptr_t pageTableStart = 0x1400000;
+ uintptr_t physicalStart = 0x90000000; // TODO: Figure out how to grab this from cbfs
+ uintptr_t virtualStart = 0xffffffff80000000;
+ uintptr_t pageTableStart = 0x91400000;
init_vm(virtualStart, physicalStart, pageTableStart);
mb();