From: Himanshu Chauhan <
hcha...@xvisor-x86.org>
GRUB boots Xvisor with framebuffer initialized in UEFI mode.
So the early prints are not printed until late when the
framebuffer is initialized.
This patch adds support for early framebuffer. It has following
changes:
1. Change early pagetable setup with 2MB page support
2. Since the framebuffer address can be in the upper 4G region
Current 3-levels of paging structure only maps the code. So
added 16K of extra pages to keep PGDP and PGDI for framebuffers.
.../common/devices/video/fb_early_console.c | 228 ++++++++++++++++++
.../x86/board/common/devices/video/
objects.mk | 1 +
.../x86/board/common/include/video/ter-i16b.h | 3 +-
.../x86/board/common/include/video/ter-i16n.h | 4 +-
arch/x86/board/x86_64_generic/brd_defterm.c | 5 +
arch/x86/cpu/x86_64/cpu_main.c | 9 +-
arch/x86/cpu/x86_64/cpu_mmu.c | 93 +++++--
arch/x86/cpu/x86_64/include/cpu_mmu.h | 4 +
arch/x86/cpu/x86_64/start.S | 5 +
9 files changed, 323 insertions(+), 29 deletions(-)
create mode 100644 arch/x86/board/common/devices/video/fb_early_console.c
diff --git a/arch/x86/board/common/devices/video/fb_early_console.c b/arch/x86/board/common/devices/video/fb_early_console.c
new file mode 100644
index 00000000..63ccf957
--- /dev/null
+++ b/arch/x86/board/common/devices/video/fb_early_console.c
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2021 Himanshu Chauhan.
+ * All rights reserved.
+ *
+ * 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; either version 2, or (at your option)
+ * any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/*!
+ * @file fb_early_console.c
+ * @author Himanshu Chauhan (
hcha...@xvisor-x86.org)
+ * @brief Early framebuffer console with only writing capabilities
+ */
+
+#include <vmm_types.h>
+#include <vmm_error.h>
+#include <vmm_compiler.h>
+#include <vmm_host_io.h>
+#include <vmm_params.h>
+#include <libs/stringlib.h>
+#include <video/fb_console.h>
+#include <video/svga.h>
+#include <video/ter-i16b.h>
+#include <video/ter-i16n.h>
+#include <brd_defterm.h>
+#include <multiboot.h>
+#include <cpu_mmu.h>
+
+/* Pointers to fonts */
+static u8 *font_reg, *font_bold;
+/* Video mode info */
+static u16 width, height, depth, bytesPerLine;
+static void *video_base;//, video_size;
+/* Cursor location (in text cells) */
+static u16 col, row;
+/* Set by escape sequences */
+static u8 fg_colour, bg_colour;
+/* Used to parse escape codes */
+static bool next_char_is_escape_seq, is_bold;
+
+extern struct multiboot_info boot_info;
+extern int __create_bootstrap_pgtbl_entry(u64 va, u64 pa, u32 page_size, u8 wt, u8 cd);
+
+#define VMM_ROUNDUP2_SIZE(_address, _size) \
+ ((_address & ~(_size-1)) + _size)
+
+/* Colour code -> 16bpp */
+static u32 early_fb_console_col_map[16] = {
+ 0x000000, 0x0000AA, 0x00AA00, 0x00AAAA,
+ 0xAA0000, 0xAA00AA, 0xAA5500, 0xAAAAAA,
+
+ 0x555555, 0x5555FF, 0x55FF55, 0x55FFFF,
+ 0xFF5555, 0xFF55FF, 0xFFFF55, 0xFFFFFF
+};
+
+static void early_memclr(void *area, u32 size)
+{
+ memset(area, 0, size);
+}
+
+static void early_fb_console_set_font(void* reg, void* bold)
+{
+ if(reg) font_reg = reg;
+ if(bold) font_bold = bold;
+}
+static void early_fb_console_scroll_up(unsigned int num_rows)
+{
+ /* Copy rows upwards */
+ u8 *read_ptr = (u8 *) video_base + ((num_rows * CHAR_HEIGHT) * bytesPerLine);
+ u8 *write_ptr = (u8 *) video_base;
+ unsigned int num_bytes = (bytesPerLine * height) - (bytesPerLine * (num_rows * CHAR_HEIGHT));
+ memcpy(write_ptr, read_ptr, num_bytes);
+
+ /* Clear the rows at the end */
+ read_ptr = (u8 *)(video_base + (bytesPerLine * height) - (bytesPerLine * (num_rows * CHAR_HEIGHT)));
+ early_memclr(read_ptr, bytesPerLine * (num_rows * CHAR_HEIGHT));
+}
+
+static void early_fb_console_control(unsigned char c)
+{
+ switch(c) {
+ case '\n':
+ col = 0;
+ /* We're on the last row, a newline should only scroll the viewport up */
+ if(row == (height / CHAR_HEIGHT)-1) {
+ early_fb_console_scroll_up(1);
+ } else {
+ row++;
+ }
+
+ break;
+
+ default:
+ break;
+ }
+}
+
+int early_fb_defterm_putc(unsigned char c)
+{
+ if (c == '\n') {
+ early_fb_console_control('\n');
+ return VMM_OK;
+ }
+
+ if(c == 0x01) {
+ next_char_is_escape_seq = true;
+ return VMM_OK;
+ }
+
+ /* Check if the following character is part of an escape sequence */
+ if(next_char_is_escape_seq) {
+ /* Codes 0x00 to 0x0F are colours */
+ if(c >= 0x00 && c <= 0x0F) {
+ fg_colour = c;
+ next_char_is_escape_seq = false;
+ } else if(c == 0x10 || c == 0x11) {
+ is_bold = (c == 0x11) ? true : false;
+
+ next_char_is_escape_seq = false;
+ } else {
+ next_char_is_escape_seq = false;
+ }
+ } else { /* Handle printing of a regular character */
+ /* Characters are 16 px tall, i.e. 0x10 bytes in stored rep */
+ u8 *read_ptr = (u8 *) ((is_bold) ? font_bold : font_reg) + (c * CHAR_HEIGHT);
+ u32 *write_base;
+
+ const u8 x_to_bitmap[CHAR_WIDTH] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
+ u8 fontChar = 0;
+ u32 out = 0;
+
+ for(u8 y = 0; y < CHAR_HEIGHT; y++) {
+ fontChar = read_ptr[y];
+
+ /* Process one column at a time */
+ if(depth == 4) {
+ write_base = (u32 *) (video_base) + (((bytesPerLine / 4) * CHAR_HEIGHT * row)) + (CHAR_WIDTH * col);
+
+ for(u8 x = 0; x < CHAR_WIDTH; x++) {
+ if(x_to_bitmap[x] & fontChar) {
+ write_base[x+(y * (bytesPerLine / 4))] = early_fb_console_col_map[fg_colour];
+ }
+ }
+ } else if(depth == 2) {
+ write_base = (u32 *) (video_base) + (((bytesPerLine / 4) * CHAR_HEIGHT * row)) + ((CHAR_WIDTH * (col)) >> 1);
+
+ /* In 16bpp, process two pixels at once */
+ for(u8 x = 0; x < CHAR_WIDTH; x+=2) {
+ out = 0;
+
+ if(x_to_bitmap[x] & fontChar) {
+ out = ((SVGA_24TO16BPP(early_fb_console_col_map[fg_colour])) & 0xFFFF) << 16;
+ }
+
+ if(x_to_bitmap[x+1] & fontChar) {
+ out |= ((SVGA_24TO16BPP(early_fb_console_col_map[fg_colour])) & 0xFFFF);
+ }
+
+ write_base[(x >> 1) + (y * (bytesPerLine / 4))] = out;
+ }
+ }
+ }
+
+ /* Increment column and check row */
+ col++;
+
+ if(col > (width / CHAR_WIDTH)) {
+ early_fb_console_control('\n');
+ }
+ }
+
+ return VMM_OK;
+}
+
+int init_early_fb_console(void)
+{
+ virtual_size_t fb_length;
+ u32 nr_pages = 0;
+
+ bytesPerLine = boot_info.framebuffer_pitch;
+ width = boot_info.framebuffer_width;
+ height = boot_info.framebuffer_height;
+ depth = boot_info.framebuffer_bpp/8;
+
+ fb_length = (bytesPerLine * height);
+ fb_length = VMM_ROUNDUP2_SIZE(fb_length, PAGE_SIZE_2M);
+ video_base = (void *)boot_info.framebuffer_addr;
+ nr_pages = fb_length/PAGE_SIZE_2M;
+ fb_length = (bytesPerLine * height);
+
+ while (nr_pages) {
+ if (__create_bootstrap_pgtbl_entry((u64)video_base,
+ (u64)video_base, PAGE_SIZE_2M,
+ 0, 1) != VMM_OK) {
+ return VMM_EFAIL;
+ }
+ video_base += PAGE_SIZE_2M;
+ nr_pages--;
+ }
+
+ video_base = (void *)boot_info.framebuffer_addr;
+
+ early_fb_console_set_font(&ter_i16n_raw, &ter_i16b_raw);
+
+ /* Clear screen */
+ early_memclr((void *)video_base, bytesPerLine * height);
+
+ is_bold = false;
+ next_char_is_escape_seq = false;
+ fg_colour = 0x0F;
+ bg_colour = 0x00;
+
+ col = row = 0;
+
+ early_putc = early_fb_defterm_putc;
+
+ return VMM_OK;
+}
diff --git a/arch/x86/board/common/devices/video/
objects.mk b/arch/x86/board/common/devices/video/
objects.mk
index 17217df2..8c9d4c07 100644
--- a/arch/x86/board/common/devices/video/
objects.mk
+++ b/arch/x86/board/common/devices/video/
objects.mk
@@ -24,3 +24,4 @@
board-common-objs-y+= devices/video/vga.o
board-common-objs-y+= devices/video/svga.o
board-common-objs-y+= devices/video/fb_console.o
+board-common-objs-y+= devices/video/fb_early_console.o
diff --git a/arch/x86/board/common/include/video/ter-i16b.h b/arch/x86/board/common/include/video/ter-i16b.h
index 7f8fc5de..52669788 100644
--- a/arch/x86/board/common/include/video/ter-i16b.h
+++ b/arch/x86/board/common/include/video/ter-i16b.h
@@ -5,7 +5,7 @@
*/
#include <vmm_types.h>
-u8 ter_i16b_raw[] = {
+static u8 ter_i16b_raw[] = {
0x00, 0x00, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0x82, 0xaa, 0x82, 0x82, 0xba, 0x92, 0x82, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xfe, 0xd6, 0xfe, 0xfe, 0xc6, 0xee, 0xfe, 0xfe, 0x7c, 0x00, 0x00, 0x00, 0x00,
@@ -263,4 +263,3 @@ u8 ter_i16b_raw[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
-unsigned int ter_i16b_raw_len = 4096;
diff --git a/arch/x86/board/common/include/video/ter-i16n.h b/arch/x86/board/common/include/video/ter-i16n.h
index 3eb3d786..1106a26a 100644
--- a/arch/x86/board/common/include/video/ter-i16n.h
+++ b/arch/x86/board/common/include/video/ter-i16n.h
@@ -5,7 +5,7 @@
*/
#include <vmm_types.h>
-u8 ter_i16n_raw[] = {
+static u8 ter_i16n_raw[] = {
0x00, 0x00, 0x7e, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0x82, 0xaa, 0x82, 0x82, 0xba, 0x92, 0x82, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xfe, 0xd6, 0xfe, 0xfe, 0xc6, 0xee, 0xfe, 0xfe, 0x7c, 0x00, 0x00, 0x00, 0x00,
@@ -263,5 +263,3 @@ u8 ter_i16n_raw[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
-
-unsigned int ter_i16n_raw_len = 4096;
diff --git a/arch/x86/board/x86_64_generic/brd_defterm.c b/arch/x86/board/x86_64_generic/brd_defterm.c
index 76e511fb..02f1149c 100644
--- a/arch/x86/board/x86_64_generic/brd_defterm.c
+++ b/arch/x86/board/x86_64_generic/brd_defterm.c
@@ -39,6 +39,7 @@
static char cmdline_console_string[CONSOLE_SETUP_STR_LEN];
static struct defterm_ops *ops = NULL;
EARLY_PUTC early_putc = NULL;
+int init_early_fb_console(void);
void arch_defterm_early_putc(u8 ch)
{
@@ -58,6 +59,9 @@ static int __init setup_early_print(char *buf)
if (!strncmp(buf, VGA_CONSOLE_NAME, strlen(VGA_CONSOLE_NAME)))
return init_early_vga_console();
+ if (!strncmp(buf, FB_CONSOLE_NAME, strlen(FB_CONSOLE_NAME)))
+ return init_early_fb_console();
+
return VMM_EFAIL;
}
@@ -79,6 +83,7 @@ static int __init set_default_console(char *buf)
vmm_snprintf(cmdline_console_string, strlen(DEFAULT_CONSOLE_STR),
DEFAULT_CONSOLE_STR);
+
return VMM_OK;
}
diff --git a/arch/x86/cpu/x86_64/cpu_main.c b/arch/x86/cpu/x86_64/cpu_main.c
index 4186de44..d15651b0 100644
--- a/arch/x86/cpu/x86_64/cpu_main.c
+++ b/arch/x86/cpu/x86_64/cpu_main.c
@@ -230,7 +230,7 @@ void arch_cpu_print_summary(struct vmm_chardev *cdev)
(cpu_info.hw_virt_available ? "Supported" : "Unsupported"));
}
-extern void __create_bootstrap_pgtbl_entry(u64 va, u64 pa);
+extern void __create_bootstrap_pgtbl_entry(u64 va, u64 pa, u32 page_size, u8 wt, u8 cd);
extern void __delete_bootstrap_pgtbl_entry(u64 va);
/*
@@ -246,7 +246,8 @@ static void __init boot_modules_move(struct multiboot_info *binfo)
u64 daddr, saddr;
int i;
- __create_bootstrap_pgtbl_entry(binfo->mods_addr, binfo->mods_addr);
+ __create_bootstrap_pgtbl_entry(binfo->mods_addr, binfo->mods_addr,
+ 4096, 0, 0);
modlist = (struct multiboot_mod_list *)((u64)binfo->mods_addr);
@@ -299,8 +300,8 @@ static void __init boot_modules_move(struct multiboot_info *binfo)
mod_size = VMM_ROUNDUP2_PAGE_SIZE(mod_size);
while (mod_size) {
- __create_bootstrap_pgtbl_entry(saddr, saddr);
- __create_bootstrap_pgtbl_entry(daddr, daddr);
+ __create_bootstrap_pgtbl_entry(saddr, saddr, 4096, 0, 0);
+ __create_bootstrap_pgtbl_entry(daddr, daddr, 4096, 0, 0);
memcpy((void *)daddr, (void *)saddr, VMM_PAGE_SIZE);
__delete_bootstrap_pgtbl_entry(daddr);
__delete_bootstrap_pgtbl_entry(saddr);
diff --git a/arch/x86/cpu/x86_64/cpu_mmu.c b/arch/x86/cpu/x86_64/cpu_mmu.c
index 7f61483b..ee09400e 100644
--- a/arch/x86/cpu/x86_64/cpu_mmu.c
+++ b/arch/x86/cpu/x86_64/cpu_mmu.c
@@ -46,9 +46,26 @@ extern u64 __pml4[];
extern u64 __pgdp[];
extern u64 __pgdi[];
extern u64 __pgti[];
+extern u64 __early_iodev_pages[];
+static char *early_iodev_pages = (char *)__early_iodev_pages;
+static early_iodev_pages_used = 0;
struct page_table host_pgtbl_array[HOST_PGTBL_MAX_TABLE_COUNT];
+static
+char *alloc_iodev_page(void)
+{
+ char *iodev_page = NULL;
+
+ if (early_iodev_pages_used >= NR_IODEV_PAGES)
+ return NULL;
+
+ iodev_page = (early_iodev_pages + (early_iodev_pages_used * PAGE_SIZE));
+ early_iodev_pages_used++;
+
+ return iodev_page;
+}
+
static void arch_preinit_pgtable_entries(void)
{
int i;
@@ -68,13 +85,18 @@ static void arch_preinit_pgtable_entries(void)
__pgdi[i] = ((u64)(pgti_base + (PAGE_SIZE * i)) & PAGE_MASK) + 3;
}
-int __create_bootstrap_pgtbl_entry(u64 va, u64 pa)
+int __create_bootstrap_pgtbl_entry(u64 va, u64 pa, u32 page_size,
+ u8 wt, u8 cd)
{
static int preinit_pgtables = 0;
union page ent;
ent._val = 0;
+ if ((page_size != PAGE_SIZE_2M) && (page_size != PAGE_SIZE_4K)) {
+ return VMM_EFAIL;
+ }
+
if (!preinit_pgtables) {
arch_preinit_pgtable_entries();
preinit_pgtables = 1;
@@ -90,23 +112,55 @@ int __create_bootstrap_pgtbl_entry(u64 va, u64 pa)
u64 *pgdp_base = (u64 *)(((u64)__pml4[pml4_index]) & ~0xff);
- if (!(pgdp_base[pgdp_index] & 0x3))
- return VMM_EFAIL;
+ if (pgdp_base[pgdp_index] == 0) {
+ pgdp_base[pgdp_index] = alloc_iodev_page();
+ if (pgdp_base[pgdp_index] == NULL)
+ return VMM_EFAIL;
+ pgdp_base[pgdp_index] |= 0x3;
+ } else {
+ if (!(pgdp_base[pgdp_index] & 0x3))
+ return VMM_EFAIL;
+ }
u64 *pgdi_base = (u64 *)(((u64)pgdp_base[pgdp_index]) & ~0xff);
- if (!(pgdi_base[pgdp_index] & 0x3))
- return VMM_EFAIL;
+ if (pgdi_base[pgdi_index] == 0) {
+ if (page_size == PAGE_SIZE_2M) {
+ pgdi_base[pgdi_index] |= ((pa >> 21) << 21);
+ pgdi_base[pgdi_index] |= (0x1UL << 7);
+ pgdi_base[pgdi_index] |= (wt ? (0x1UL << 3) : 0);
+ pgdi_base[pgdi_index] |= (cd ? (0x1UL << 4) : 0);
+ pgdi_base[pgdi_index] |= 0x3;
+ return VMM_OK;
+ } else {
+ pgdi_base[pgdi_index] = alloc_iodev_page();
+ if (pgdi_base[pgdi_index] == NULL)
+ return VMM_EFAIL;
+ pgdi_base[pgdi_index] |= 0x3;
+ }
+ } else {
+ if (!(pgdi_base[pgdi_index] & 0x3))
+ return VMM_EFAIL;
+ }
u64 *pgti_base = (u64 *)(((u64)pgdi_base[pgdi_index]) & ~0xff);
- if (pgti_base[pgti_index] & 0x3)
- return VMM_EFAIL;
+ if (pgti_base[pgti_index] == 0) {
+ pgti_base[pgti_index] = alloc_iodev_page();
+ if (pgti_base[pgti_index] == NULL)
+ return VMM_EFAIL;
+ pgti_base[pgti_index] |= 0x3;
+ } else {
+ if (pgti_base[pgti_index] & 0x3)
+ return VMM_EFAIL;
+ }
ent.bits.paddr = pa >> PAGE_SHIFT;
ent.bits.present = 1;
ent.bits.rw = 1;
pgti_base[pgti_index] = ent._val;
+ pgti_base[pgti_index] |= (wt ? (0x1UL << 3) : 0);
+ pgti_base[pgti_index] |= (cd ? (0x1UL << 4) : 0);
invalidate_vaddr_tlb(va);
@@ -249,7 +303,7 @@ int __init arch_cpu_aspace_primary_init(physical_addr_t *core_resv_pa,
*/
arch_preinit_pgtable_entries();
- /* Check & setup core reserved space and update the
+ /* Check & setup core reserved space and update the
* core_resv_pa, core_resv_va, and core_resv_sz parameters
* to inform host aspace about correct placement of the
* core reserved space.
@@ -272,8 +326,8 @@ int __init arch_cpu_aspace_primary_init(physical_addr_t *core_resv_pa,
*core_resv_va = resv_va;
*core_resv_sz = resv_sz;
- /* Initialize MMU control and allocate arch reserved space and
- * update the *arch_resv_pa, *arch_resv_va, and *arch_resv_sz
+ /* Initialize MMU control and allocate arch reserved space and
+ * update the *arch_resv_pa, *arch_resv_va, and *arch_resv_sz
* parameters to inform host aspace about the arch reserved space.
*/
memset(&host_pgtbl_ctl, 0, sizeof(host_pgtbl_ctl));
@@ -309,8 +363,8 @@ int __init arch_cpu_aspace_primary_init(physical_addr_t *core_resv_pa,
pgtbl->stage = 0;
pgtbl->parent = NULL;
pgtbl->map_ia = 0;
- pgtbl->tbl_pa = (virtual_addr_t)__pml4 -
- arch_code_vaddr_start() +
+ pgtbl->tbl_pa = (virtual_addr_t)__pml4 -
+ arch_code_vaddr_start() +
arch_code_paddr_start();
INIT_SPIN_LOCK(&pgtbl->tbl_lock);
pgtbl->tbl_va = (virtual_addr_t)__pml4;
@@ -331,8 +385,8 @@ int __init arch_cpu_aspace_primary_init(physical_addr_t *core_resv_pa,
pgtbl->stage = 0;
pgtbl->parent = &host_pgtbl_ctl.pgtbl_pml4;
pgtbl->map_ia = arch_code_vaddr_start() & mmu_level_map_mask(0);
- pgtbl->tbl_pa = (virtual_addr_t)__pgdp -
- arch_code_vaddr_start() +
+ pgtbl->tbl_pa = (virtual_addr_t)__pgdp -
+ arch_code_vaddr_start() +
arch_code_paddr_start();
INIT_SPIN_LOCK(&pgtbl->tbl_lock);
pgtbl->tbl_va = (virtual_addr_t)__pgdp;
@@ -355,8 +409,8 @@ int __init arch_cpu_aspace_primary_init(physical_addr_t *core_resv_pa,
pgtbl->stage = 0;
pgtbl->parent = &host_pgtbl_ctl.pgtbl_pgdp;
pgtbl->map_ia = arch_code_vaddr_start() & mmu_level_map_mask(1);
- pgtbl->tbl_pa = (virtual_addr_t)__pgdi -
- arch_code_vaddr_start() +
+ pgtbl->tbl_pa = (virtual_addr_t)__pgdi -
+ arch_code_vaddr_start() +
arch_code_paddr_start();
INIT_SPIN_LOCK(&pgtbl->tbl_lock);
pgtbl->tbl_va = (virtual_addr_t)__pgdi;
@@ -379,8 +433,8 @@ int __init arch_cpu_aspace_primary_init(physical_addr_t *core_resv_pa,
pgtbl->stage = 0;
pgtbl->parent = &host_pgtbl_ctl.pgtbl_pgdi;
pgtbl->map_ia = arch_code_vaddr_start() & mmu_level_map_mask(2);
- pgtbl->tbl_pa = (virtual_addr_t)__pgti -
- arch_code_vaddr_start() +
+ pgtbl->tbl_pa = (virtual_addr_t)__pgti -
+ arch_code_vaddr_start() +
arch_code_paddr_start();
INIT_SPIN_LOCK(&pgtbl->tbl_lock);
pgtbl->tbl_va = (virtual_addr_t)__pgti;
@@ -412,7 +466,7 @@ int __init arch_cpu_aspace_primary_init(physical_addr_t *core_resv_pa,
hyppg._val = 0x0;
hyppg.bits.paddr = (pa >> PAGE_SHIFT);
hyppg.bits.present = 1;
-
hyppg.bits.rw = 1;
+
hyppg.bits.rw = 1;
if ((rc = mmu_map_page(&host_pgtbl_ctl, host_pgtbl_ctl.base_pgtbl, va, &hyppg))) {
goto mmu_init_error;
}
@@ -439,4 +493,3 @@ int __cpuinit arch_cpu_aspace_secondary_init(void)
/* FIXME: For now nothing to do here. */
return VMM_OK;
}
-
diff --git a/arch/x86/cpu/x86_64/include/cpu_mmu.h b/arch/x86/cpu/x86_64/include/cpu_mmu.h
index db49e7e1..4dec7947 100644
--- a/arch/x86/cpu/x86_64/include/cpu_mmu.h
+++ b/arch/x86/cpu/x86_64/include/cpu_mmu.h
@@ -27,6 +27,7 @@
#define NR_PGDP_PAGES 4
#define NR_PGDI_PAGES 8
#define NR_PGTI_PAGES 32
+#define NR_IODEV_PAGES 4
#define VMM_CODE_SEG_SEL 0x08
#define VMM_DATA_SEG_SEL 0x10
@@ -80,6 +81,9 @@
extern struct pgtbl_ctrl host_pgtbl_ctl;
+#define PAGE_SIZE_1G (0x40000000UL)
+#define PAGE_SIZE_2M (0x200000UL)
+#define PAGE_SIZE_4K (0x1000UL)
static inline void invalidate_vaddr_tlb(virtual_addr_t vaddr)
{
diff --git a/arch/x86/cpu/x86_64/start.S b/arch/x86/cpu/x86_64/start.S
index 9a120467..7b2f5f57 100644
--- a/arch/x86/cpu/x86_64/start.S
+++ b/arch/x86/cpu/x86_64/start.S
@@ -323,6 +323,11 @@ __pgdi:
__pgti:
.zero (PAGE_SIZE * NR_PGTI_PAGES)
+__early_iodev_pages:
+ .globl __early_iodev_pages
+ .align 32
+ .type __early_iodev_pages, @object
+ .zero (PAGE_SIZE * NR_IODEV_PAGES)
.align 4
.type _mboot_info, @object
--
2.25.1