direct-io.hg

changeset 5591:a8f9132a9ddd

bitkeeper revision 1.1760.1.3 (42c10175tVLAVy7ULar9xcSazDReXw)

[PATCH] [PATCH] VMXassist print e820 table

This patch integrates some of my debug environment back into the main
stream and it prints the e820 map as it is seen by a VMX domain.

Leendert

Signed-Off-By: Leendert van Doorn <leendert@watson.ibm.com>
author leendert@watson.ibm.com[kaf24]
date Tue Jun 28 07:51:17 2005 +0000 (2005-06-28)
parents f9eade8778af
children b75294458106
files tools/firmware/rombios/rombios.c tools/firmware/vmxassist/setup.c tools/firmware/vmxassist/util.c tools/firmware/vmxassist/util.h tools/firmware/vmxassist/vm86.c
line diff
     1.1 --- a/tools/firmware/rombios/rombios.c	Tue Jun 28 07:51:00 2005 +0000
     1.2 +++ b/tools/firmware/rombios/rombios.c	Tue Jun 28 07:51:17 2005 +0000
     1.3 @@ -27,6 +27,7 @@
     1.4  // ROM BIOS for use with Bochs/Plex x86 emulation environment
     1.5  
     1.6  #define VMXASSIST
     1.7 +#undef VMXTEST
     1.8  
     1.9  // ROM BIOS compatability entry points:
    1.10  // ===================================
    1.11 @@ -4070,10 +4071,10 @@ ASM_END
    1.12          switch(regs.u.r8.al)
    1.13          {
    1.14           case 0x20: // coded by osmaker aka K.J.
    1.15 -            if(regs.u.r32.edx == 0x534D4150)
    1.16 +            if(regs.u.r32.edx == 0x534D4150) /* SMAP */
    1.17              {
    1.18  #ifdef VMXASSIST
    1.19 -		if ((regs.u.r16.bx / 0x14)* 0x14 == regs.u.r16.bx) {
    1.20 +		if ((regs.u.r16.bx / 0x14) * 0x14 == regs.u.r16.bx) {
    1.21  		    Bit16u e820_table_size = read_word(0xe000, 0x8) * 0x14;
    1.22  
    1.23  		    if (regs.u.r16.bx + 0x14 <= e820_table_size) {
    1.24 @@ -10353,8 +10354,17 @@ dummy_iret_handler:
    1.25    HALT(__LINE__)
    1.26    iret
    1.27  
    1.28 +#ifdef VMXTEST
    1.29 +.org 0xffe0
    1.30 +  jmp 0xf000:post;
    1.31 +#endif
    1.32 +
    1.33  .org 0xfff0 ; Power-up Entry Point
    1.34 +#ifdef VMXTEST
    1.35 +  jmp 0xd000:0x0003;
    1.36 +#else
    1.37    jmp 0xf000:post
    1.38 +#endif
    1.39  
    1.40  .org 0xfff5 ; ASCII Date ROM was built - 8 characters in MM/DD/YY
    1.41  .ascii BIOS_BUILD_DATE
     2.1 --- a/tools/firmware/vmxassist/setup.c	Tue Jun 28 07:51:00 2005 +0000
     2.2 +++ b/tools/firmware/vmxassist/setup.c	Tue Jun 28 07:51:17 2005 +0000
     2.3 @@ -46,7 +46,19 @@ struct dtr idtr = { sizeof(idt)-1, (unsi
     2.4  
     2.5  #ifdef TEST
     2.6  unsigned pgd[NR_PGD] __attribute__ ((aligned(PGSIZE))) = { 0 };
     2.7 -#endif
     2.8 +
     2.9 +struct e820entry e820map[] = {
    2.10 +	{ 0x0000000000000000ULL, 0x000000000009F800ULL, E820_RAM },
    2.11 +	{ 0x000000000009F800ULL, 0x0000000000000800ULL, E820_RESERVED },
    2.12 +	{ 0x00000000000A0000ULL, 0x0000000000020000ULL, E820_IO },
    2.13 +	{ 0x00000000000C0000ULL, 0x0000000000040000ULL, E820_RESERVED },
    2.14 +	{ 0x0000000000100000ULL, 0x0000000000000000ULL, E820_RAM },
    2.15 +	{ 0x0000000000000000ULL, 0x0000000000001000ULL, E820_SHARED },
    2.16 +	{ 0x0000000000000000ULL, 0x0000000000003000ULL, E820_NVS },
    2.17 +	{ 0x0000000000003000ULL, 0x000000000000A000ULL, E820_ACPI },
    2.18 +	{ 0x00000000FEC00000ULL, 0x0000000001400000ULL, E820_IO },
    2.19 +};
    2.20 +#endif /* TEST */
    2.21  
    2.22  struct vmx_assist_context oldctx;
    2.23  struct vmx_assist_context newctx;
    2.24 @@ -72,7 +84,20 @@ banner(void)
    2.25  		    (((get_cmos(0x31) << 8) | get_cmos(0x30)) + 0x400) << 10;
    2.26  	memory_size += 0x400 << 10; /* + 1MB */
    2.27  
    2.28 +#ifdef TEST
    2.29 +	/* Create an SMAP for our debug environment */
    2.30 +	e820map[4].size = memory_size - e820map[4].addr - PGSIZE;
    2.31 +	e820map[5].addr = memory_size - PGSIZE;
    2.32 +	e820map[6].addr = memory_size;
    2.33 +	e820map[7].addr += memory_size;
    2.34 +
    2.35 +	*LINUX_E820_MAP_NR = sizeof(e820map)/sizeof(e820map[0]);
    2.36 +	memcpy(LINUX_E820_MAP, e820map, sizeof(e820map));
    2.37 +#endif
    2.38 +
    2.39  	printf("Memory size %ld MB\n", memory_size >> 20);
    2.40 +	printf("E820 map:\n");
    2.41 +	print_e820_map(LINUX_E820_MAP, *LINUX_E820_MAP_NR);
    2.42  	printf("\n");
    2.43  }
    2.44  
     3.1 --- a/tools/firmware/vmxassist/util.c	Tue Jun 28 07:51:00 2005 +0000
     3.2 +++ b/tools/firmware/vmxassist/util.c	Tue Jun 28 07:51:17 2005 +0000
     3.3 @@ -74,6 +74,36 @@ hexdump(unsigned char *data, int sz)
     3.4  }
     3.5  
     3.6  void
     3.7 +print_e820_map(struct e820entry *map, int entries)
     3.8 +{
     3.9 +	struct e820entry *m;
    3.10 +
    3.11 +	if (entries > 32)
    3.12 +		entries = 32;
    3.13 +
    3.14 +	for (m = map; m < &map[entries]; m++) {
    3.15 +		printf("%08lx%08lx - %08lx%08lx ",
    3.16 +			(unsigned long) (m->addr >> 32),
    3.17 +			(unsigned long) (m->addr),
    3.18 +			(unsigned long) ((m->addr+m->size) >> 32),
    3.19 +			(unsigned long) ((m->addr+m->size)));
    3.20 +
    3.21 +		switch (m->type) {
    3.22 +		case E820_RAM:
    3.23 +			printf("(RAM)\n"); break;
    3.24 +		case E820_RESERVED:
    3.25 +			printf("(Reserved)\n"); break;
    3.26 +		case E820_ACPI:
    3.27 +			printf("(ACPI Data)\n"); break;
    3.28 +		case E820_NVS:
    3.29 +			printf("(ACPI NVS)\n"); break;
    3.30 +		default:
    3.31 +			printf("(Type %ld)\n", m->type); break;
    3.32 +		}
    3.33 +	}
    3.34 +}
    3.35 +
    3.36 +void
    3.37  dump_dtr(unsigned long base, unsigned long limit)
    3.38  {
    3.39  	unsigned long long entry;
     4.1 --- a/tools/firmware/vmxassist/util.h	Tue Jun 28 07:51:00 2005 +0000
     4.2 +++ b/tools/firmware/vmxassist/util.h	Tue Jun 28 07:51:17 2005 +0000
     4.3 @@ -23,6 +23,24 @@
     4.4  #include <stdarg.h>
     4.5  #include <vm86.h>
     4.6  
     4.7 +
     4.8 +#define	LINUX_E820_MAP_NR	((unsigned char *)0x901E8)
     4.9 +#define	LINUX_E820_MAP		((struct e820entry *)0x902D0)
    4.10 +
    4.11 +#define	E820_RAM	1
    4.12 +#define	E820_RESERVED	2
    4.13 +#define	E820_ACPI	3
    4.14 +#define	E820_NVS	4
    4.15 +#define	E820_IO		16
    4.16 +#define	E820_SHARED	17
    4.17 +
    4.18 +struct e820entry {
    4.19 +	unsigned long long	addr;
    4.20 +	unsigned long long	size;
    4.21 +	unsigned long		type;
    4.22 +} __attribute__((packed));
    4.23 +
    4.24 +
    4.25  #define	offsetof(type, member)	((unsigned) &((type *)0)->member)
    4.26  
    4.27  struct vmx_assist_context;
    4.28 @@ -30,6 +48,7 @@ struct vmx_assist_context;
    4.29  extern void hexdump(unsigned char *, int);
    4.30  extern void dump_regs(struct regs *);
    4.31  extern void dump_vmx_context(struct vmx_assist_context *);
    4.32 +extern void print_e820_map(struct e820entry *, int);
    4.33  extern void dump_dtr(unsigned long, unsigned long);
    4.34  extern void *memcpy(void *, const void *, unsigned);
    4.35  extern void *memset(void *, int, unsigned);
     5.1 --- a/tools/firmware/vmxassist/vm86.c	Tue Jun 28 07:51:00 2005 +0000
     5.2 +++ b/tools/firmware/vmxassist/vm86.c	Tue Jun 28 07:51:17 2005 +0000
     5.3 @@ -950,7 +950,7 @@ trap(int trapno, int errno, struct regs 
     5.4  
     5.5  	default:
     5.6  	invalid:
     5.7 -		printf("Trap (%d) while in %s mode\n",
     5.8 +		printf("Trap (0x%x) while in %s mode\n",
     5.9  		    trapno, regs->eflags & EFLAGS_VM ? "real" : "protected");
    5.10  		if (trapno == 14)
    5.11  			printf("Page fault address 0x%x\n", get_cr2());