// XXX: figure out how to do this arch-independent(?) -SG, 2014-06-16
#define VREGION_FLAGS_LARGE 0x40 // Map large pages, if possible
#define VREGION_FLAGS_HUGE 0x80 // Map huge pages, if possible
-#define VREGION_FLAGS_MASK 0xff // Mask of all individual VREGION_FLAGS
+#define VREGION_FLAGS_WRITE_COMBINING 0x100 // Write-combining caching
+#define VREGION_FLAGS_MASK 0x1ff // Mask of all individual VREGION_FLAGS
#define VREGION_FLAGS_READ_WRITE \
(VREGION_FLAGS_READ | VREGION_FLAGS_WRITE)
#include <arch/x86/apic.h>
#include <target/x86/barrelfish_kpi/coredata_target.h>
#include <arch/x86/startup_x86.h>
+#include <dev/ia32_dev.h>
#ifdef __scc__
# include <rck.h>
//}
panic("Error spawning init!");
}
+
+/*
+ * Configure the IA32_PAT_MSR register such that PA4 is write-combining and
+ * PA5 is write-protect.
+ */
+void configure_page_attribute_table(void)
+{
+ ia32_t ia32;
+ ia32_cr_pat_t pat;
+
+ ia32_initialize(&ia32);
+
+ pat = ia32_cr_pat_rd(&ia32);
+
+ pat = ia32_cr_pat_pa4_insert(pat, ia32_wc);
+ pat = ia32_cr_pat_pa5_insert(pat, ia32_wp);
+
+ ia32_cr_pat_wr(&ia32, pat);
+
+ debug(SUBSYS_STARTUP, "Configured IA32_PAT_MSR.\n");
+}
// Check/Enable MONITOR/MWAIT opcodes
enable_monitor_mwait();
+ // Setup Page Attribute Table MSR
+ configure_page_attribute_table();
+
// Call main kernel startup function -- this should never return
kernel_startup();
// Check/Enable MONITOR/MWAIT opcodes
enable_monitor_mwait();
+ // Setup Page Attribute Table MSR
+ configure_page_attribute_table();
+
// Call main kernel startup function -- this should never return
kernel_startup();
*ap_wait = AP_STARTED;
}
+void configure_page_attribute_table(void);
+
#endif // __STARTUP_X86_H
if (vregion_flags & VREGION_FLAGS_NOCACHE) {
pmap_flags |= X86_32_PTABLE_CACHE_DISABLED;
}
+ else if (vregion_flags & VREGION_FLAGS_WRITE_COMBINING) {
+ // PA4 is configured as write-combining
+ pmap_flags |= PTABLE_ATTR_INDEX;
+ }
#ifdef __scc__
if (vregion_flags & VREGION_FLAGS_MPB) {
pmap_flags |= SCC_PTABLE_MESSAGE_BUFFER;
if (vregion_flags & VREGION_FLAGS_NOCACHE) {
pmap_flags |= PTABLE_CACHE_DISABLED;
}
+ else if (vregion_flags & VREGION_FLAGS_WRITE_COMBINING) {
+ // PA4 is configured as write-combining
+ pmap_flags |= PTABLE_ATTR_INDEX;
+ }
}
return pmap_flags;